shareneus 1.7.322 → 1.7.324
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/debit-note/debit-note-print.service.d.ts +5 -0
- package/dist/accounting/debit-note/debit-note-print.service.js +91 -9
- package/dist/shared/table-section/pdf-table.header.js +5 -5
- package/dist/shared/table-section/pdf-table.section.js +1 -1
- package/dist/shared/transactions-pdf.service.d.ts +1 -0
- package/dist/shared/transactions-pdf.service.js +28 -0
- package/dist/tax/tax-calculator.js +2 -2
- package/dist/tax/tax.types.d.ts +2 -0
- package/package.json +1 -1
- package/src/accounting/debit-note/debit-note-print.service.ts +103 -17
- package/src/shared/table-section/pdf-table.header.ts +6 -6
- package/src/shared/table-section/pdf-table.section.ts +22 -22
- package/src/shared/transactions-pdf.service.ts +32 -0
- package/src/tax/tax-calculator.ts +2 -2
- package/src/tax/tax.types.ts +3 -0
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
export declare class DebitNotePrintService {
|
|
2
2
|
static GetDebitNotePrintInfo(OriginalInvoiceData: any, OriginalEntityData: any, image: any, IncludeGST: boolean, ConsolidateGST: boolean, TaxCodes: any, IsProforma: boolean, IsCustBillTo: boolean): any;
|
|
3
|
+
static GetLaborPrintInfo(LaborList: any, Consolidate: boolean, TaxCodes: any, LineTotal: string, DecimalsNumber: number): any;
|
|
4
|
+
static getTaxName(TCode: any, TaxCodes: any): any;
|
|
5
|
+
static GetTaxAmountFromTaxes(item: any, taxCode: string): any;
|
|
6
|
+
static GetTaxRateFromTaxes(item: any, taxCode: string): any;
|
|
7
|
+
static GetTCodeFromTaxes(item: any): any;
|
|
3
8
|
static GetPrintConditionsBasedOnInput(InvoicePrintData: any, IncludeGST: boolean, ConsolidateGST: boolean, SType: any, OriginalInvoiceData: any, IsProforma: boolean, IsBillTo: boolean): any;
|
|
4
9
|
static GetInvoiceTypeHeading(InvoicePrintData: any, OriginalInvoiceData: any, IncludeGST: boolean, ConsolidateGST: boolean, IsProforma: boolean, IsBillTo: boolean): any;
|
|
5
10
|
static GetInvoiceOtherDetailsForPrint(InvoicePrintData: any, OriginalInvoiceData: any, IsCustBillTo: boolean): any;
|
|
@@ -10,7 +10,7 @@ const my_date_1 = require("../../utils/my-date");
|
|
|
10
10
|
const math_operations_1 = require("../../shared/math-operations");
|
|
11
11
|
class DebitNotePrintService {
|
|
12
12
|
static GetDebitNotePrintInfo(OriginalInvoiceData, OriginalEntityData, image, IncludeGST, ConsolidateGST, TaxCodes, IsProforma, IsCustBillTo) {
|
|
13
|
-
var _a, _b, _c, _d;
|
|
13
|
+
var _a, _b, _c, _d, _e, _f;
|
|
14
14
|
let InvoicePrintData = {};
|
|
15
15
|
let argInvoiceData = tr_utils_1.TrUtils.Stringify(OriginalInvoiceData);
|
|
16
16
|
if (!IncludeGST) {
|
|
@@ -31,7 +31,8 @@ class DebitNotePrintService {
|
|
|
31
31
|
finalTotalsData.CustPartsTotalBeforeDisc = finalTotalsData.CustPartAfterTax;
|
|
32
32
|
}
|
|
33
33
|
InvoicePrintData = tr_utils_1.TrUtils.ConcatObjects(InvoicePrintData, finalTotalsData);
|
|
34
|
-
InvoicePrintData.
|
|
34
|
+
InvoicePrintData.Ops = this.GetLaborPrintInfo(InvoicePrintData.Services, ConsolidateGST, TaxCodes, (_b = (_a = OriginalEntityData.Entity.Settings) === null || _a === void 0 ? void 0 : _a.Acc) === null || _b === void 0 ? void 0 : _b.LTot, InvoicePrintData.Entity.DecimalsNumber);
|
|
35
|
+
InvoicePrintData.Items = this.GetItemsPrintInfo(InvoicePrintData.Items, ConsolidateGST, TaxCodes, (_d = (_c = OriginalEntityData.Entity.Settings) === null || _c === void 0 ? void 0 : _c.Acc) === null || _d === void 0 ? void 0 : _d.LTot, (_e = InvoicePrintData.Entity) === null || _e === void 0 ? void 0 : _e.DecimalsNumber);
|
|
35
36
|
argInvoiceData = this.ReverseItemsForInvoicePrint(argInvoiceData);
|
|
36
37
|
InvoicePrintData.PrintInfo = this.PrepareFormatForInvoicePrint(InvoicePrintData, code_enums_1.ROTypeEnum.Invoice, argInvoiceData.Sts);
|
|
37
38
|
InvoicePrintData = this.GetFormattedProductDataForPrint(argInvoiceData, InvoicePrintData);
|
|
@@ -39,7 +40,7 @@ class DebitNotePrintService {
|
|
|
39
40
|
if (tr_utils_1.TrUtils.IsNull(argInvoiceData.Payments)) {
|
|
40
41
|
argInvoiceData.Payments = [];
|
|
41
42
|
}
|
|
42
|
-
let PaymentData = this.GetPaymentsTotal(argInvoiceData.Payments, InvoicePrintData.Total, argInvoiceData.Sts, (
|
|
43
|
+
let PaymentData = this.GetPaymentsTotal(argInvoiceData.Payments, InvoicePrintData.Total, argInvoiceData.Sts, (_f = InvoicePrintData.Entity) === null || _f === void 0 ? void 0 : _f.DecimalsNumber);
|
|
43
44
|
InvoicePrintData.Due = PaymentData.Due;
|
|
44
45
|
InvoicePrintData.Paid = PaymentData.Paid;
|
|
45
46
|
if (!tr_utils_1.TrUtils.IsNull(PaymentData.Sts)) {
|
|
@@ -51,6 +52,78 @@ class DebitNotePrintService {
|
|
|
51
52
|
}
|
|
52
53
|
return InvoicePrintData;
|
|
53
54
|
}
|
|
55
|
+
static GetLaborPrintInfo(LaborList, Consolidate, TaxCodes, LineTotal, DecimalsNumber) {
|
|
56
|
+
LaborList.forEach((Labor) => {
|
|
57
|
+
Labor.HSN = Labor.SAC;
|
|
58
|
+
if (tr_utils_1.TrUtils.IsNull(Labor.Qty)) {
|
|
59
|
+
Labor.Qty = 1;
|
|
60
|
+
}
|
|
61
|
+
if (Consolidate) {
|
|
62
|
+
Labor.UnPr = tr_utils_1.TrUtils.FixedTo(Labor.AfterLaborTax, DecimalsNumber);
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
Labor.UnPr = tr_utils_1.TrUtils.FixPriceValue(Labor.Pr, DecimalsNumber);
|
|
66
|
+
}
|
|
67
|
+
if (!tr_utils_1.TrUtils.IsEmpty(Labor.Perc)) {
|
|
68
|
+
Labor.DiscPerc = Labor.Perc;
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
Labor.DiscPerc = Labor.Perc;
|
|
72
|
+
if (!tr_utils_1.TrUtils.IsZero(Number(Labor.UnPr))) {
|
|
73
|
+
Labor.DiscPerc = (0, math_operations_1.Divide)((0, math_operations_1.Multiply)(100, Labor.Disc), Labor.UnPr);
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
Labor.DiscPerc = 0;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
Labor.TCode = this.GetTCodeFromTaxes(Labor);
|
|
80
|
+
Labor.CGSTAmt = tr_utils_1.TrUtils.FixPriceValue(this.GetTaxAmountFromTaxes(Labor, 'CGST'), DecimalsNumber);
|
|
81
|
+
Labor.SGSTAmt = tr_utils_1.TrUtils.FixPriceValue(this.GetTaxAmountFromTaxes(Labor, 'SGST'), DecimalsNumber);
|
|
82
|
+
Labor.IGSTAmt = tr_utils_1.TrUtils.FixPriceValue(this.GetTaxAmountFromTaxes(Labor, 'IGST'), DecimalsNumber);
|
|
83
|
+
Labor.QtyAndUoM = Labor.Qty.toString();
|
|
84
|
+
Labor.CGSTPerc = this.GetTaxRateFromTaxes(Labor, 'CGST');
|
|
85
|
+
Labor.SGSTPerc = this.GetTaxRateFromTaxes(Labor, 'SGST');
|
|
86
|
+
Labor.IGSTPerc = this.GetTaxRateFromTaxes(Labor, 'IGST');
|
|
87
|
+
Labor.TaxName = this.getTaxName(Labor.TCode, TaxCodes);
|
|
88
|
+
if (LineTotal === 'AT') {
|
|
89
|
+
Labor.LineTotal = tr_utils_1.TrUtils.FixPriceValue(Labor.AfterLaborTax, DecimalsNumber);
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
Labor.LineTotal = tr_utils_1.TrUtils.FixPriceValue((0, math_operations_1.Subtract)(Labor.Amt, Labor.Disc), DecimalsNumber);
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
return LaborList;
|
|
96
|
+
}
|
|
97
|
+
static getTaxName(TCode, TaxCodes) {
|
|
98
|
+
let Index = TaxCodes.findIndex((TaxCode) => {
|
|
99
|
+
return Number(TCode) === TaxCode._id;
|
|
100
|
+
});
|
|
101
|
+
return (Index !== -1) ? TaxCodes[Index].Name : '';
|
|
102
|
+
}
|
|
103
|
+
static GetTaxAmountFromTaxes(item, taxCode) {
|
|
104
|
+
const taxes = Array.isArray(item === null || item === void 0 ? void 0 : item.Taxes) ? item.Taxes : [];
|
|
105
|
+
const matchedTaxes = taxes.filter((tax) => (tax === null || tax === void 0 ? void 0 : tax.Code) === taxCode);
|
|
106
|
+
if (matchedTaxes.length !== 0) {
|
|
107
|
+
return matchedTaxes.reduce((total, tax) => (0, math_operations_1.Add)(total, tax === null || tax === void 0 ? void 0 : tax.Amt), 0);
|
|
108
|
+
}
|
|
109
|
+
return 0;
|
|
110
|
+
}
|
|
111
|
+
static GetTaxRateFromTaxes(item, taxCode) {
|
|
112
|
+
const taxes = Array.isArray(item === null || item === void 0 ? void 0 : item.Taxes) ? item.Taxes : [];
|
|
113
|
+
const matchedTaxes = taxes.filter((tax) => (tax === null || tax === void 0 ? void 0 : tax.Code) === taxCode);
|
|
114
|
+
if (matchedTaxes.length !== 0) {
|
|
115
|
+
return matchedTaxes.reduce((total, tax) => (0, math_operations_1.Add)(total, tax === null || tax === void 0 ? void 0 : tax.Rate), 0);
|
|
116
|
+
}
|
|
117
|
+
return 0;
|
|
118
|
+
}
|
|
119
|
+
static GetTCodeFromTaxes(item) {
|
|
120
|
+
const taxes = Array.isArray(item === null || item === void 0 ? void 0 : item.Taxes) ? item.Taxes : [];
|
|
121
|
+
const matchedTax = taxes.find((tax) => !tr_utils_1.TrUtils.IsNull(tax === null || tax === void 0 ? void 0 : tax.TaxCodeId));
|
|
122
|
+
if (!tr_utils_1.TrUtils.IsNull(matchedTax === null || matchedTax === void 0 ? void 0 : matchedTax.TaxCodeId)) {
|
|
123
|
+
return matchedTax.TaxCodeId;
|
|
124
|
+
}
|
|
125
|
+
return item === null || item === void 0 ? void 0 : item.TCode;
|
|
126
|
+
}
|
|
54
127
|
static GetPrintConditionsBasedOnInput(InvoicePrintData, IncludeGST, ConsolidateGST, SType, OriginalInvoiceData, IsProforma, IsBillTo) {
|
|
55
128
|
InvoicePrintData.For = enums_1.PayTypeEnum.Customer;
|
|
56
129
|
InvoicePrintData.IncludeGST = IncludeGST;
|
|
@@ -102,12 +175,21 @@ class DebitNotePrintService {
|
|
|
102
175
|
else {
|
|
103
176
|
Item.UnPr = tr_utils_1.TrUtils.FixPriceValue(Item.UnPr, DecimalsNumber);
|
|
104
177
|
}
|
|
105
|
-
Item.
|
|
106
|
-
Item.
|
|
107
|
-
Item.
|
|
108
|
-
Item.
|
|
109
|
-
Item.
|
|
110
|
-
Item.
|
|
178
|
+
Item.TCode = this.GetTCodeFromTaxes(Item);
|
|
179
|
+
Item.CGSTAmt = tr_utils_1.TrUtils.FixPriceValue(this.GetTaxAmountFromTaxes(Item, 'CGST'), DecimalsNumber);
|
|
180
|
+
Item.SGSTAmt = tr_utils_1.TrUtils.FixPriceValue(this.GetTaxAmountFromTaxes(Item, 'SGST'), DecimalsNumber);
|
|
181
|
+
Item.IGSTAmt = tr_utils_1.TrUtils.FixPriceValue(this.GetTaxAmountFromTaxes(Item, 'IGST'), DecimalsNumber);
|
|
182
|
+
Item.QtyAndUoM = Item.Qty.toString();
|
|
183
|
+
Item.CGSTPerc = this.GetTaxRateFromTaxes(Item, 'CGST');
|
|
184
|
+
Item.SGSTPerc = this.GetTaxRateFromTaxes(Item, 'SGST');
|
|
185
|
+
Item.IGSTPerc = this.GetTaxRateFromTaxes(Item, 'IGST');
|
|
186
|
+
Item.TaxName = this.getTaxName(Item.TCode, TaxCodes);
|
|
187
|
+
// Item.CGSTAmt = TrUtils.FixPriceValue(Item.CGST, DecimalsNumber);
|
|
188
|
+
// Item.SGSTAmt = TrUtils.FixPriceValue(Item.SGST, DecimalsNumber);
|
|
189
|
+
// Item.IGSTAmt = TrUtils.FixPriceValue(Item.IGST, DecimalsNumber);
|
|
190
|
+
// Item.CGSTPerc = PrintSharedService.GetCGSTValueBasedOnTaxCode(Item.TCode, TaxCodes);
|
|
191
|
+
// Item.SGSTPerc = PrintSharedService.GetSGSTValueBasedOnTaxCode(Item.TCode, TaxCodes);
|
|
192
|
+
// Item.IGSTPerc = PrintSharedService.GetIGSTValueBasedOnTaxCode(Item.TCode, TaxCodes);
|
|
111
193
|
if (LineTotal === 'AT') {
|
|
112
194
|
Item.LineTotal = tr_utils_1.TrUtils.FixPriceValue(Item.AfterPartTax, DecimalsNumber);
|
|
113
195
|
}
|
|
@@ -11,11 +11,11 @@ function GetTableHeader(itemsHeader, taxMode = '') {
|
|
|
11
11
|
: orderedHeaders;
|
|
12
12
|
const toHeaderObject = (item) => {
|
|
13
13
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
14
|
-
const itemTitle = (_c = (_b = (_a = item === null || item === void 0 ? void 0 : item.title) !== null && _a !== void 0 ? _a : item === null || item === void 0 ? void 0 : item.CustTitle) !== null && _b !== void 0 ? _b : item === null || item === void 0 ? void 0 : item.
|
|
14
|
+
const itemTitle = (_c = (_b = (_a = item === null || item === void 0 ? void 0 : item.title) !== null && _a !== void 0 ? _a : item === null || item === void 0 ? void 0 : item.CustTitle) !== null && _b !== void 0 ? _b : item === null || item === void 0 ? void 0 : item.Title) !== null && _c !== void 0 ? _c : '';
|
|
15
15
|
const itemWidth = (_d = item === null || item === void 0 ? void 0 : item.width) !== null && _d !== void 0 ? _d : item === null || item === void 0 ? void 0 : item.Width;
|
|
16
16
|
const itemDbFields = (_f = (_e = item === null || item === void 0 ? void 0 : item.dbFields) !== null && _e !== void 0 ? _e : item === null || item === void 0 ? void 0 : item.DBFields) !== null && _f !== void 0 ? _f : [];
|
|
17
17
|
const stackSource = (_g = item === null || item === void 0 ? void 0 : item.stackFields) !== null && _g !== void 0 ? _g : item === null || item === void 0 ? void 0 : item.Stacked;
|
|
18
|
-
const stackTitle = (_j = (_h = stackSource === null || stackSource === void 0 ? void 0 : stackSource.title) !== null && _h !== void 0 ? _h : stackSource === null || stackSource === void 0 ? void 0 : stackSource.
|
|
18
|
+
const stackTitle = (_j = (_h = stackSource === null || stackSource === void 0 ? void 0 : stackSource.title) !== null && _h !== void 0 ? _h : stackSource === null || stackSource === void 0 ? void 0 : stackSource.Title) !== null && _j !== void 0 ? _j : null;
|
|
19
19
|
const stackSeq = (_k = stackSource === null || stackSource === void 0 ? void 0 : stackSource.seq) !== null && _k !== void 0 ? _k : stackSource === null || stackSource === void 0 ? void 0 : stackSource.Seq;
|
|
20
20
|
return {
|
|
21
21
|
text: itemTitle,
|
|
@@ -33,11 +33,11 @@ function GetTableHeader(itemsHeader, taxMode = '') {
|
|
|
33
33
|
.filter((item) => { var _a; return !((_a = item === null || item === void 0 ? void 0 : item.stackFields) !== null && _a !== void 0 ? _a : item === null || item === void 0 ? void 0 : item.Stacked); })
|
|
34
34
|
.map((item) => {
|
|
35
35
|
var _a, _b;
|
|
36
|
-
const parentTitle = (_b = (_a = item === null || item === void 0 ? void 0 : item.title) !== null && _a !== void 0 ? _a : item === null || item === void 0 ? void 0 : item.CustTitle) !== null && _b !== void 0 ? _b : item === null || item === void 0 ? void 0 : item.
|
|
36
|
+
const parentTitle = (_b = (_a = item === null || item === void 0 ? void 0 : item.title) !== null && _a !== void 0 ? _a : item === null || item === void 0 ? void 0 : item.CustTitle) !== null && _b !== void 0 ? _b : item === null || item === void 0 ? void 0 : item.Title;
|
|
37
37
|
const stackFields = visibleHeaders
|
|
38
38
|
.filter((stackedItem) => {
|
|
39
39
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
40
|
-
const stackedParent = (_f = (_d = (_b = (_a = stackedItem === null || stackedItem === void 0 ? void 0 : stackedItem.stackFields) === null || _a === void 0 ? void 0 : _a.title) !== null && _b !== void 0 ? _b : (_c = stackedItem === null || stackedItem === void 0 ? void 0 : stackedItem.stackFields) === null || _c === void 0 ? void 0 : _c.
|
|
40
|
+
const stackedParent = (_f = (_d = (_b = (_a = stackedItem === null || stackedItem === void 0 ? void 0 : stackedItem.stackFields) === null || _a === void 0 ? void 0 : _a.title) !== null && _b !== void 0 ? _b : (_c = stackedItem === null || stackedItem === void 0 ? void 0 : stackedItem.stackFields) === null || _c === void 0 ? void 0 : _c.Title) !== null && _d !== void 0 ? _d : (_e = stackedItem === null || stackedItem === void 0 ? void 0 : stackedItem.Stacked) === null || _e === void 0 ? void 0 : _e.title) !== null && _f !== void 0 ? _f : (_g = stackedItem === null || stackedItem === void 0 ? void 0 : stackedItem.Stacked) === null || _g === void 0 ? void 0 : _g.Title;
|
|
41
41
|
return stackedParent === parentTitle;
|
|
42
42
|
})
|
|
43
43
|
.sort((a, b) => {
|
|
@@ -273,7 +273,7 @@ function getSingleTaxHeaderText(header) {
|
|
|
273
273
|
}
|
|
274
274
|
function isTaxHeaderConfig(header) {
|
|
275
275
|
var _a, _b, _c, _d;
|
|
276
|
-
const title = (_d = (_c = (_b = (_a = header === null || header === void 0 ? void 0 : header.Title) !== null && _a !== void 0 ? _a : header === null || header === void 0 ? void 0 : header.
|
|
276
|
+
const title = (_d = (_c = (_b = (_a = header === null || header === void 0 ? void 0 : header.Title) !== null && _a !== void 0 ? _a : header === null || header === void 0 ? void 0 : header.Title) !== null && _b !== void 0 ? _b : header === null || header === void 0 ? void 0 : header.CustTitle) !== null && _c !== void 0 ? _c : header === null || header === void 0 ? void 0 : header.Title) !== null && _d !== void 0 ? _d : header === null || header === void 0 ? void 0 : header.text;
|
|
277
277
|
const normalizedTitle = normalizeHeaderText(title);
|
|
278
278
|
return normalizedTitle === 'TAX%' || normalizedTitle === 'TAXAMOUNT';
|
|
279
279
|
}
|
|
@@ -375,7 +375,7 @@ function normalizeTableConfig(tableConfig, pdfInvoiceData) {
|
|
|
375
375
|
}
|
|
376
376
|
function isDiscountColumnConfig(column) {
|
|
377
377
|
var _a, _b, _c;
|
|
378
|
-
const title = String((_c = (_b = (_a = column === null || column === void 0 ? void 0 : column.title) !== null && _a !== void 0 ? _a : column === null || column === void 0 ? void 0 : column.CustTitle) !== null && _b !== void 0 ? _b : column === null || column === void 0 ? void 0 : column.
|
|
378
|
+
const title = String((_c = (_b = (_a = column === null || column === void 0 ? void 0 : column.title) !== null && _a !== void 0 ? _a : column === null || column === void 0 ? void 0 : column.CustTitle) !== null && _b !== void 0 ? _b : column === null || column === void 0 ? void 0 : column.Title) !== null && _c !== void 0 ? _c : '').trim();
|
|
379
379
|
return title === 'Disc %' || title === 'Disc Amount' || title === 'Adisc Amount';
|
|
380
380
|
}
|
|
381
381
|
function buildSectionRows({ rows, columnsOrHeaders, descriptionColumnIndex, label, buildRow, buildTotalRow, showSectionSummaryRows }) {
|
|
@@ -2,5 +2,6 @@ export declare function GetInvoicePDF(invoiceData: any, entityData: any, headerC
|
|
|
2
2
|
export declare function GetSalesOrderPDF(salesOrderData: any, entityData: any, headerConfig: any, printConfig: any, taxCodes: any, image?: any, numberofCopies?: string[], options?: any): any;
|
|
3
3
|
export declare function GetDeliveryChallanPDF(deliveryChallanData: any, entityData: any, headerConfig: any, printConfig: any, taxCodes: any, image?: any, numberofCopies?: string[], options?: any): any;
|
|
4
4
|
export declare function GetCreditNotePDF(creditNoteData: any, entityData: any, headerConfig: any, printConfig: any, taxCodes: any, image?: any, numberofCopies?: string[], options?: any): any;
|
|
5
|
+
export declare function GetDebitNotePDF(debitNoteData: any, entityData: any, headerConfig: any, printConfig: any, taxCodes: any, image?: any, numberofCopies?: string[], options?: any): any;
|
|
5
6
|
export declare function GetSalesReceiptPDF(salesReceiptData: any, entityData: any, headerConfig: any, printConfig: any, taxCodes: any, image?: any, numberofCopies?: string[], withPass?: boolean, options?: any): any;
|
|
6
7
|
export declare function GetBillPDF(billData: any, entityData: any, headerConfig: any, printConfig: any, taxCodes: any, image?: any): any;
|
|
@@ -4,6 +4,7 @@ exports.GetInvoicePDF = GetInvoicePDF;
|
|
|
4
4
|
exports.GetSalesOrderPDF = GetSalesOrderPDF;
|
|
5
5
|
exports.GetDeliveryChallanPDF = GetDeliveryChallanPDF;
|
|
6
6
|
exports.GetCreditNotePDF = GetCreditNotePDF;
|
|
7
|
+
exports.GetDebitNotePDF = GetDebitNotePDF;
|
|
7
8
|
exports.GetSalesReceiptPDF = GetSalesReceiptPDF;
|
|
8
9
|
exports.GetBillPDF = GetBillPDF;
|
|
9
10
|
const purchase_order_print_service_1 = require("../purchases/purchase-order/purchase-order-print.service");
|
|
@@ -20,6 +21,7 @@ const credit_note_pdf_service_1 = require("../accounting/credit-note/credit-note
|
|
|
20
21
|
const inv_print_service_1 = require("../accounting/invoice/inv-print.service");
|
|
21
22
|
const invoice_pdf_service_1 = require("../accounting/invoice/invoice-pdf/invoice-pdf.service");
|
|
22
23
|
const unified_invoice_pdf_service_1 = require("../accounting/invoice/unified-invoice-pdf.service");
|
|
24
|
+
const debit_note_print_service_1 = require("../accounting/debit-note/debit-note-print.service");
|
|
23
25
|
function GetInvoicePDF(invoiceData, entityData, headerConfig, printConfig, taxCodes, image = null, numberofCopies = ['Original'], withPass = false, options = null) {
|
|
24
26
|
var _a;
|
|
25
27
|
if (!options) {
|
|
@@ -133,6 +135,32 @@ function GetCreditNotePDF(creditNoteData, entityData, headerConfig, printConfig,
|
|
|
133
135
|
}
|
|
134
136
|
return cnPrint;
|
|
135
137
|
}
|
|
138
|
+
function GetDebitNotePDF(debitNoteData, entityData, headerConfig, printConfig, taxCodes, image = null, numberofCopies = ['Original'], options = null) {
|
|
139
|
+
var _a;
|
|
140
|
+
if (!options) {
|
|
141
|
+
options = {
|
|
142
|
+
ShowGST: (((_a = debitNoteData === null || debitNoteData === void 0 ? void 0 : debitNoteData.Settings) === null || _a === void 0 ? void 0 : _a.Tax) === 'TI') ? true : false,
|
|
143
|
+
ConsolidateGST: false,
|
|
144
|
+
Size: 'full',
|
|
145
|
+
MoreDiscDetails: false,
|
|
146
|
+
Orientation: 'portrait'
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
const printConfigData = tr_utils_1.TrUtils.ConcatObjects(tr_utils_1.TrUtils.Stringify(headerConfig), tr_utils_1.TrUtils.Stringify(printConfig));
|
|
150
|
+
const debitNotePrintData = debit_note_print_service_1.DebitNotePrintService.GetDebitNotePrintInfo(debitNoteData, entityData, image, true, false, taxCodes, false, true);
|
|
151
|
+
let dnPrint;
|
|
152
|
+
if (options.ConsolidateGST) {
|
|
153
|
+
dnPrint = debit_note_print_service_1.DebitNotePrintService.GetDebitNotePrintInfo(debitNotePrintData, entityData, image, true, true, taxCodes, false, true);
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
debitNotePrintData.Round = tr_utils_1.TrUtils.FixedTo(debitNoteData.Round);
|
|
157
|
+
debitNotePrintData.Total = tr_utils_1.TrUtils.FixedTo(debitNoteData.Total);
|
|
158
|
+
debitNotePrintData.SubToal = tr_utils_1.TrUtils.FixedTo(debitNoteData.SubToal);
|
|
159
|
+
debitNotePrintData.TaxTotal = tr_utils_1.TrUtils.FixedTo(debitNoteData.TaxTotal);
|
|
160
|
+
dnPrint = (0, invoice_pdf_service_1.CreateInvoicePDFService)(debitNotePrintData, printConfigData, numberofCopies);
|
|
161
|
+
}
|
|
162
|
+
return dnPrint;
|
|
163
|
+
}
|
|
136
164
|
function GetSalesReceiptPDF(salesReceiptData, entityData, headerConfig, printConfig, taxCodes, image = null, numberofCopies = ['Original'], withPass = false, options = null) {
|
|
137
165
|
var _a;
|
|
138
166
|
if (!options) {
|
|
@@ -498,7 +498,7 @@ function ComputeTaxSummary(input) {
|
|
|
498
498
|
* // }
|
|
499
499
|
*/
|
|
500
500
|
function ComputeDocumentTotals(input) {
|
|
501
|
-
const { Lines, Rounding, RegimeCode } = input;
|
|
501
|
+
const { Lines, Rounding, RegimeCode, Adjust } = input;
|
|
502
502
|
// 1. SubTotal = sum of gross line values before discounts/tax
|
|
503
503
|
let subTotal = 0;
|
|
504
504
|
let discount = 0;
|
|
@@ -517,7 +517,7 @@ function ComputeDocumentTotals(input) {
|
|
|
517
517
|
// 3. TaxTotal from the (potentially rounded) summary
|
|
518
518
|
const taxTotal = taxSummary.TotalTax;
|
|
519
519
|
// 4. GrandTotal before doc-level rounding
|
|
520
|
-
const grandTotal = (0, math_operations_1.Add)(taxableAmount, taxTotal);
|
|
520
|
+
const grandTotal = (0, math_operations_1.Add)(taxableAmount, taxTotal, Adjust !== null && Adjust !== void 0 ? Adjust : 0);
|
|
521
521
|
// 5. DocTotal rounding
|
|
522
522
|
let roundedTotal = grandTotal;
|
|
523
523
|
let roundAdj = 0;
|
package/dist/tax/tax.types.d.ts
CHANGED
|
@@ -323,6 +323,8 @@ export interface IDocumentTotalsInput {
|
|
|
323
323
|
Rounding: IRoundingConfig;
|
|
324
324
|
/** Tax regime code for the TaxSummary snapshot */
|
|
325
325
|
RegimeCode?: string;
|
|
326
|
+
/** Optional adjustment to grand total before rounding (e.g., for round-off entries) */
|
|
327
|
+
Adjust?: number;
|
|
326
328
|
}
|
|
327
329
|
/** Result of full document totals computation */
|
|
328
330
|
export interface IDocumentTotals {
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@ import { ROTypeEnum } from '../../enums/code-enums';
|
|
|
6
6
|
import { TrUtils } from '../../utils/tr-utils';
|
|
7
7
|
import { InvoiceStatusEnum, PayTypeEnum } from '../../enums/enums';
|
|
8
8
|
import { MyDate } from '../../utils/my-date';
|
|
9
|
-
import { Add, Divide, Subtract } from '../../shared/math-operations';
|
|
9
|
+
import { Add, Divide, Multiply, Subtract } from '../../shared/math-operations';
|
|
10
10
|
|
|
11
11
|
export class DebitNotePrintService {
|
|
12
12
|
|
|
@@ -47,8 +47,8 @@ export class DebitNotePrintService {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
InvoicePrintData = TrUtils.ConcatObjects(InvoicePrintData, finalTotalsData);
|
|
50
|
-
|
|
51
|
-
InvoicePrintData.Items = this.GetItemsPrintInfo(InvoicePrintData.Items, ConsolidateGST, TaxCodes,OriginalEntityData.Entity.Settings?.Acc?.LTot, InvoicePrintData.Entity?.DecimalsNumber);
|
|
50
|
+
InvoicePrintData.Ops = this.GetLaborPrintInfo(InvoicePrintData.Services, ConsolidateGST, TaxCodes, OriginalEntityData.Entity.Settings?.Acc?.LTot, InvoicePrintData.Entity.DecimalsNumber);
|
|
51
|
+
InvoicePrintData.Items = this.GetItemsPrintInfo(InvoicePrintData.Items, ConsolidateGST, TaxCodes, OriginalEntityData.Entity.Settings?.Acc?.LTot, InvoicePrintData.Entity?.DecimalsNumber);
|
|
52
52
|
|
|
53
53
|
argInvoiceData = this.ReverseItemsForInvoicePrint(argInvoiceData);
|
|
54
54
|
|
|
@@ -57,8 +57,8 @@ export class DebitNotePrintService {
|
|
|
57
57
|
InvoicePrintData = this.GetFormattedProductDataForPrint(argInvoiceData, InvoicePrintData);
|
|
58
58
|
|
|
59
59
|
InvoicePrintData = this.GetBillNameForInvoicePrint(argInvoiceData, InvoicePrintData, IsCustBillTo);
|
|
60
|
-
if(TrUtils.IsNull(argInvoiceData.Payments)){
|
|
61
|
-
argInvoiceData.Payments=[];
|
|
60
|
+
if (TrUtils.IsNull(argInvoiceData.Payments)) {
|
|
61
|
+
argInvoiceData.Payments = [];
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
let PaymentData = this.GetPaymentsTotal(argInvoiceData.Payments, InvoicePrintData.Total, argInvoiceData.Sts, InvoicePrintData.Entity?.DecimalsNumber);
|
|
@@ -74,6 +74,83 @@ export class DebitNotePrintService {
|
|
|
74
74
|
return InvoicePrintData;
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
static GetLaborPrintInfo(LaborList: any, Consolidate: boolean, TaxCodes: any, LineTotal: string, DecimalsNumber: number) {
|
|
81
|
+
LaborList.forEach((Labor: any) => {
|
|
82
|
+
Labor.HSN = Labor.SAC;
|
|
83
|
+
if (TrUtils.IsNull(Labor.Qty)) {
|
|
84
|
+
Labor.Qty = 1;
|
|
85
|
+
}
|
|
86
|
+
if (Consolidate) {
|
|
87
|
+
Labor.UnPr = TrUtils.FixedTo(Labor.AfterLaborTax, DecimalsNumber);
|
|
88
|
+
} else {
|
|
89
|
+
Labor.UnPr = TrUtils.FixPriceValue(Labor.Pr, DecimalsNumber);
|
|
90
|
+
}
|
|
91
|
+
if (!TrUtils.IsEmpty(Labor.Perc)) {
|
|
92
|
+
Labor.DiscPerc = Labor.Perc;
|
|
93
|
+
} else {
|
|
94
|
+
Labor.DiscPerc = Labor.Perc;
|
|
95
|
+
if (!TrUtils.IsZero(Number(Labor.UnPr))) {
|
|
96
|
+
Labor.DiscPerc = Divide(Multiply(100, Labor.Disc), Labor.UnPr);
|
|
97
|
+
} else {
|
|
98
|
+
Labor.DiscPerc = 0;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
Labor.TCode = this.GetTCodeFromTaxes(Labor);
|
|
102
|
+
Labor.CGSTAmt = TrUtils.FixPriceValue(this.GetTaxAmountFromTaxes(Labor, 'CGST'), DecimalsNumber);
|
|
103
|
+
Labor.SGSTAmt = TrUtils.FixPriceValue(this.GetTaxAmountFromTaxes(Labor, 'SGST'), DecimalsNumber);
|
|
104
|
+
Labor.IGSTAmt = TrUtils.FixPriceValue(this.GetTaxAmountFromTaxes(Labor, 'IGST'), DecimalsNumber);
|
|
105
|
+
Labor.QtyAndUoM = Labor.Qty.toString();
|
|
106
|
+
Labor.CGSTPerc = this.GetTaxRateFromTaxes(Labor, 'CGST');
|
|
107
|
+
Labor.SGSTPerc = this.GetTaxRateFromTaxes(Labor, 'SGST');
|
|
108
|
+
Labor.IGSTPerc = this.GetTaxRateFromTaxes(Labor, 'IGST');
|
|
109
|
+
Labor.TaxName = this.getTaxName(Labor.TCode, TaxCodes);
|
|
110
|
+
if (LineTotal === 'AT') {
|
|
111
|
+
Labor.LineTotal = TrUtils.FixPriceValue(Labor.AfterLaborTax, DecimalsNumber);
|
|
112
|
+
} else {
|
|
113
|
+
Labor.LineTotal = TrUtils.FixPriceValue(Subtract(Labor.Amt, Labor.Disc), DecimalsNumber);
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
return LaborList;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
static getTaxName(TCode: any, TaxCodes: any) {
|
|
120
|
+
let Index: any = TaxCodes.findIndex((TaxCode: any) => {
|
|
121
|
+
return Number(TCode) === TaxCode._id;
|
|
122
|
+
});
|
|
123
|
+
return (Index !== -1) ? TaxCodes[Index].Name : '';
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
static GetTaxAmountFromTaxes(item: any, taxCode: string) {
|
|
127
|
+
const taxes = Array.isArray(item?.Taxes) ? item.Taxes : [];
|
|
128
|
+
const matchedTaxes = taxes.filter((tax: any) => tax?.Code === taxCode);
|
|
129
|
+
if (matchedTaxes.length !== 0) {
|
|
130
|
+
return matchedTaxes.reduce((total: number, tax: any) => Add(total, tax?.Amt), 0);
|
|
131
|
+
}
|
|
132
|
+
return 0;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
static GetTaxRateFromTaxes(item: any, taxCode: string) {
|
|
137
|
+
const taxes = Array.isArray(item?.Taxes) ? item.Taxes : [];
|
|
138
|
+
const matchedTaxes = taxes.filter((tax: any) => tax?.Code === taxCode);
|
|
139
|
+
if (matchedTaxes.length !== 0) {
|
|
140
|
+
return matchedTaxes.reduce((total: number, tax: any) => Add(total, tax?.Rate), 0);
|
|
141
|
+
}
|
|
142
|
+
return 0;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
static GetTCodeFromTaxes(item: any) {
|
|
146
|
+
const taxes = Array.isArray(item?.Taxes) ? item.Taxes : [];
|
|
147
|
+
const matchedTax = taxes.find((tax: any) => !TrUtils.IsNull(tax?.TaxCodeId));
|
|
148
|
+
if (!TrUtils.IsNull(matchedTax?.TaxCodeId)) {
|
|
149
|
+
return matchedTax.TaxCodeId;
|
|
150
|
+
}
|
|
151
|
+
return item?.TCode;
|
|
152
|
+
}
|
|
153
|
+
|
|
77
154
|
static GetPrintConditionsBasedOnInput(InvoicePrintData: any, IncludeGST: boolean, ConsolidateGST: boolean,
|
|
78
155
|
SType: any, OriginalInvoiceData: any, IsProforma: boolean, IsBillTo: boolean) {
|
|
79
156
|
InvoicePrintData.For = PayTypeEnum.Customer;
|
|
@@ -122,23 +199,32 @@ export class DebitNotePrintService {
|
|
|
122
199
|
return InvoicePrintData;
|
|
123
200
|
}
|
|
124
201
|
|
|
125
|
-
static GetItemsPrintInfo(Items: any, Consolidate: boolean, TaxCodes: any, LineTotal:string, DecimalsNumber: number) {
|
|
202
|
+
static GetItemsPrintInfo(Items: any, Consolidate: boolean, TaxCodes: any, LineTotal: string, DecimalsNumber: number) {
|
|
126
203
|
Items.forEach((Item: any) => {
|
|
127
204
|
if (Consolidate) {
|
|
128
205
|
let AfterDiscForEach = Divide(Item.AfterPartDisc, Item.Qty);
|
|
129
|
-
let CTaxAmtPerItem = Divide(Item.CGST
|
|
130
|
-
let STaxAmtPerItem = Divide(Item.SGST
|
|
131
|
-
let ITaxAmtPerItem = Divide(Item.IGST
|
|
132
|
-
Item.UnPr = TrUtils.FixedTo(Add(AfterDiscForEach
|
|
133
|
-
}else{
|
|
206
|
+
let CTaxAmtPerItem = Divide(Item.CGST, Item.Qty);
|
|
207
|
+
let STaxAmtPerItem = Divide(Item.SGST, Item.Qty);
|
|
208
|
+
let ITaxAmtPerItem = Divide(Item.IGST, Item.Qty);
|
|
209
|
+
Item.UnPr = TrUtils.FixedTo(Add(AfterDiscForEach, CTaxAmtPerItem, STaxAmtPerItem, ITaxAmtPerItem), DecimalsNumber);
|
|
210
|
+
} else {
|
|
134
211
|
Item.UnPr = TrUtils.FixPriceValue(Item.UnPr, DecimalsNumber);
|
|
135
212
|
}
|
|
136
|
-
Item.
|
|
137
|
-
Item.
|
|
138
|
-
Item.
|
|
139
|
-
Item.
|
|
140
|
-
Item.
|
|
141
|
-
Item.
|
|
213
|
+
Item.TCode = this.GetTCodeFromTaxes(Item);
|
|
214
|
+
Item.CGSTAmt = TrUtils.FixPriceValue(this.GetTaxAmountFromTaxes(Item, 'CGST'), DecimalsNumber);
|
|
215
|
+
Item.SGSTAmt = TrUtils.FixPriceValue(this.GetTaxAmountFromTaxes(Item, 'SGST'), DecimalsNumber);
|
|
216
|
+
Item.IGSTAmt = TrUtils.FixPriceValue(this.GetTaxAmountFromTaxes(Item, 'IGST'), DecimalsNumber);
|
|
217
|
+
Item.QtyAndUoM = Item.Qty.toString();
|
|
218
|
+
Item.CGSTPerc = this.GetTaxRateFromTaxes(Item, 'CGST');
|
|
219
|
+
Item.SGSTPerc = this.GetTaxRateFromTaxes(Item, 'SGST');
|
|
220
|
+
Item.IGSTPerc = this.GetTaxRateFromTaxes(Item, 'IGST');
|
|
221
|
+
Item.TaxName = this.getTaxName(Item.TCode, TaxCodes);
|
|
222
|
+
// Item.CGSTAmt = TrUtils.FixPriceValue(Item.CGST, DecimalsNumber);
|
|
223
|
+
// Item.SGSTAmt = TrUtils.FixPriceValue(Item.SGST, DecimalsNumber);
|
|
224
|
+
// Item.IGSTAmt = TrUtils.FixPriceValue(Item.IGST, DecimalsNumber);
|
|
225
|
+
// Item.CGSTPerc = PrintSharedService.GetCGSTValueBasedOnTaxCode(Item.TCode, TaxCodes);
|
|
226
|
+
// Item.SGSTPerc = PrintSharedService.GetSGSTValueBasedOnTaxCode(Item.TCode, TaxCodes);
|
|
227
|
+
// Item.IGSTPerc = PrintSharedService.GetIGSTValueBasedOnTaxCode(Item.TCode, TaxCodes);
|
|
142
228
|
if (LineTotal === 'AT') {
|
|
143
229
|
Item.LineTotal = TrUtils.FixPriceValue(Item.AfterPartTax, DecimalsNumber);
|
|
144
230
|
} else {
|
|
@@ -7,11 +7,11 @@ export function GetTableHeader(itemsHeader: any[], taxMode: string = '') {
|
|
|
7
7
|
: orderedHeaders;
|
|
8
8
|
|
|
9
9
|
const toHeaderObject = (item: any) => {
|
|
10
|
-
const itemTitle = item?.title ?? item?.CustTitle ?? item?.
|
|
10
|
+
const itemTitle = item?.title ?? item?.CustTitle ?? item?.Title ?? '';
|
|
11
11
|
const itemWidth = item?.width ?? item?.Width;
|
|
12
12
|
const itemDbFields = item?.dbFields ?? item?.DBFields ?? [];
|
|
13
13
|
const stackSource = item?.stackFields ?? item?.Stacked;
|
|
14
|
-
const stackTitle = stackSource?.title ?? stackSource?.
|
|
14
|
+
const stackTitle = stackSource?.title ?? stackSource?.Title ?? null;
|
|
15
15
|
const stackSeq = stackSource?.seq ?? stackSource?.Seq;
|
|
16
16
|
return {
|
|
17
17
|
text: itemTitle,
|
|
@@ -30,13 +30,13 @@ export function GetTableHeader(itemsHeader: any[], taxMode: string = '') {
|
|
|
30
30
|
const headerRow = visibleHeaders
|
|
31
31
|
.filter((item: any) => !(item?.stackFields ?? item?.Stacked))
|
|
32
32
|
.map((item: any) => {
|
|
33
|
-
const parentTitle = item?.title ?? item?.CustTitle ?? item?.
|
|
33
|
+
const parentTitle = item?.title ?? item?.CustTitle ?? item?.Title;
|
|
34
34
|
const stackFields = visibleHeaders
|
|
35
35
|
.filter((stackedItem: any) => {
|
|
36
36
|
const stackedParent = stackedItem?.stackFields?.title
|
|
37
|
-
?? stackedItem?.stackFields?.
|
|
37
|
+
?? stackedItem?.stackFields?.Title
|
|
38
38
|
?? stackedItem?.Stacked?.title
|
|
39
|
-
?? stackedItem?.Stacked?.
|
|
39
|
+
?? stackedItem?.Stacked?.Title;
|
|
40
40
|
return stackedParent === parentTitle;
|
|
41
41
|
})
|
|
42
42
|
.sort((a: any, b: any) => {
|
|
@@ -345,7 +345,7 @@ function getSingleTaxHeaderText(header: any) {
|
|
|
345
345
|
}
|
|
346
346
|
|
|
347
347
|
function isTaxHeaderConfig(header: any) {
|
|
348
|
-
const title = header?.Title ?? header?.
|
|
348
|
+
const title = header?.Title ?? header?.Title ?? header?.CustTitle ?? header?.Title ?? header?.text;
|
|
349
349
|
const normalizedTitle = normalizeHeaderText(title);
|
|
350
350
|
return normalizedTitle === 'TAX%' || normalizedTitle === 'TAXAMOUNT';
|
|
351
351
|
}
|
|
@@ -275,14 +275,14 @@ function buildSectionTotalRow(columns: any[], label: string, totals: any, fixedT
|
|
|
275
275
|
if (column.dbField === 'SGST' && column.taxKind === 'amount') {
|
|
276
276
|
return buildTotalValueCell(formatAmount(totals.sgstAmount, fixedTo));
|
|
277
277
|
}
|
|
278
|
-
if (column.dbField === 'IGST' && column.taxKind === 'amount') {
|
|
279
|
-
return buildTotalValueCell(formatAmount(totals.igstAmount, fixedTo));
|
|
280
|
-
}
|
|
281
|
-
if (column.dbField === 'GST' && column.taxKind === 'amount') {
|
|
282
|
-
return buildTotalValueCell(formatAmount(totals.cgstAmount + totals.sgstAmount + totals.igstAmount, fixedTo));
|
|
283
|
-
}
|
|
284
|
-
return buildTotalValueCell('');
|
|
285
|
-
}
|
|
278
|
+
if (column.dbField === 'IGST' && column.taxKind === 'amount') {
|
|
279
|
+
return buildTotalValueCell(formatAmount(totals.igstAmount, fixedTo));
|
|
280
|
+
}
|
|
281
|
+
if (column.dbField === 'GST' && column.taxKind === 'amount') {
|
|
282
|
+
return buildTotalValueCell(formatAmount(totals.cgstAmount + totals.sgstAmount + totals.igstAmount, fixedTo));
|
|
283
|
+
}
|
|
284
|
+
return buildTotalValueCell('');
|
|
285
|
+
}
|
|
286
286
|
|
|
287
287
|
const headerText = column.header?.text ?? '';
|
|
288
288
|
if (headerText === 'Description') {
|
|
@@ -407,7 +407,7 @@ function normalizeTableConfig(tableConfig: any[], pdfInvoiceData: any) {
|
|
|
407
407
|
}
|
|
408
408
|
|
|
409
409
|
function isDiscountColumnConfig(column: any) {
|
|
410
|
-
const title = String(column?.title ?? column?.CustTitle ?? column?.
|
|
410
|
+
const title = String(column?.title ?? column?.CustTitle ?? column?.Title ?? '').trim();
|
|
411
411
|
return title === 'Disc %' || title === 'Disc Amount' || title === 'Adisc Amount';
|
|
412
412
|
}
|
|
413
413
|
|
|
@@ -455,24 +455,24 @@ function shouldNegateFallbackHeaderValue(item: any, headerText: string) {
|
|
|
455
455
|
function shouldSkipFixedTo(header: any) {
|
|
456
456
|
const text = String(header?.text ?? '').trim().toUpperCase();
|
|
457
457
|
const normalizedText = text.replace(/\s+/g, '');
|
|
458
|
-
if (text === 'HSN/SAC' || text === 'BN' || text === 'BNO' || text.includes('%') || normalizedText === 'QTY' || normalizedText === 'OFFERQTY' || normalizedText === 'OFQTY' || normalizedText === 'MPN') {
|
|
459
|
-
return true;
|
|
460
|
-
}
|
|
458
|
+
if (text === 'HSN/SAC' || text === 'BN' || text === 'BNO' || text.includes('%') || normalizedText === 'QTY' || normalizedText === 'OFFERQTY' || normalizedText === 'OFQTY' || normalizedText === 'MPN') {
|
|
459
|
+
return true;
|
|
460
|
+
}
|
|
461
461
|
|
|
462
462
|
const dbFields = Array.isArray(header?.dbFields) ? header.dbFields : [];
|
|
463
463
|
return dbFields.some((field: any) => {
|
|
464
464
|
const normalized = String(field ?? '').trim().toUpperCase();
|
|
465
465
|
return normalized === 'BN'
|
|
466
|
-
|| normalized === 'BNO'
|
|
467
|
-
|| normalized === 'QTY'
|
|
468
|
-
|| normalized === 'OFQTY'
|
|
469
|
-
|| normalized === 'MPN'
|
|
470
|
-
|| normalized.endsWith('.BN')
|
|
471
|
-
|| normalized.endsWith('.QTY')
|
|
472
|
-
|| normalized.endsWith('.OFQTY')
|
|
473
|
-
|| normalized.endsWith('.MPN')
|
|
474
|
-
|| normalized.endsWith('PERC')
|
|
475
|
-
|| normalized.endsWith('.PERC');
|
|
466
|
+
|| normalized === 'BNO'
|
|
467
|
+
|| normalized === 'QTY'
|
|
468
|
+
|| normalized === 'OFQTY'
|
|
469
|
+
|| normalized === 'MPN'
|
|
470
|
+
|| normalized.endsWith('.BN')
|
|
471
|
+
|| normalized.endsWith('.QTY')
|
|
472
|
+
|| normalized.endsWith('.OFQTY')
|
|
473
|
+
|| normalized.endsWith('.MPN')
|
|
474
|
+
|| normalized.endsWith('PERC')
|
|
475
|
+
|| normalized.endsWith('.PERC');
|
|
476
476
|
});
|
|
477
477
|
}
|
|
478
478
|
|
|
@@ -14,6 +14,7 @@ import { CreditNotePdfService } from "../accounting/credit-note/credit-note-pdf.
|
|
|
14
14
|
import { GetInvoicePrintInfo } from "../accounting/invoice/inv-print.service";
|
|
15
15
|
import { CreateInvoicePDFService } from "../accounting/invoice/invoice-pdf/invoice-pdf.service";
|
|
16
16
|
import { GetInvoicePrint } from "../accounting/invoice/unified-invoice-pdf.service";
|
|
17
|
+
import { DebitNotePrintService } from "../accounting/debit-note/debit-note-print.service";
|
|
17
18
|
|
|
18
19
|
export function GetInvoicePDF(invoiceData: any, entityData: any, headerConfig: any, printConfig: any, taxCodes: any, image: any = null, numberofCopies: string[] = ['Original'], withPass: boolean = false, options: any = null) {
|
|
19
20
|
if (!options) {
|
|
@@ -146,6 +147,37 @@ export function GetCreditNotePDF(creditNoteData: any, entityData: any, headerCon
|
|
|
146
147
|
return cnPrint;
|
|
147
148
|
}
|
|
148
149
|
|
|
150
|
+
export function GetDebitNotePDF(debitNoteData: any, entityData: any, headerConfig: any, printConfig: any, taxCodes: any, image: any = null, numberofCopies: string[] = ['Original'], options: any = null) {
|
|
151
|
+
if (!options) {
|
|
152
|
+
options = {
|
|
153
|
+
ShowGST: (debitNoteData?.Settings?.Tax === 'TI') ? true : false,
|
|
154
|
+
ConsolidateGST: false,
|
|
155
|
+
Size: 'full',
|
|
156
|
+
MoreDiscDetails: false,
|
|
157
|
+
Orientation: 'portrait'
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
const printConfigData: any = TrUtils.ConcatObjects(
|
|
161
|
+
TrUtils.Stringify(headerConfig),
|
|
162
|
+
TrUtils.Stringify(printConfig)
|
|
163
|
+
);
|
|
164
|
+
const debitNotePrintData: any = DebitNotePrintService.GetDebitNotePrintInfo(debitNoteData, entityData, image,
|
|
165
|
+
true, false, taxCodes, false, true);
|
|
166
|
+
let dnPrint: any;
|
|
167
|
+
if (options.ConsolidateGST) {
|
|
168
|
+
dnPrint = DebitNotePrintService.GetDebitNotePrintInfo(debitNotePrintData,entityData, image,true, true, taxCodes, false, true);
|
|
169
|
+
} else {
|
|
170
|
+
debitNotePrintData.Round = TrUtils.FixedTo(debitNoteData.Round);
|
|
171
|
+
debitNotePrintData.Total = TrUtils.FixedTo(debitNoteData.Total);
|
|
172
|
+
debitNotePrintData.SubToal = TrUtils.FixedTo(debitNoteData.SubToal);
|
|
173
|
+
debitNotePrintData.TaxTotal = TrUtils.FixedTo(debitNoteData.TaxTotal);
|
|
174
|
+
dnPrint = CreateInvoicePDFService(debitNotePrintData, printConfigData, numberofCopies);
|
|
175
|
+
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
return dnPrint;
|
|
179
|
+
}
|
|
180
|
+
|
|
149
181
|
|
|
150
182
|
export function GetSalesReceiptPDF(salesReceiptData: any, entityData: any, headerConfig: any, printConfig: any, taxCodes: any, image: any = null, numberofCopies: string[] = ['Original'], withPass: boolean = false, options: any = null) {
|
|
151
183
|
if (!options) {
|
|
@@ -628,7 +628,7 @@ export function ComputeTaxSummary(input: ITaxSummaryInput): ITaxSummary {
|
|
|
628
628
|
* // }
|
|
629
629
|
*/
|
|
630
630
|
export function ComputeDocumentTotals(input: IDocumentTotalsInput): IDocumentTotals {
|
|
631
|
-
const { Lines, Rounding, RegimeCode } = input;
|
|
631
|
+
const { Lines, Rounding, RegimeCode, Adjust } = input;
|
|
632
632
|
// 1. SubTotal = sum of gross line values before discounts/tax
|
|
633
633
|
let subTotal = 0;
|
|
634
634
|
let discount = 0;
|
|
@@ -651,7 +651,7 @@ export function ComputeDocumentTotals(input: IDocumentTotalsInput): IDocumentTot
|
|
|
651
651
|
const taxTotal = taxSummary.TotalTax;
|
|
652
652
|
|
|
653
653
|
// 4. GrandTotal before doc-level rounding
|
|
654
|
-
const grandTotal = Add(taxableAmount, taxTotal);
|
|
654
|
+
const grandTotal = Add(taxableAmount, taxTotal, Adjust ?? 0);
|
|
655
655
|
|
|
656
656
|
// 5. DocTotal rounding
|
|
657
657
|
let roundedTotal = grandTotal;
|
package/src/tax/tax.types.ts
CHANGED
|
@@ -401,6 +401,9 @@ export interface IDocumentTotalsInput {
|
|
|
401
401
|
|
|
402
402
|
/** Tax regime code for the TaxSummary snapshot */
|
|
403
403
|
RegimeCode?: string;
|
|
404
|
+
|
|
405
|
+
/** Optional adjustment to grand total before rounding (e.g., for round-off entries) */
|
|
406
|
+
Adjust?: number;
|
|
404
407
|
}
|
|
405
408
|
|
|
406
409
|
/** Result of full document totals computation */
|