@chenchaolong/plugin-trade-compliance-workbench 1.0.234 → 1.0.235
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.
- package/dist/lib/domain/default-settings.d.ts +1 -0
- package/dist/lib/domain/default-settings.d.ts.map +1 -1
- package/dist/lib/domain/default-settings.js +1 -0
- package/dist/lib/domain/default-settings.js.map +1 -1
- package/dist/lib/entities/settings.entity.d.ts +2 -0
- package/dist/lib/entities/settings.entity.d.ts.map +1 -1
- package/dist/lib/entities/settings.entity.js +4 -0
- package/dist/lib/entities/settings.entity.js.map +1 -1
- package/dist/lib/packing/packing-complete-rows.d.ts +1 -1
- package/dist/lib/packing/packing-complete-rows.d.ts.map +1 -1
- package/dist/lib/packing/packing-complete-rows.js +10 -11
- package/dist/lib/packing/packing-complete-rows.js.map +1 -1
- package/dist/lib/packing/packing-full-text.d.ts.map +1 -1
- package/dist/lib/packing/packing-full-text.js +69 -8
- package/dist/lib/packing/packing-full-text.js.map +1 -1
- package/dist/lib/packing/packing-render.d.ts.map +1 -1
- package/dist/lib/packing/packing-render.js +2 -19
- package/dist/lib/packing/packing-render.js.map +1 -1
- package/dist/lib/remote-components/trade-compliance-workbench/app.js +1 -1
- package/dist/lib/remote-components/trade-compliance-workbench/editor-source.mjs +61 -1
- package/dist/lib/remote-components/trade-compliance-workbench/editor.js +141 -127
- package/dist/lib/remote-ui/components/packing-generation-actions.js +1 -1
- package/dist/lib/remote-ui/components/packing-generation-actions.js.map +1 -1
- package/dist/lib/remote-ui/components/supplier-materials.d.ts +1 -0
- package/dist/lib/remote-ui/components/supplier-materials.d.ts.map +1 -1
- package/dist/lib/remote-ui/components/supplier-materials.js +2 -2
- package/dist/lib/remote-ui/components/supplier-materials.js.map +1 -1
- package/dist/lib/remote-ui/pages/settings.d.ts.map +1 -1
- package/dist/lib/remote-ui/pages/settings.js +1 -1
- package/dist/lib/remote-ui/pages/settings.js.map +1 -1
- package/dist/lib/remote-ui/settings-contracts.d.ts +1 -0
- package/dist/lib/remote-ui/settings-contracts.d.ts.map +1 -1
- package/dist/lib/sales-file.service.d.ts +1 -1
- package/dist/lib/sales-file.service.d.ts.map +1 -1
- package/dist/lib/sales-file.service.js +48 -21
- package/dist/lib/sales-file.service.js.map +1 -1
- package/dist/lib/schema-maintenance.d.ts.map +1 -1
- package/dist/lib/schema-maintenance.js +2 -0
- package/dist/lib/schema-maintenance.js.map +1 -1
- package/dist/lib/supplier-materials/customs-coverage.js +1 -1
- package/dist/lib/supplier-materials/customs-coverage.js.map +1 -1
- package/dist/lib/supplier-materials/customs-packaging-recovery.d.ts +14 -0
- package/dist/lib/supplier-materials/customs-packaging-recovery.d.ts.map +1 -0
- package/dist/lib/supplier-materials/customs-packaging-recovery.js +29 -0
- package/dist/lib/supplier-materials/customs-packaging-recovery.js.map +1 -0
- package/dist/lib/supplier-materials/customs-source-fields.d.ts.map +1 -1
- package/dist/lib/supplier-materials/customs-source-fields.js +39 -1
- package/dist/lib/supplier-materials/customs-source-fields.js.map +1 -1
- package/dist/lib/supplier-materials/generation-materials.d.ts +2 -0
- package/dist/lib/supplier-materials/generation-materials.d.ts.map +1 -1
- package/dist/lib/supplier-materials/generation-materials.js +9 -2
- package/dist/lib/supplier-materials/generation-materials.js.map +1 -1
- package/dist/lib/supplier-materials/supplier-materials.d.ts +2 -1
- package/dist/lib/supplier-materials/supplier-materials.d.ts.map +1 -1
- package/dist/lib/supplier-materials/supplier-materials.js +5 -2
- package/dist/lib/supplier-materials/supplier-materials.js.map +1 -1
- package/dist/lib/types.d.ts +1 -0
- package/dist/lib/types.d.ts.map +1 -1
- package/dist/lib/workbench-view.provider.d.ts +2 -0
- package/dist/lib/workbench-view.provider.d.ts.map +1 -1
- package/dist/lib/workbench.middleware.d.ts +7 -0
- package/dist/lib/workbench.middleware.d.ts.map +1 -1
- package/dist/lib/workbench.middleware.js +1 -1
- package/dist/lib/workbench.middleware.js.map +1 -1
- package/dist/lib/workbench.service.d.ts +1 -0
- package/dist/lib/workbench.service.d.ts.map +1 -1
- package/dist/lib/workbench.service.js +13 -4
- package/dist/lib/workbench.service.js.map +1 -1
- package/package.json +1 -1
|
@@ -39,8 +39,8 @@ export const MAX_EDITED_WORKBOOK_BYTES = 20 * 1024 * 1024;
|
|
|
39
39
|
export const MAX_EDITED_WORKBOOK_ZIP_ENTRIES = 2048;
|
|
40
40
|
export const MAX_EDITED_WORKBOOK_ZIP_UNCOMPRESSED_BYTES = 100 * 1024 * 1024;
|
|
41
41
|
export const OLD_SALES_FILE_CLEANUP_DELAY_MS = 30_000;
|
|
42
|
-
export const SALES_EXPORT_INTEGRITY_VERSION = '2026-11-
|
|
43
|
-
const PACKING_LAYOUT_VERSION = '
|
|
42
|
+
export const SALES_EXPORT_INTEGRITY_VERSION = '2026-11-11.customs-packaging-source';
|
|
43
|
+
const PACKING_LAYOUT_VERSION = 'v15';
|
|
44
44
|
const COMPANY_LOGO_PLACEMENTS = {
|
|
45
45
|
PI: { tl: { col: 0, row: 0.02925 }, br: { col: 2, row: 0.999996875 } },
|
|
46
46
|
CI: { tl: { col: 0, row: 0.02925 }, br: { col: 2, row: 0.999996875 } },
|
|
@@ -1154,7 +1154,7 @@ function fillPackingSheet(sheet, data) {
|
|
|
1154
1154
|
set(sheet, 'F5', orderDateValue === '' ? '—' : orderDateValue);
|
|
1155
1155
|
if (orderDateValue !== '')
|
|
1156
1156
|
sheet.getCell('F5').numFmt = 'yyyy/m/d';
|
|
1157
|
-
set(sheet, 'F6',
|
|
1157
|
+
set(sheet, 'F6', company?.contactName?.trim() || '—');
|
|
1158
1158
|
set(sheet, 'F7', company?.email || '—');
|
|
1159
1159
|
set(sheet, 'F8', company?.phone || '—');
|
|
1160
1160
|
rows.forEach((line, index) => {
|
|
@@ -1340,13 +1340,17 @@ function fillCustomsSheet(sheet, data) {
|
|
|
1340
1340
|
set(sheet, 'C9', packing?.totals.cartons > 0 ? packing.totals.cartons : '待确认');
|
|
1341
1341
|
set(sheet, 'D9', packing?.totals.grossKg > 0 ? packing.totals.grossKg : '待确认');
|
|
1342
1342
|
set(sheet, 'E9', data.customsCoverage?.acceptedNetWeightKg != null ? Number(data.customsCoverage.acceptedNetWeightKg) : '待确认');
|
|
1343
|
+
set(sheet, 'L8', pricing.currencyCode === 'USD' ? '美元' : '人民币');
|
|
1343
1344
|
const terms = [...new Set(((deliveryClauseText(data.clauses ?? []) || '').toUpperCase().match(/\b(?:EXW|FCA|FAS|FOB|CFR|CIF|CPT|CIP|DAP|DPU|DDP)\b/g) ?? []))];
|
|
1344
1345
|
set(sheet, 'F9', terms.length === 1 ? terms[0] : '待确认');
|
|
1345
1346
|
for (const address of ['F6', 'H6']) {
|
|
1346
1347
|
set(sheet, address, null);
|
|
1347
1348
|
markReview(sheet.getCell(address));
|
|
1348
1349
|
}
|
|
1349
|
-
|
|
1350
|
+
const packagingTypes = [...new Set(purchaseLines.map((line) => String(line.packagingType ?? '').trim()).filter(Boolean))];
|
|
1351
|
+
set(sheet, 'A9', packagingTypes.join('、') || '待确认');
|
|
1352
|
+
if (packagingTypes.length > 1)
|
|
1353
|
+
markReview(sheet.getCell('A9'), 'FFFFE0B2');
|
|
1350
1354
|
set(sheet, 'G9', '待确认');
|
|
1351
1355
|
set(sheet, 'I9', '待确认');
|
|
1352
1356
|
set(sheet, 'K9', '待确认');
|
|
@@ -1358,7 +1362,8 @@ function fillCustomsSheet(sheet, data) {
|
|
|
1358
1362
|
for (const offset of [0, 1])
|
|
1359
1363
|
for (const column of [6, 7, 8])
|
|
1360
1364
|
sheet.getCell(row + offset, column).value = null;
|
|
1361
|
-
|
|
1365
|
+
const fallbackDescription = [product.productDescription, product.modelSpecification && !String(product.productDescription ?? '').includes(product.modelSpecification) ? product.modelSpecification : null].filter(Boolean).join('\n');
|
|
1366
|
+
set(sheet, `C${row + 1}`, product.declarationElements || fallbackDescription || null);
|
|
1362
1367
|
if (!String(product.declarationElements ?? '').trim())
|
|
1363
1368
|
markReview(sheet.getCell(`C${row + 1}`));
|
|
1364
1369
|
safeMerge(sheet, `A${row}:A${row + 1}`);
|
|
@@ -1374,8 +1379,15 @@ function fillCustomsSheet(sheet, data) {
|
|
|
1374
1379
|
const quantities = customsQuantityRows(product, derived.lines[index]);
|
|
1375
1380
|
// Price belongs to the commercial quantity row, never the statutory kg row
|
|
1376
1381
|
// merely because it is first in the declaration template.
|
|
1377
|
-
const
|
|
1378
|
-
const priceRow = row +
|
|
1382
|
+
const tradeRow = quantities.findIndex(entry => entry.quantity != null && customsUnitsCompatible(product.unit, entry.unit));
|
|
1383
|
+
const priceRow = row + Math.max(0, tradeRow);
|
|
1384
|
+
if (tradeRow < 0) {
|
|
1385
|
+
// Two statutory slots can be occupied by sets and kg. Keep commercial
|
|
1386
|
+
// pieces separately in the goods cell instead of silently equating units.
|
|
1387
|
+
set(sheet, `C${row}`, `${product.productName || ''}\n成交数量:${new Decimal(derived.lines[index].quantity).toString()} ${String(product.unit || '').trim()}`.trim());
|
|
1388
|
+
markReview(sheet.getCell(`C${row}`), 'FFFFE0B2');
|
|
1389
|
+
markReview(sheet.getCell(`F${priceRow}`), 'FFFFE0B2');
|
|
1390
|
+
}
|
|
1379
1391
|
set(sheet, `F${priceRow}`, Number(pricing.lines[index].unitPrice));
|
|
1380
1392
|
set(sheet, `G${priceRow}`, Number(pricing.lines[index].lineAmount));
|
|
1381
1393
|
set(sheet, `H${priceRow}`, pricing.currencyCode === 'USD' ? '美元' : '人民币');
|
|
@@ -1384,11 +1396,15 @@ function fillCustomsSheet(sheet, data) {
|
|
|
1384
1396
|
set(sheet, `E${row + offset}`, entry.unit);
|
|
1385
1397
|
if (entry.review)
|
|
1386
1398
|
markReview(sheet.getCell(`D${row + offset}`));
|
|
1399
|
+
if (entry.inferred)
|
|
1400
|
+
for (const column of ['D', 'E'])
|
|
1401
|
+
markReview(sheet.getCell(`${column}${row + offset}`), 'FFFFE0B2');
|
|
1387
1402
|
}
|
|
1388
1403
|
for (const warning of data.generationWarnings ?? [])
|
|
1389
1404
|
if (String(warning.field ?? '').startsWith(`customs.${purchaseLines[index].id}.`))
|
|
1390
1405
|
markReview(sheet.getCell(String(warning.field).endsWith('.hsCode') ? `B${row}` : `C${row}`));
|
|
1391
|
-
|
|
1406
|
+
const priceFormat = pricing.currencyCode === 'CNY' && new Decimal(pricing.lines[index].unitPrice).decimalPlaces() > 2 ? '0.0000' : '0.00';
|
|
1407
|
+
sheet.getCell(`F${priceRow}`).numFmt = priceFormat + (tradeRow < 0 && product.unit ? `" / ${String(product.unit).replace(/["\\]/g, '')}"` : '');
|
|
1392
1408
|
sheet.getCell(`G${priceRow}`).numFmt = '0.00';
|
|
1393
1409
|
}
|
|
1394
1410
|
const tail = 14 + derived.lines.length * 2;
|
|
@@ -1396,27 +1412,38 @@ function fillCustomsSheet(sheet, data) {
|
|
|
1396
1412
|
set(sheet, `B${tail + 3}`, companyText);
|
|
1397
1413
|
}
|
|
1398
1414
|
/** Quantity order follows explicit statutory units; trade quantity and sale pricing remain independent. */
|
|
1415
|
+
function customsUnitsCompatible(source, target) {
|
|
1416
|
+
const normalize = (value) => String(value ?? '').normalize('NFKC').trim().toLowerCase().replace(/\.$/, '');
|
|
1417
|
+
const a = normalize(source), b = normalize(target);
|
|
1418
|
+
const count = /^(?:pcs?|pieces?|个|件|台)$/;
|
|
1419
|
+
const set = /^(?:sets?|套)$/;
|
|
1420
|
+
const kg = /^(?:千克|公斤|kg|kgs|kilograms?)$/;
|
|
1421
|
+
return Boolean(a && b) && (a === b || count.test(a) && count.test(b) || set.test(a) && set.test(b) || kg.test(a) && kg.test(b));
|
|
1422
|
+
}
|
|
1399
1423
|
function customsQuantityRows(product, commercial) {
|
|
1400
|
-
const
|
|
1424
|
+
const explicitPrimary = String(product.statutoryUnitPrimary || '').trim();
|
|
1401
1425
|
const isKg = (unit) => /^(?:千克|公斤|kg|kgs|kilograms?)$/i.test(unit);
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1426
|
+
const tradeUnit = String(product.unit || '').trim();
|
|
1427
|
+
// Commercial quantities must remain visible. A purchase unit is traceable
|
|
1428
|
+
// evidence, not a confirmed statutory unit: mark the fallback for review.
|
|
1429
|
+
const primary = explicitPrimary || tradeUnit;
|
|
1430
|
+
const explicitSecondary = String(product.statutoryUnitSecondary || '').trim();
|
|
1431
|
+
const secondary = explicitSecondary || (isKg(primary) && tradeUnit && !isKg(tradeUnit) ? tradeUnit : '');
|
|
1432
|
+
return [primary, secondary].map((unit, index) => {
|
|
1433
|
+
const inferred = Boolean(unit && (index === 0 ? !explicitPrimary : !explicitSecondary));
|
|
1405
1434
|
if (!unit)
|
|
1406
1435
|
return { unit, quantity: null, review: false };
|
|
1407
1436
|
if (isKg(unit)) {
|
|
1408
1437
|
const weight = product.netWeightKg;
|
|
1409
|
-
const valid = typeof weight === 'number' && Number.isFinite(weight) && weight
|
|
1410
|
-
|
|
1438
|
+
const valid = typeof weight === 'number' && Number.isFinite(weight) && weight > 0;
|
|
1439
|
+
// If the commercial unit itself is kg, its quantity remains authoritative.
|
|
1440
|
+
const quantity = isKg(tradeUnit) && Number.isFinite(Number(commercial.quantity)) && commercial.quantity != null ? Number(commercial.quantity) : valid ? weight : null;
|
|
1441
|
+
return { unit, quantity, review: quantity == null, inferred };
|
|
1411
1442
|
}
|
|
1412
|
-
const
|
|
1413
|
-
const
|
|
1414
|
-
const setUnit = (value) => /^(?:sets?|套)$/.test(value);
|
|
1415
|
-
const sourceUnit = normalizedUnit(product.unit);
|
|
1416
|
-
const targetUnit = normalizedUnit(unit);
|
|
1417
|
-
const compatible = Boolean(sourceUnit) && (sourceUnit === targetUnit || (countUnit(sourceUnit) && countUnit(targetUnit)) || (setUnit(sourceUnit) && setUnit(targetUnit)));
|
|
1443
|
+
const compatible = customsUnitsCompatible(product.unit, unit);
|
|
1444
|
+
const sourceQuantity = (index === (isKg(primary) ? 1 : 0)) && product.customsSourceQuantity != null && Number.isFinite(Number(product.customsSourceQuantity)) && Number(product.customsSourceQuantity) > 0 ? Number(product.customsSourceQuantity) : null;
|
|
1418
1445
|
const valid = compatible && commercial.quantity != null && Number.isFinite(Number(commercial.quantity));
|
|
1419
|
-
return { unit, quantity: valid ? Number(commercial.quantity) :
|
|
1446
|
+
return { unit, quantity: valid ? Number(commercial.quantity) : sourceQuantity, review: !valid, inferred };
|
|
1420
1447
|
});
|
|
1421
1448
|
}
|
|
1422
1449
|
function normalizeCustomsConfirmationRow(sheet, row) {
|