import { z } from 'zod'; import { hiboutikDecimal, hiboutikId, hiboutikInt, hiboutikList, hiboutikRef, hiboutikText } from './hiboutik.schema'; /** Line of a sale: a snapshot of the product at sale time. */ export const saleLineHiboutikSchema = z.object({ product_id: hiboutikRef, /** Hiboutik size id, 0 for a product without sizes. */ product_size: hiboutikRef, /** Negative for a returned item. */ quantity: hiboutikInt, product_model: hiboutikText, product_barcode: hiboutikText, /** Size name, empty for a product without sizes. */ size_name: hiboutikText, /** Unit price actually paid, discount deducted, taxes included. */ item_unit_gross: hiboutikDecimal, }); /** * Sale as returned by Hiboutik `GET /sales/:sale_id`, with its lines. Only the fields used by the sync: the payload * also carries many computed copies (dates split in parts, totals by tax, customer and store details...). */ export const saleHiboutikSchema = z.object({ sale_id: hiboutikId, /** French local time, "YYYY-MM-DD HH:mm:ss". */ created_at: hiboutikText, /** French local time, "0000-00-00 00:00:00" while the sale is not completed. */ completed_at: hiboutikText, /** 0 for an anonymous sale. */ customer_id: hiboutikRef, /** Taxes included. */ total: hiboutikDecimal, /** 1 for a quotation. */ quotation: hiboutikInt, line_items: hiboutikList(saleLineHiboutikSchema), }); export type SaleLineHiboutikDto = z.output; export type SaleHiboutikDto = z.output;