shareneus 1.6.64 → 1.6.66
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.
|
@@ -416,13 +416,17 @@ function formatDisplayDate(value) {
|
|
|
416
416
|
}
|
|
417
417
|
const dt = new Date(value);
|
|
418
418
|
if (!Number.isNaN(dt.getTime())) {
|
|
419
|
-
const day =
|
|
420
|
-
const month =
|
|
419
|
+
const day = leftPadWithZero(dt.getDate());
|
|
420
|
+
const month = leftPadWithZero(dt.getMonth() + 1);
|
|
421
421
|
const year = dt.getFullYear();
|
|
422
422
|
return `${day}/${month}/${year}`;
|
|
423
423
|
}
|
|
424
424
|
return value;
|
|
425
425
|
}
|
|
426
|
+
function leftPadWithZero(value) {
|
|
427
|
+
const text = String(value);
|
|
428
|
+
return text.length >= 2 ? text : `0${text}`;
|
|
429
|
+
}
|
|
426
430
|
function resolveShowBarCode(transactionData, printConfig = {}) {
|
|
427
431
|
var _a, _b;
|
|
428
432
|
if (Object.prototype.hasOwnProperty.call(printConfig || {}, 'Customer')) {
|
|
@@ -9,6 +9,7 @@ const pdf_table_section_1 = require("../table-section/pdf-table.section");
|
|
|
9
9
|
function buildInvoiceTotalsAndNotesSection(invoiceData, availableWidth, PrintConfigData = {}) {
|
|
10
10
|
var _a;
|
|
11
11
|
const normalizedInvoice = invoiceData || {};
|
|
12
|
+
const sType = (0, pdf_shared_utils_1.firstValue)(normalizedInvoice === null || normalizedInvoice === void 0 ? void 0 : normalizedInvoice.SType);
|
|
12
13
|
const hideTopSection = isTruthy((_a = normalizedInvoice === null || normalizedInvoice === void 0 ? void 0 : normalizedInvoice.Settings) === null || _a === void 0 ? void 0 : _a.NoPr);
|
|
13
14
|
const shouldShowTaxSummary = resolveShowTaxSummary(normalizedInvoice, PrintConfigData);
|
|
14
15
|
const taxSummary = resolveTaxSummary(normalizedInvoice, shouldShowTaxSummary);
|
|
@@ -20,7 +21,7 @@ function buildInvoiceTotalsAndNotesSection(invoiceData, availableWidth, PrintCon
|
|
|
20
21
|
const notes = (0, pdf_shared_utils_1.firstValue)(normalizedInvoice === null || normalizedInvoice === void 0 ? void 0 : normalizedInvoice.Notes, normalizedInvoice === null || normalizedInvoice === void 0 ? void 0 : normalizedInvoice.Note, normalizedInvoice === null || normalizedInvoice === void 0 ? void 0 : normalizedInvoice.Remarks, normalizedInvoice === null || normalizedInvoice === void 0 ? void 0 : normalizedInvoice.Remark);
|
|
21
22
|
const terms = (0, pdf_shared_utils_1.firstValue)(normalizedInvoice === null || normalizedInvoice === void 0 ? void 0 : normalizedInvoice.TermsAndConditions, normalizedInvoice === null || normalizedInvoice === void 0 ? void 0 : normalizedInvoice.TermsCondition, normalizedInvoice === null || normalizedInvoice === void 0 ? void 0 : normalizedInvoice.Terms, normalizedInvoice === null || normalizedInvoice === void 0 ? void 0 : normalizedInvoice.TC);
|
|
22
23
|
const dueInfo = resolveDueInfo(normalizedInvoice, totals);
|
|
23
|
-
const qrPayload = resolveQrPayload(normalizedInvoice);
|
|
24
|
+
const qrPayload = resolveQrPayload(normalizedInvoice, PrintConfigData);
|
|
24
25
|
const hasTopSection = !hideTopSection && (taxSummary.hasData || bankDetails.hasData || totals.hasData);
|
|
25
26
|
const hasBottomSection = !!(notes || terms || totalInWords || (showDueSection && dueInfo.hasData) || qrPayload);
|
|
26
27
|
if (!hasTopSection && !hasBottomSection) {
|
|
@@ -33,7 +34,7 @@ function buildInvoiceTotalsAndNotesSection(invoiceData, availableWidth, PrintCon
|
|
|
33
34
|
margin: [0, 10, 0, 10]
|
|
34
35
|
};
|
|
35
36
|
const topColumns = {
|
|
36
|
-
columns: buildTopSectionColumns(taxSummary, showBankDetails, bankDetails, totals),
|
|
37
|
+
columns: buildTopSectionColumns(taxSummary, sType, showBankDetails, bankDetails, totals),
|
|
37
38
|
columnGap: 20,
|
|
38
39
|
margin: [0, 0, 0, 8]
|
|
39
40
|
};
|
|
@@ -44,6 +45,7 @@ function buildInvoiceTotalsAndNotesSection(invoiceData, availableWidth, PrintCon
|
|
|
44
45
|
paidAmount: dueInfo.paid,
|
|
45
46
|
dueAmount: dueInfo.due,
|
|
46
47
|
qrPayload,
|
|
48
|
+
upiPhone: resolveUpiPhone(normalizedInvoice),
|
|
47
49
|
showDueSection
|
|
48
50
|
});
|
|
49
51
|
if (hasTopSection && hasBottomSection) {
|
|
@@ -54,10 +56,10 @@ function buildInvoiceTotalsAndNotesSection(invoiceData, availableWidth, PrintCon
|
|
|
54
56
|
}
|
|
55
57
|
return [dividerLine, bottomColumns];
|
|
56
58
|
}
|
|
57
|
-
function buildTopSectionColumns(taxSummary, showBankDetails, bankDetails, totals) {
|
|
59
|
+
function buildTopSectionColumns(taxSummary, sType, showBankDetails, bankDetails, totals) {
|
|
58
60
|
if (taxSummary.hasData) {
|
|
59
61
|
return [
|
|
60
|
-
{ width: '42%', stack: buildTaxSummaryTableStack(null, taxSummary.rows) },
|
|
62
|
+
{ width: '42%', stack: buildTaxSummaryTableStack(null, taxSummary.rows, sType) },
|
|
61
63
|
{ width: '28%', stack: showBankDetails ? buildInfoCardStack('Bank Details', bankDetails.lines) : [{ text: '' }] },
|
|
62
64
|
{ width: '30%', stack: buildInfoCardStack(null, totals.lines, { rightAlign: true }) }
|
|
63
65
|
];
|
|
@@ -134,7 +136,14 @@ function buildPostTotalsInfoSection(data) {
|
|
|
134
136
|
bold: true,
|
|
135
137
|
alignment: 'right',
|
|
136
138
|
margin: [0, 2, 0, 0]
|
|
137
|
-
}
|
|
139
|
+
},
|
|
140
|
+
...((0, pdf_shared_utils_1.firstValue)(data.upiPhone) ? [{
|
|
141
|
+
text: `UPIPhone: ${data.upiPhone}`,
|
|
142
|
+
fontSize: 8,
|
|
143
|
+
bold: true,
|
|
144
|
+
alignment: 'right',
|
|
145
|
+
margin: [0, 2, 0, 0]
|
|
146
|
+
}] : [])
|
|
138
147
|
]
|
|
139
148
|
});
|
|
140
149
|
}
|
|
@@ -286,11 +295,15 @@ function formatGatePassDate(value) {
|
|
|
286
295
|
return formatAsDDMMYYYY(parsed);
|
|
287
296
|
}
|
|
288
297
|
function formatAsDDMMYYYY(dateValue) {
|
|
289
|
-
const day =
|
|
290
|
-
const month =
|
|
298
|
+
const day = leftPadWithZero(dateValue.getDate());
|
|
299
|
+
const month = leftPadWithZero(dateValue.getMonth() + 1);
|
|
291
300
|
const year = dateValue.getFullYear();
|
|
292
301
|
return `${day}/${month}/${year}`;
|
|
293
302
|
}
|
|
303
|
+
function leftPadWithZero(value) {
|
|
304
|
+
const text = String(value);
|
|
305
|
+
return text.length >= 2 ? text : `0${text}`;
|
|
306
|
+
}
|
|
294
307
|
function buildSimpleTextCardStack(title, value) {
|
|
295
308
|
return [
|
|
296
309
|
{ text: title, bold: true, fontSize: 9, color: '#374151', margin: [0, 0, 0, 4] },
|
|
@@ -331,34 +344,55 @@ function buildInfoCardStack(title, lines, options = {}) {
|
|
|
331
344
|
}
|
|
332
345
|
];
|
|
333
346
|
}
|
|
334
|
-
function buildTaxSummaryTableStack(title, rows) {
|
|
347
|
+
function buildTaxSummaryTableStack(title, rows, sType = '') {
|
|
348
|
+
const isInter = sType === 'Inter';
|
|
335
349
|
const normalizedRows = Array.isArray(rows) ? rows : [];
|
|
336
350
|
const tableRows = normalizedRows.length > 0
|
|
337
|
-
? normalizedRows.map((row) => (
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
{ text: '-', fontSize: 7, color: '#111827' },
|
|
345
|
-
{ text: '-', fontSize: 7, color: '#111827', alignment: 'right' },
|
|
346
|
-
{ text: '-', fontSize: 7, color: '#111827', alignment: 'right' },
|
|
347
|
-
{ text: '-', fontSize: 7, color: '#111827', alignment: 'right' }
|
|
348
|
-
]
|
|
351
|
+
? normalizedRows.map((row) => (isInter
|
|
352
|
+
? [
|
|
353
|
+
{ text: row.taxRate || '-', fontSize: 7, color: '#111827' },
|
|
354
|
+
{ text: row.taxableAmount || '-', fontSize: 7, color: '#111827', alignment: 'right' },
|
|
355
|
+
{ text: row.igstAmount || '-', fontSize: 7, color: '#111827', alignment: 'right' }
|
|
356
|
+
]
|
|
357
|
+
: [
|
|
358
|
+
{ text: row.taxRate || '-', fontSize: 7, color: '#111827' },
|
|
359
|
+
{ text: row.taxableAmount || '-', fontSize: 7, color: '#111827', alignment: 'right' },
|
|
360
|
+
{ text: row.cgstAmount || '-', fontSize: 7, color: '#111827', alignment: 'right' },
|
|
361
|
+
{ text: row.sgstAmount || '-', fontSize: 7, color: '#111827', alignment: 'right' }
|
|
362
|
+
]))
|
|
363
|
+
: [
|
|
364
|
+
isInter
|
|
365
|
+
? [
|
|
366
|
+
{ text: '-', fontSize: 7, color: '#111827' },
|
|
367
|
+
{ text: '-', fontSize: 7, color: '#111827', alignment: 'right' },
|
|
368
|
+
{ text: '-', fontSize: 7, color: '#111827', alignment: 'right' }
|
|
369
|
+
]
|
|
370
|
+
: [
|
|
371
|
+
{ text: '-', fontSize: 7, color: '#111827' },
|
|
372
|
+
{ text: '-', fontSize: 7, color: '#111827', alignment: 'right' },
|
|
373
|
+
{ text: '-', fontSize: 7, color: '#111827', alignment: 'right' },
|
|
374
|
+
{ text: '-', fontSize: 7, color: '#111827', alignment: 'right' }
|
|
375
|
+
]
|
|
376
|
+
];
|
|
349
377
|
return [
|
|
350
378
|
// { text: title, bold: true, fontSize: 9, color: '#374151', margin: [0, 0, 0, 4] },
|
|
351
379
|
{
|
|
352
380
|
table: {
|
|
353
381
|
headerRows: 0,
|
|
354
|
-
widths: ['auto', '*', '*', '*'],
|
|
382
|
+
widths: isInter ? ['auto', '*', '*'] : ['auto', '*', '*', '*'],
|
|
355
383
|
body: [
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
384
|
+
isInter
|
|
385
|
+
? [
|
|
386
|
+
{ text: 'Tax Rate', bold: true, fontSize: 7, fillColor: '#eeeeee' },
|
|
387
|
+
{ text: 'Taxable Amount', bold: true, fontSize: 7, fillColor: '#eeeeee', alignment: 'right' },
|
|
388
|
+
{ text: 'IGST(Rs)', bold: true, fontSize: 7, fillColor: '#eeeeee', alignment: 'right' }
|
|
389
|
+
]
|
|
390
|
+
: [
|
|
391
|
+
{ text: 'Tax Rate', bold: true, fontSize: 7, fillColor: '#eeeeee' },
|
|
392
|
+
{ text: 'Taxable Amount', bold: true, fontSize: 7, fillColor: '#eeeeee', alignment: 'right' },
|
|
393
|
+
{ text: 'CGST(Rs)', bold: true, fontSize: 7, fillColor: '#eeeeee', alignment: 'right' },
|
|
394
|
+
{ text: 'SGST(Rs)', bold: true, fontSize: 7, fillColor: '#eeeeee', alignment: 'right' }
|
|
395
|
+
],
|
|
362
396
|
...tableRows
|
|
363
397
|
]
|
|
364
398
|
},
|
|
@@ -540,9 +574,16 @@ function resolveDueInfo(invoiceData, totals) {
|
|
|
540
574
|
hasData: paid !== 0 || due !== 0 || !!(totals === null || totals === void 0 ? void 0 : totals.hasData)
|
|
541
575
|
};
|
|
542
576
|
}
|
|
543
|
-
function resolveQrPayload(invoiceData) {
|
|
544
|
-
var _a, _b;
|
|
545
|
-
|
|
577
|
+
function resolveQrPayload(invoiceData, printConfigData = {}) {
|
|
578
|
+
var _a, _b, _c;
|
|
579
|
+
if (!isTruthy(printConfigData === null || printConfigData === void 0 ? void 0 : printConfigData.ShowPayQrCode)) {
|
|
580
|
+
return '';
|
|
581
|
+
}
|
|
582
|
+
return (0, pdf_shared_utils_1.firstValue)((_a = invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.Entity) === null || _a === void 0 ? void 0 : _a.UPI, invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.QRText, invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.QrText, invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.QRCode, invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.QRData, invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.UPIId, (_b = invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.Bank) === null || _b === void 0 ? void 0 : _b.UPI, (_c = invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.BankDetails) === null || _c === void 0 ? void 0 : _c.UPI);
|
|
583
|
+
}
|
|
584
|
+
function resolveUpiPhone(invoiceData) {
|
|
585
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
586
|
+
return (0, pdf_shared_utils_1.firstValue)(invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.UPIPhone, (_a = invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.Entity) === null || _a === void 0 ? void 0 : _a.UPIPhone, (_b = invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.Bank) === null || _b === void 0 ? void 0 : _b.UPIPhone, (_c = invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.BankDetails) === null || _c === void 0 ? void 0 : _c.UPIPhone, (_e = (_d = invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.Entity) === null || _d === void 0 ? void 0 : _d.Bank) === null || _e === void 0 ? void 0 : _e.UPIPhone, (_g = (_f = invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.Entity) === null || _f === void 0 ? void 0 : _f.BankDetails) === null || _g === void 0 ? void 0 : _g.UPIPhone);
|
|
546
587
|
}
|
|
547
588
|
function formatAmountFixed2(value) {
|
|
548
589
|
if (!Number.isFinite(value)) {
|
|
@@ -521,7 +521,6 @@ function ComputeDocumentTotals(input) {
|
|
|
521
521
|
// 5. DocTotal rounding
|
|
522
522
|
let roundedTotal = grandTotal;
|
|
523
523
|
let roundAdj = 0;
|
|
524
|
-
console.log('Rounding', Rounding);
|
|
525
524
|
if ((Rounding === null || Rounding === void 0 ? void 0 : Rounding.DocTotal) !== false) { // default true
|
|
526
525
|
roundedTotal = RoundAmount(grandTotal, { Method: Rounding.Method, Precision: Rounding.Precision });
|
|
527
526
|
roundAdj = (0, math_operations_1.Subtract)(roundedTotal, grandTotal);
|