shareneus 1.6.96 → 1.6.97
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.
- package/dist/accounting/invoice/invoice-pdf/invoice-pdf.service.js +4 -4
- package/dist/shared/table-section/pdf-table.header.js +11 -2
- package/dist/shared/table-section/pdf-table.row.d.ts +1 -1
- package/dist/shared/table-section/pdf-table.row.js +3 -34
- package/dist/shared/totals-section/pdf-totals.section.js +9 -3
- package/package.json +1 -1
|
@@ -194,12 +194,12 @@ function GetHeaderInfo(Entity, marginleft, InvoicePDFData = {}) {
|
|
|
194
194
|
if (!tr_utils_1.TrUtils.IsEmpty(Entity.DLNo)) {
|
|
195
195
|
TaxInfo.push({ text: 'D.L.NO : ' + Entity.DLNo, marginTop: 2, marginLeft: 5, alignment: 'left', fontSize: 9, width: '*' });
|
|
196
196
|
}
|
|
197
|
-
TaxInfo.push(GetBillofSupplyName(InvoicePDFData.Settings));
|
|
197
|
+
// TaxInfo.push(GetBillofSupplyName(InvoicePDFData.Settings));
|
|
198
198
|
return TaxInfo;
|
|
199
199
|
}
|
|
200
|
-
function GetBillofSupplyName(Settings) {
|
|
201
|
-
|
|
202
|
-
}
|
|
200
|
+
// function GetBillofSupplyName(Settings: any) {
|
|
201
|
+
// return { text: Settings.Tax === 'BS' ? ' Bill of Supply' : null, alignment: 'center', marginLeft: 15, marginTop: 2, marginBottom: 3, fontSize: 9, width: 'auto' };
|
|
202
|
+
// }
|
|
203
203
|
// function SalesReceiptHeaderData(Entity: any, Image: any, AColor: any, HColor: any, text: any) {
|
|
204
204
|
// return [
|
|
205
205
|
// SharedPDFService.GetMainHeader(Entity, Image, AColor, HColor, text),
|
|
@@ -18,6 +18,8 @@ function GetTableHeader(itemsHeader) {
|
|
|
18
18
|
text: itemTitle,
|
|
19
19
|
width: itemWidth,
|
|
20
20
|
bold: (_l = item.bold) !== null && _l !== void 0 ? _l : true,
|
|
21
|
+
fontSize: 9,
|
|
22
|
+
alignment: resolveHeaderAlignment(itemTitle),
|
|
21
23
|
dbFields: itemDbFields,
|
|
22
24
|
stackParent: stackTitle,
|
|
23
25
|
stackSeq: typeof stackSeq === 'number' ? stackSeq : Number.MAX_SAFE_INTEGER
|
|
@@ -191,7 +193,7 @@ function buildHeaderRows(headerConfig, sType = '') {
|
|
|
191
193
|
const hasDiscGroup = hasDiscPercent && hasDiscAmount;
|
|
192
194
|
const hasGroupedHeaders = hasTaxPercent || hasTaxAmount || hasDiscGroup;
|
|
193
195
|
if (!hasGroupedHeaders) {
|
|
194
|
-
const singleRow = headerConfig.map((header) => (Object.assign({ text: header.text, dbFields: header.dbFields, stackFields: header.stackFields }, getHeaderCellStyle())));
|
|
196
|
+
const singleRow = headerConfig.map((header) => (Object.assign({ text: header.text, alignment: header.alignment, dbFields: header.dbFields, stackFields: header.stackFields }, getHeaderCellStyle())));
|
|
195
197
|
return [singleRow];
|
|
196
198
|
}
|
|
197
199
|
const topRow = [];
|
|
@@ -246,7 +248,7 @@ function buildHeaderRows(headerConfig, sType = '') {
|
|
|
246
248
|
if (hasDiscGroup && isDiscountAmountHeader(header.text)) {
|
|
247
249
|
continue;
|
|
248
250
|
}
|
|
249
|
-
topRow.push(Object.assign({ text: header.text, rowSpan: 2 }, getHeaderCellStyle()));
|
|
251
|
+
topRow.push(Object.assign({ text: header.text, rowSpan: 2, alignment: header.alignment }, getHeaderCellStyle()));
|
|
250
252
|
subRow.push({});
|
|
251
253
|
}
|
|
252
254
|
return [topRow, subRow];
|
|
@@ -272,6 +274,13 @@ function normalizeHeaderText(value) {
|
|
|
272
274
|
.trim()
|
|
273
275
|
.toUpperCase();
|
|
274
276
|
}
|
|
277
|
+
function resolveHeaderAlignment(title) {
|
|
278
|
+
const normalizedTitle = normalizeHeaderText(title);
|
|
279
|
+
if (normalizedTitle === 'LINETOTAL' || normalizedTitle === 'PRICE' || normalizedTitle === 'QTY') {
|
|
280
|
+
return 'right';
|
|
281
|
+
}
|
|
282
|
+
return undefined;
|
|
283
|
+
}
|
|
275
284
|
function getHeaderCellStyle() {
|
|
276
285
|
return {
|
|
277
286
|
bold: true,
|
|
@@ -11,6 +11,6 @@ export declare function buildDataRow(item: any, index: number, headerConfig: any
|
|
|
11
11
|
color?: undefined;
|
|
12
12
|
alignment?: undefined;
|
|
13
13
|
})[];
|
|
14
|
-
export declare function getFirstFieldValue(item: any, dbFields?: string[]
|
|
14
|
+
export declare function getFirstFieldValue(item: any, dbFields?: string[]): string;
|
|
15
15
|
export declare function getNumericAlignment(value: string): "left" | "right";
|
|
16
16
|
export declare function getCellAlignment(headerText: string, value: string): "left" | "right";
|
|
@@ -7,6 +7,7 @@ exports.getCellAlignment = getCellAlignment;
|
|
|
7
7
|
const pdf_table_config_1 = require("./pdf-table.config");
|
|
8
8
|
const my_date_1 = require("../../utils/my-date");
|
|
9
9
|
function buildDataRow(item, index, headerConfig, fixedTo = 2) {
|
|
10
|
+
console.log('Building data row for headerConfig:', headerConfig);
|
|
10
11
|
return headerConfig.map((column) => {
|
|
11
12
|
var _a;
|
|
12
13
|
if (column.type === 'tax') {
|
|
@@ -49,7 +50,7 @@ function buildDataRow(item, index, headerConfig, fixedTo = 2) {
|
|
|
49
50
|
});
|
|
50
51
|
}
|
|
51
52
|
function formatFieldValue(item, fieldConfig, fixedTo) {
|
|
52
|
-
const rawValue =
|
|
53
|
+
const rawValue = getFirstFieldValue(item, fieldConfig === null || fieldConfig === void 0 ? void 0 : fieldConfig.dbFields);
|
|
53
54
|
if (isExpiryField(fieldConfig)) {
|
|
54
55
|
return formatExpiryDateValue(rawValue);
|
|
55
56
|
}
|
|
@@ -58,17 +59,6 @@ function formatFieldValue(item, fieldConfig, fixedTo) {
|
|
|
58
59
|
: rawValue;
|
|
59
60
|
return formatNumericLikeValue(signedValue, fixedTo, shouldSkipFixedTo(fieldConfig));
|
|
60
61
|
}
|
|
61
|
-
function getDisplayFieldValue(item, fieldConfig) {
|
|
62
|
-
const directValue = getFirstFieldValue(item, fieldConfig === null || fieldConfig === void 0 ? void 0 : fieldConfig.dbFields);
|
|
63
|
-
if (directValue) {
|
|
64
|
-
return directValue;
|
|
65
|
-
}
|
|
66
|
-
const fallbackFields = getFallbackDbFields(fieldConfig);
|
|
67
|
-
if (fallbackFields.length === 0) {
|
|
68
|
-
return '';
|
|
69
|
-
}
|
|
70
|
-
return getFirstFieldValue(item, fallbackFields);
|
|
71
|
-
}
|
|
72
62
|
function getTaxValue(item, taxName, taxKind) {
|
|
73
63
|
if (taxName === 'IGST') {
|
|
74
64
|
const fields = taxKind === 'rate' ? ['IGSTPerc'] : ['IGSTAmt'];
|
|
@@ -104,8 +94,7 @@ function negateNumericLikeValue(value) {
|
|
|
104
94
|
return String(normalized === 0 ? 0 : -Math.abs(normalized));
|
|
105
95
|
}
|
|
106
96
|
function getFirstFieldValue(item, dbFields = []) {
|
|
107
|
-
const
|
|
108
|
-
for (const field of normalizedFields) {
|
|
97
|
+
for (const field of dbFields) {
|
|
109
98
|
const value = readValue(item, field);
|
|
110
99
|
if (value !== undefined && value !== null && value !== '') {
|
|
111
100
|
return String(value);
|
|
@@ -131,15 +120,6 @@ function readValue(item, field) {
|
|
|
131
120
|
}
|
|
132
121
|
return deepFindByKey(item, field);
|
|
133
122
|
}
|
|
134
|
-
function normalizeDbFields(dbFields) {
|
|
135
|
-
if (Array.isArray(dbFields)) {
|
|
136
|
-
return dbFields;
|
|
137
|
-
}
|
|
138
|
-
if (typeof dbFields === 'string') {
|
|
139
|
-
return dbFields ? [dbFields] : [];
|
|
140
|
-
}
|
|
141
|
-
return [];
|
|
142
|
-
}
|
|
143
123
|
function deepFindByKey(source, field) {
|
|
144
124
|
if (!source || typeof source !== 'object') {
|
|
145
125
|
return undefined;
|
|
@@ -219,17 +199,6 @@ function formatExpiryDateValue(value) {
|
|
|
219
199
|
}
|
|
220
200
|
return my_date_1.MyDate.ConvertUTCDateToReadableExDate(input) || input;
|
|
221
201
|
}
|
|
222
|
-
function getFallbackDbFields(fieldConfig) {
|
|
223
|
-
var _a;
|
|
224
|
-
const text = String((_a = fieldConfig === null || fieldConfig === void 0 ? void 0 : fieldConfig.text) !== null && _a !== void 0 ? _a : '').trim().toUpperCase();
|
|
225
|
-
if (text === 'BN' || text === 'BATCH' || text === 'BATCH NO' || text === 'BATCH NO.') {
|
|
226
|
-
return ['Batch.BN', 'Batch.MBN', 'BN'];
|
|
227
|
-
}
|
|
228
|
-
if (text === 'EXDT' || text === 'EXPIRY' || text === 'EXPIRY DATE') {
|
|
229
|
-
return ['Batch.ExDt', 'ExDt'];
|
|
230
|
-
}
|
|
231
|
-
return [];
|
|
232
|
-
}
|
|
233
202
|
function shouldSkipFixedTo(header) {
|
|
234
203
|
var _a;
|
|
235
204
|
const text = String((_a = header === null || header === void 0 ? void 0 : header.text) !== null && _a !== void 0 ? _a : '').trim().toUpperCase();
|
|
@@ -520,7 +520,9 @@ function hasDisplayValue(value) {
|
|
|
520
520
|
return true;
|
|
521
521
|
}
|
|
522
522
|
function resolveTotals(invoiceData, totalTax, printConfigData = {}) {
|
|
523
|
+
var _a;
|
|
523
524
|
const subtotal = (0, pdf_table_section_1.readNumericValue)(invoiceData, ['SIndTotal', 'STotal', 'SubTotal', 'SubTot', 'TaxableAmount', 'TaxableValue']);
|
|
525
|
+
const isPoSPrint = isTruthy((_a = printConfigData === null || printConfigData === void 0 ? void 0 : printConfigData.IsPoSPrint) !== null && _a !== void 0 ? _a : printConfigData === null || printConfigData === void 0 ? void 0 : printConfigData.isPoSPrint);
|
|
524
526
|
const showDetailedDisc = isTruthy((0, pdf_shared_utils_1.firstValue)(printConfigData === null || printConfigData === void 0 ? void 0 : printConfigData.ShowDetailedDisc));
|
|
525
527
|
const itemsDiscount = parseNumber((0, pdf_shared_utils_1.firstValue)(invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.PDisc));
|
|
526
528
|
const servicesDiscount = parseNumber((0, pdf_shared_utils_1.firstValue)(invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.LDisc));
|
|
@@ -539,6 +541,7 @@ function resolveTotals(invoiceData, totalTax, printConfigData = {}) {
|
|
|
539
541
|
const returnTotal = (0, pdf_shared_utils_1.firstValue)(invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.RetTotal);
|
|
540
542
|
const finalTotalRaw = (0, pdf_shared_utils_1.firstValue)(invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.FinalTotal, invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.Total, invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.GrandTotal, invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.NetTotal);
|
|
541
543
|
const finalTotal = parseNumber(finalTotalRaw);
|
|
544
|
+
const paidAmount = (0, pdf_table_section_1.readNumericValue)(invoiceData, ['Paid', 'PaidAmount', 'PaidAmt', 'ReceivedAmount', 'RecAmt']);
|
|
542
545
|
let totalBeforeRound = (0, pdf_table_section_1.readNumericValue)(invoiceData, ['TotalBeforeRound', 'BeforeRoundTotal', 'PreRoundTotal']);
|
|
543
546
|
if (totalBeforeRound === 0) {
|
|
544
547
|
if (finalTotalRaw) {
|
|
@@ -552,6 +555,8 @@ function resolveTotals(invoiceData, totalTax, printConfigData = {}) {
|
|
|
552
555
|
}
|
|
553
556
|
}
|
|
554
557
|
const resolvedFinalTotal = finalTotalRaw ? finalTotal : totalBeforeRound + roundOff;
|
|
558
|
+
const dueFromInvoice = (0, pdf_table_section_1.readNumericValue)(invoiceData, ['Due', 'DueAmount', 'DueAmt', 'Balance', 'BalAmt']);
|
|
559
|
+
const dueAmount = dueFromInvoice !== 0 ? dueFromInvoice : Math.max(0, resolvedFinalTotal - paidAmount);
|
|
555
560
|
const discountLines = (showDetailedDisc
|
|
556
561
|
? [
|
|
557
562
|
{ label: 'Items Discount', amount: itemsDiscount },
|
|
@@ -561,7 +566,7 @@ function resolveTotals(invoiceData, totalTax, printConfigData = {}) {
|
|
|
561
566
|
: [
|
|
562
567
|
{ label: 'Discount', amount: (0, math_operations_1.Add)(overalItemsDiscount, overalServicesDiscount) }
|
|
563
568
|
])
|
|
564
|
-
.filter((line) =>
|
|
569
|
+
.filter((line) => parseNumber(line === null || line === void 0 ? void 0 : line.amount) !== 0);
|
|
565
570
|
const totalLines = [
|
|
566
571
|
{ label: 'SubTotal', amount: subtotal },
|
|
567
572
|
...discountLines,
|
|
@@ -569,10 +574,11 @@ function resolveTotals(invoiceData, totalTax, printConfigData = {}) {
|
|
|
569
574
|
{ label: 'Return Total', amount: returnTotal },
|
|
570
575
|
{ label: 'Total', amount: totalBeforeRound },
|
|
571
576
|
{ label: 'Rounding', amount: roundOff },
|
|
572
|
-
{ label: 'Final Total', amount: resolvedFinalTotal }
|
|
577
|
+
...(roundOff !== 0 ? [{ label: 'Final Total', amount: resolvedFinalTotal }] : []),
|
|
578
|
+
...(isPoSPrint ? [{ label: 'Due', amount: dueAmount }] : [])
|
|
573
579
|
];
|
|
574
580
|
const lines = totalLines
|
|
575
|
-
.filter((line) =>
|
|
581
|
+
.filter((line) => parseNumber(line === null || line === void 0 ? void 0 : line.amount) !== 0)
|
|
576
582
|
.map((line) => ({ label: line.label, value: formatAmountFixed2(parseNumber(line === null || line === void 0 ? void 0 : line.amount)) }));
|
|
577
583
|
const hasData = lines.some((line) => hasDisplayValue(line === null || line === void 0 ? void 0 : line.value));
|
|
578
584
|
return {
|