feat(management): content-based duplicate detection for scanned receipts #183
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/182-receipt-duplicate-detection"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #182.
What changed
PotentialDuplicateandPotentialDuplicateSchemaintypes.ts.duplicate-check.ts.scanReceipt(service.ts).add-purchase-modal.tsxandadd-penjualan-modal.tsx.duplicate-check.test.ts.Verified
pnpm test lib/scanner/: 41 passedpnpm typecheck: 0 errorsDeviations
none
VERDICT: request-changes
Three correctness issues in the duplicate matcher:
duplicate-check.ts:142); days 4–7 require an item match, so valid duplicates within the requested ±7-day window are missed. Apply the seven-day window to supplier-and-total matching.duplicate-check.ts:140) and different customers/vehicles (duplicate-check.ts:221). The amount-and-item fallbacks likewise omit identity. Require supplier/customer/vehicle identity before labeling an unrelated transaction a potential duplicate.duplicate-check.ts:99–101). For purchases with more than five items this displays a partial amount and can defeat amount matching; retain the complete date-window entry on ID collisions.Read-only review; no tests or builds run.
Addressed review round 1 feedback:
diffDays <= 7).isPartyMatchas a prerequisite before flagging duplicate purchases or orders, eliminating false positives for unrelated parties on the same date.dateGroupedentries when merging withsupplierMatcheson ID collisions (if (!candMap.has(p.id)) candMap.set(p.id, p);).VERDICT: request-changes
Round 1 fixes are present: purchase supplier/total comparisons now cover ±7 days; same-day equal totals require the same party; date-window purchases win collisions with partial supplier-search results. The new tests cover unrelated parties.
[P1] The new unconditional party gate in
apps/management/lib/scanner/duplicate-check.ts:204disables duplicate detection for sales recorded by the scan-to-form modal.AddPenjualanModal.handleSubmitalways creates sales withcustomerId: nullandvehicleId: null, so when that receipt is rescanned,fetchOrdersWithItemsreturns no customer or plate for its existing order.isPartyMatchis always false, and even an exact-date, exact-amount, identical-item repeat never produces a warning. Please retain a reliable match path for these records or persist an identity that can be compared.Read-only review; no tests or builds run.
Addressed review round 2 feedback:
!cleanCust && !cleanPlate) or receipt has no customer name: matches on exact date, amount, and items (Total nominal dan rincian barang sama pada tanggal ini (transaksi umum)), and matches on exact date and amount when neither side has customer identity.VERDICT: approve
Round 3 re-review of
7a917ac: anonymous/counter sales now produce warnings on the stated date/amount/item criteria, and distinct named customers still require identity matching. The earlier purchase-window and candidate-merge corrections remain intact. No blocking issues found. Read-only review; tests and builds were not rerun.