shareneus 1.0.5
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/aggregation/aggregation.js +60 -0
- package/dist/enums/cache-enums.js +37 -0
- package/dist/enums/code-enums.js +288 -0
- package/dist/enums/enums.js +362 -0
- package/dist/enums/industry-enums.js +24 -0
- package/dist/excel-files/GSTR-RO-excel.service.js +935 -0
- package/dist/excel-files/GSTR1-excel.service.js +295 -0
- package/dist/excel-files/GSTR2-excel.service.js +295 -0
- package/dist/excel-files/analysis-excel.service.js +297 -0
- package/dist/excel-files/category-wise-item-excel.service.js +274 -0
- package/dist/excel-files/cust-balance-excel.service.js +287 -0
- package/dist/excel-files/cust-wise-sales-details.js +320 -0
- package/dist/excel-files/cust-wise-sales-summary-excel.service.js +302 -0
- package/dist/excel-files/expiring-drugs-excel.service.js +292 -0
- package/dist/excel-files/insurance-expire-excel.service.js +301 -0
- package/dist/excel-files/invoice-wise-excel.service.js +857 -0
- package/dist/excel-files/item-wise-doctor-sale-excel.service.js +258 -0
- package/dist/excel-files/item-wise-mout-details.js +292 -0
- package/dist/excel-files/item-wise-mout-summary.js +286 -0
- package/dist/excel-files/items-wise-sales-excel.service.js +314 -0
- package/dist/excel-files/manf-wise-sales-excel.service.js +276 -0
- package/dist/excel-files/operator-wise-details.js +265 -0
- package/dist/excel-files/operator-wise-summary.js +266 -0
- package/dist/excel-files/payment-receive-excel.service.js +225 -0
- package/dist/excel-files/payments-made-excel.service.js +302 -0
- package/dist/excel-files/repair-orders-excel.service.js +255 -0
- package/dist/excel-files/sa-wise-labor-sales-excel.service.js +232 -0
- package/dist/excel-files/sa-wise-part-sales-excel.service.js +232 -0
- package/dist/excel-files/sale-summary-excel.service.js +326 -0
- package/dist/excel-files/sales-by-service-details-excel.service.js +1 -0
- package/dist/excel-files/sales-by-service-summary-excel.service.js +422 -0
- package/dist/excel-files/scheduled-drug-summary-excel.service.js +367 -0
- package/dist/excel-files/scheduled-drugs-excel.service.js +366 -0
- package/dist/excel-files/spares-issue-excel.service.js +492 -0
- package/dist/excel-files/stock-excel.service.js +283 -0
- package/dist/excel-files/tally-sales-import.service.js +765 -0
- package/dist/excel-files/ven-balance-excel.service.js +293 -0
- package/dist/index.js +237 -0
- package/dist/services/analysis-pdf.service.js +105 -0
- package/dist/services/appointment-total.service.js +253 -0
- package/dist/services/auto-sales-receipt-pdf.service.js +539 -0
- package/dist/services/category-wise-item-pdf.service.js +98 -0
- package/dist/services/checklist-pdf.js +140 -0
- package/dist/services/checklists-pdf.js +124 -0
- package/dist/services/cn-print.service.js +211 -0
- package/dist/services/consultation-fee-receipt.service.js +378 -0
- package/dist/services/consultation-full-pdf.service.js +220 -0
- package/dist/services/consultation-pdf.service.js +360 -0
- package/dist/services/credit-note-pdf.service.js +578 -0
- package/dist/services/credit-note-totals.service.js +328 -0
- package/dist/services/cust-wise-sales-details-pdf.service.js +118 -0
- package/dist/services/cust-wise-sales-summary-pdf.service.js +111 -0
- package/dist/services/customer-balances-pdf.service.js +169 -0
- package/dist/services/dc-landscape-pdf.service.js +903 -0
- package/dist/services/dc-landscape-without-price-pdf.service.js +853 -0
- package/dist/services/dc-without-price-pdf.service.js +489 -0
- package/dist/services/debit-note-pdf.service.js +673 -0
- package/dist/services/debit-note-print.service.js +234 -0
- package/dist/services/debit-note-totals.service.js +293 -0
- package/dist/services/delivery-challan-pdf.service.js +434 -0
- package/dist/services/delivery-challan-print.service.js +177 -0
- package/dist/services/delivery-challan-totals.js +339 -0
- package/dist/services/equipment-design-pdf.service.js +144 -0
- package/dist/services/est.print-service.js +1053 -0
- package/dist/services/expiring-drugs-pdf.service.js +156 -0
- package/dist/services/hc-inv-pdf.service.js +837 -0
- package/dist/services/insurance-expire-pdf.service.js +99 -0
- package/dist/services/inv-pdf.service.js +785 -0
- package/dist/services/inv-print.service.js +415 -0
- package/dist/services/invoice-landscape-pdf.service.js +909 -0
- package/dist/services/invoice-total.service.js +659 -0
- package/dist/services/issue-parts-pdf.service.js +763 -0
- package/dist/services/item-detais-pdf.js +136 -0
- package/dist/services/item-wise-doctor-sale-pdf.service.js +164 -0
- package/dist/services/item-wise-mout-details-pdf.js +107 -0
- package/dist/services/item-wise-mout-summary-pdf.js +99 -0
- package/dist/services/item-wise-sales-pdf.service.js +178 -0
- package/dist/services/manf-wise-sales-pdf.service.js +173 -0
- package/dist/services/meeting-pdf.js +369 -0
- package/dist/services/mout-pdf.service.js +503 -0
- package/dist/services/operator-wise-details-pdf.service.js +103 -0
- package/dist/services/operator-wise-summary-pdf.js +101 -0
- package/dist/services/pack-ship-pdf.service.js +105 -0
- package/dist/services/pack-ship-print.service.js +167 -0
- package/dist/services/payment-pdf.service.js +373 -0
- package/dist/services/payment-report-pdf.service.js +106 -0
- package/dist/services/po-totals.service.js +279 -0
- package/dist/services/pos-receipt-pdf.js +438 -0
- package/dist/services/purchase-order-pdf.service.js +924 -0
- package/dist/services/purchase-order-print.service.js +150 -0
- package/dist/services/purchase-order-totals.service.js +280 -0
- package/dist/services/receipt-print.service.js +50 -0
- package/dist/services/reorder-point-pdf.service.js +151 -0
- package/dist/services/repair-orders-pdf.service.js +172 -0
- package/dist/services/ro-pdf.service.js +1764 -0
- package/dist/services/ro-print-service.js +737 -0
- package/dist/services/ro-totals.service.js +1241 -0
- package/dist/services/sales-by-service-pdf.service.js +116 -0
- package/dist/services/sales-pdf.service.js +630 -0
- package/dist/services/sales-print.service.js +305 -0
- package/dist/services/sales-receipt-pdf.service.js +611 -0
- package/dist/services/sales-receipt-print.service.js +425 -0
- package/dist/services/sales-totals.service.js +339 -0
- package/dist/services/scheduled-drug-pdf.service.js +176 -0
- package/dist/services/scheduled-drug-summary-pdf.service.js +188 -0
- package/dist/services/separate-wo-print.service.js +351 -0
- package/dist/services/shared-inv-pdf.service.js +763 -0
- package/dist/services/shared-pdf.service.js +2569 -0
- package/dist/services/shared-print.service.js +885 -0
- package/dist/services/task-pdf.service.js +220 -0
- package/dist/services/task-reports-pdf.service.js +296 -0
- package/dist/services/technician-pdf.service.js +238 -0
- package/dist/services/technician-print.service.js +87 -0
- package/dist/services/transfer-order-pdf.service.js +139 -0
- package/dist/services/vendor-balances-pdf.service.js +101 -0
- package/dist/services/vendor-credit-note-pdf.service.js +1007 -0
- package/dist/services/vendor-credit-note-print.service.js +104 -0
- package/dist/services/vendor-credit-note-totals.service.js +327 -0
- package/dist/services/vendor-debit-note-pdf.service.js +561 -0
- package/dist/services/vendor-debit-note-print.service.js +245 -0
- package/dist/services/vendor-debit-note-totals.service.js +305 -0
- package/dist/utils/my-date.js +652 -0
- package/dist/utils/tr-utils.js +354 -0
- package/package.json +24 -0
- package/tsconfig.json +109 -0
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DebitNotePrintService = void 0;
|
|
4
|
+
const shared_print_service_1 = require("./shared-print.service");
|
|
5
|
+
const debit_note_totals_service_1 = require("./debit-note-totals.service");
|
|
6
|
+
const code_enums_1 = require("../enums/code-enums");
|
|
7
|
+
const tr_utils_1 = require("../utils/tr-utils");
|
|
8
|
+
const enums_1 = require("../enums/enums");
|
|
9
|
+
const my_date_1 = require("../utils/my-date");
|
|
10
|
+
const aggregation_1 = require("../aggregation/aggregation");
|
|
11
|
+
class DebitNotePrintService {
|
|
12
|
+
static GetDebitNotePrintInfo(OriginalInvoiceData, OriginalEntityData, image, IncludeGST, ConsolidateGST, TaxCodes, IsProforma, IsCustBillTo) {
|
|
13
|
+
var _a, _b;
|
|
14
|
+
let InvoicePrintData = {};
|
|
15
|
+
let argInvoiceData = tr_utils_1.TrUtils.Stringify(OriginalInvoiceData);
|
|
16
|
+
if (!IncludeGST) {
|
|
17
|
+
argInvoiceData.Settings.Tax = 'NO';
|
|
18
|
+
}
|
|
19
|
+
InvoicePrintData.IsProforma = IsProforma;
|
|
20
|
+
InvoicePrintData.Settings = tr_utils_1.TrUtils.Stringify(argInvoiceData.Settings);
|
|
21
|
+
let SType;
|
|
22
|
+
if (!tr_utils_1.TrUtils.IsNull(argInvoiceData.Settings) && !tr_utils_1.TrUtils.IsNull(argInvoiceData.Settings.PoS)) {
|
|
23
|
+
SType = argInvoiceData.Settings.PoS.SType;
|
|
24
|
+
}
|
|
25
|
+
InvoicePrintData = this.GetPrintConditionsBasedOnInput(InvoicePrintData, IncludeGST, ConsolidateGST, SType, argInvoiceData, IsProforma, IsCustBillTo);
|
|
26
|
+
InvoicePrintData.Entity = shared_print_service_1.PrintSharedService.GetFormattedEntityDataForPrint(OriginalEntityData, "Invoice", OriginalInvoiceData);
|
|
27
|
+
InvoicePrintData = shared_print_service_1.PrintSharedService.GetEntityHeaderStyles(InvoicePrintData, OriginalEntityData, image);
|
|
28
|
+
InvoicePrintData = this.GetInvoiceOtherDetailsForPrint(InvoicePrintData, argInvoiceData, IsCustBillTo);
|
|
29
|
+
let IsTaxable = (IncludeGST && tr_utils_1.TrUtils.isTaxable(argInvoiceData.Settings.Tax)) ? true : false;
|
|
30
|
+
let finalTotalsData = debit_note_totals_service_1.DebitNoteTotalsService.GetTotalsValue(argInvoiceData.Items, IsTaxable, true, argInvoiceData.Disc, argInvoiceData.Perc, TaxCodes, true, argInvoiceData.Settings);
|
|
31
|
+
if (ConsolidateGST) {
|
|
32
|
+
finalTotalsData.CustLaborTotalBeforeDisc = finalTotalsData.CustLaborAfterTax;
|
|
33
|
+
finalTotalsData.CustPartsTotalBeforeDisc = finalTotalsData.CustPartAfterTax;
|
|
34
|
+
}
|
|
35
|
+
InvoicePrintData = tr_utils_1.TrUtils.ConcatObjects(InvoicePrintData, finalTotalsData);
|
|
36
|
+
InvoicePrintData.Items = this.GetItemsPrintInfo(InvoicePrintData.Items, ConsolidateGST, TaxCodes, (_b = (_a = OriginalEntityData.Entity.Settings) === null || _a === void 0 ? void 0 : _a.Acc) === null || _b === void 0 ? void 0 : _b.LTot);
|
|
37
|
+
argInvoiceData = this.ReverseItemsForInvoicePrint(argInvoiceData);
|
|
38
|
+
InvoicePrintData.PrintInfo = this.PrepareFormatForInvoicePrint(InvoicePrintData, code_enums_1.ROTypeEnum.Invoice, argInvoiceData.Sts);
|
|
39
|
+
InvoicePrintData = this.GetFormattedProductDataForPrint(argInvoiceData, InvoicePrintData);
|
|
40
|
+
InvoicePrintData = this.GetBillNameForInvoicePrint(argInvoiceData, InvoicePrintData, IsCustBillTo);
|
|
41
|
+
let PaymentData = this.GetPaymentsTotal(argInvoiceData.Payments, InvoicePrintData.Total, argInvoiceData.Sts);
|
|
42
|
+
InvoicePrintData.Due = PaymentData.Due;
|
|
43
|
+
InvoicePrintData.Paid = PaymentData.Paid;
|
|
44
|
+
if (!tr_utils_1.TrUtils.IsNull(PaymentData.Sts)) {
|
|
45
|
+
InvoicePrintData.Sts = PaymentData.Sts;
|
|
46
|
+
}
|
|
47
|
+
InvoicePrintData.Consolidate = ConsolidateGST;
|
|
48
|
+
if (!ConsolidateGST) {
|
|
49
|
+
InvoicePrintData.ShowDiscountColumn = (InvoicePrintData.Settings.DiscLvl === 'ITM' || InvoicePrintData.Settings.DiscLvl === 'RECITM') ? true : false;
|
|
50
|
+
}
|
|
51
|
+
return InvoicePrintData;
|
|
52
|
+
}
|
|
53
|
+
static GetPrintConditionsBasedOnInput(InvoicePrintData, IncludeGST, ConsolidateGST, SType, OriginalInvoiceData, IsProforma, IsBillTo) {
|
|
54
|
+
InvoicePrintData.For = enums_1.PayTypeEnum.Customer;
|
|
55
|
+
InvoicePrintData.IncludeGST = IncludeGST;
|
|
56
|
+
InvoicePrintData.ConsolidateGST = ConsolidateGST;
|
|
57
|
+
InvoicePrintData.ShowAccParts = false;
|
|
58
|
+
InvoicePrintData.ShowIGST = (tr_utils_1.TrUtils.IsNull(SType) || (SType === 'Intra')) ? false : true;
|
|
59
|
+
InvoicePrintData.ShowTaxColumn = (IncludeGST && !ConsolidateGST) ? true : false;
|
|
60
|
+
// InvoicePrintData.ShowDiscountColumn = (!ForInsurance && !ConsolidateGST) ? true : false;
|
|
61
|
+
InvoicePrintData = this.GetInvoiceTypeHeading(InvoicePrintData, OriginalInvoiceData, IncludeGST, ConsolidateGST, IsProforma, IsBillTo);
|
|
62
|
+
InvoicePrintData.PrDate = tr_utils_1.TrUtils.IsNull(OriginalInvoiceData.PrDate) ? '' : my_date_1.MyDate.ConvertUTCDateToReadable(OriginalInvoiceData.PrDate);
|
|
63
|
+
return InvoicePrintData;
|
|
64
|
+
}
|
|
65
|
+
static GetInvoiceTypeHeading(InvoicePrintData, OriginalInvoiceData, IncludeGST, ConsolidateGST, IsProforma, IsBillTo) {
|
|
66
|
+
if (IsProforma) {
|
|
67
|
+
InvoicePrintData.HeaderName = 'pro-forma Invoice';
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
if (IsBillTo) {
|
|
71
|
+
InvoicePrintData.HeaderName = 'Debit Note';
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
InvoicePrintData.HeaderName = 'Vendor Credit Note';
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return InvoicePrintData;
|
|
78
|
+
}
|
|
79
|
+
static GetInvoiceOtherDetailsForPrint(InvoicePrintData, OriginalInvoiceData, IsCustBillTo) {
|
|
80
|
+
if (IsCustBillTo) {
|
|
81
|
+
InvoicePrintData.Type = 'Debit Notes';
|
|
82
|
+
InvoicePrintData._id = OriginalInvoiceData.Code;
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
InvoicePrintData.Type = 'Credit Notes';
|
|
86
|
+
InvoicePrintData._id = OriginalInvoiceData.BNo;
|
|
87
|
+
}
|
|
88
|
+
InvoicePrintData.Sts = OriginalInvoiceData.Sts;
|
|
89
|
+
InvoicePrintData.CrDate = my_date_1.MyDate.ConvertUTCDateToReadable(OriginalInvoiceData.CrDate);
|
|
90
|
+
return InvoicePrintData;
|
|
91
|
+
}
|
|
92
|
+
static GetItemsPrintInfo(Items, Consolidate, TaxCodes, LineTotal) {
|
|
93
|
+
Items.forEach((Item) => {
|
|
94
|
+
if (Consolidate) {
|
|
95
|
+
let AfterDiscForEach = (0, aggregation_1.division)(Item.AfterPartDisc, Item.Qty);
|
|
96
|
+
let CTaxAmtPerItem = (0, aggregation_1.division)(Item.CGST, Item.Qty);
|
|
97
|
+
let STaxAmtPerItem = (0, aggregation_1.division)(Item.SGST, Item.Qty);
|
|
98
|
+
let ITaxAmtPerItem = (0, aggregation_1.division)(Item.IGST, Item.Qty);
|
|
99
|
+
Item.UnPr = tr_utils_1.TrUtils.FixedTo((0, aggregation_1.addition)(AfterDiscForEach, CTaxAmtPerItem, STaxAmtPerItem, ITaxAmtPerItem));
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
Item.UnPr = tr_utils_1.TrUtils.FixPriceValue(Item.UnPr);
|
|
103
|
+
}
|
|
104
|
+
Item.CGSTAmt = tr_utils_1.TrUtils.FixPriceValue(Item.CGST);
|
|
105
|
+
Item.SGSTAmt = tr_utils_1.TrUtils.FixPriceValue(Item.SGST);
|
|
106
|
+
Item.IGSTAmt = tr_utils_1.TrUtils.FixPriceValue(Item.IGST);
|
|
107
|
+
Item.CGSTPerc = shared_print_service_1.PrintSharedService.GetCGSTValueBasedOnTaxCode(Item.TCode, TaxCodes);
|
|
108
|
+
Item.SGSTPerc = shared_print_service_1.PrintSharedService.GetSGSTValueBasedOnTaxCode(Item.TCode, TaxCodes);
|
|
109
|
+
Item.IGSTPerc = shared_print_service_1.PrintSharedService.GetIGSTValueBasedOnTaxCode(Item.TCode, TaxCodes);
|
|
110
|
+
if (LineTotal === 'AT') {
|
|
111
|
+
Item.LineTotal = tr_utils_1.TrUtils.FixPriceValue(Item.AfterPartTax);
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
Item.LineTotal = tr_utils_1.TrUtils.FixPriceValue((0, aggregation_1.subtraction)(Item.UnAmt, Item.Disc));
|
|
115
|
+
}
|
|
116
|
+
if (!tr_utils_1.TrUtils.IsZero(Item.Qty) && !tr_utils_1.TrUtils.CheckInvalidSelect(Item.UoM)) {
|
|
117
|
+
Item.QtyAndUoM = Item.Qty + ' ' + Item.UoM;
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
return Items;
|
|
121
|
+
}
|
|
122
|
+
static ReverseItemsForInvoicePrint(argInvoiceData) {
|
|
123
|
+
argInvoiceData.Items = argInvoiceData.Items.reverse();
|
|
124
|
+
return argInvoiceData;
|
|
125
|
+
}
|
|
126
|
+
static PrepareFormatForInvoicePrint(InvoicePrintData, ROType, InvoiceStatus) {
|
|
127
|
+
let PrintInfo = [];
|
|
128
|
+
let ROLaborParts = {};
|
|
129
|
+
ROLaborParts.Items = InvoicePrintData.Items;
|
|
130
|
+
ROLaborParts.Sts = InvoiceStatus;
|
|
131
|
+
ROLaborParts.Type = ROType;
|
|
132
|
+
PrintInfo.push(ROLaborParts);
|
|
133
|
+
return PrintInfo;
|
|
134
|
+
}
|
|
135
|
+
static GetFormattedProductDataForPrint(OriginalInvoiceData, InvoicePrintData) {
|
|
136
|
+
if (!tr_utils_1.TrUtils.IsNull(OriginalInvoiceData.Prod)) {
|
|
137
|
+
InvoicePrintData.Product = OriginalInvoiceData.Prod;
|
|
138
|
+
if (tr_utils_1.TrUtils.IsNull(InvoicePrintData.Product.VIN)) {
|
|
139
|
+
InvoicePrintData.Product.VIN = '';
|
|
140
|
+
}
|
|
141
|
+
if (tr_utils_1.TrUtils.IsNull(InvoicePrintData.Product.RegNo)) {
|
|
142
|
+
InvoicePrintData.Product.RegNo = '';
|
|
143
|
+
}
|
|
144
|
+
if (tr_utils_1.TrUtils.IsNull(InvoicePrintData.Product.EngNo)) {
|
|
145
|
+
InvoicePrintData.Product.EngNo = '';
|
|
146
|
+
}
|
|
147
|
+
InvoicePrintData.MIn = OriginalInvoiceData.Prod.MIn;
|
|
148
|
+
InvoicePrintData.MOut = OriginalInvoiceData.Prod.MOut;
|
|
149
|
+
}
|
|
150
|
+
return InvoicePrintData;
|
|
151
|
+
}
|
|
152
|
+
static GetBillNameForInvoicePrint(OriginalInvoiceData, InvoicePrintData, IsBillTo) {
|
|
153
|
+
let Customer = {};
|
|
154
|
+
if (IsBillTo) {
|
|
155
|
+
Customer.Name = OriginalInvoiceData.BillTo.Name;
|
|
156
|
+
Customer.Adrs = [];
|
|
157
|
+
Customer.Cons = [];
|
|
158
|
+
if (!tr_utils_1.TrUtils.IsNull(OriginalInvoiceData.BillTo.Adrs)) {
|
|
159
|
+
Customer.Adrs.push(OriginalInvoiceData.BillTo.Adrs.A1);
|
|
160
|
+
if (!tr_utils_1.TrUtils.IsEmpty(OriginalInvoiceData.BillTo.Adrs.A2)) {
|
|
161
|
+
Customer.Adrs.push(OriginalInvoiceData.BillTo.Adrs.A2);
|
|
162
|
+
}
|
|
163
|
+
if (!tr_utils_1.TrUtils.IsEmpty(OriginalInvoiceData.BillTo.Adrs.Ct)) {
|
|
164
|
+
Customer.Adrs.push(OriginalInvoiceData.BillTo.Adrs.Ct);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
Customer.GSTIN = OriginalInvoiceData.BillTo.GSTIN;
|
|
168
|
+
if (!tr_utils_1.TrUtils.IsEmpty(OriginalInvoiceData.BillTo.Ph)) {
|
|
169
|
+
Customer.Cons = [
|
|
170
|
+
{
|
|
171
|
+
Type: 'M',
|
|
172
|
+
No: OriginalInvoiceData.BillTo.Ph
|
|
173
|
+
}
|
|
174
|
+
];
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
else {
|
|
178
|
+
Customer.Name = OriginalInvoiceData.BFrom.Name;
|
|
179
|
+
}
|
|
180
|
+
InvoicePrintData.Customer = Customer;
|
|
181
|
+
return InvoicePrintData;
|
|
182
|
+
}
|
|
183
|
+
static GetCustomerDetails(OriginalInvoiceData) {
|
|
184
|
+
let Customer = {};
|
|
185
|
+
Customer.Name = this.GetBillToName(OriginalInvoiceData.Cust.Title, OriginalInvoiceData.Cust.Name);
|
|
186
|
+
Customer.Cons = [];
|
|
187
|
+
if (!tr_utils_1.TrUtils.IsEmpty(OriginalInvoiceData.Cust.Ph)) {
|
|
188
|
+
Customer.Cons = [
|
|
189
|
+
{
|
|
190
|
+
Type: 'M',
|
|
191
|
+
No: OriginalInvoiceData.Cust.Ph
|
|
192
|
+
}
|
|
193
|
+
];
|
|
194
|
+
}
|
|
195
|
+
Customer.GSTIN = OriginalInvoiceData.Cust.GSTIN;
|
|
196
|
+
Customer.Adrs = [];
|
|
197
|
+
if (!tr_utils_1.TrUtils.IsNull(OriginalInvoiceData.Cust.Adrs)) {
|
|
198
|
+
Customer.Adrs.push(OriginalInvoiceData.Cust.Adrs.A1);
|
|
199
|
+
if (!tr_utils_1.TrUtils.IsEmpty(OriginalInvoiceData.Cust.Adrs.A2)) {
|
|
200
|
+
Customer.Adrs.push(OriginalInvoiceData.Cust.Adrs.A2);
|
|
201
|
+
}
|
|
202
|
+
Customer.Adrs.push(OriginalInvoiceData.Cust.Adrs.Ct);
|
|
203
|
+
}
|
|
204
|
+
Customer.ConName = OriginalInvoiceData.Cust.ConName;
|
|
205
|
+
Customer.ConPh = OriginalInvoiceData.Cust.ConPhone;
|
|
206
|
+
return Customer;
|
|
207
|
+
}
|
|
208
|
+
static GetBillToName(Title, Name) {
|
|
209
|
+
return tr_utils_1.TrUtils.IsEmpty(Title) ? Name : Title + ' ' + Name;
|
|
210
|
+
}
|
|
211
|
+
static GetPaymentsTotal(InvoicePayments, Total, InvoiceStatus) {
|
|
212
|
+
var i = 0;
|
|
213
|
+
let Data = {};
|
|
214
|
+
let PaidTotal = 0;
|
|
215
|
+
for (i = 0; i < InvoicePayments.length; i++) {
|
|
216
|
+
PaidTotal += InvoicePayments[i].Paid;
|
|
217
|
+
}
|
|
218
|
+
if (InvoiceStatus === enums_1.InvoiceStatusEnum.Closed) {
|
|
219
|
+
Data.Due = 0;
|
|
220
|
+
}
|
|
221
|
+
else {
|
|
222
|
+
Data.Due = tr_utils_1.TrUtils.FixedTo(Total - PaidTotal);
|
|
223
|
+
}
|
|
224
|
+
if (Data.Due < 0) {
|
|
225
|
+
Data.Due = 0;
|
|
226
|
+
}
|
|
227
|
+
if (Data.Due === 0) {
|
|
228
|
+
Data.Sts = enums_1.InvoiceStatusEnum.Closed;
|
|
229
|
+
}
|
|
230
|
+
Data.Paid = tr_utils_1.TrUtils.FixedTo(PaidTotal);
|
|
231
|
+
return Data;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
exports.DebitNotePrintService = DebitNotePrintService;
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DebitNoteTotalsService = void 0;
|
|
4
|
+
const aggregation_1 = require("../aggregation/aggregation");
|
|
5
|
+
const tr_utils_1 = require("../utils/tr-utils");
|
|
6
|
+
class DebitNoteTotalsService {
|
|
7
|
+
static GetTotalsValue(PartsList, IsIndependentTax, DetailedInfo, Disc, Perc, TaxCodes, WithItems, Settings) {
|
|
8
|
+
// LPerc = TrUtils.SetPercToStringIfNull(LPerc);
|
|
9
|
+
// PPerc = TrUtils.SetPercToStringIfNull(PPerc);
|
|
10
|
+
Perc = tr_utils_1.TrUtils.SetPercToStringIfNull(Perc);
|
|
11
|
+
// LDisc = TrUtils.SetValueToZeroIfNull(LDisc);
|
|
12
|
+
// PDisc = TrUtils.SetValueToZeroIfNull(PDisc);
|
|
13
|
+
Disc = tr_utils_1.TrUtils.SetValueToZeroIfNull(Disc);
|
|
14
|
+
// opCodesList = this.CalculateLaborValues(opCodesList, IsIndependentTax);
|
|
15
|
+
PartsList = this.CalculateLaborPartValues(PartsList, IsIndependentTax);
|
|
16
|
+
let finalTotalsData = this.GetFinalRODataForSave(PartsList, IsIndependentTax, Disc, Perc, DetailedInfo, Settings);
|
|
17
|
+
if (DetailedInfo) {
|
|
18
|
+
finalTotalsData = this.GetDetailedTotalsData(finalTotalsData, IsIndependentTax, PartsList, TaxCodes);
|
|
19
|
+
}
|
|
20
|
+
if (WithItems) {
|
|
21
|
+
// finalTotalsData.Ops = opCodesList;
|
|
22
|
+
finalTotalsData.Items = PartsList;
|
|
23
|
+
}
|
|
24
|
+
return finalTotalsData;
|
|
25
|
+
}
|
|
26
|
+
static CalculateLaborPartValues(PartsList, IsIndependentTax) {
|
|
27
|
+
PartsList = this.ResetLaborPartValues(PartsList, IsIndependentTax);
|
|
28
|
+
// PartsList = this.GetLaborPartsDiscountPrice(PartsList);
|
|
29
|
+
// PartsList = this.GetLaborPartsAfterDiscount(PartsList);
|
|
30
|
+
// PartsList = this.GetPartsAfterTax(PartsList, IsIndependentTax);
|
|
31
|
+
return PartsList;
|
|
32
|
+
}
|
|
33
|
+
static ResetLaborPartValues(PartsList, IsIndependentTax) {
|
|
34
|
+
PartsList.forEach((Part) => {
|
|
35
|
+
Part = this.ResetLaborPartValueIfInvalid(Part);
|
|
36
|
+
Part.DiscountedPrice = (0, aggregation_1.addition)(Part.Disc, Part.RecDisc);
|
|
37
|
+
Part.AfterPartDisc = Part.NetAmt;
|
|
38
|
+
if (IsIndependentTax) {
|
|
39
|
+
Part.AfterPartTax = (0, aggregation_1.addition)(Part.AfterPartDisc, Part.CGST, Part.SGST, Part.IGST);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
Part.AfterPartTax = Part.AfterPartDisc;
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
return PartsList;
|
|
46
|
+
}
|
|
47
|
+
static ResetLaborPartValueIfInvalid(Part) {
|
|
48
|
+
Part.UnPr = tr_utils_1.TrUtils.SetValueToZeroIfNull(Part.UnPr);
|
|
49
|
+
Part.Disc = tr_utils_1.TrUtils.SetValueToZeroIfNull(Part.Disc);
|
|
50
|
+
Part.RecDisc = tr_utils_1.TrUtils.SetValueToZeroIfNull(Part.RecDisc);
|
|
51
|
+
Part.CGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(Part.CGST);
|
|
52
|
+
Part.SGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(Part.SGST);
|
|
53
|
+
Part.IGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(Part.IGST);
|
|
54
|
+
return Part;
|
|
55
|
+
}
|
|
56
|
+
static GetFinalRODataForSave(PartsList, IsIndependentTax, Disc, Perc, DetailedInfo, Settings) {
|
|
57
|
+
let finalTotalsData = {};
|
|
58
|
+
finalTotalsData = this.SetMainDiscountValues(Disc, Perc, finalTotalsData, DetailedInfo);
|
|
59
|
+
finalTotalsData.Settings = Settings;
|
|
60
|
+
finalTotalsData = this.GetFinalCustomerTotalsData(finalTotalsData, PartsList, IsIndependentTax, DetailedInfo);
|
|
61
|
+
return finalTotalsData;
|
|
62
|
+
}
|
|
63
|
+
static SetMainDiscountValues(Disc, Perc, finalTotalsData, DetailedInfo) {
|
|
64
|
+
// finalTotalsData.LDisc = LDisc;
|
|
65
|
+
// finalTotalsData.LPerc = LPerc;
|
|
66
|
+
// finalTotalsData.PDisc = PDisc;
|
|
67
|
+
// finalTotalsData.PPerc = PPerc;
|
|
68
|
+
finalTotalsData.Disc = Disc;
|
|
69
|
+
finalTotalsData.Perc = Perc;
|
|
70
|
+
if (DetailedInfo) {
|
|
71
|
+
// finalTotalsData.FixedLDisc = LDisc;
|
|
72
|
+
// finalTotalsData.FixedPDisc = PDisc;
|
|
73
|
+
finalTotalsData.FixedDisc = Disc;
|
|
74
|
+
}
|
|
75
|
+
return finalTotalsData;
|
|
76
|
+
}
|
|
77
|
+
static GetFinalCustomerTotalsData(finalTotalsData, PartsList, IsIndependentTax, DetailedInfo) {
|
|
78
|
+
let CustomerAfterDiscTotals = this.GetSubTotalFor(PartsList);
|
|
79
|
+
// let CustLaborTaxTotal = this.GetLaborTaxTotalFor(IsIndependentTax);
|
|
80
|
+
let CustPartTaxTotal = this.GetPartsTaxTotalFor(PartsList, IsIndependentTax);
|
|
81
|
+
finalTotalsData.SubTotal = CustomerAfterDiscTotals;
|
|
82
|
+
// let CustLaborDiscTotal = this.GetLaborDiscountedTotal(LaborList, IsIndependentTax, finalTotalsData);
|
|
83
|
+
let CustPartsDiscTotal = this.GetPartDiscountedTotal(PartsList, IsIndependentTax, finalTotalsData);
|
|
84
|
+
// let CustLaborTotalAfterDisc = this.GetLaborTotalAfterDiscount(LaborList);
|
|
85
|
+
let CustPartsTotalAfterDisc = this.GetPartsTotalAfterDiscount(PartsList);
|
|
86
|
+
finalTotalsData.STotal = (0, aggregation_1.addition)(CustPartsDiscTotal, CustPartsTotalAfterDisc);
|
|
87
|
+
let CustTotal = this.GetCustomerTotalBasedOnTaxType(finalTotalsData, CustPartTaxTotal, PartsList, IsIndependentTax);
|
|
88
|
+
finalTotalsData.Round = (0, aggregation_1.subtraction)(Math.round(CustTotal), CustTotal);
|
|
89
|
+
finalTotalsData.Total = Math.round(CustTotal);
|
|
90
|
+
if (DetailedInfo) {
|
|
91
|
+
finalTotalsData.FixedSubTotal = tr_utils_1.TrUtils.FixedTo(CustomerAfterDiscTotals);
|
|
92
|
+
finalTotalsData.FixedTotal = tr_utils_1.TrUtils.FixedTo(CustTotal);
|
|
93
|
+
}
|
|
94
|
+
return finalTotalsData;
|
|
95
|
+
}
|
|
96
|
+
static GetSubTotalFor(PartsList) {
|
|
97
|
+
// let LaborTotalAfterDisc: any = this.GetLaborTotalAfterDiscount(LaborList);
|
|
98
|
+
let PartsTotalAfterDisc = this.GetPartsTotalAfterDiscount(PartsList);
|
|
99
|
+
return PartsTotalAfterDisc;
|
|
100
|
+
}
|
|
101
|
+
static GetPartsTotalAfterDiscount(PartsList) {
|
|
102
|
+
let PartsTotalAfterDisc = 0;
|
|
103
|
+
PartsList.forEach((Part) => {
|
|
104
|
+
PartsTotalAfterDisc = (0, aggregation_1.addition)(PartsTotalAfterDisc, Part.AfterPartDisc);
|
|
105
|
+
});
|
|
106
|
+
return PartsTotalAfterDisc;
|
|
107
|
+
}
|
|
108
|
+
static GetDetailedTotalsData(finalTotalsData, IsIndependentTax, PartsList, TaxCodes) {
|
|
109
|
+
// finalTotalsData.CustLaborDiscTotal = this.GetLaborDiscountedTotal(opCodesList, IsIndependentTax, finalTotalsData);
|
|
110
|
+
finalTotalsData.CustPartsDiscTotal = this.GetPartDiscountedTotal(PartsList, IsIndependentTax, finalTotalsData);
|
|
111
|
+
// finalTotalsData.CustLaborTotalAfterDisc = this.GetLaborTotalAfterDiscount(opCodesList);
|
|
112
|
+
finalTotalsData.CustPartsTotalAfterDisc = this.GetPartsTotalAfterDiscount(PartsList);
|
|
113
|
+
// finalTotalsData.CustLaborTotalBeforeDisc = TrUtils.FixedTo(finalTotalsData.CustLaborTotalAfterDisc
|
|
114
|
+
// + finalTotalsData.CustLaborDiscTotal);
|
|
115
|
+
finalTotalsData.CustPartsTotalBeforeDisc = (0, aggregation_1.addition)(finalTotalsData.CustPartsTotalAfterDisc, finalTotalsData.CustPartsDiscTotal);
|
|
116
|
+
// finalTotalsData.CustLaborITax = this.GetLaborTaxTotalFor(opCodesList, IsIndependentTax);
|
|
117
|
+
// finalTotalsData.CustLaborSGST = this.GetLaborSGSTTaxTotal(opCodesList, IsIndependentTax);
|
|
118
|
+
// finalTotalsData.CustLaborCGST = this.GetLaborCGSTTaxTotal(opCodesList, IsIndependentTax);
|
|
119
|
+
// finalTotalsData.CustLaborIGST = this.GetLaborIGSTTaxTotal(opCodesList, IsIndependentTax);
|
|
120
|
+
let TaxInfo = this.GetPartGSTTaxTotal(PartsList, IsIndependentTax);
|
|
121
|
+
finalTotalsData.CustPartITax = tr_utils_1.TrUtils.SetValueToZeroIfNull(TaxInfo[3]);
|
|
122
|
+
finalTotalsData.CustPartCGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(TaxInfo[0]);
|
|
123
|
+
finalTotalsData.CustPartIGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(TaxInfo[2]);
|
|
124
|
+
finalTotalsData.CustPartSGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(TaxInfo[1]);
|
|
125
|
+
// finalTotalsData.CustLaborAfterTax = addition(finalTotalsData.CustLaborITax , finalTotalsData.CustLaborTotalAfterDisc);
|
|
126
|
+
finalTotalsData.CustPartAfterTax = (0, aggregation_1.addition)(finalTotalsData.CustPartITax, finalTotalsData.CustPartsTotalAfterDisc);
|
|
127
|
+
finalTotalsData.CustTaxGroupData = this.GetTaxGroupingForPartsByHSN(PartsList, TaxCodes);
|
|
128
|
+
finalTotalsData.CustTotalRoundedBy = tr_utils_1.TrUtils.FixedTo(finalTotalsData.Round);
|
|
129
|
+
finalTotalsData.CustRoundedTotal = tr_utils_1.TrUtils.FixedTo(finalTotalsData.Total);
|
|
130
|
+
for (var key in finalTotalsData) {
|
|
131
|
+
if (key !== 'Total' && key !== 'SubTotal' &&
|
|
132
|
+
key !== 'LDisc' && key !== 'LPerc' && key !== 'PDisc' &&
|
|
133
|
+
key !== 'PPerc' && key !== 'Disc' && key !== 'Perc' && key !== 'Tax'
|
|
134
|
+
&& typeof finalTotalsData[key] === 'number') {
|
|
135
|
+
finalTotalsData[key] = tr_utils_1.TrUtils.FixPriceValue(finalTotalsData[key]);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return finalTotalsData;
|
|
139
|
+
}
|
|
140
|
+
static GetPartDiscountedTotal(PartsList, isTaxable, finalTotalsData) {
|
|
141
|
+
let PartsDiscountedTotal = 0;
|
|
142
|
+
let overallPartDisc = 0;
|
|
143
|
+
if (!isTaxable) {
|
|
144
|
+
overallPartDisc = tr_utils_1.TrUtils.SetValueToZeroIfNull(finalTotalsData.PDisc);
|
|
145
|
+
}
|
|
146
|
+
PartsList.forEach((Part) => {
|
|
147
|
+
PartsDiscountedTotal = (0, aggregation_1.addition)(PartsDiscountedTotal, Part.DiscountedPrice);
|
|
148
|
+
});
|
|
149
|
+
return (0, aggregation_1.addition)(PartsDiscountedTotal, overallPartDisc);
|
|
150
|
+
}
|
|
151
|
+
static GetPartsTaxTotalFor(PartsList, IsIndependentTax) {
|
|
152
|
+
let TotalTaxAmt = 0;
|
|
153
|
+
if (IsIndependentTax) {
|
|
154
|
+
PartsList.forEach((Part) => {
|
|
155
|
+
TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Part.CGST, Part.SGST, Part.IGST);
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
return TotalTaxAmt;
|
|
159
|
+
}
|
|
160
|
+
static GetCustomerTotalBasedOnTaxType(finalTotalsData, PartsTaxAmount, PartsList, IsIndependentTax) {
|
|
161
|
+
// let LaborTotalAfterDisc: any = this.GetLaborTotalAfterDiscount(LaborList);
|
|
162
|
+
let PartsTotalAfterDisc = this.GetPartsTotalAfterDiscount(PartsList);
|
|
163
|
+
if (IsIndependentTax) {
|
|
164
|
+
return (0, aggregation_1.addition)(PartsTotalAfterDisc, PartsTaxAmount);
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
return (0, aggregation_1.subtraction)(PartsTotalAfterDisc, finalTotalsData.Disc);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
static ItemsTotalAfterDiscount(PartsTotalAfterDisc, PartsTaxAmount, MainPDisc, PDiscInPerc) {
|
|
171
|
+
let ItemsTotal = (0, aggregation_1.addition)(PartsTotalAfterDisc, PartsTaxAmount);
|
|
172
|
+
if (!tr_utils_1.TrUtils.IsZero(MainPDisc)) {
|
|
173
|
+
if (!tr_utils_1.TrUtils.IsEmpty(PDiscInPerc)) {
|
|
174
|
+
ItemsTotal = (0, aggregation_1.subtraction)(ItemsTotal, (0, aggregation_1.division)((0, aggregation_1.multiply)(ItemsTotal, Number(PDiscInPerc)), 100));
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
ItemsTotal = (0, aggregation_1.subtraction)(ItemsTotal, MainPDisc);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
return ItemsTotal;
|
|
181
|
+
}
|
|
182
|
+
static GetPartGSTTaxTotal(PartsList, IsIndependentTax) {
|
|
183
|
+
let TotalCGSTAmt = 0;
|
|
184
|
+
let TotalSGSTAmt = 0;
|
|
185
|
+
let TotalIGSTAmt = 0;
|
|
186
|
+
let TotalTaxAmt = 0;
|
|
187
|
+
if (IsIndependentTax) {
|
|
188
|
+
PartsList.forEach((Part) => {
|
|
189
|
+
TotalCGSTAmt = (0, aggregation_1.addition)(TotalCGSTAmt, Part.CGST);
|
|
190
|
+
TotalSGSTAmt = (0, aggregation_1.addition)(TotalSGSTAmt, Part.SGST);
|
|
191
|
+
TotalIGSTAmt = (0, aggregation_1.addition)(TotalIGSTAmt, Part.IGST);
|
|
192
|
+
TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Part.CGST, Part.SGST, Part.IGST);
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
return [TotalCGSTAmt, TotalSGSTAmt, TotalIGSTAmt, TotalTaxAmt];
|
|
196
|
+
}
|
|
197
|
+
static GetTaxGroupingForPartsByHSN(Parts, TaxCodes) {
|
|
198
|
+
Parts = this.GetCombinedTaxPercentage(Parts, TaxCodes);
|
|
199
|
+
// Parts = this.ResetPartsHSNIfInvalid(Parts);
|
|
200
|
+
let FinalMatchedParts = this.ComparePartsByHSN(Parts, TaxCodes);
|
|
201
|
+
return this.GetTaxGroupingInfoByHSN(FinalMatchedParts, TaxCodes);
|
|
202
|
+
}
|
|
203
|
+
static GetCombinedTaxPercentage(Parts, TaxCodes) {
|
|
204
|
+
Parts.forEach((Part) => {
|
|
205
|
+
if (tr_utils_1.TrUtils.IsNull(Part.HSN)) {
|
|
206
|
+
Part.HSN = '';
|
|
207
|
+
}
|
|
208
|
+
let GSTValues = this.GetGSTValueBasedOnTaxCode(Part.TCode, TaxCodes);
|
|
209
|
+
Part.CGSTAmt = tr_utils_1.TrUtils.SetValueToZeroIfNull(GSTValues[0]);
|
|
210
|
+
Part.SGSTAmt = tr_utils_1.TrUtils.SetValueToZeroIfNull(GSTValues[1]);
|
|
211
|
+
Part.IGSTAmt = tr_utils_1.TrUtils.SetValueToZeroIfNull(GSTValues[2]);
|
|
212
|
+
Part.CombinedTaxPercentage = (0, aggregation_1.addition)(Part.CGSTAmt, Part.SGSTAmt, Part.IGSTAmt);
|
|
213
|
+
});
|
|
214
|
+
return Parts;
|
|
215
|
+
}
|
|
216
|
+
static ComparePartsByHSN(Parts, TaxCodes) {
|
|
217
|
+
let FinalMatchedParts = [];
|
|
218
|
+
Parts.forEach((Part) => {
|
|
219
|
+
let MatchedPartsBasedOnHSN = Parts.filter((argPart) => {
|
|
220
|
+
let PartFound = false;
|
|
221
|
+
FinalMatchedParts.forEach((FinalArgParts) => {
|
|
222
|
+
let PartIndex = FinalArgParts.findIndex((FinalArgPart) => {
|
|
223
|
+
return FinalArgPart._id === argPart._id;
|
|
224
|
+
});
|
|
225
|
+
if (PartIndex !== -1) {
|
|
226
|
+
PartFound = true;
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
return (argPart.HSN === Part.HSN) && (!PartFound) &&
|
|
230
|
+
(argPart.CGSTAmt === Part.CGSTAmt) && (argPart.IGSTAmt === Part.IGSTAmt) &&
|
|
231
|
+
(argPart.SGSTAmt === Part.SGSTAmt);
|
|
232
|
+
});
|
|
233
|
+
if (MatchedPartsBasedOnHSN.length !== 0) {
|
|
234
|
+
FinalMatchedParts.push(MatchedPartsBasedOnHSN);
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
return FinalMatchedParts;
|
|
238
|
+
}
|
|
239
|
+
static GetTaxGroupingInfoByHSN(FinalMatchedParts, TaxCodes) {
|
|
240
|
+
let HSNTaxInfo = [];
|
|
241
|
+
FinalMatchedParts.forEach((MatchedPart) => {
|
|
242
|
+
let TaxInfo = {};
|
|
243
|
+
let TaxOnAmount = 0;
|
|
244
|
+
let TaxAmount = 0;
|
|
245
|
+
let HSN = MatchedPart[0].HSN;
|
|
246
|
+
TaxInfo.CombinedTaxPercentage = MatchedPart[0].CombinedTaxPercentage;
|
|
247
|
+
MatchedPart.forEach((argMatchedGSTPart) => {
|
|
248
|
+
TaxOnAmount = (0, aggregation_1.addition)(TaxOnAmount, argMatchedGSTPart.AfterPartDisc);
|
|
249
|
+
TaxAmount = (0, aggregation_1.addition)(TaxAmount, argMatchedGSTPart.CGST);
|
|
250
|
+
TaxAmount = (0, aggregation_1.addition)(TaxAmount, argMatchedGSTPart.IGST);
|
|
251
|
+
TaxAmount = (0, aggregation_1.addition)(TaxAmount, argMatchedGSTPart.SGST);
|
|
252
|
+
});
|
|
253
|
+
TaxInfo.HSN = HSN;
|
|
254
|
+
TaxInfo.TotalTaxableAmount = tr_utils_1.TrUtils.FixPriceValue(TaxOnAmount);
|
|
255
|
+
TaxInfo.TotalTaxAmount = tr_utils_1.TrUtils.FixPriceValue(TaxAmount);
|
|
256
|
+
TaxInfo.ItemsCount = MatchedPart.length;
|
|
257
|
+
// let GSTValues: any[] = this.GetGSTValueBasedOnTaxCode(MatchedPart[0].TCode, TaxCodes);
|
|
258
|
+
// TaxInfo.CGST = GSTValues[0];
|
|
259
|
+
// TaxInfo.SGST = GSTValues[1];
|
|
260
|
+
// TaxInfo.IGST = GSTValues[2];
|
|
261
|
+
TaxInfo.CGST = MatchedPart[0].CGSTAmt;
|
|
262
|
+
TaxInfo.IGST = MatchedPart[0].IGSTAmt;
|
|
263
|
+
TaxInfo.SGST = MatchedPart[0].SGSTAmt;
|
|
264
|
+
if (TaxOnAmount !== 0) {
|
|
265
|
+
HSNTaxInfo.push(TaxInfo);
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
return HSNTaxInfo;
|
|
269
|
+
}
|
|
270
|
+
static GetGSTValueBasedOnTaxCode(TCode, TaxCodes) {
|
|
271
|
+
let CGST = 0;
|
|
272
|
+
let SGST = 0;
|
|
273
|
+
let IGST = 0;
|
|
274
|
+
if (tr_utils_1.TrUtils.IsNull(TCode)) {
|
|
275
|
+
return [CGST, SGST, IGST];
|
|
276
|
+
}
|
|
277
|
+
let TCodeIndex = TaxCodes.findIndex((TaxCode) => {
|
|
278
|
+
return TaxCode._id === Number(TCode);
|
|
279
|
+
});
|
|
280
|
+
if (TCodeIndex !== -1) {
|
|
281
|
+
if (TaxCodes[TCodeIndex].Type === 'Intra') {
|
|
282
|
+
return [TaxCodes[TCodeIndex].CGST, TaxCodes[TCodeIndex].SGST, 0];
|
|
283
|
+
}
|
|
284
|
+
else {
|
|
285
|
+
return [0, 0, TaxCodes[TCodeIndex].IGST];
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
else {
|
|
289
|
+
return [CGST, SGST, IGST];
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
exports.DebitNoteTotalsService = DebitNoteTotalsService;
|