shareneus 1.6.64 → 1.6.65
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
|
};
|
|
@@ -54,10 +55,10 @@ function buildInvoiceTotalsAndNotesSection(invoiceData, availableWidth, PrintCon
|
|
|
54
55
|
}
|
|
55
56
|
return [dividerLine, bottomColumns];
|
|
56
57
|
}
|
|
57
|
-
function buildTopSectionColumns(taxSummary, showBankDetails, bankDetails, totals) {
|
|
58
|
+
function buildTopSectionColumns(taxSummary, sType, showBankDetails, bankDetails, totals) {
|
|
58
59
|
if (taxSummary.hasData) {
|
|
59
60
|
return [
|
|
60
|
-
{ width: '42%', stack: buildTaxSummaryTableStack(null, taxSummary.rows) },
|
|
61
|
+
{ width: '42%', stack: buildTaxSummaryTableStack(null, taxSummary.rows, sType) },
|
|
61
62
|
{ width: '28%', stack: showBankDetails ? buildInfoCardStack('Bank Details', bankDetails.lines) : [{ text: '' }] },
|
|
62
63
|
{ width: '30%', stack: buildInfoCardStack(null, totals.lines, { rightAlign: true }) }
|
|
63
64
|
];
|
|
@@ -286,11 +287,15 @@ function formatGatePassDate(value) {
|
|
|
286
287
|
return formatAsDDMMYYYY(parsed);
|
|
287
288
|
}
|
|
288
289
|
function formatAsDDMMYYYY(dateValue) {
|
|
289
|
-
const day =
|
|
290
|
-
const month =
|
|
290
|
+
const day = leftPadWithZero(dateValue.getDate());
|
|
291
|
+
const month = leftPadWithZero(dateValue.getMonth() + 1);
|
|
291
292
|
const year = dateValue.getFullYear();
|
|
292
293
|
return `${day}/${month}/${year}`;
|
|
293
294
|
}
|
|
295
|
+
function leftPadWithZero(value) {
|
|
296
|
+
const text = String(value);
|
|
297
|
+
return text.length >= 2 ? text : `0${text}`;
|
|
298
|
+
}
|
|
294
299
|
function buildSimpleTextCardStack(title, value) {
|
|
295
300
|
return [
|
|
296
301
|
{ text: title, bold: true, fontSize: 9, color: '#374151', margin: [0, 0, 0, 4] },
|
|
@@ -331,34 +336,55 @@ function buildInfoCardStack(title, lines, options = {}) {
|
|
|
331
336
|
}
|
|
332
337
|
];
|
|
333
338
|
}
|
|
334
|
-
function buildTaxSummaryTableStack(title, rows) {
|
|
339
|
+
function buildTaxSummaryTableStack(title, rows, sType = '') {
|
|
340
|
+
const isInter = sType === 'Inter';
|
|
335
341
|
const normalizedRows = Array.isArray(rows) ? rows : [];
|
|
336
342
|
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
|
-
]
|
|
343
|
+
? normalizedRows.map((row) => (isInter
|
|
344
|
+
? [
|
|
345
|
+
{ text: row.taxRate || '-', fontSize: 7, color: '#111827' },
|
|
346
|
+
{ text: row.taxableAmount || '-', fontSize: 7, color: '#111827', alignment: 'right' },
|
|
347
|
+
{ text: row.igstAmount || '-', fontSize: 7, color: '#111827', alignment: 'right' }
|
|
348
|
+
]
|
|
349
|
+
: [
|
|
350
|
+
{ text: row.taxRate || '-', fontSize: 7, color: '#111827' },
|
|
351
|
+
{ text: row.taxableAmount || '-', fontSize: 7, color: '#111827', alignment: 'right' },
|
|
352
|
+
{ text: row.cgstAmount || '-', fontSize: 7, color: '#111827', alignment: 'right' },
|
|
353
|
+
{ text: row.sgstAmount || '-', fontSize: 7, color: '#111827', alignment: 'right' }
|
|
354
|
+
]))
|
|
355
|
+
: [
|
|
356
|
+
isInter
|
|
357
|
+
? [
|
|
358
|
+
{ text: '-', fontSize: 7, color: '#111827' },
|
|
359
|
+
{ text: '-', fontSize: 7, color: '#111827', alignment: 'right' },
|
|
360
|
+
{ text: '-', fontSize: 7, color: '#111827', alignment: 'right' }
|
|
361
|
+
]
|
|
362
|
+
: [
|
|
363
|
+
{ text: '-', fontSize: 7, color: '#111827' },
|
|
364
|
+
{ text: '-', fontSize: 7, color: '#111827', alignment: 'right' },
|
|
365
|
+
{ text: '-', fontSize: 7, color: '#111827', alignment: 'right' },
|
|
366
|
+
{ text: '-', fontSize: 7, color: '#111827', alignment: 'right' }
|
|
367
|
+
]
|
|
368
|
+
];
|
|
349
369
|
return [
|
|
350
370
|
// { text: title, bold: true, fontSize: 9, color: '#374151', margin: [0, 0, 0, 4] },
|
|
351
371
|
{
|
|
352
372
|
table: {
|
|
353
373
|
headerRows: 0,
|
|
354
|
-
widths: ['auto', '*', '*', '*'],
|
|
374
|
+
widths: isInter ? ['auto', '*', '*'] : ['auto', '*', '*', '*'],
|
|
355
375
|
body: [
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
376
|
+
isInter
|
|
377
|
+
? [
|
|
378
|
+
{ text: 'Tax Rate', bold: true, fontSize: 7, fillColor: '#eeeeee' },
|
|
379
|
+
{ text: 'Taxable Amount', bold: true, fontSize: 7, fillColor: '#eeeeee', alignment: 'right' },
|
|
380
|
+
{ text: 'IGST(Rs)', bold: true, fontSize: 7, fillColor: '#eeeeee', alignment: 'right' }
|
|
381
|
+
]
|
|
382
|
+
: [
|
|
383
|
+
{ text: 'Tax Rate', bold: true, fontSize: 7, fillColor: '#eeeeee' },
|
|
384
|
+
{ text: 'Taxable Amount', bold: true, fontSize: 7, fillColor: '#eeeeee', alignment: 'right' },
|
|
385
|
+
{ text: 'CGST(Rs)', bold: true, fontSize: 7, fillColor: '#eeeeee', alignment: 'right' },
|
|
386
|
+
{ text: 'SGST(Rs)', bold: true, fontSize: 7, fillColor: '#eeeeee', alignment: 'right' }
|
|
387
|
+
],
|
|
362
388
|
...tableRows
|
|
363
389
|
]
|
|
364
390
|
},
|
|
@@ -540,9 +566,12 @@ function resolveDueInfo(invoiceData, totals) {
|
|
|
540
566
|
hasData: paid !== 0 || due !== 0 || !!(totals === null || totals === void 0 ? void 0 : totals.hasData)
|
|
541
567
|
};
|
|
542
568
|
}
|
|
543
|
-
function resolveQrPayload(invoiceData) {
|
|
544
|
-
var _a, _b;
|
|
545
|
-
|
|
569
|
+
function resolveQrPayload(invoiceData, printConfigData = {}) {
|
|
570
|
+
var _a, _b, _c;
|
|
571
|
+
if (!isTruthy(printConfigData === null || printConfigData === void 0 ? void 0 : printConfigData.ShowPayQrCode)) {
|
|
572
|
+
return '';
|
|
573
|
+
}
|
|
574
|
+
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);
|
|
546
575
|
}
|
|
547
576
|
function formatAmountFixed2(value) {
|
|
548
577
|
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);
|