@@ -0,0 +1,36 @@
|
||||
import type { ReceiptProgress } from '@/types/inventory';
|
||||
import { hasPreparationChanges } from '@/lib/requisition-history';
|
||||
|
||||
export function receiptPreparationKey(
|
||||
tenant: number | null | undefined,
|
||||
actor: number | undefined,
|
||||
order: number,
|
||||
progress: ReceiptProgress,
|
||||
): string {
|
||||
const source = [...progress.lines]
|
||||
.sort((a, b) => a.id - b.id)
|
||||
.map((line) =>
|
||||
[
|
||||
line.id,
|
||||
line.ordered_milli,
|
||||
line.received_milli,
|
||||
line.accepted_milli,
|
||||
line.rejected_milli,
|
||||
line.delivery_pending_milli,
|
||||
line.acceptance_pending_milli,
|
||||
line.supplier_returned_milli ?? 0,
|
||||
line.effective_accepted_milli ?? line.accepted_milli,
|
||||
].join(':'),
|
||||
)
|
||||
.join('~');
|
||||
return `receipt-preparation:${tenant}:${actor}:${order}:${source}`;
|
||||
}
|
||||
|
||||
export function receiptPreparationChanged(
|
||||
initial: Record<string, unknown>,
|
||||
current: Record<string, unknown>,
|
||||
): boolean {
|
||||
const { idempotency_key: _initialKey, ...original } = initial;
|
||||
const { idempotency_key: _currentKey, ...preparation } = current;
|
||||
return hasPreparationChanges(original, preparation);
|
||||
}
|
||||
Reference in New Issue
Block a user