@chenchaolong/plugin-trade-compliance-workbench 1.0.239 → 1.0.240
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/customs-formatting.d.ts.map +1 -1
- package/dist/lib/customs-formatting.js +5 -4
- package/dist/lib/customs-formatting.js.map +1 -1
- package/dist/lib/export-formatting.d.ts +5 -0
- package/dist/lib/export-formatting.d.ts.map +1 -0
- package/dist/lib/export-formatting.js +18 -0
- package/dist/lib/export-formatting.js.map +1 -0
- package/dist/lib/invoice-formatting.d.ts.map +1 -1
- package/dist/lib/invoice-formatting.js +9 -7
- package/dist/lib/invoice-formatting.js.map +1 -1
- package/dist/lib/packing/packing-full-text.d.ts +2 -2
- package/dist/lib/packing/packing-full-text.d.ts.map +1 -1
- package/dist/lib/packing/packing-full-text.js +21 -73
- package/dist/lib/packing/packing-full-text.js.map +1 -1
- package/dist/lib/packing/packing-layout.js +5 -5
- package/dist/lib/packing/packing-layout.js.map +1 -1
- package/dist/lib/packing/packing-pi-model-column.js +4 -4
- package/dist/lib/packing/packing-pi-model-column.js.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 +28 -25
- package/dist/lib/sales-file.service.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { __decorate, __metadata, __param } from "tslib";
|
|
2
|
+
import { clearExportReviewColors } from './export-formatting.js';
|
|
2
3
|
import { customsPackingWeights } from './customs-packing-weight.js';
|
|
3
4
|
import { addPackingPiModelColumn } from './packing/packing-pi-model-column.js';
|
|
4
5
|
import { scopeCustomsDocument, isPlaceholderCustomerName } from './customs-document-scope.js';
|
|
@@ -42,8 +43,8 @@ export const MAX_EDITED_WORKBOOK_BYTES = 20 * 1024 * 1024;
|
|
|
42
43
|
export const MAX_EDITED_WORKBOOK_ZIP_ENTRIES = 2048;
|
|
43
44
|
export const MAX_EDITED_WORKBOOK_ZIP_UNCOMPRESSED_BYTES = 100 * 1024 * 1024;
|
|
44
45
|
export const OLD_SALES_FILE_CLEANUP_DELAY_MS = 30_000;
|
|
45
|
-
export const SALES_EXPORT_INTEGRITY_VERSION = '2026-11-
|
|
46
|
-
const PACKING_LAYOUT_VERSION = '
|
|
46
|
+
export const SALES_EXPORT_INTEGRITY_VERSION = '2026-11-12.compact-without-review-colors';
|
|
47
|
+
const PACKING_LAYOUT_VERSION = 'v21';
|
|
47
48
|
const COMPANY_LOGO_PLACEMENTS = {
|
|
48
49
|
PI: { tl: { col: 0, row: 0.02925 }, br: { col: 2, row: 0.999996875 } },
|
|
49
50
|
CI: { tl: { col: 0, row: 0.02925 }, br: { col: 2, row: 0.999996875 } },
|
|
@@ -956,6 +957,7 @@ export async function renderSalesWorkbook(type, data, logo) {
|
|
|
956
957
|
for (const other of [...workbook.worksheets])
|
|
957
958
|
if (other.id !== sheet.id)
|
|
958
959
|
workbook.removeWorksheet(other.id);
|
|
960
|
+
clearExportReviewColors(sheet, type);
|
|
959
961
|
return removeExportComments(Buffer.from(await workbook.xlsx.writeBuffer()));
|
|
960
962
|
}
|
|
961
963
|
/** Remove comment parts and their relationships without changing drawings or business cells. */
|
|
@@ -1140,10 +1142,15 @@ function fillPackingPhysicalRows(sheet, rows, data) {
|
|
|
1140
1142
|
if (conflict || !completeScope || !repeated && (value == null || typeof value === 'number' && (!Number.isFinite(value) || value <= 0)))
|
|
1141
1143
|
markReview(cell, conflict ? 'FFFFC7CE' : !completeScope ? 'FFFFE0B2' : undefined);
|
|
1142
1144
|
});
|
|
1143
|
-
//
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
sheet.getCell(excelRow,
|
|
1145
|
+
// Estimate only from this physical group's gross; never allocate a shared
|
|
1146
|
+
// carton weight among commercial goods or count it again on repeated rows.
|
|
1147
|
+
for (const [column, grossColumn] of [[10, 6], [11, 12]]) {
|
|
1148
|
+
const gross = sheet.getCell(excelRow, grossColumn).value;
|
|
1149
|
+
const cell = sheet.getCell(excelRow, column);
|
|
1150
|
+
cell.value = typeof gross === 'number' && Number.isFinite(gross) && gross >= 0 ? new Decimal(gross).mul('0.8').toNumber() : null;
|
|
1151
|
+
cell.numFmt = '0.######';
|
|
1152
|
+
if (!repeated)
|
|
1153
|
+
markReview(cell, cell.value == null ? 'FFFFF2CC' : conflict ? 'FFFFC7CE' : 'FFFFE0B2');
|
|
1147
1154
|
}
|
|
1148
1155
|
if (conflict || !completeScope) {
|
|
1149
1156
|
markReview(sheet.getCell(excelRow, 3));
|
|
@@ -1193,8 +1200,8 @@ function fillPackingSheet(sheet, data) {
|
|
|
1193
1200
|
const incomplete = packing?.totalsComplete === false;
|
|
1194
1201
|
const labels = ['Total Gross weight (KG)', 'Total Net weight (KG)', 'Volume (CBM)', 'Total Carton (CTN)'];
|
|
1195
1202
|
const grossKg = packing?.totals.grossKg;
|
|
1196
|
-
const
|
|
1197
|
-
const totals = [grossKg,
|
|
1203
|
+
const estimatedNet = grossKg != null && Number.isFinite(Number(grossKg)) && Number(grossKg) >= 0 ? new Decimal(grossKg).mul('0.8').toNumber() : null;
|
|
1204
|
+
const totals = [grossKg, estimatedNet, packing?.totals.volumeCbm, packing?.totals.cartons];
|
|
1198
1205
|
labels.forEach((label, offset) => {
|
|
1199
1206
|
set(sheet, `A${totalsRow + offset}`, label);
|
|
1200
1207
|
const total = totals[offset];
|
|
@@ -1232,10 +1239,7 @@ function fillPackingSheet(sheet, data) {
|
|
|
1232
1239
|
if (incomplete)
|
|
1233
1240
|
for (const offset of [0, 1, 2, 3])
|
|
1234
1241
|
markReview(sheet.getCell(totalsRow + offset, 6));
|
|
1235
|
-
|
|
1236
|
-
markReview(sheet.getCell(totalsRow + 1, 6));
|
|
1237
|
-
else
|
|
1238
|
-
sheet.getCell(totalsRow + 1, 6).note = 'Net weight from confirmed source documents; no proportional estimation.';
|
|
1242
|
+
markReview(sheet.getCell(totalsRow + 1, 6), totals[1] == null ? 'FFFFF2CC' : 'FFFFE0B2');
|
|
1239
1243
|
sheet.getCell(totalsRow + 1, 6).numFmt = '0.######';
|
|
1240
1244
|
}
|
|
1241
1245
|
/**
|
|
@@ -1417,7 +1421,10 @@ function fillCustomsSheet(sheet, data) {
|
|
|
1417
1421
|
// Price belongs to the commercial quantity row, never the statutory kg row
|
|
1418
1422
|
// merely because it is first in the declaration template.
|
|
1419
1423
|
const tradeRow = quantities.findIndex(entry => customsUnitsCompatible(product.unit, entry.unit));
|
|
1420
|
-
|
|
1424
|
+
// Missing statutory units stay blank; keep commercial prices off a kg row
|
|
1425
|
+
// when the sale itself is counted in pieces, even without a secondary unit.
|
|
1426
|
+
const kgUnit = (unit) => /^(?:千克|公斤|kg|kgs|kilograms?)$/i.test(String(unit ?? '').trim());
|
|
1427
|
+
const priceRow = row + (tradeRow >= 0 ? tradeRow : kgUnit(quantities[0].unit) && product.unit && !kgUnit(product.unit) ? 1 : 0);
|
|
1421
1428
|
if (tradeRow < 0) {
|
|
1422
1429
|
// Retain source text and financial values; communicate unit conflicts by color only.
|
|
1423
1430
|
markReview(sheet.getCell(`C${row}`), 'FFFFE0B2');
|
|
@@ -1433,9 +1440,6 @@ function fillCustomsSheet(sheet, data) {
|
|
|
1433
1440
|
markReview(sheet.getCell(`D${row + offset}`));
|
|
1434
1441
|
if (weights.byLine[product.id]?.estimated && /^(?:千克|公斤|kg|kgs|kilograms?)$/i.test(entry.unit) && entry.quantity != null)
|
|
1435
1442
|
markReview(sheet.getCell(`D${row + offset}`), 'FFFFE0B2');
|
|
1436
|
-
if (entry.inferred)
|
|
1437
|
-
for (const column of ['D', 'E'])
|
|
1438
|
-
markReview(sheet.getCell(`${column}${row + offset}`), 'FFFFE0B2');
|
|
1439
1443
|
}
|
|
1440
1444
|
for (const warning of data.generationWarnings ?? [])
|
|
1441
1445
|
if (String(warning.field ?? '').startsWith(`customs.${purchaseLines[index].id}.`))
|
|
@@ -1460,14 +1464,13 @@ function customsUnitsCompatible(source, target) {
|
|
|
1460
1464
|
function customsQuantityRows(product, commercial) {
|
|
1461
1465
|
const explicitPrimary = String(product.statutoryUnitPrimary || '').trim();
|
|
1462
1466
|
const isKg = (unit) => /^(?:千克|公斤|kg|kgs|kilograms?)$/i.test(unit);
|
|
1463
|
-
|
|
1464
|
-
//
|
|
1465
|
-
|
|
1466
|
-
const primary = explicitPrimary || tradeUnit;
|
|
1467
|
+
// Only source-confirmed statutory units authorize a declaration quantity.
|
|
1468
|
+
// A purchase/trade unit must never fill an absent primary or secondary unit.
|
|
1469
|
+
const primary = explicitPrimary;
|
|
1467
1470
|
const explicitSecondary = String(product.statutoryUnitSecondary || '').trim();
|
|
1468
|
-
const secondary = explicitSecondary
|
|
1471
|
+
const secondary = explicitSecondary;
|
|
1472
|
+
const sourceCountRow = [primary, secondary].findIndex(unit => Boolean(unit) && !isKg(unit));
|
|
1469
1473
|
return [primary, secondary].map((unit, index) => {
|
|
1470
|
-
const inferred = Boolean(unit && (index === 0 ? !explicitPrimary : !explicitSecondary));
|
|
1471
1474
|
if (!unit)
|
|
1472
1475
|
return { unit, quantity: null, review: false };
|
|
1473
1476
|
if (isKg(unit)) {
|
|
@@ -1475,12 +1478,12 @@ function customsQuantityRows(product, commercial) {
|
|
|
1475
1478
|
const valid = typeof weight === 'number' && Number.isFinite(weight) && weight > 0;
|
|
1476
1479
|
// A commercial kg quantity cannot substitute for missing PL net weight.
|
|
1477
1480
|
const quantity = valid ? weight : null;
|
|
1478
|
-
return { unit, quantity, review: quantity == null
|
|
1481
|
+
return { unit, quantity, review: quantity == null };
|
|
1479
1482
|
}
|
|
1480
1483
|
const compatible = customsUnitsCompatible(product.unit, unit);
|
|
1481
|
-
const sourceQuantity = (index ===
|
|
1484
|
+
const sourceQuantity = (index === sourceCountRow) && product.customsSourceQuantity != null && Number.isFinite(Number(product.customsSourceQuantity)) && Number(product.customsSourceQuantity) > 0 ? Number(product.customsSourceQuantity) : null;
|
|
1482
1485
|
const valid = compatible && commercial.quantity != null && Number.isFinite(Number(commercial.quantity));
|
|
1483
|
-
return { unit, quantity: valid ? Number(commercial.quantity) : sourceQuantity, review: !valid
|
|
1486
|
+
return { unit, quantity: valid ? Number(commercial.quantity) : sourceQuantity, review: !valid };
|
|
1484
1487
|
});
|
|
1485
1488
|
}
|
|
1486
1489
|
function normalizeCustomsConfirmationRow(sheet, row) {
|