shareneus 1.6.97 → 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
|
}
|
|
@@ -142,6 +143,9 @@ function getNumericAlignment(value) {
|
|
|
142
143
|
return isNumericLike(value) ? 'right' : 'left';
|
|
143
144
|
}
|
|
144
145
|
function getCellAlignment(headerText, value) {
|
|
146
|
+
if (isRightAlignedHeader(headerText)) {
|
|
147
|
+
return 'right';
|
|
148
|
+
}
|
|
145
149
|
if (isLeftAlignedHeader(headerText)) {
|
|
146
150
|
return 'left';
|
|
147
151
|
}
|
|
@@ -155,7 +159,11 @@ function isNumericLike(value) {
|
|
|
155
159
|
return /^-?\d+(\.\d+)?$/.test(normalized);
|
|
156
160
|
}
|
|
157
161
|
function isLeftAlignedHeader(headerText) {
|
|
158
|
-
return
|
|
162
|
+
return false;
|
|
163
|
+
}
|
|
164
|
+
function isRightAlignedHeader(headerText) {
|
|
165
|
+
const normalizedHeader = String(headerText !== null && headerText !== void 0 ? headerText : '').replace(/\s+/g, '').trim().toUpperCase();
|
|
166
|
+
return normalizedHeader === 'QTY' || normalizedHeader === 'OFFERQTY';
|
|
159
167
|
}
|
|
160
168
|
function formatNumericLikeValue(value, fixedTo, skipFixedTo = false) {
|
|
161
169
|
if (skipFixedTo) {
|
|
@@ -384,7 +384,10 @@ function shouldNegateFallbackHeaderValue(item, headerText) {
|
|
|
384
384
|
|| normalized === 'LINE TOTAL';
|
|
385
385
|
}
|
|
386
386
|
function getDisplayValueForFallbackRow(item, dbFields = [], shouldNegate = false) {
|
|
387
|
+
console.log(item, dbFields, shouldNegate);
|
|
388
|
+
console.log((0, pdf_table_row_1.getFirstFieldValue)(item, dbFields));
|
|
387
389
|
const value = (0, pdf_table_row_1.getFirstFieldValue)(item, dbFields);
|
|
390
|
+
console.log('value', value);
|
|
388
391
|
if (!shouldNegate) {
|
|
389
392
|
return value;
|
|
390
393
|
}
|
|
@@ -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);
|
|
@@ -36,7 +37,7 @@ function buildInvoiceTotalsAndNotesSection(invoiceData, availableWidth, PrintCon
|
|
|
36
37
|
margin: [0, 5, 0, 5]
|
|
37
38
|
};
|
|
38
39
|
const topColumns = {
|
|
39
|
-
columns: buildTopSectionColumns(taxSummary, sType, showBankDetails, bankDetails, totals),
|
|
40
|
+
columns: buildTopSectionColumns(taxSummary, sType, showBankDetails, bankDetails, totals, totalInWords),
|
|
40
41
|
columnGap: 20,
|
|
41
42
|
margin: [0, 0, 0, 8]
|
|
42
43
|
};
|
|
@@ -44,10 +45,12 @@ 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,
|
|
50
52
|
upiPhone: resolveUpiPhone(normalizedInvoice),
|
|
53
|
+
showInWords: taxSummary.hasData || showBankDetails,
|
|
51
54
|
showDueSection,
|
|
52
55
|
isPoSPrint
|
|
53
56
|
});
|
|
@@ -59,7 +62,8 @@ function buildInvoiceTotalsAndNotesSection(invoiceData, availableWidth, PrintCon
|
|
|
59
62
|
}
|
|
60
63
|
return [dividerLine, bottomColumns];
|
|
61
64
|
}
|
|
62
|
-
function buildTopSectionColumns(taxSummary, sType, showBankDetails, bankDetails, totals) {
|
|
65
|
+
function buildTopSectionColumns(taxSummary, sType, showBankDetails, bankDetails, totals, totalInWords) {
|
|
66
|
+
const inWords = totalInWords || '-';
|
|
63
67
|
if (taxSummary.hasData) {
|
|
64
68
|
return [
|
|
65
69
|
{ width: '42%', stack: buildTaxSummaryTableStack(null, taxSummary.rows, sType) },
|
|
@@ -74,24 +78,34 @@ function buildTopSectionColumns(taxSummary, sType, showBankDetails, bankDetails,
|
|
|
74
78
|
];
|
|
75
79
|
}
|
|
76
80
|
return [
|
|
77
|
-
{
|
|
81
|
+
{
|
|
82
|
+
width: '70%',
|
|
83
|
+
columns: [
|
|
84
|
+
{ width: 'auto', text: 'In Words :', bold: true, fontSize: 9, color: '#111827' },
|
|
85
|
+
{ width: '*', text: inWords, bold: true, fontSize: 9, color: '#111827' }
|
|
86
|
+
],
|
|
87
|
+
columnGap: 6,
|
|
88
|
+
margin: [0, 0, 0, 4]
|
|
89
|
+
},
|
|
90
|
+
{ width: '30%', stack: buildInfoCardStack(null, totals.lines, { rightAlign: true }) }
|
|
78
91
|
];
|
|
79
92
|
}
|
|
80
93
|
function buildPostTotalsInfoSection(data) {
|
|
81
94
|
const hasQr = !!(0, pdf_shared_utils_1.firstValue)(data.qrPayload);
|
|
82
95
|
const inWords = data.totalInWords || '-';
|
|
83
96
|
const termsText = (0, pdf_shared_utils_1.firstValue)(data.terms);
|
|
84
|
-
const leftStack = [
|
|
85
|
-
|
|
97
|
+
const leftStack = [];
|
|
98
|
+
if (data.showInWords) {
|
|
99
|
+
leftStack.push({
|
|
86
100
|
columns: [
|
|
87
101
|
{ width: 'auto', text: 'In Words :', bold: true, fontSize: 9, color: '#111827' },
|
|
88
102
|
{ width: '*', text: inWords, bold: true, fontSize: 9, color: '#111827' }
|
|
89
103
|
],
|
|
90
104
|
columnGap: 6,
|
|
91
105
|
margin: [0, 0, 0, 4]
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
if (data.showDueSection) {
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
if (data.showDueSection && !data.isPoSPrint) {
|
|
95
109
|
const paidText = `Paid : Rs.${formatAmountFixed2(data.paidAmount)}`;
|
|
96
110
|
const dueText = `Due : Rs.${formatAmountFixed2(data.dueAmount)}`;
|
|
97
111
|
leftStack.push({
|
|
@@ -113,14 +127,27 @@ function buildPostTotalsInfoSection(data) {
|
|
|
113
127
|
}
|
|
114
128
|
if (data.isPoSPrint) {
|
|
115
129
|
leftStack.push({
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
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
|
+
}
|
|
119
148
|
],
|
|
120
|
-
|
|
121
|
-
margin: [
|
|
122
|
-
lineHeight: 1.1,
|
|
123
|
-
color: '#111827'
|
|
149
|
+
columnGap: 6,
|
|
150
|
+
margin: [0, 4, 0, 0]
|
|
124
151
|
});
|
|
125
152
|
}
|
|
126
153
|
if (termsText) {
|
|
@@ -174,6 +201,9 @@ function buildSignatureSection(PrintConfig, invoiceData, availableWidth) {
|
|
|
174
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);
|
|
175
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);
|
|
176
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
|
+
}
|
|
177
207
|
const signatureRows = [
|
|
178
208
|
{
|
|
179
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. */
|