feat(sync): synchronize customer orders from Hiboutik sales

For each customer sale not yet stored as completed, fetch the full sale
(GET /sales/:id) and upsert it as a STORE order keyed on hiboutikSaleId.
Lines are replaced on each upsert and linked to the matching product
version when it still exists. Quotations are skipped, orders are never
deleted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
MastersGame
2026-11-07 10:48:54 +01:00
parent ad8e39f63c
commit 1a04bafa0b
10 changed files with 371 additions and 4 deletions

View File

@@ -2,3 +2,11 @@ import { Prisma } from '../generated/client';
/** Product loaded with its versions (`include: { versions: true }`). */
export type ProductWithVersions = Prisma.ProductGetPayload<{ include: { versions: true } }>;
/**
* Order to save with its lines. Lines are kept apart from the nested Prisma input so that the repository can link
* them to the current catalog (`productVersion`) and replace them on update.
*/
export type OrderWithLinesInput = Omit<Prisma.OrderCreateInput, 'lines'> & {
lines: Prisma.OrderLineCreateWithoutOrderInput[];
};