@chenchaolong/plugin-trade-compliance-workbench 1.0.258 → 1.0.259

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/dist/lib/domain/purchase-pricing.d.ts +1 -0
  2. package/dist/lib/domain/purchase-pricing.d.ts.map +1 -1
  3. package/dist/lib/domain/purchase-pricing.js +4 -2
  4. package/dist/lib/domain/purchase-pricing.js.map +1 -1
  5. package/dist/lib/import-jobs/source-field-recovery.d.ts.map +1 -1
  6. package/dist/lib/import-jobs/source-field-recovery.js +6 -3
  7. package/dist/lib/import-jobs/source-field-recovery.js.map +1 -1
  8. package/dist/lib/import-jobs/spreadsheet-contract-facts.d.ts.map +1 -1
  9. package/dist/lib/import-jobs/spreadsheet-contract-facts.js +5 -1
  10. package/dist/lib/import-jobs/spreadsheet-contract-facts.js.map +1 -1
  11. package/dist/lib/invoice/source-layout.d.ts +19 -0
  12. package/dist/lib/invoice/source-layout.d.ts.map +1 -1
  13. package/dist/lib/invoice/source-layout.js +48 -3
  14. package/dist/lib/invoice/source-layout.js.map +1 -1
  15. package/dist/lib/packing/packing-binding.d.ts +4 -0
  16. package/dist/lib/packing/packing-binding.d.ts.map +1 -1
  17. package/dist/lib/packing/packing-binding.js +20 -4
  18. package/dist/lib/packing/packing-binding.js.map +1 -1
  19. package/dist/lib/packing/supplier-packing.service.d.ts.map +1 -1
  20. package/dist/lib/packing/supplier-packing.service.js +10 -4
  21. package/dist/lib/packing/supplier-packing.service.js.map +1 -1
  22. package/dist/lib/remote-components/trade-compliance-workbench/app.js +2 -2
  23. package/dist/lib/remote-ui/import-task-status.d.ts +2 -2
  24. package/dist/lib/sales-file.service.d.ts.map +1 -1
  25. package/dist/lib/sales-file.service.js +25 -7
  26. package/dist/lib/sales-file.service.js.map +1 -1
  27. package/dist/lib/supplier-materials/customs-packaging-recovery.d.ts +1 -1
  28. package/dist/lib/supplier-materials/customs-packaging-recovery.d.ts.map +1 -1
  29. package/dist/lib/supplier-materials/customs-packaging-recovery.js +13 -5
  30. package/dist/lib/supplier-materials/customs-packaging-recovery.js.map +1 -1
  31. package/dist/lib/supplier-materials/customs-source-fields.d.ts.map +1 -1
  32. package/dist/lib/supplier-materials/customs-source-fields.js +14 -10
  33. package/dist/lib/supplier-materials/customs-source-fields.js.map +1 -1
  34. package/dist/lib/supplier-materials/generation-materials.d.ts +2 -0
  35. package/dist/lib/supplier-materials/generation-materials.d.ts.map +1 -1
  36. package/dist/lib/supplier-materials/generation-materials.js +17 -0
  37. package/dist/lib/supplier-materials/generation-materials.js.map +1 -1
  38. package/dist/lib/supplier-materials/supplier-materials.d.ts +9 -6
  39. package/dist/lib/supplier-materials/supplier-materials.d.ts.map +1 -1
  40. package/dist/lib/supplier-materials/supplier-materials.js +108 -32
  41. package/dist/lib/supplier-materials/supplier-materials.js.map +1 -1
  42. package/dist/lib/workbench-view.provider.d.ts +1 -1
  43. package/dist/lib/workbench.middleware.d.ts +114 -114
  44. package/dist/lib/workbench.service.d.ts +8 -7
  45. package/dist/lib/workbench.service.d.ts.map +1 -1
  46. package/dist/lib/workbench.service.js +4 -6
  47. package/dist/lib/workbench.service.js.map +1 -1
  48. package/package.json +1 -1
@@ -28,9 +28,9 @@ export declare function selectTaskForChat(synchronizer: TaskChatSynchronizer, ta
28
28
  export declare function syncSelectedTaskForChat(synchronizer: TaskChatSynchronizer, tasks: ImportTaskStatusItem[]): Promise<void>;
29
29
  export declare function taskChatContext(task: ImportTaskStatusItem): {
30
30
  id: string;
31
- documentType: "ENGLISH_QUOTATION" | "CUSTOMS_INFO" | "SUPPLIER_PACKING" | import("./contracts.js").CatalogDocumentType | import("./contract-import.js").ContractDocumentType;
31
+ documentType: "CUSTOMS_INFO" | "ENGLISH_QUOTATION" | "SUPPLIER_PACKING" | import("./contracts.js").CatalogDocumentType | import("./contract-import.js").ContractDocumentType;
32
32
  sourceFileName: string | null;
33
- status: "FAILED" | "AWAITING_REVIEW" | "SUCCEEDED" | "QUEUED" | "EXTRACTING" | "AI_PARSING" | "VALIDATING" | "PERSISTING" | "TIMED_OUT" | "CANCELED";
33
+ status: "SUCCEEDED" | "FAILED" | "AWAITING_REVIEW" | "QUEUED" | "EXTRACTING" | "AI_PARSING" | "VALIDATING" | "PERSISTING" | "TIMED_OUT" | "CANCELED";
34
34
  progress: {
35
35
  columnMappings?: Array<{
36
36
  sheetName: string;
@@ -1 +1 @@
1
- {"version":3,"file":"sales-file.service.d.ts","sourceRoot":"","sources":["../../src/lib/sales-file.service.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,6BAA6B,EAAE,MAAM,gDAAgD,CAAA;AAK9F,OAAO,EAAE,6BAA6B,EAAE,MAAM,gDAAgD,CAAA;AAe9F,OAAO,EAAE,UAAU,EAAc,KAAK,aAAa,EAAE,MAAM,SAAS,CAAA;AAepE,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AACpC,OAAO,EAA4F,kBAAkB,EAAuH,MAAM,qBAAqB,CAAA;AACvQ,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAA;AAC9E,OAAO,EAAE,+BAA+B,EAAE,MAAM,wBAAwB,CAAA;AACxE,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAA;AACxE,OAAO,EAAE,0BAA0B,EAAE,MAAM,4BAA4B,CAAA;AACvE,OAAO,EAAE,6BAA6B,EAAE,MAAM,+BAA+B,CAAA;AAI7E,OAAO,EAA+E,KAAK,yBAAyB,EAAkC,KAAK,YAAY,EAAE,KAAK,wBAAwB,EAA+B,KAAK,wBAAwB,EAAE,KAAK,2BAA2B,EAAE,KAAK,aAAa,EAAE,MAAM,YAAY,CAAA;AAM5U,eAAO,MAAM,yBAAyB,QAAmB,CAAA;AACzD,eAAO,MAAM,+BAA+B,OAAO,CAAA;AACnD,eAAO,MAAM,0CAA0C,QAAoB,CAAA;AAC3E,eAAO,MAAM,+BAA+B,QAAS,CAAA;AACrD,eAAO,MAAM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;IAYpC,gCAAgC;IAChC,OAAO,CAAC,oBAAoB;CAQ7B;AA+DD,wBAAgB,sBAAsB,CAAC,eAAe,EAAE,KAAK,CAAC;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE,CAAC,EAAE,YAAY,EAAE,KAAK,CAAC;IAAE,mBAAmB,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,CAAC,GAAG,yBAAyB,EAAE,CAE7L;AAmJD,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CA2GxG;AAiXD,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE;IAAE,KAAK,EAAE,KAAK,CAAC;QAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC,CAAA;CAAE,GAAG,IAAI,EAAE,QAAQ,EAAE,OAAO,UAM1J"}
@@ -2,7 +2,7 @@ import { __decorate, __metadata, __param } from "tslib";
2
2
  import { borderWorkbookSection } from './workbook-borders.js';
3
3
  import { combineSalesWorkbooks, CUSTOMS_MISC_FEE_RATE } from './sales-batch-workbook.js';
4
4
  import { applyDynamicInvoiceLayout, DYNAMIC_INVOICE_LAYOUT_VERSION } from './invoice/dynamic-render.js';
5
- import { mergeInvoiceLayouts } from './invoice/source-layout.js';
5
+ import { buyerContactFromInvoices, mergeInvoiceLayouts } from './invoice/source-layout.js';
6
6
  import { InvoiceLayoutAnalysisProvider } from './adapters/invoice-layout-analysis.provider.js';
7
7
  import { invoicePaymentTerms } from './invoice-payment-terms.js';
8
8
  import { balanceDocumentPricing, DOCUMENT_UNIT_PRICE_FORMAT } from './document-pricing.js';
@@ -89,7 +89,8 @@ let SalesFileService = class SalesFileService {
89
89
  result.customsCoverage = { ...materialData.customsDocumentCoverage, sourceNetWeightKg: null, acceptedNetWeightKg: customsWeights.totalNetWeightKg == null ? null : String(customsWeights.totalNetWeightKg) };
90
90
  const materialWarnings = materialData.warnings.filter(warning => !warning.code.startsWith('CUSTOMS_NET_WEIGHT_') && (!warning.code.startsWith('CUSTOMS_') || ['CUSTOMS_DECLARATION', 'ALL'].includes(input.fileType)) && (!warning.code.startsWith('ENGLISH_') || input.fileType !== 'CUSTOMS_DECLARATION'));
91
91
  if (['CUSTOMS_DECLARATION', 'ALL'].includes(input.fileType))
92
- materialWarnings.push({ code: 'CUSTOMS_PACKING_NET_WEIGHT_ESTIMATED', message: '净重暂按PL毛重×80%估算并标色;共箱仅在单品净重完整且能与整箱核对时采用,无法确认的商品净重留空。' });
92
+ materialWarnings.push(...customsMissingItemWeights(materialData.customsLines, materialData.customsScope, customsWeights), { code: 'CUSTOMS_PACKING_NET_WEIGHT_ESTIMATED', message: '净重暂按PL毛重×80%估算并标色;共箱仅在单品净重完整且能与整箱核对时采用,无法确认的商品净重留空。' });
93
+ materialWarnings.push(...buyerContactWarnings(input.fileType, buyerContactFromInvoices(evaluated.customer, materialDocs.flatMap(doc => doc.buyerContacts ?? []))));
93
94
  const priceWarnings = evaluated.warnings.filter(warning => warning.code === 'PURCHASE_NET_PRICE_CONFLICT');
94
95
  if (materialWarnings.length || priceWarnings.length)
95
96
  result.materialWarnings = [...materialWarnings, ...priceWarnings];
@@ -112,7 +113,7 @@ let SalesFileService = class SalesFileService {
112
113
  async generate(scope, input, context, hooks) {
113
114
  await hooks?.progress('VALIDATING', 0);
114
115
  const evaluated = await this.evaluate(scope, input);
115
- const { derived, customerContract, customer, purchaseOrder, purchaseLines, rule, compliance, exchangeCost, exchangeRate, bank, warnings, orders, ordersKey, paymentTermsVariants, documentPricing } = evaluated;
116
+ const { derived, customerContract, purchaseOrder, purchaseLines, rule, compliance, exchangeCost, exchangeRate, bank, warnings, orders, ordersKey, paymentTermsVariants, documentPricing } = evaluated;
116
117
  const generationWarnings = [...warnings];
117
118
  if (['PI', 'CI', 'PI_CI_PL', 'ALL'].includes(input.fileType) && paymentTermsVariants && paymentTermsVariants.length > 1)
118
119
  generationWarnings.push({ code: 'PAYMENT_TERMS_VARY', message: `各订单付款条款不一致,已使用订单 ${orders[0].salesOrderNo} 的付款条款(${paymentTermsVariants[0]}),其余为:${paymentTermsVariants.slice(1).join(';')},请人工核对文件条款` });
@@ -133,6 +134,9 @@ let SalesFileService = class SalesFileService {
133
134
  generationWarnings.push({ code: 'PACKING_ORDER_BASIS', message: '尚无已选定的装箱数据,本文件暂按订单商品数量生成;请按实际发货情况人工核对数量和包装信息。' });
134
135
  const materialDocuments = await this.workbench.loadSupplierMaterials?.(scope, purchaseIds) ?? [];
135
136
  const materialData = generationMaterials(purchaseLines, materialDocuments);
137
+ const contact = buyerContactFromInvoices(evaluated.customer, materialDocuments.flatMap(doc => doc.buyerContacts ?? []));
138
+ const customer = { ...evaluated.customer, address: contact.address, phone: contact.phone };
139
+ generationWarnings.push(...buyerContactWarnings(input.fileType, contact));
136
140
  const sourceInvoiceLayout = mergeInvoiceLayouts(materialDocuments.filter(doc => doc.documentType === 'ENGLISH_QUOTATION' && doc.rows.some(row => row.reviewed && row.purchaseOrderLineId)).map(doc => 'invoiceLayout' in doc ? doc.invoiceLayout : undefined));
137
141
  const invoiceLayout = requestedTypes.some(type => type === 'PI' || type === 'CI') ? this.invoiceLayoutAnalyzer ? await this.invoiceLayoutAnalyzer.analyze(sourceInvoiceLayout, scope.organizationId) : sourceInvoiceLayout : undefined;
138
142
  const customsWeights = customsPackingWeights(packing, materialData.customsLines.filter(line => !materialData.customsScope || materialData.customsScope.purchaseOrderLineIds.includes(line.id)));
@@ -145,7 +149,7 @@ let SalesFileService = class SalesFileService {
145
149
  }
146
150
  generationWarnings.push(...materialData.warnings.filter(warning => !warning.code.startsWith('CUSTOMS_NET_WEIGHT_')));
147
151
  if (requestedTypes.includes('CUSTOMS_DECLARATION'))
148
- generationWarnings.push({ code: 'CUSTOMS_PACKING_NET_WEIGHT_ESTIMATED', message: '净重暂按PL毛重×80%估算并标色;共箱仅在单品净重完整且能与整箱核对时采用,无法确认的商品净重留空。' });
152
+ generationWarnings.push(...customsMissingItemWeights(materialData.customsLines, materialData.customsScope, customsWeights), { code: 'CUSTOMS_PACKING_NET_WEIGHT_ESTIMATED', message: '净重暂按PL毛重×80%估算并标色;共箱仅在单品净重完整且能与整箱核对时采用,无法确认的商品净重留空。' });
149
153
  if (isPlaceholderCustomerName(customer.name))
150
154
  generationWarnings.push({ code: 'CUSTOMS_CUSTOMER_PLACEHOLDER_MISSING', field: 'customer.name', message: '收货人名称为占位内容,报关单保留原值并标色,请核对真实名称。' });
151
155
  const materialsFingerprint = materialSelectionFingerprint(materialDocuments);
@@ -187,7 +191,7 @@ let SalesFileService = class SalesFileService {
187
191
  const field = String(warning.field ?? '');
188
192
  if (String(warning.code ?? '').startsWith('CUSTOMS_') && fileType !== 'CUSTOMS_DECLARATION')
189
193
  return false;
190
- if (String(warning.code ?? '').startsWith('ENGLISH_') && fileType === 'CUSTOMS_DECLARATION')
194
+ if ((String(warning.code ?? '').startsWith('ENGLISH_') || warning.code === 'BUYER_CONTACT_MISSING') && fileType === 'CUSTOMS_DECLARATION')
191
195
  return false;
192
196
  if (fileType === 'CUSTOMS_DECLARATION' && (String(warning.code ?? '').startsWith('TRANSLATION_') || warning.code === 'SOURCE_FIELD_REVIEW'))
193
197
  return false;
@@ -203,7 +207,7 @@ let SalesFileService = class SalesFileService {
203
207
  fileWarnings.push({ code: 'CUSTOMS_ELEMENTS_REVIEW', message: '商品描述采用报关资料申报要素,数量及单位按第一、第二法定单位列示;黄色空缺字段请核对补全,本文件尚未提交海关。' });
204
208
  const dynamicInvoice = (fileType === 'PI' || fileType === 'CI') && invoiceLayout;
205
209
  const request = { currencyCode: documentPricing.currencyCode, ...(batchGenerationId ? { batchGenerationId } : {}), exportIntegrityVersion: SALES_EXPORT_INTEGRITY_VERSION, shipmentDocumentsVersion: 'v2', orderDataFingerprint: fileType === 'PI' ? commercialOrderDataFingerprint : orderDataFingerprint, templateVersion, fileNumber, remarks, bankType, ...(dynamicInvoice ? { dynamicInvoiceLayoutVersion: DYNAMIC_INVOICE_LAYOUT_VERSION } : {}), ...(needsPacking ? { packingMode: input.packingMode ?? 'DRAFT', packingIds: packing?.batchIds ?? [] } : {}), ...(fileType === 'PL' ? { packingLayoutVersion: PACKING_LAYOUT_VERSION } : {}), packingFingerprint: packing?.fingerprint ?? '', ordersKey };
206
- const snapshot = { ...((fileType === 'PI' || fileType === 'CI') && invoiceLayout ? { invoiceLayout } : {}), ...(fileType === 'CUSTOMS_DECLARATION' ? { piTotalAmount: documentPricing.orderAmount, customsWeightSource: { type: 'SUPPLIER_PACKING', packingIds: packing?.batchIds ?? [], grossWeightKg: packing?.totals.grossKg ?? null, netWeightKg: customsWeights.totalNetWeightKg, method: 'PL_GROSS_80_PERCENT', ratio: 0.8, byLine: customsWeights.byLine } } : {}), customsScope: fileType === 'CUSTOMS_DECLARATION' ? materialData.customsScope : null, customsSourceCities, customsCoverage: fileCustomsCoverage, materials: fileType === 'CUSTOMS_DECLARATION' ? materialData.sources.map(source => source.documentType === 'CUSTOMS_INFO' ? { ...source, fields: source.fields.filter(field => field !== 'netWeightKg' || customsWeights.byLine[source.purchaseOrderLineId]?.source === 'REVIEWED_SHARED_ITEM_NET') } : source) : materialData.sources, materialsFingerprint, version: 'v1', generatedAt: generatedAt.toISOString(), fileType, request, orders, documentPricing: fileDocumentPricing, customer: { ...customer }, customerContract: { ...customerContract }, purchaseOrder: { ...purchaseOrder }, purchaseLines: filePurchaseLines.map(item => ({ ...item })), derived: fileDerived, shipment: { reference: shipmentReference, orders, packingIds: packing?.batchIds ?? [], status: 'PENDING_REVIEW' }, company: company ? { ...company } : null, bank: bank ? { ...bank } : null, clauses: clauses.map(item => ({ ...item })), translated: fileTranslated, packing: packing ? { ...packing, mode: input.packingMode ?? 'DRAFT', shipmentLines: fileDerived.lines.filter((line) => (packing.byPurchaseLine[line.purchaseOrderLineId]?.shippedQty ?? 0) > 0).map((line) => ({ purchaseOrderLineId: line.purchaseOrderLineId, quantity: String(packing.byPurchaseLine[line.purchaseOrderLineId].shippedQty) })) } : null, compliance: { profitCny: compliance.profitCny.toString(), complianceProfitRate: compliance.complianceProfitRate.toString() }, exchangeRate: exchangeRate ? { ...exchangeRate } : null, exchangeCost: exchangeCost?.toString() ?? null, rule: { ...rule } };
210
+ const snapshot = { ...((fileType === 'PI' || fileType === 'CI') && invoiceLayout ? { invoiceLayout } : {}), ...(fileType === 'CUSTOMS_DECLARATION' ? { piTotalAmount: documentPricing.orderAmount, customsWeightSource: { type: 'SUPPLIER_PACKING', packingIds: packing?.batchIds ?? [], grossWeightKg: packing?.totals.grossKg ?? null, netWeightKg: customsWeights.totalNetWeightKg, method: 'PL_GROSS_80_PERCENT', ratio: 0.8, byLine: customsWeights.byLine } } : {}), customsScope: fileType === 'CUSTOMS_DECLARATION' ? materialData.customsScope : null, customsSourceCities, customsCoverage: fileCustomsCoverage, materials: fileType === 'CUSTOMS_DECLARATION' ? materialData.sources.map(source => source.documentType === 'CUSTOMS_INFO' ? { ...source, fields: source.fields.filter(field => field !== 'netWeightKg' || customsWeights.byLine[source.purchaseOrderLineId]?.source === 'REVIEWED_SHARED_ITEM_NET') } : source) : materialData.sources, materialsFingerprint, ...(Object.keys(contact.sources).length ? { buyerContactSources: contact.sources } : {}), version: 'v1', generatedAt: generatedAt.toISOString(), fileType, request, orders, documentPricing: fileDocumentPricing, customer: { ...customer }, customerContract: { ...customerContract }, purchaseOrder: { ...purchaseOrder }, purchaseLines: filePurchaseLines.map(item => ({ ...item })), derived: fileDerived, shipment: { reference: shipmentReference, orders, packingIds: packing?.batchIds ?? [], status: 'PENDING_REVIEW' }, company: company ? { ...company } : null, bank: bank ? { ...bank } : null, clauses: clauses.map(item => ({ ...item })), translated: fileTranslated, packing: packing ? { ...packing, mode: input.packingMode ?? 'DRAFT', shipmentLines: fileDerived.lines.filter((line) => (packing.byPurchaseLine[line.purchaseOrderLineId]?.shippedQty ?? 0) > 0).map((line) => ({ purchaseOrderLineId: line.purchaseOrderLineId, quantity: String(packing.byPurchaseLine[line.purchaseOrderLineId].shippedQty) })) } : null, compliance: { profitCny: compliance.profitCny.toString(), complianceProfitRate: compliance.complianceProfitRate.toString() }, exchangeRate: exchangeRate ? { ...exchangeRate } : null, exchangeCost: exchangeCost?.toString() ?? null, rule: { ...rule } };
207
211
  const sheetSources = { itemNetByProduct: {} };
208
212
  const logo = await this.readCompanyLogo(scope, fileType, company?.logoFileId);
209
213
  const buffer = await this.fillWorkbook(fileType, { snapshot, customer, customerContract, purchaseOrder, purchaseLines: filePurchaseLines, derived: fileDerived, company, bank, clauses, translated: fileTranslated, packing, customsCoverage: fileCustomsCoverage, generationWarnings: fileWarnings, sheetSources }, logo);
@@ -690,10 +694,24 @@ SalesFileService = __decorate([
690
694
  InvoiceLayoutAnalysisProvider])
691
695
  ], SalesFileService);
692
696
  export { SalesFileService };
697
+ function customsMissingItemWeights(lines, scope, weights) {
698
+ return lines.filter(line => (!scope || scope.purchaseOrderLineIds.includes(line.id)) &&
699
+ [line.statutoryUnitPrimary, line.statutoryUnitSecondary].some(unit => /^(?:千克|公斤|kgs?)$/i.test(unit ?? '')) && !weights.byLine[line.id])
700
+ .map(line => ({ code: 'CUSTOMS_ITEM_WEIGHT_MISSING', purchaseOrderLineId: line.id, field: `customs.${line.id}.netWeightKg`,
701
+ message: `商品“${line.modelSpecification || line.productName}”法定单位包含千克,但没有可对应的商品净重,请核对装箱关联。` }));
702
+ }
703
+ function buyerContactWarnings(fileType, contact) {
704
+ if (fileType === 'CUSTOMS_DECLARATION')
705
+ return [];
706
+ return ['address', 'phone'].flatMap(field => contact[field] ? [] : [{
707
+ code: 'BUYER_CONTACT_MISSING', field: `customer.${field}`,
708
+ message: `客户档案及本次可核验的英文资料未提供唯一的买方${field === 'address' ? '地址' : '电话'},文件留空。`
709
+ }]);
710
+ }
693
711
  function materialSelectionFingerprint(documents) {
694
712
  // Upload progress is not a change to the adopted generation facts. Approval,
695
713
  // binding, source revision and adoption state still invalidate a running batch.
696
- return createHash('sha256').update(JSON.stringify(documents.map(({ id, documentType, sourceFileName, revision, rows, sourceRows, adoption }) => ({ id, documentType, sourceFileName, revision, rows, sourceRows, adoption })))).digest('hex');
714
+ return createHash('sha256').update(JSON.stringify(documents.map(({ id, documentType, sourceFileName, revision, rows, sourceRows, adoption, buyerContacts }) => ({ id, documentType, sourceFileName, revision, rows, sourceRows, adoption, buyerContacts })))).digest('hex');
697
715
  }
698
716
  function editedWorkbookLimits() {
699
717
  return {