shareneus 1.6.98 → 1.6.99
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.
|
@@ -51,6 +51,7 @@ function buildDataRow(item, index, headerConfig, fixedTo = 2) {
|
|
|
51
51
|
}
|
|
52
52
|
function formatFieldValue(item, fieldConfig, fixedTo) {
|
|
53
53
|
const rawValue = getFirstFieldValue(item, fieldConfig === null || fieldConfig === void 0 ? void 0 : fieldConfig.dbFields);
|
|
54
|
+
console.log('rawValue for fieldConfig', fieldConfig === null || fieldConfig === void 0 ? void 0 : fieldConfig.dbFields, 'is', rawValue);
|
|
54
55
|
if (isExpiryField(fieldConfig)) {
|
|
55
56
|
return formatExpiryDateValue(rawValue);
|
|
56
57
|
}
|
|
@@ -94,8 +95,7 @@ function negateNumericLikeValue(value) {
|
|
|
94
95
|
return String(normalized === 0 ? 0 : -Math.abs(normalized));
|
|
95
96
|
}
|
|
96
97
|
function getFirstFieldValue(item, dbFields = []) {
|
|
97
|
-
const
|
|
98
|
-
for (const field of fields) {
|
|
98
|
+
for (const field of dbFields) {
|
|
99
99
|
const value = readValue(item, field);
|
|
100
100
|
if (value !== undefined && value !== null && value !== '') {
|
|
101
101
|
return String(value);
|
|
@@ -104,14 +104,13 @@ function getFirstFieldValue(item, dbFields = []) {
|
|
|
104
104
|
return '';
|
|
105
105
|
}
|
|
106
106
|
function readValue(item, field) {
|
|
107
|
-
|
|
108
|
-
if (!item || !normalizedField) {
|
|
107
|
+
if (!item || !field) {
|
|
109
108
|
return undefined;
|
|
110
109
|
}
|
|
111
|
-
if (item[
|
|
112
|
-
return item[
|
|
110
|
+
if (item[field] !== undefined) {
|
|
111
|
+
return item[field];
|
|
113
112
|
}
|
|
114
|
-
const dottedPathValue =
|
|
113
|
+
const dottedPathValue = field.split('.').reduce((current, key) => {
|
|
115
114
|
if (current && current[key] !== undefined) {
|
|
116
115
|
return current[key];
|
|
117
116
|
}
|
|
@@ -120,7 +119,7 @@ function readValue(item, field) {
|
|
|
120
119
|
if (dottedPathValue !== undefined) {
|
|
121
120
|
return dottedPathValue;
|
|
122
121
|
}
|
|
123
|
-
return deepFindByKey(item,
|
|
122
|
+
return deepFindByKey(item, field);
|
|
124
123
|
}
|
|
125
124
|
function deepFindByKey(source, field) {
|
|
126
125
|
if (!source || typeof source !== 'object') {
|
|
@@ -187,7 +186,7 @@ function isExpiryField(fieldConfig) {
|
|
|
187
186
|
}
|
|
188
187
|
const dbFields = Array.isArray(fieldConfig === null || fieldConfig === void 0 ? void 0 : fieldConfig.dbFields) ? fieldConfig.dbFields : [];
|
|
189
188
|
return dbFields.some((field) => {
|
|
190
|
-
const normalized =
|
|
189
|
+
const normalized = String(field !== null && field !== void 0 ? field : '').trim().toUpperCase();
|
|
191
190
|
return normalized === 'EXDT' || normalized.endsWith('.EXDT') || normalized.endsWith('.EXPIRY');
|
|
192
191
|
});
|
|
193
192
|
}
|
|
@@ -216,15 +215,7 @@ function shouldSkipFixedTo(header) {
|
|
|
216
215
|
}
|
|
217
216
|
const dbFields = Array.isArray(header === null || header === void 0 ? void 0 : header.dbFields) ? header.dbFields : [];
|
|
218
217
|
return dbFields.some((field) => {
|
|
219
|
-
const normalized =
|
|
218
|
+
const normalized = String(field !== null && field !== void 0 ? field : '').trim().toUpperCase();
|
|
220
219
|
return normalized === 'BN' || normalized === 'BNO' || normalized.endsWith('.BN');
|
|
221
220
|
});
|
|
222
221
|
}
|
|
223
|
-
function normalizeDbFieldPath(field) {
|
|
224
|
-
const value = String(field !== null && field !== void 0 ? field : '').trim();
|
|
225
|
-
if (!value) {
|
|
226
|
-
return '';
|
|
227
|
-
}
|
|
228
|
-
const bracketMatch = value.match(/^\[(.*)\]$/);
|
|
229
|
-
return bracketMatch ? bracketMatch[1].trim() : value;
|
|
230
|
-
}
|
|
@@ -8,10 +8,11 @@ const pdf_shared_utils_1 = require("../header-footer-section/pdf-shared.utils");
|
|
|
8
8
|
const math_operations_1 = require("../math-operations");
|
|
9
9
|
const pdf_table_section_1 = require("../table-section/pdf-table.section");
|
|
10
10
|
function buildInvoiceTotalsAndNotesSection(invoiceData, availableWidth, PrintConfigData = {}) {
|
|
11
|
-
var _a;
|
|
11
|
+
var _a, _b, _c;
|
|
12
12
|
const normalizedInvoice = invoiceData || {};
|
|
13
13
|
const sType = (0, pdf_shared_utils_1.firstValue)(normalizedInvoice === null || normalizedInvoice === void 0 ? void 0 : normalizedInvoice.SType);
|
|
14
|
-
const
|
|
14
|
+
const companyName = (0, pdf_shared_utils_1.firstValue)((_a = normalizedInvoice === null || normalizedInvoice === void 0 ? void 0 : normalizedInvoice.Entity) === null || _a === void 0 ? void 0 : _a.CName, (_b = normalizedInvoice === null || normalizedInvoice === void 0 ? void 0 : normalizedInvoice.Entity) === null || _b === void 0 ? void 0 : _b.Name, normalizedInvoice === null || normalizedInvoice === void 0 ? void 0 : normalizedInvoice.CName, normalizedInvoice === null || normalizedInvoice === void 0 ? void 0 : normalizedInvoice.CompanyName);
|
|
15
|
+
const hideTopSection = isTruthy((_c = normalizedInvoice === null || normalizedInvoice === void 0 ? void 0 : normalizedInvoice.Settings) === null || _c === void 0 ? void 0 : _c.NoPr);
|
|
15
16
|
const isPoSPrint = isTruthy(PrintConfigData === null || PrintConfigData === void 0 ? void 0 : PrintConfigData.IsPoSPrint);
|
|
16
17
|
const shouldShowTaxSummary = resolveShowTaxSummary(normalizedInvoice, PrintConfigData);
|
|
17
18
|
const taxSummary = resolveTaxSummary(normalizedInvoice, shouldShowTaxSummary);
|
|
@@ -44,6 +45,7 @@ function buildInvoiceTotalsAndNotesSection(invoiceData, availableWidth, PrintCon
|
|
|
44
45
|
totalInWords,
|
|
45
46
|
notes,
|
|
46
47
|
terms,
|
|
48
|
+
companyName,
|
|
47
49
|
paidAmount: dueInfo.paid,
|
|
48
50
|
dueAmount: dueInfo.due,
|
|
49
51
|
qrPayload,
|
|
@@ -125,14 +127,27 @@ function buildPostTotalsInfoSection(data) {
|
|
|
125
127
|
}
|
|
126
128
|
if (data.isPoSPrint) {
|
|
127
129
|
leftStack.push({
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
130
|
+
columns: [
|
|
131
|
+
{
|
|
132
|
+
width: '60%',
|
|
133
|
+
stack: [
|
|
134
|
+
{ text: '* Goods once sold will not be taken back or exchanged', fontSize: 6, color: '#111827' },
|
|
135
|
+
{ text: '* PLEASE GET YOUR MEDICINES CHECKED BY YOUR DOCTOR BEFORE USE *', fontSize: 6, color: '#111827' }
|
|
136
|
+
],
|
|
137
|
+
margin: [5, 0, 0, 6],
|
|
138
|
+
lineHeight: 1.1
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
width: '40%',
|
|
142
|
+
text: `For ${data.companyName || ''}`.trim(),
|
|
143
|
+
fontSize: 9,
|
|
144
|
+
bold: true,
|
|
145
|
+
color: '#111827',
|
|
146
|
+
alignment: 'right'
|
|
147
|
+
}
|
|
131
148
|
],
|
|
132
|
-
|
|
133
|
-
margin: [
|
|
134
|
-
lineHeight: 1.1,
|
|
135
|
-
color: '#111827'
|
|
149
|
+
columnGap: 6,
|
|
150
|
+
margin: [0, 4, 0, 0]
|
|
136
151
|
});
|
|
137
152
|
}
|
|
138
153
|
if (termsText) {
|
|
@@ -186,6 +201,9 @@ function buildSignatureSection(PrintConfig, invoiceData, availableWidth) {
|
|
|
186
201
|
const isPoSPrint = isTruthy((_b = PrintConfig === null || PrintConfig === void 0 ? void 0 : PrintConfig.IsPoSPrint) !== null && _b !== void 0 ? _b : PrintConfig === null || PrintConfig === void 0 ? void 0 : PrintConfig.isPoSPrint);
|
|
187
202
|
const companyName = (0, pdf_shared_utils_1.firstValue)((_c = headerData === null || headerData === void 0 ? void 0 : headerData.organization) === null || _c === void 0 ? void 0 : _c.cName, (_d = invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.Entity) === null || _d === void 0 ? void 0 : _d.CName, (_e = invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.Entity) === null || _e === void 0 ? void 0 : _e.Name, invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.CName);
|
|
188
203
|
const withPass = !!((PrintConfig === null || PrintConfig === void 0 ? void 0 : PrintConfig.withPass) || (invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.withPass) || (invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.WithPass));
|
|
204
|
+
if (isPoSPrint) {
|
|
205
|
+
return [];
|
|
206
|
+
}
|
|
189
207
|
const signatureRows = [
|
|
190
208
|
{
|
|
191
209
|
columns: [
|
package/package.json
CHANGED
package/tsconfig.json
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
/* Language and Environment */
|
|
16
16
|
"target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
|
|
17
|
-
|
|
17
|
+
"lib": ["es2017", "dom"],
|
|
18
18
|
// "jsx": "preserve", /* Specify what JSX code is generated. */
|
|
19
19
|
// "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
|
|
20
20
|
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
|
|
29
29
|
/* Modules */
|
|
30
30
|
"module": "commonjs", /* Specify what module code is generated. */
|
|
31
|
-
|
|
31
|
+
"rootDir": "./src",
|
|
32
32
|
// "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */
|
|
33
33
|
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
|
|
34
34
|
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
|