feat(orders): reopen cancelled orders only after confirmation; accurate sales
Docker Image bauen und veroeffentlichen / build-and-push (push) Successful in 2m24s
Docker Image bauen und veroeffentlichen / build-and-push (push) Successful in 2m24s
Cancelled orders: - Moving an order out of STORNIERT is possible again, but only after a warning is confirmed in the status form (OrderStatusForm); without the confirmation the server changes nothing. - Reopening books the counter-entry to the cancellation: goods that the cancellation restocked are deducted again (atomically, only if enough stock is left, otherwise the order stays cancelled). A later second cancellation therefore restocks +1 again instead of leaving +2. - The warning states that no new payment is collected. Dashboard figures: - One definition of a counted sale (lib/sales.ts): not unpaid (NEU), not cancelled, no refunded return. Used for revenue today/month, sold glasses, average cart, top products/categories, revenue trend and repeat customers. - "Verkaufte Gläser" previously summed every order item, including cancelled orders and refunded returns. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
1 parent
dc1523aafd
commit
e0b47faf45
11 files changed
+243
-82
No files matched your search
@@ -10,6 +10,7 @@ import {
|
||||
deleteOrderAction,
|
||||
} from "../../actions";
|
||||
import { ConfirmForm } from "@/components/confirm-form";
|
||||
import { OrderStatusForm } from "@/components/order-status-form";
|
||||
import { checkOrderDeletable } from "@/lib/order-delete";
|
||||
import { getLocale } from "@/i18n/locale";
|
||||
import { getDictionary } from "@/i18n/get-dictionary";
|
||||
@@ -57,26 +58,15 @@ export default async function AdminOrderDetailPage(props: PageProps<"/admin/best
|
||||
</div>
|
||||
<p className="text-sm text-ink/65 mt-1">{formatDate(order.createdAt)}</p>
|
||||
</div>
|
||||
{/* Storniert ist ein Endzustand (isOrderStatusChangeAllowed) — keine Auswahl anbieten, die der Server ablehnt. */}
|
||||
{order.status !== "STORNIERT" ? (
|
||||
<form action={updateOrderStatusAction} className="flex items-center gap-2">
|
||||
<input type="hidden" name="orderId" value={order.id} />
|
||||
<select
|
||||
name="status"
|
||||
defaultValue={order.status}
|
||||
className="border border-ink/20 bg-background px-3 py-2 text-sm"
|
||||
>
|
||||
{Object.entries(statusLabels).map(([value, label]) => (
|
||||
<option key={value} value={value}>
|
||||
{label}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
<Button type="submit" className="px-5 py-2.5">
|
||||
{t.adminOrderDetailPage.saveStatus}
|
||||
</Button>
|
||||
</form>
|
||||
) : null}
|
||||
<OrderStatusForm
|
||||
action={updateOrderStatusAction}
|
||||
orderId={order.id}
|
||||
currentStatus={order.status}
|
||||
labels={statusLabels}
|
||||
saveLabel={t.adminOrderDetailPage.saveStatus}
|
||||
statusAriaLabel={t.adminOrdersPage.statusLabel}
|
||||
reopenConfirmMessage={t.adminOrdersPage.reopenConfirm}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Wo steht die Bestellung? Dieselbe Waben-Zeitleiste wie im Kundenkonto. */}
|
||||
|
||||
Reference in new issue
Block a user