修复 R125 发票删除后重传查重

这个提交包含在:
2026-05-08 22:20:34 +08:00
父节点 b78e82edab
当前提交 b75ad226c6
共修改 4 个文件,包含 556 行新增和 2 行删除
+17 -2
查看文件
@@ -31,6 +31,10 @@ function isUsedInvoice(invoice) {
);
}
function isInactiveArchivedInvoice(invoice) {
return Boolean(invoice?.status === "archived" && invoice?.archived_reason !== USED_COMPLETE_ARCHIVED_REASON);
}
function classifyInvoiceConflict(conflict, ownerEmployeeId) {
if (!conflict) {
return null;
@@ -40,6 +44,10 @@ function classifyInvoiceConflict(conflict, ownerEmployeeId) {
return INVOICE_UNAVAILABLE_REASONS.usedByCompany;
}
if (isInactiveArchivedInvoice(conflict)) {
return null;
}
if (conflict.owner_employee_id && conflict.owner_employee_id !== ownerEmployeeId) {
return INVOICE_UNAVAILABLE_REASONS.duplicateOtherOwner;
}
@@ -94,8 +102,15 @@ async function findInvoiceDedupConflicts(tx, input) {
where: {
...(input.excludeInvoiceId ? { id: { not: input.excludeInvoiceId } } : {}),
is_duplicate_override: false,
OR: filters,
status: { in: ["pending_ocr", "ocr_failed", "available", "bound", "archived"] },
AND: [
{ OR: filters },
{
OR: [
{ status: { in: ["pending_ocr", "ocr_failed", "available", "bound"] } },
{ status: "archived", archived_reason: USED_COMPLETE_ARCHIVED_REASON },
],
},
],
},
orderBy: [{ created_at: "asc" }, { id: "asc" }],
select: {