@chenchaolong/plugin-trade-compliance-workbench 0.1.73 → 1.0.0

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 (180) hide show
  1. package/README.md +41 -22
  2. package/dist/assets/templates/CI.xlsx +0 -0
  3. package/dist/assets/templates/CUSTOMS_DECLARATION.xlsx +0 -0
  4. package/dist/assets/templates/PI.xlsx +0 -0
  5. package/dist/assets/templates/PL.xlsx +0 -0
  6. package/dist/index.d.ts +115 -228
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +19 -108
  9. package/dist/index.js.map +1 -1
  10. package/dist/lib/{document-text-extractor.d.ts → adapters/document-text-extractor.d.ts} +2 -2
  11. package/dist/lib/adapters/document-text-extractor.d.ts.map +1 -0
  12. package/dist/lib/{document-text-extractor.js → adapters/document-text-extractor.js} +8 -2
  13. package/dist/lib/adapters/document-text-extractor.js.map +1 -0
  14. package/dist/lib/adapters/file-storage.d.ts +9 -0
  15. package/dist/lib/adapters/file-storage.d.ts.map +1 -0
  16. package/dist/lib/adapters/file-storage.js +37 -0
  17. package/dist/lib/adapters/file-storage.js.map +1 -0
  18. package/dist/lib/{trade-compliance.enrichment.d.ts → adapters/hsbianma.provider.d.ts} +6 -6
  19. package/dist/lib/adapters/hsbianma.provider.d.ts.map +1 -0
  20. package/dist/lib/{trade-compliance.enrichment.js → adapters/hsbianma.provider.js} +1 -1
  21. package/dist/lib/adapters/hsbianma.provider.js.map +1 -0
  22. package/dist/lib/adapters/translation.provider.d.ts +4 -0
  23. package/dist/lib/adapters/translation.provider.d.ts.map +1 -0
  24. package/dist/lib/adapters/translation.provider.js +35 -0
  25. package/dist/lib/adapters/translation.provider.js.map +1 -0
  26. package/dist/lib/constants.d.ts +17 -11
  27. package/dist/lib/constants.d.ts.map +1 -1
  28. package/dist/lib/constants.js +17 -21
  29. package/dist/lib/constants.js.map +1 -1
  30. package/dist/lib/domain/contract-number.d.ts +14 -0
  31. package/dist/lib/domain/contract-number.d.ts.map +1 -0
  32. package/dist/lib/domain/contract-number.js +36 -0
  33. package/dist/lib/domain/contract-number.js.map +1 -0
  34. package/dist/lib/domain/default-settings.d.ts +28 -0
  35. package/dist/lib/domain/default-settings.d.ts.map +1 -0
  36. package/dist/lib/domain/default-settings.js +16 -0
  37. package/dist/lib/domain/default-settings.js.map +1 -0
  38. package/dist/lib/domain/finance.d.ts +37 -0
  39. package/dist/lib/domain/finance.d.ts.map +1 -0
  40. package/dist/lib/domain/finance.js +60 -0
  41. package/dist/lib/domain/finance.js.map +1 -0
  42. package/dist/lib/domain/import-issues.d.ts +10 -0
  43. package/dist/lib/domain/import-issues.d.ts.map +1 -0
  44. package/dist/lib/domain/import-issues.js +23 -0
  45. package/dist/lib/domain/import-issues.js.map +1 -0
  46. package/dist/lib/domain/normalization.d.ts +8 -0
  47. package/dist/lib/domain/normalization.d.ts.map +1 -0
  48. package/dist/lib/domain/normalization.js +50 -0
  49. package/dist/lib/domain/normalization.js.map +1 -0
  50. package/dist/lib/domain/workflow.d.ts +4 -0
  51. package/dist/lib/domain/workflow.d.ts.map +1 -0
  52. package/dist/lib/domain/workflow.js +14 -0
  53. package/dist/lib/domain/workflow.js.map +1 -0
  54. package/dist/lib/entities/base.d.ts +20 -0
  55. package/dist/lib/entities/base.d.ts.map +1 -0
  56. package/dist/lib/entities/base.js +51 -0
  57. package/dist/lib/entities/base.js.map +1 -0
  58. package/dist/lib/entities/catalog.entity.d.ts +80 -0
  59. package/dist/lib/entities/catalog.entity.d.ts.map +1 -0
  60. package/dist/lib/entities/catalog.entity.js +308 -0
  61. package/dist/lib/entities/catalog.entity.js.map +1 -0
  62. package/dist/lib/entities/customer.entity.d.ts +72 -0
  63. package/dist/lib/entities/customer.entity.d.ts.map +1 -0
  64. package/dist/lib/entities/customer.entity.js +276 -0
  65. package/dist/lib/entities/customer.entity.js.map +1 -0
  66. package/dist/lib/entities/index.d.ts +12 -6
  67. package/dist/lib/entities/index.d.ts.map +1 -1
  68. package/dist/lib/entities/index.js +20 -7
  69. package/dist/lib/entities/index.js.map +1 -1
  70. package/dist/lib/entities/procurement.entity.d.ts +99 -0
  71. package/dist/lib/entities/procurement.entity.d.ts.map +1 -0
  72. package/dist/lib/entities/procurement.entity.js +386 -0
  73. package/dist/lib/entities/procurement.entity.js.map +1 -0
  74. package/dist/lib/entities/settings.entity.d.ts +64 -0
  75. package/dist/lib/entities/settings.entity.d.ts.map +1 -0
  76. package/dist/lib/entities/settings.entity.js +243 -0
  77. package/dist/lib/entities/settings.entity.js.map +1 -0
  78. package/dist/lib/entities/shared.entity.d.ts +40 -0
  79. package/dist/lib/entities/shared.entity.d.ts.map +1 -0
  80. package/dist/lib/entities/shared.entity.js +149 -0
  81. package/dist/lib/entities/shared.entity.js.map +1 -0
  82. package/dist/lib/remote-components/trade-compliance-workbench/app.js +245 -2677
  83. package/dist/lib/remote-components/trade-compliance-workbench/editor-source.mjs +53 -0
  84. package/dist/lib/remote-components/trade-compliance-workbench/editor.css +1 -0
  85. package/dist/lib/remote-components/trade-compliance-workbench/editor.js +533 -0
  86. package/dist/lib/sales-file.service.d.ts +29 -0
  87. package/dist/lib/sales-file.service.d.ts.map +1 -0
  88. package/dist/lib/sales-file.service.js +300 -0
  89. package/dist/lib/sales-file.service.js.map +1 -0
  90. package/dist/lib/trade-compliance.config.d.ts +94 -187
  91. package/dist/lib/trade-compliance.config.d.ts.map +1 -1
  92. package/dist/lib/trade-compliance.config.js +12 -96
  93. package/dist/lib/trade-compliance.config.js.map +1 -1
  94. package/dist/lib/types.d.ts +104 -1
  95. package/dist/lib/types.d.ts.map +1 -1
  96. package/dist/lib/types.js +47 -1
  97. package/dist/lib/types.js.map +1 -1
  98. package/dist/lib/workbench-view.provider.d.ts +276 -0
  99. package/dist/lib/workbench-view.provider.d.ts.map +1 -0
  100. package/dist/lib/workbench-view.provider.js +222 -0
  101. package/dist/lib/workbench-view.provider.js.map +1 -0
  102. package/dist/lib/workbench.middleware.d.ts +351 -0
  103. package/dist/lib/workbench.middleware.d.ts.map +1 -0
  104. package/dist/lib/workbench.middleware.js +48 -0
  105. package/dist/lib/workbench.middleware.js.map +1 -0
  106. package/dist/lib/workbench.plugin.d.ts +5 -0
  107. package/dist/lib/workbench.plugin.d.ts.map +1 -0
  108. package/dist/lib/workbench.plugin.js +24 -0
  109. package/dist/lib/workbench.plugin.js.map +1 -0
  110. package/dist/lib/workbench.service.d.ts +257 -0
  111. package/dist/lib/workbench.service.d.ts.map +1 -0
  112. package/dist/lib/workbench.service.js +755 -0
  113. package/dist/lib/workbench.service.js.map +1 -0
  114. package/package.json +19 -25
  115. package/dist/assets/customs-workbook-template.xls +0 -0
  116. package/dist/lib/controlled-goods-extracted-text-store.d.ts +0 -29
  117. package/dist/lib/controlled-goods-extracted-text-store.d.ts.map +0 -1
  118. package/dist/lib/controlled-goods-extracted-text-store.js +0 -42
  119. package/dist/lib/controlled-goods-extracted-text-store.js.map +0 -1
  120. package/dist/lib/controlled-goods-file-parser.d.ts +0 -9
  121. package/dist/lib/controlled-goods-file-parser.d.ts.map +0 -1
  122. package/dist/lib/controlled-goods-file-parser.js +0 -298
  123. package/dist/lib/controlled-goods-file-parser.js.map +0 -1
  124. package/dist/lib/document-text-extractor.d.ts.map +0 -1
  125. package/dist/lib/document-text-extractor.js.map +0 -1
  126. package/dist/lib/entities/controlled-goods-record.entity.d.ts +0 -5
  127. package/dist/lib/entities/controlled-goods-record.entity.d.ts.map +0 -1
  128. package/dist/lib/entities/controlled-goods-record.entity.js +0 -68
  129. package/dist/lib/entities/controlled-goods-record.entity.js.map +0 -1
  130. package/dist/lib/entities/customs-workbook-generation.entity.d.ts +0 -5
  131. package/dist/lib/entities/customs-workbook-generation.entity.d.ts.map +0 -1
  132. package/dist/lib/entities/customs-workbook-generation.entity.js +0 -72
  133. package/dist/lib/entities/customs-workbook-generation.entity.js.map +0 -1
  134. package/dist/lib/entities/trade-compliance-import-batch.entity.d.ts +0 -5
  135. package/dist/lib/entities/trade-compliance-import-batch.entity.d.ts.map +0 -1
  136. package/dist/lib/entities/trade-compliance-import-batch.entity.js +0 -60
  137. package/dist/lib/entities/trade-compliance-import-batch.entity.js.map +0 -1
  138. package/dist/lib/entities/trade-compliance-review-item.entity.d.ts +0 -5
  139. package/dist/lib/entities/trade-compliance-review-item.entity.d.ts.map +0 -1
  140. package/dist/lib/entities/trade-compliance-review-item.entity.js +0 -84
  141. package/dist/lib/entities/trade-compliance-review-item.entity.js.map +0 -1
  142. package/dist/lib/entities/trade-product.entity.d.ts +0 -5
  143. package/dist/lib/entities/trade-product.entity.d.ts.map +0 -1
  144. package/dist/lib/entities/trade-product.entity.js +0 -105
  145. package/dist/lib/entities/trade-product.entity.js.map +0 -1
  146. package/dist/lib/entities/trade-supplier.entity.d.ts +0 -5
  147. package/dist/lib/entities/trade-supplier.entity.d.ts.map +0 -1
  148. package/dist/lib/entities/trade-supplier.entity.js +0 -55
  149. package/dist/lib/entities/trade-supplier.entity.js.map +0 -1
  150. package/dist/lib/trade-compliance-workbench-view.provider.d.ts +0 -129
  151. package/dist/lib/trade-compliance-workbench-view.provider.d.ts.map +0 -1
  152. package/dist/lib/trade-compliance-workbench-view.provider.js +0 -863
  153. package/dist/lib/trade-compliance-workbench-view.provider.js.map +0 -1
  154. package/dist/lib/trade-compliance-workbench.middleware.d.ts +0 -485
  155. package/dist/lib/trade-compliance-workbench.middleware.d.ts.map +0 -1
  156. package/dist/lib/trade-compliance-workbench.middleware.js +0 -494
  157. package/dist/lib/trade-compliance-workbench.middleware.js.map +0 -1
  158. package/dist/lib/trade-compliance-workbench.plugin.d.ts +0 -11
  159. package/dist/lib/trade-compliance-workbench.plugin.d.ts.map +0 -1
  160. package/dist/lib/trade-compliance-workbench.plugin.js +0 -39
  161. package/dist/lib/trade-compliance-workbench.plugin.js.map +0 -1
  162. package/dist/lib/trade-compliance-workbench.service.d.ts +0 -33
  163. package/dist/lib/trade-compliance-workbench.service.d.ts.map +0 -1
  164. package/dist/lib/trade-compliance-workbench.service.js +0 -369
  165. package/dist/lib/trade-compliance-workbench.service.js.map +0 -1
  166. package/dist/lib/trade-compliance-workbench.templates.d.ts +0 -31
  167. package/dist/lib/trade-compliance-workbench.templates.d.ts.map +0 -1
  168. package/dist/lib/trade-compliance-workbench.templates.js +0 -60
  169. package/dist/lib/trade-compliance-workbench.templates.js.map +0 -1
  170. package/dist/lib/trade-compliance-workbook.d.ts +0 -28
  171. package/dist/lib/trade-compliance-workbook.d.ts.map +0 -1
  172. package/dist/lib/trade-compliance-workbook.js +0 -635
  173. package/dist/lib/trade-compliance-workbook.js.map +0 -1
  174. package/dist/lib/trade-compliance.enrichment.d.ts.map +0 -1
  175. package/dist/lib/trade-compliance.enrichment.js.map +0 -1
  176. package/dist/lib/trade-compliance.matching.d.ts +0 -10
  177. package/dist/lib/trade-compliance.matching.d.ts.map +0 -1
  178. package/dist/lib/trade-compliance.matching.js +0 -63
  179. package/dist/lib/trade-compliance.matching.js.map +0 -1
  180. package/dist/xpert-trade-compliance-workbench-assistant.yaml +0 -27
@@ -1,635 +0,0 @@
1
- // @ts-nocheck
2
- import * as XLSX from 'xlsx';
3
- import ExcelJS from 'exceljs';
4
- const SHEET_NAMES = ['报关单', 'CI', 'Contract', 'PL'];
5
- export const CUSTOMS_WORKBOOK_XLS_MIME_TYPE = 'application/vnd.ms-excel';
6
- export const CUSTOMS_WORKBOOK_XLSX_MIME_TYPE = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
7
- export function buildCustomsWorkbookModel(source, defaults) {
8
- return {
9
- ...source,
10
- invoiceNo: source.invoiceNo ?? buildInvoiceNo(),
11
- sellerEnglishName: source.sellerEnglishName ?? defaults.sellerEnglishName,
12
- sellerEnglishAddress: source.sellerEnglishAddress ?? defaults.sellerEnglishAddress,
13
- paymentTerm: source.paymentTerm ?? defaults.paymentTerm,
14
- tradeTerm: source.tradeTerm ?? defaults.tradeTerm,
15
- origin: source.origin ?? defaults.origin,
16
- destination: source.destination ?? defaults.destination,
17
- packageType: source.packageType ?? defaults.packageType,
18
- supervisionMode: source.supervisionMode ?? defaults.supervisionMode,
19
- taxExemptionNature: source.taxExemptionNature ?? defaults.taxExemptionNature,
20
- domesticSourceLocation: source.domesticSourceLocation ?? defaults.domesticSourceLocation,
21
- bankBeneficiary: source.bankBeneficiary ?? defaults.bankBeneficiary,
22
- bankName: source.bankName ?? defaults.bankName,
23
- bankAddress: source.bankAddress ?? defaults.bankAddress,
24
- bankAccountNo: source.bankAccountNo ?? defaults.bankAccountNo,
25
- cnapsCode: source.cnapsCode ?? defaults.cnapsCode,
26
- swiftCode: source.swiftCode ?? defaults.swiftCode,
27
- exchangeRate: source.exchangeRate ?? defaults.exchangeRate,
28
- items: source.items ?? []
29
- };
30
- }
31
- export function createCustomsWorkbookBuffer(model) {
32
- const workbook = XLSX.utils.book_new();
33
- XLSX.utils.book_append_sheet(workbook, XLSX.utils.aoa_to_sheet(buildDeclarationRows(model)), SHEET_NAMES[0]);
34
- XLSX.utils.book_append_sheet(workbook, XLSX.utils.aoa_to_sheet(buildCommercialInvoiceRows(model)), SHEET_NAMES[1]);
35
- XLSX.utils.book_append_sheet(workbook, XLSX.utils.aoa_to_sheet(buildSalesContractRows(model)), SHEET_NAMES[2]);
36
- XLSX.utils.book_append_sheet(workbook, XLSX.utils.aoa_to_sheet(buildPackingListRows(model)), SHEET_NAMES[3]);
37
- return {
38
- fileName: `${sanitizeFilePart(model.invoiceNo)}-customs-workbook.xlsx`,
39
- sheetNames: [...SHEET_NAMES],
40
- mimeType: CUSTOMS_WORKBOOK_XLSX_MIME_TYPE,
41
- bookType: 'xlsx',
42
- buffer: XLSX.write(workbook, { type: 'buffer', bookType: 'xlsx' })
43
- };
44
- }
45
- export function createCustomsWorkbookFromTemplateBuffer(model, _templateBuffer) {
46
- return createStyledCustomsWorkbook(model);
47
- }
48
- export async function createStyledCustomsWorkbook(model) {
49
- const workbook = new ExcelJS.Workbook();
50
- workbook.creator = 'Trade Compliance Workbench';
51
- workbook.created = new Date();
52
- workbook.modified = new Date();
53
- buildDeclarationWorksheet(workbook.addWorksheet('报关单'), model);
54
- buildInvoiceWorksheet(workbook.addWorksheet('CI'), model, 'Commercial Invoice');
55
- buildInvoiceWorksheet(workbook.addWorksheet('Contract'), model, 'Sales Contract');
56
- buildPackingListWorksheet(workbook.addWorksheet('PL'), model);
57
- const buffer = Buffer.from(await workbook.xlsx.writeBuffer());
58
- return {
59
- fileName: buildCustomsWorkbookTemplateFileName(model.invoiceNo),
60
- sheetNames: [...SHEET_NAMES],
61
- mimeType: CUSTOMS_WORKBOOK_XLSX_MIME_TYPE,
62
- bookType: 'xlsx',
63
- buffer
64
- };
65
- }
66
- export function buildCustomsWorkbookTemplateFileName(invoiceNo) {
67
- return `${sanitizeFilePart(invoiceNo)}-销售发票.xlsx`;
68
- }
69
- export function readCustomsWorkbookTemplateSheetNames(templateBuffer) {
70
- return XLSX.read(templateBuffer, { type: 'buffer', bookSheets: true }).SheetNames;
71
- }
72
- const thinBorder = {
73
- top: { style: 'thin' },
74
- left: { style: 'thin' },
75
- bottom: { style: 'thin' },
76
- right: { style: 'thin' }
77
- };
78
- const baseFont = { name: 'Arial', size: 12, color: { argb: 'FF000000' } };
79
- const boldFont = { ...baseFont, bold: true };
80
- const titleFont = { name: 'Arial', size: 22, bold: true, color: { argb: 'FF000000' } };
81
- const logoFont = { name: 'Arial', size: 18, bold: true, italic: true, color: { argb: 'FF00A8E8' } };
82
- const centerMiddle = { vertical: 'middle', horizontal: 'center', wrapText: true };
83
- const leftMiddle = { vertical: 'middle', horizontal: 'left', wrapText: true };
84
- const rightMiddle = { vertical: 'middle', horizontal: 'right', wrapText: true };
85
- const tableHeaderFill = { type: 'pattern', pattern: 'solid', fgColor: { argb: 'FF808080' } };
86
- const whiteBoldFont = { name: 'Arial', size: 12, bold: true, color: { argb: 'FFFFFFFF' } };
87
- function setColumns(sheet, widths) {
88
- sheet.columns = widths.map((width) => ({ width }));
89
- }
90
- function mergeRanges(sheet, ranges) {
91
- for (const range of ranges)
92
- sheet.mergeCells(range);
93
- }
94
- function put(sheet, address, value, options = {}) {
95
- const cell = sheet.getCell(address);
96
- if (value !== undefined && value !== null && value !== '') {
97
- cell.value = typeof value === 'object' ? JSON.stringify(value) : value;
98
- }
99
- cell.font = options.font ?? cell.font ?? baseFont;
100
- cell.alignment = options.alignment ?? cell.alignment ?? leftMiddle;
101
- if (options.numFmt)
102
- cell.numFmt = options.numFmt;
103
- if (options.fill)
104
- cell.fill = options.fill;
105
- if (options.border)
106
- cell.border = options.border;
107
- }
108
- function applyGrid(sheet, range) {
109
- const [start, end] = range.split(':');
110
- const startCell = decodeAddress(start);
111
- const endCell = decodeAddress(end);
112
- for (let row = startCell.row; row <= endCell.row; row += 1) {
113
- for (let col = startCell.col; col <= endCell.col; col += 1) {
114
- const cell = sheet.getCell(row, col);
115
- cell.border = thinBorder;
116
- cell.font = cell.font && Object.keys(cell.font).length ? cell.font : baseFont;
117
- cell.alignment = cell.alignment && Object.keys(cell.alignment).length ? cell.alignment : leftMiddle;
118
- }
119
- }
120
- }
121
- function decodeAddress(address) {
122
- const match = /^([A-Z]+)(\d+)$/.exec(address);
123
- if (!match)
124
- throw new Error(`Invalid cell address: ${address}`);
125
- return { col: columnIndex(match[1]), row: Number(match[2]) };
126
- }
127
- function columnIndex(name) {
128
- return name.split('').reduce((total, char) => total * 26 + char.charCodeAt(0) - 64, 0);
129
- }
130
- function columnName(index) {
131
- let name = '';
132
- let value = index;
133
- while (value > 0) {
134
- const remainder = (value - 1) % 26;
135
- name = String.fromCharCode(65 + remainder) + name;
136
- value = Math.floor((value - 1) / 26);
137
- }
138
- return name;
139
- }
140
- function applyTableStyle(sheet, range, headerRow) {
141
- const [start, end] = range.split(':');
142
- const startCell = decodeAddress(start);
143
- const endCell = decodeAddress(end);
144
- for (let row = startCell.row; row <= endCell.row; row += 1) {
145
- for (let col = startCell.col; col <= endCell.col; col += 1) {
146
- const cell = sheet.getCell(row, col);
147
- cell.border = thinBorder;
148
- cell.font = cell.font && Object.keys(cell.font).length ? cell.font : baseFont;
149
- cell.alignment = cell.alignment && Object.keys(cell.alignment).length ? cell.alignment : centerMiddle;
150
- if (headerRow && row === headerRow) {
151
- cell.fill = tableHeaderFill;
152
- cell.font = whiteBoldFont;
153
- cell.alignment = centerMiddle;
154
- }
155
- }
156
- }
157
- }
158
- function templateSellerAddress(model) {
159
- return cleanPlaceholder(model.sellerEnglishAddress) ??
160
- 'Room602,Building16,No.A3,4thIndustrial Zone,Heshuikou Community,Matian Street,Guangming District,Shenzhen,Guangdong';
161
- }
162
- function templateSellerName(model) {
163
- return cleanPlaceholder(model.sellerEnglishName) ?? cleanPlaceholder(model.sellerName) ?? 'Yuneec Technology(Shenzhen)Co.,Ltd';
164
- }
165
- function cleanPlaceholder(value) {
166
- const text = stringValue(value)?.trim();
167
- return text && text !== '未识别' ? text : undefined;
168
- }
169
- function descriptionRowHeight(item) {
170
- const text = [item.description, item.model].filter(Boolean).join('\n');
171
- const lineCount = text.split(/\r?\n|\/\s*/).filter(Boolean).length;
172
- return Math.max(54, Math.min(190, lineCount * 18));
173
- }
174
- function declarationDetailText(item) {
175
- const productName = normalizeComparableText(item.productName);
176
- const englishName = normalizeComparableText(item.englishName);
177
- return [item.description, item.model]
178
- .map((value) => stringValue(value)?.trim())
179
- .filter((value) => {
180
- const normalized = normalizeComparableText(value);
181
- return normalized && normalized !== productName && normalized !== englishName;
182
- })
183
- .join('\n');
184
- }
185
- function normalizeComparableText(value) {
186
- return stringValue(value)?.replace(/\s+/g, '').toLowerCase();
187
- }
188
- function formatQuantityUnit(item) {
189
- const quantity = item.quantity ?? '';
190
- const unit = item.unit ?? '';
191
- return [quantity, unit].filter((value) => value !== undefined && value !== null && value !== '').join(' ');
192
- }
193
- function buildDeclarationWorksheet(sheet, model) {
194
- sheet.views = [{ showGridLines: false }];
195
- sheet.pageSetup = { orientation: 'landscape', fitToPage: true, fitToWidth: 1, fitToHeight: 1 };
196
- setColumns(sheet, [15, 16, 54, 14, 14, 14, 18, 12, 14, 14, 13, 10]);
197
- for (let row = 1; row <= 24; row += 1)
198
- sheet.getRow(row).height = 22;
199
- sheet.getRow(14).height = 28;
200
- sheet.getRow(15).height = 42;
201
- sheet.getRow(16).height = 28;
202
- sheet.getRow(17).height = 42;
203
- mergeRanges(sheet, ['B3:C3', 'I3:J3', 'B4:E4', 'G4:H4', 'I4:J4', 'B5:E5', 'G5:H5', 'I5:J5', 'B6:E6', 'G6:H6', 'I6:J6', 'B7:C7', 'E7:F7', 'H7:I7', 'K7:L7', 'A9:C9', 'F20:J20', 'H21:J21']);
204
- put(sheet, 'A3', '预录入编号:', { font: boldFont });
205
- put(sheet, 'C3', '海关编号:', { font: boldFont });
206
- put(sheet, 'K3', '页码/页数:', { font: boldFont });
207
- put(sheet, 'A4', '境内发货人', { font: boldFont });
208
- put(sheet, 'B4', model.sellerName ?? model.sellerEnglishName);
209
- put(sheet, 'F4', '出境关别', { font: boldFont });
210
- put(sheet, 'H4', '出口日期', { font: boldFont });
211
- put(sheet, 'J4', '申报日期', { font: boldFont });
212
- put(sheet, 'K4', '备案号', { font: boldFont });
213
- put(sheet, 'A5', '境外收货人', { font: boldFont });
214
- put(sheet, 'B5', model.buyerName);
215
- put(sheet, 'F5', '运输方式', { font: boldFont });
216
- put(sheet, 'H5', '运输工具名称及航次号', { font: boldFont });
217
- put(sheet, 'J5', '提运单号', { font: boldFont });
218
- put(sheet, 'A6', '生产销售单位', { font: boldFont });
219
- put(sheet, 'B6', model.sellerName ?? model.sellerEnglishName);
220
- put(sheet, 'F6', '监管方式', { font: boldFont });
221
- put(sheet, 'G6', model.supervisionMode);
222
- put(sheet, 'H6', '征免性质', { font: boldFont });
223
- put(sheet, 'I6', model.taxExemptionNature);
224
- put(sheet, 'J6', '许可证号', { font: boldFont });
225
- put(sheet, 'A7', '合同协议号', { font: boldFont });
226
- put(sheet, 'B7', model.contractNo);
227
- put(sheet, 'D7', '贸易国(地区)', { font: boldFont });
228
- put(sheet, 'F7', '运抵国(地区)', { font: boldFont });
229
- put(sheet, 'G7', model.destination);
230
- put(sheet, 'H7', '指运港', { font: boldFont });
231
- put(sheet, 'J7', '离境口岸', { font: boldFont });
232
- put(sheet, 'A8', '包装种类', { font: boldFont });
233
- put(sheet, 'B8', '件数', { font: boldFont });
234
- put(sheet, 'D8', '毛重(千克)', { font: boldFont });
235
- put(sheet, 'E8', '净重(千克)', { font: boldFont });
236
- put(sheet, 'F8', '成交方式', { font: boldFont });
237
- put(sheet, 'G8', '运费', { font: boldFont });
238
- put(sheet, 'H8', '保费', { font: boldFont });
239
- put(sheet, 'I8', '杂费', { font: boldFont });
240
- put(sheet, 'A9', model.packageType);
241
- put(sheet, 'D9', sum(model.items, 'grossWeight') || readNumber(model, 'grossWeight'));
242
- put(sheet, 'E9', sum(model.items, 'netWeight') || readNumber(model, 'netWeight'));
243
- put(sheet, 'F9', model.tradeTerm);
244
- put(sheet, 'K9', readNumber(model, 'freight'));
245
- put(sheet, 'A10', '随附单证及编号', { font: boldFont });
246
- put(sheet, 'A11', '标记唛码及备注', { font: boldFont });
247
- put(sheet, 'A12', 'N/M', { font: boldFont });
248
- const headers = ['项号', '商品编号', '商品名称及规格型号', '数量及单位', '单价', '总价', '币制', '原产国(地区)', '最终目的国', '境内货源地', '征免'];
249
- headers.forEach((header, index) => put(sheet, `${columnName(index + 1)}13`, header, { font: boldFont, alignment: centerMiddle }));
250
- model.items.slice(0, 2).forEach((item, index) => {
251
- const row = 14 + index * 2;
252
- put(sheet, `A${row}`, index + 1, { alignment: rightMiddle });
253
- put(sheet, `B${row}`, item.hsCode);
254
- put(sheet, `C${row}`, item.productName || item.englishName);
255
- put(sheet, `D${row}`, formatQuantityUnit(item));
256
- put(sheet, `E${row}`, item.unitPrice, { numFmt: '#,##0.00' });
257
- put(sheet, `F${row}`, item.amount, { numFmt: '#,##0.00' });
258
- put(sheet, `G${row}`, model.currency || 'RMB');
259
- put(sheet, `H${row}`, model.origin);
260
- put(sheet, `I${row}`, model.destination);
261
- put(sheet, `J${row}`, model.domesticSourceLocation);
262
- put(sheet, `K${row}`, '照章征免');
263
- put(sheet, `C${row + 1}`, declarationDetailText(item));
264
- put(sheet, `D${row + 1}`, formatQuantityUnit({ quantity: item.netWeight, unit: item.netWeight ? '千克' : undefined }));
265
- });
266
- put(sheet, 'A18', '特殊关系确认:否', { font: boldFont });
267
- put(sheet, 'C18', '价格影响确认:否', { font: boldFont });
268
- put(sheet, 'E18', '支付特许权使用费确认:否', { font: boldFont });
269
- put(sheet, 'H18', '自报自缴:是', { font: boldFont });
270
- put(sheet, 'A19', '报关人员', { font: boldFont });
271
- put(sheet, 'C19', '报关人员证号', { font: boldFont });
272
- put(sheet, 'F19', '电话', { font: boldFont });
273
- put(sheet, 'F20', '兹申明对以上内容承担如实申报、依法纳税之法律责任', { alignment: centerMiddle });
274
- put(sheet, 'J20', '海关批注及签章', { font: boldFont });
275
- put(sheet, 'A21', '申报单位', { font: boldFont });
276
- put(sheet, 'H21', '申报单位(签章)', { alignment: centerMiddle });
277
- applyGrid(sheet, 'A3:L21');
278
- }
279
- function buildInvoiceWorksheet(sheet, model, title) {
280
- sheet.views = [{ showGridLines: false }];
281
- sheet.pageSetup = { fitToPage: true, fitToWidth: 1, fitToHeight: 1 };
282
- setColumns(sheet, [11, 22, 48, 8, 14, 8, 12, 12, 16, 14]);
283
- for (let row = 1; row <= 24; row += 1)
284
- sheet.getRow(row).height = 22;
285
- sheet.getRow(1).height = 24;
286
- sheet.getRow(12).height = 48;
287
- sheet.getRow(13).height = 48;
288
- mergeRanges(sheet, ['A1:B2', 'C1:J1', 'C2:E2', 'F2:J2', 'A3:J3', 'B4:D4', 'F4:J4', 'B5:D5', 'F5:J5', 'B8:D8', 'F8:J8', 'B9:D9', 'F9:J9', 'C15:J15', 'C16:J16', 'C18:J18', 'C19:J19', 'C20:J20', 'C21:J21', 'C22:J22']);
289
- put(sheet, 'A1', 'YUNEEC', { font: logoFont, alignment: centerMiddle });
290
- put(sheet, 'C1', templateSellerAddress(model), { font: boldFont, alignment: centerMiddle });
291
- put(sheet, 'C2', `Tel:${stringValue(readModelValue(model, 'phone')) ?? '+86 15112619120'}`, { alignment: centerMiddle });
292
- put(sheet, 'F2', `Email: ${stringValue(readModelValue(model, 'email')) ?? 'sales03@yuneectech.com'}`, { alignment: centerMiddle });
293
- put(sheet, 'A3', title, { font: titleFont, alignment: centerMiddle });
294
- put(sheet, 'A4', 'Buyer', { font: boldFont });
295
- put(sheet, 'B4', model.buyerName);
296
- put(sheet, 'E4', 'Seller', { font: boldFont });
297
- put(sheet, 'F4', templateSellerName(model));
298
- put(sheet, 'A5', 'Address:', { font: boldFont });
299
- put(sheet, 'B5', model.buyerAddress || '未识别');
300
- put(sheet, 'E5', 'Invoice No.:', { font: boldFont });
301
- put(sheet, 'F5', model.invoiceNo);
302
- put(sheet, 'A6', 'Attn:', { font: boldFont });
303
- put(sheet, 'E6', 'Date:', { font: boldFont });
304
- put(sheet, 'F6', model.date);
305
- put(sheet, 'A7', 'Tel:', { font: boldFont });
306
- put(sheet, 'E7', 'Contract No.:', { font: boldFont });
307
- put(sheet, 'F7', model.contractNo);
308
- put(sheet, 'A8', 'From:', { font: boldFont });
309
- put(sheet, 'B8', model.origin);
310
- put(sheet, 'E8', 'Payment Term:', { font: boldFont });
311
- put(sheet, 'F8', model.paymentTerm);
312
- put(sheet, 'A9', 'To:', { font: boldFont });
313
- put(sheet, 'B9', model.destination);
314
- put(sheet, 'E9', 'Remark:', { font: boldFont });
315
- put(sheet, 'F9', 'The quotation is valid for one week');
316
- const headers = ['Item No.', 'Item', 'Description', 'QTY', 'UNITPRICE', 'UNIT', 'RATE(USD to RMB)', 'AMOUNT', 'PRICE', 'HS CODE'];
317
- headers.forEach((header, index) => put(sheet, `${columnName(index + 1)}11`, header, { font: whiteBoldFont, alignment: centerMiddle, fill: tableHeaderFill }));
318
- model.items.slice(0, 2).forEach((item, index) => {
319
- const row = 12 + index;
320
- sheet.getRow(row).height = descriptionRowHeight(item);
321
- put(sheet, `A${row}`, index + 1, { alignment: rightMiddle });
322
- put(sheet, `B${row}`, item.model || item.englishName || item.productName);
323
- put(sheet, `C${row}`, item.description);
324
- put(sheet, `D${row}`, item.quantity);
325
- put(sheet, `E${row}`, item.unitPrice, { numFmt: '"¥"#,##0.00' });
326
- put(sheet, `F${row}`, item.unit);
327
- put(sheet, `G${row}`, model.exchangeRate);
328
- put(sheet, `I${row}`, item.amount, { numFmt: '"¥"#,##0.00' });
329
- put(sheet, `J${row}`, item.hsCode);
330
- });
331
- put(sheet, 'A14', 'Total Amount(RMB)', { font: boldFont });
332
- put(sheet, 'I14', totalAmount(model.items), { numFmt: '"¥"#,##0.00', font: boldFont });
333
- put(sheet, 'A15', 'Price/Цена:', { font: boldFont });
334
- put(sheet, 'C15', 'Remark:All price are in RMB');
335
- put(sheet, 'A16', 'Delivery term/Условия Поставки:', { font: boldFont });
336
- put(sheet, 'C16', model.tradeTerm ? `${model.tradeTerm} in Shenzhen, Guangdong, China` : '');
337
- put(sheet, 'A17', 'Bank details/Банковские реквизиты:', { font: boldFont });
338
- put(sheet, 'A18', '1. Beneficiary/Бенифициар:', { font: boldFont });
339
- put(sheet, 'C18', model.bankBeneficiary);
340
- put(sheet, 'A19', '2. Bank Name/Банк:', { font: boldFont });
341
- put(sheet, 'C19', model.bankName);
342
- put(sheet, 'A20', '3. Bank Address/Адрес', { font: boldFont });
343
- put(sheet, 'C20', model.bankAddress);
344
- put(sheet, 'A21', '4.CNAPS CODE:', { font: boldFont });
345
- put(sheet, 'C21', model.cnapsCode);
346
- put(sheet, 'A22', '5. Account No.:', { font: boldFont });
347
- put(sheet, 'C22', model.bankAccountNo);
348
- put(sheet, 'A23', '6. Swift Code:', { font: boldFont });
349
- put(sheet, 'C23', model.swiftCode);
350
- put(sheet, 'C24', 'Seller Confirm:', { font: boldFont, alignment: centerMiddle });
351
- applyTableStyle(sheet, 'A11:J14', 11);
352
- }
353
- function buildPackingListWorksheet(sheet, model) {
354
- sheet.views = [{ showGridLines: false }];
355
- sheet.pageSetup = { fitToPage: true, fitToWidth: 1, fitToHeight: 1 };
356
- setColumns(sheet, [18, 14, 34, 10, 10, 12, 18, 12, 12]);
357
- for (let row = 1; row <= 24; row += 1)
358
- sheet.getRow(row).height = 22;
359
- sheet.getRow(3).height = 34;
360
- mergeRanges(sheet, ['A1:A2', 'B1:I1', 'C2:E2', 'F2:I2', 'A3:I3', 'B4:D4', 'F4:I4', 'B5:D5', 'F5:I5', 'B6:D6', 'F6:I6', 'B7:D7', 'F7:I7', 'B8:D8', 'F8:I8', 'B9:D9', 'F9:I9']);
361
- put(sheet, 'A1', 'YUNEEC', { font: logoFont, alignment: centerMiddle });
362
- put(sheet, 'B1', templateSellerAddress(model), { font: boldFont, alignment: centerMiddle });
363
- put(sheet, 'C2', `Tel:${stringValue(readModelValue(model, 'phone')) ?? '+86 15112619120'}`, { alignment: centerMiddle });
364
- put(sheet, 'F2', `Email: ${stringValue(readModelValue(model, 'email')) ?? 'sales03@yuneectech.com'}`, { alignment: centerMiddle });
365
- put(sheet, 'A3', 'PACKING LIST', { font: titleFont, alignment: centerMiddle });
366
- put(sheet, 'A4', 'Ship to:', { font: boldFont });
367
- put(sheet, 'B4', model.buyerName);
368
- put(sheet, 'E4', 'Seller', { font: boldFont });
369
- put(sheet, 'F4', templateSellerName(model));
370
- put(sheet, 'A5', 'Address:', { font: boldFont });
371
- put(sheet, 'E5', 'Date:', { font: boldFont });
372
- put(sheet, 'F5', model.date);
373
- put(sheet, 'A6', 'Country:', { font: boldFont });
374
- put(sheet, 'B6', model.destination);
375
- put(sheet, 'E6', 'Attn:', { font: boldFont });
376
- put(sheet, 'F6', 'Lulu');
377
- put(sheet, 'A7', 'Attn:', { font: boldFont });
378
- put(sheet, 'E7', 'Email:', { font: boldFont });
379
- put(sheet, 'F7', stringValue(readModelValue(model, 'email')) ?? 'sales03@yuneectech.com');
380
- put(sheet, 'A8', 'Tel:', { font: boldFont });
381
- put(sheet, 'E8', 'Tel:', { font: boldFont });
382
- put(sheet, 'F8', '15112619120');
383
- put(sheet, 'E9', 'Date:', { font: boldFont });
384
- const headers = ['Items', 'Model', 'Description', 'Qty', 'Unit', 'Ctn No', 'Dimension(mm)', 'NW(kg)', 'GW(kg)'];
385
- headers.forEach((header, index) => put(sheet, `${columnName(index + 1)}11`, header, { font: whiteBoldFont, alignment: centerMiddle, fill: tableHeaderFill }));
386
- model.items.slice(0, 2).forEach((item, index) => {
387
- const row = 12 + index;
388
- sheet.getRow(row).height = descriptionRowHeight(item);
389
- put(sheet, `A${row}`, item.englishName || item.productName, { alignment: centerMiddle });
390
- put(sheet, `B${row}`, item.model, { alignment: centerMiddle });
391
- put(sheet, `C${row}`, item.description);
392
- put(sheet, `D${row}`, item.quantity, { alignment: centerMiddle });
393
- put(sheet, `E${row}`, item.unit, { alignment: centerMiddle });
394
- put(sheet, `F${row}`, item.cartonNo, { alignment: centerMiddle });
395
- put(sheet, `G${row}`, item.dimension, { alignment: centerMiddle });
396
- put(sheet, `H${row}`, item.netWeight, { alignment: centerMiddle });
397
- put(sheet, `I${row}`, item.grossWeight, { alignment: centerMiddle });
398
- });
399
- put(sheet, 'A14', 'Total weight (KG)', { font: boldFont });
400
- put(sheet, 'H14', sum(model.items, 'netWeight') || readNumber(model, 'netWeight'));
401
- put(sheet, 'I14', sum(model.items, 'grossWeight') || readNumber(model, 'grossWeight'));
402
- put(sheet, 'A15', 'Volume (CBM)', { font: boldFont });
403
- put(sheet, 'I15', readNumber(model, 'volumeCbm'));
404
- put(sheet, 'A16', 'Total Carton (CTN)', { font: boldFont });
405
- put(sheet, 'I16', readNumber(model, 'cartonCount'));
406
- put(sheet, 'A17', 'Bank details/Банковские реквизиты:', { font: boldFont });
407
- put(sheet, 'A18', '1. Beneficiary/Бенифициар:', { font: boldFont });
408
- put(sheet, 'B18', model.bankBeneficiary);
409
- put(sheet, 'A19', '2. Bank Name/Банк:', { font: boldFont });
410
- put(sheet, 'B19', model.bankName);
411
- put(sheet, 'A20', '3. Bank Address/Адрес', { font: boldFont });
412
- put(sheet, 'B20', model.bankAddress);
413
- put(sheet, 'A21', '4. CNY account:', { font: boldFont });
414
- put(sheet, 'H21', model.bankAccountNo);
415
- put(sheet, 'A22', '5. Swift Code:', { font: boldFont });
416
- put(sheet, 'A23', '6.CNAPS CODE', { font: boldFont });
417
- put(sheet, 'A24', 'SIGNATURE:', { font: boldFont });
418
- applyTableStyle(sheet, 'A11:I24', 11);
419
- }
420
- function fillDeclarationSheet(sheet, model) {
421
- if (!sheet)
422
- return;
423
- setCell(sheet, 'B5', model.buyerName);
424
- setCell(sheet, 'B7', model.contractNo);
425
- setCell(sheet, 'F6', model.supervisionMode);
426
- setCell(sheet, 'H6', model.taxExemptionNature);
427
- setCell(sheet, 'A9', model.packageType);
428
- setCell(sheet, 'D9', sum(model.items, 'grossWeight') || readNumber(model, 'grossWeight'));
429
- setCell(sheet, 'E9', sum(model.items, 'netWeight') || readNumber(model, 'netWeight'));
430
- setCell(sheet, 'F9', model.tradeTerm);
431
- setCell(sheet, 'K9', readNumber(model, 'freight'));
432
- model.items.slice(0, 2).forEach((item, index) => {
433
- const row = 14 + index * 2;
434
- setCell(sheet, `A${row}`, index + 1);
435
- setCell(sheet, `B${row}`, item.hsCode);
436
- setCell(sheet, `C${row}`, item.productName || item.englishName);
437
- setCell(sheet, `D${row}`, item.quantity);
438
- setCell(sheet, `E${row}`, item.unit);
439
- setCell(sheet, `F${row}`, item.unitPrice);
440
- setCell(sheet, `G${row}`, item.amount);
441
- setCell(sheet, `H${row}`, model.currency || '人民币');
442
- setCell(sheet, `I${row}`, model.origin);
443
- setCell(sheet, `J${row}`, model.destination);
444
- setCell(sheet, `K${row}`, model.domesticSourceLocation);
445
- setCell(sheet, `C${row + 1}`, item.description);
446
- setCell(sheet, `D${row + 1}`, item.netWeight);
447
- setCell(sheet, `E${row + 1}`, '千克');
448
- });
449
- }
450
- function fillInvoiceLikeSheet(sheet, model) {
451
- if (!sheet)
452
- return;
453
- setCell(sheet, 'B4', model.buyerName);
454
- setCell(sheet, 'F4', model.sellerEnglishName || model.sellerName);
455
- setCell(sheet, 'B5', model.buyerAddress);
456
- setCell(sheet, 'F5', model.invoiceNo);
457
- setCell(sheet, 'F6', model.date);
458
- setCell(sheet, 'F7', model.contractNo);
459
- setCell(sheet, 'B8', model.origin);
460
- setCell(sheet, 'F8', model.paymentTerm);
461
- setCell(sheet, 'B9', model.destination);
462
- model.items.slice(0, 2).forEach((item, index) => {
463
- const row = 12 + index;
464
- setCell(sheet, `A${row}`, index + 1);
465
- setCell(sheet, `B${row}`, item.model || item.englishName || item.productName);
466
- setCell(sheet, `C${row}`, item.description);
467
- setCell(sheet, `D${row}`, item.quantity);
468
- setCell(sheet, `E${row}`, item.unitPrice);
469
- setCell(sheet, `F${row}`, item.unit);
470
- setCell(sheet, `G${row}`, model.exchangeRate);
471
- setCell(sheet, `I${row}`, item.amount);
472
- setCell(sheet, `J${row}`, item.hsCode);
473
- });
474
- setCell(sheet, 'G14', totalAmount(model.items));
475
- }
476
- function fillPackingListSheet(sheet, model) {
477
- if (!sheet)
478
- return;
479
- setCell(sheet, 'B4', model.buyerName);
480
- setCell(sheet, 'F4', model.sellerEnglishName || model.sellerName);
481
- setCell(sheet, 'F5', model.date);
482
- setCell(sheet, 'B6', model.destination);
483
- model.items.slice(0, 2).forEach((item, index) => {
484
- const row = 12 + index;
485
- setCell(sheet, `A${row}`, item.englishName || item.productName);
486
- setCell(sheet, `B${row}`, item.model);
487
- setCell(sheet, `C${row}`, item.description);
488
- setCell(sheet, `D${row}`, item.quantity);
489
- setCell(sheet, `E${row}`, item.unit);
490
- setCell(sheet, `F${row}`, item.cartonNo);
491
- setCell(sheet, `G${row}`, item.dimension);
492
- setCell(sheet, `H${row}`, item.netWeight);
493
- setCell(sheet, `I${row}`, item.grossWeight);
494
- });
495
- setCell(sheet, 'H14', sum(model.items, 'netWeight') || readNumber(model, 'netWeight'));
496
- setCell(sheet, 'I14', sum(model.items, 'grossWeight') || readNumber(model, 'grossWeight'));
497
- }
498
- function buildDeclarationRows(model) {
499
- return [
500
- ['境内发货人', model.sellerName ?? model.sellerEnglishName ?? ''],
501
- ['境外收货人', model.buyerName ?? ''],
502
- ['合同协议号', model.contractNo ?? ''],
503
- ['监管方式', model.supervisionMode ?? ''],
504
- ['征免性质', model.taxExemptionNature ?? ''],
505
- ['包装种类', model.packageType ?? ''],
506
- ['项号', '商品编号', '商品名称及规格型号', '数量及单位', '单价', '总价', '境内货源地'],
507
- ...model.items.map((item, index) => [
508
- index + 1,
509
- item.hsCode ?? '',
510
- item.productName ?? item.englishName ?? '',
511
- formatQuantity(item),
512
- item.unitPrice ?? '',
513
- item.amount ?? '',
514
- model.domesticSourceLocation ?? ''
515
- ])
516
- ];
517
- }
518
- function buildCommercialInvoiceRows(model) {
519
- return [
520
- [model.sellerEnglishName ?? ''],
521
- [model.sellerEnglishAddress ?? ''],
522
- ['Commercial Invoice'],
523
- ['Buyer', model.buyerName ?? '', '', 'Seller', model.sellerEnglishName ?? ''],
524
- ['Address', model.buyerAddress ?? '', '', 'Invoice No.', model.invoiceNo],
525
- ['From', model.origin ?? '', '', 'Payment Term', model.paymentTerm ?? ''],
526
- ['To', model.destination ?? '', '', 'Contract No.', model.contractNo ?? ''],
527
- ['Item No.', 'Item', 'Description', 'QTY', 'UNIT PRICE', 'UNIT', 'RATE', 'AMOUNT', 'HS CODE'],
528
- ...model.items.map((item, index) => [
529
- index + 1,
530
- item.model ?? item.englishName ?? item.productName ?? '',
531
- item.description ?? '',
532
- item.quantity ?? '',
533
- item.unitPrice ?? '',
534
- item.unit ?? '',
535
- model.exchangeRate ?? '',
536
- item.amount ?? '',
537
- item.hsCode ?? ''
538
- ]),
539
- ['Total Amount(RMB)', '', '', '', '', '', totalAmount(model.items)]
540
- ];
541
- }
542
- function buildSalesContractRows(model) {
543
- return [
544
- [model.sellerEnglishName ?? ''],
545
- [model.sellerEnglishAddress ?? ''],
546
- ['Sales Contract'],
547
- ['Buyer', model.buyerName ?? '', '', 'Seller', model.sellerEnglishName ?? ''],
548
- ['Address', model.buyerAddress ?? '', '', 'Invoice No.', model.invoiceNo],
549
- ['From', model.origin ?? '', '', 'Payment Term', model.paymentTerm ?? ''],
550
- ['To', model.destination ?? '', '', 'Contract No.', model.contractNo ?? ''],
551
- ['Item No.', 'Item', 'Description', 'QTY', 'UNIT PRICE', 'UNIT', 'RATE', 'AMOUNT', 'HS CODE'],
552
- ...model.items.map((item, index) => [
553
- index + 1,
554
- item.model ?? item.englishName ?? item.productName ?? '',
555
- item.description ?? '',
556
- item.quantity ?? '',
557
- item.unitPrice ?? '',
558
- item.unit ?? '',
559
- model.exchangeRate ?? '',
560
- item.amount ?? '',
561
- item.hsCode ?? ''
562
- ])
563
- ];
564
- }
565
- function buildPackingListRows(model) {
566
- return [
567
- [model.sellerEnglishAddress ?? ''],
568
- ['PACKING LIST'],
569
- ['Ship to', model.buyerName ?? '', '', 'Seller', model.sellerEnglishName ?? ''],
570
- ['Country', model.destination ?? ''],
571
- ['Items', 'Model', 'Description', 'Qty', 'Unit', 'Ctn No', 'Dimension(mm)', 'NW(kg)', 'GW(kg)'],
572
- ...model.items.map((item) => [
573
- item.englishName ?? item.productName ?? '',
574
- item.model ?? '',
575
- item.description ?? '',
576
- item.quantity ?? '',
577
- item.unit ?? '',
578
- item.cartonNo ?? '',
579
- item.dimension ?? '',
580
- item.netWeight ?? '',
581
- item.grossWeight ?? ''
582
- ]),
583
- ['Total weight (KG)', '', '', '', '', '', '', sum(model.items, 'netWeight'), sum(model.items, 'grossWeight')]
584
- ];
585
- }
586
- function formatQuantity(item) {
587
- return [item.quantity, item.unit].filter((value) => value !== undefined && value !== '').join(' ');
588
- }
589
- function totalAmount(items) {
590
- return sum(items, 'amount');
591
- }
592
- function sum(items, key) {
593
- return items.reduce((total, item) => {
594
- const value = item[key];
595
- return typeof value === 'number' ? total + value : total;
596
- }, 0);
597
- }
598
- function setCell(sheet, address, value) {
599
- if (value === undefined || value === null || value === '')
600
- return;
601
- const existing = sheet[address];
602
- const cellValue = typeof value === 'object' ? JSON.stringify(value) : value;
603
- sheet[address] = {
604
- ...(existing || {}),
605
- t: typeof cellValue === 'number' ? 'n' : 's',
606
- v: cellValue
607
- };
608
- }
609
- function readNumber(input, key) {
610
- const value = typeof input === 'object' && input != null ? Reflect.get(input, key) : undefined;
611
- if (typeof value === 'number' && Number.isFinite(value))
612
- return value;
613
- if (typeof value === 'string' && value.trim()) {
614
- const parsed = Number(value.replace(/,/g, ''));
615
- return Number.isFinite(parsed) ? parsed : undefined;
616
- }
617
- return undefined;
618
- }
619
- function stringValue(value) {
620
- return value === undefined || value === null || value === '' ? undefined : String(value);
621
- }
622
- function readModelValue(model, key) {
623
- return Reflect.get(model, key);
624
- }
625
- function buildInvoiceNo() {
626
- const now = new Date();
627
- const yyyy = now.getUTCFullYear();
628
- const mm = String(now.getUTCMonth() + 1).padStart(2, '0');
629
- const dd = String(now.getUTCDate()).padStart(2, '0');
630
- return `INV-${yyyy}${mm}${dd}`;
631
- }
632
- function sanitizeFilePart(value) {
633
- return value.replace(/[^a-zA-Z0-9._-]+/g, '-');
634
- }
635
- //# sourceMappingURL=trade-compliance-workbook.js.map