feat(POS-FIX-11): completed feature
This commit is contained in:
@@ -1338,6 +1338,7 @@ export async function registerPosRoutes(app: FastifyInstance, deps: PosRouteDeps
|
||||
items: { type: 'array', minItems: 1, items: { type: 'object' } },
|
||||
payments: { type: 'array', minItems: 0, items: { type: 'object' } },
|
||||
customerId: { type: 'string', format: 'uuid' },
|
||||
posLabel: { type: 'string', maxLength: 100 },
|
||||
},
|
||||
},
|
||||
response: {
|
||||
@@ -1389,6 +1390,7 @@ export async function registerPosRoutes(app: FastifyInstance, deps: PosRouteDeps
|
||||
items: z.array(z.union([freeLine, stockLine])).min(1),
|
||||
payments: z.array(payment).min(0),
|
||||
customerId: z.string().uuid().optional(),
|
||||
posLabel: z.string().max(100).optional(),
|
||||
}),
|
||||
request.body ?? {},
|
||||
);
|
||||
@@ -1655,6 +1657,7 @@ export async function registerPosRoutes(app: FastifyInstance, deps: PosRouteDeps
|
||||
o.discount_cents AS "discountCents", o.created_at AS "createdAt",
|
||||
o.store_id AS "storeId", o.terminal_id AS "terminalId",
|
||||
o.cash_session_id AS "cashSessionId",
|
||||
o.pos_label AS "posLabel",
|
||||
COALESCE(payments.sum_paid, 0)::int AS "paidCents",
|
||||
(o.total_cents - COALESCE(payments.sum_paid, 0))::int AS "outstandingCents",
|
||||
u.email AS "userEmail"
|
||||
|
||||
@@ -288,8 +288,8 @@ export class CreatePosSaleUseCase {
|
||||
const orderResult = await client.query<{ id: string; created_at: Date }>(
|
||||
`INSERT INTO orders_orders (
|
||||
user_id, idempotency_key, state, subtotal_cents, discount_cents, tax_cents,
|
||||
total_cents, source, terminal_id, cash_session_id, store_id, receipt_number
|
||||
) VALUES ($1, $2, 'PENDING', $3, $4, $5, $6, 'pos', $7, $8, $9, $10)
|
||||
total_cents, source, terminal_id, cash_session_id, store_id, receipt_number, pos_label
|
||||
) VALUES ($1, $2, 'PENDING', $3, $4, $5, $6, 'pos', $7, $8, $9, $10, $11)
|
||||
RETURNING id, created_at`,
|
||||
[
|
||||
input.customerId ?? null,
|
||||
@@ -302,6 +302,7 @@ export class CreatePosSaleUseCase {
|
||||
input.cashSessionId,
|
||||
session.store_id,
|
||||
receiptNumber,
|
||||
input.posLabel ?? null,
|
||||
],
|
||||
);
|
||||
const order = orderResult.rows[0];
|
||||
|
||||
@@ -57,6 +57,8 @@ export interface PosSaleInput {
|
||||
items: PosSaleLineInput[];
|
||||
payments: PosPaymentInput[];
|
||||
customerId?: string;
|
||||
/** Optional label for pending sales without customer */
|
||||
posLabel?: string;
|
||||
}
|
||||
|
||||
export interface PosReceiptItem {
|
||||
|
||||
Reference in New Issue
Block a user