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,1241 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ROTotalsService = void 0;
|
|
4
|
+
const aggregation_1 = require("../aggregation/aggregation");
|
|
5
|
+
const enums_1 = require("../enums/enums");
|
|
6
|
+
const tr_utils_1 = require("../utils/tr-utils");
|
|
7
|
+
class ROTotalsService {
|
|
8
|
+
static GetTotalsValue(OriRecordData, TaxCodes, isWorkOrder, detailedInfo, withItems, isRoundable) {
|
|
9
|
+
let dupRecordData = tr_utils_1.TrUtils.Stringify(OriRecordData);
|
|
10
|
+
let argRecordData = {};
|
|
11
|
+
dupRecordData.Ops = this.CalculateLaborValues(dupRecordData.Ops, isWorkOrder, tr_utils_1.TrUtils.isTaxable(dupRecordData.Settings.Tax));
|
|
12
|
+
dupRecordData.Parts = this.CalculatePartValues(dupRecordData.Parts, dupRecordData.Ops, isWorkOrder, tr_utils_1.TrUtils.isTaxable(dupRecordData.Settings.Tax));
|
|
13
|
+
argRecordData = this.GetROTotalsData(argRecordData, dupRecordData, TaxCodes, withItems, detailedInfo, isWorkOrder, isRoundable);
|
|
14
|
+
return argRecordData;
|
|
15
|
+
}
|
|
16
|
+
static CalculateLaborValues(opCodesList, isWorkOrder, isTaxable) {
|
|
17
|
+
opCodesList = this.FilterValidLaborItems(opCodesList);
|
|
18
|
+
opCodesList = this.ResetLaborValuesIfInvalid(opCodesList, isWorkOrder);
|
|
19
|
+
opCodesList = this.GetOperationsDiscountPrice(opCodesList, isWorkOrder);
|
|
20
|
+
opCodesList = this.GetOperationsAfterDiscount(opCodesList, isWorkOrder);
|
|
21
|
+
opCodesList = this.GetOperationsAfterTax(opCodesList, isWorkOrder, isTaxable);
|
|
22
|
+
return opCodesList;
|
|
23
|
+
}
|
|
24
|
+
static FilterValidLaborItems(opCodesList) {
|
|
25
|
+
opCodesList = opCodesList.filter((Labor) => {
|
|
26
|
+
return Labor.Sts !== enums_1.LaborStatusEnum.Cancelled && Labor.Sts !== enums_1.LaborStatusEnum.Declined;
|
|
27
|
+
});
|
|
28
|
+
return opCodesList;
|
|
29
|
+
}
|
|
30
|
+
static ResetLaborValuesIfInvalid(opCodesList, isWorkOrder) {
|
|
31
|
+
opCodesList.forEach((Operation) => {
|
|
32
|
+
Operation = this.ResetLaborValueIfInvalid(Operation, isWorkOrder);
|
|
33
|
+
});
|
|
34
|
+
return opCodesList;
|
|
35
|
+
}
|
|
36
|
+
static ResetLaborValueIfInvalid(Operation, isWorkOrder) {
|
|
37
|
+
Operation.Perc = tr_utils_1.TrUtils.SetPercToStringIfNull(Operation.Perc);
|
|
38
|
+
Operation.Disc = tr_utils_1.TrUtils.SetValueToZeroIfNull(Operation.Disc);
|
|
39
|
+
Operation.Pr = tr_utils_1.TrUtils.SetValueToZeroIfNull(Operation.Pr);
|
|
40
|
+
Operation.AssPr = tr_utils_1.TrUtils.SetValueToZeroIfNull(Operation.AssPr);
|
|
41
|
+
Operation.ACGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(Operation.ACGST);
|
|
42
|
+
Operation.ASGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(Operation.ASGST);
|
|
43
|
+
Operation.AIGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(Operation.AIGST);
|
|
44
|
+
Operation.CCGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(Operation.CCGST);
|
|
45
|
+
Operation.CSGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(Operation.CSGST);
|
|
46
|
+
Operation.CIGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(Operation.CIGST);
|
|
47
|
+
Operation.NetAmt = tr_utils_1.TrUtils.SetValueToZeroIfNull(Operation.NetAmt);
|
|
48
|
+
Operation.RecDisc = tr_utils_1.TrUtils.SetValueToZeroIfNull(Operation.RecDisc);
|
|
49
|
+
if (!isWorkOrder) {
|
|
50
|
+
Operation.EstPr = tr_utils_1.TrUtils.SetValueToZeroIfNull(Operation.EstPr);
|
|
51
|
+
Operation.ECGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(Operation.ECGST);
|
|
52
|
+
Operation.ESGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(Operation.ESGST);
|
|
53
|
+
Operation.EIGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(Operation.EIGST);
|
|
54
|
+
}
|
|
55
|
+
return Operation;
|
|
56
|
+
}
|
|
57
|
+
static GetOperationsDiscountPrice(OperationsList, isWorkOrder) {
|
|
58
|
+
OperationsList.forEach((Operation) => {
|
|
59
|
+
if (isWorkOrder) {
|
|
60
|
+
Operation.CustDiscountedPrice = (0, aggregation_1.addition)(Operation.Disc, Operation.RecDisc);
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
if (Operation.Sts === enums_1.LaborStatusEnum.New || Operation.Sts === enums_1.LaborStatusEnum.WtngForAppr) {
|
|
64
|
+
Operation.CustDiscountedPrice = 0;
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
Operation.CustDiscountedPrice = (0, aggregation_1.addition)(Operation.Disc, Operation.RecDisc);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
return OperationsList;
|
|
72
|
+
}
|
|
73
|
+
static GetOperationsAfterDiscount(OperationsList, isWorkOrder) {
|
|
74
|
+
OperationsList.forEach((Operation) => {
|
|
75
|
+
let CustAfterLaborDisc = 0;
|
|
76
|
+
let InsAfterLaborDisc = 0;
|
|
77
|
+
if (Operation.PBy === enums_1.PayTypeEnum.Customer) {
|
|
78
|
+
if (isWorkOrder) {
|
|
79
|
+
CustAfterLaborDisc = Operation.NetAmt;
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
if (Operation.Sts === enums_1.LaborStatusEnum.New || Operation.Sts === enums_1.LaborStatusEnum.WtngForAppr) {
|
|
83
|
+
CustAfterLaborDisc = Operation.EstPr;
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
CustAfterLaborDisc = Operation.NetAmt;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
if (isWorkOrder) {
|
|
92
|
+
CustAfterLaborDisc = Operation.NetAmt;
|
|
93
|
+
InsAfterLaborDisc = Operation.AssPr;
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
if (Operation.Sts === enums_1.LaborStatusEnum.New || Operation.Sts === enums_1.LaborStatusEnum.WtngForAppr) {
|
|
97
|
+
InsAfterLaborDisc = Operation.EstPr;
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
CustAfterLaborDisc = Operation.NetAmt;
|
|
101
|
+
InsAfterLaborDisc = Operation.AssPr;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
Operation.CustAfterLaborDisc = CustAfterLaborDisc;
|
|
106
|
+
Operation.InsAfterLaborDisc = InsAfterLaborDisc;
|
|
107
|
+
});
|
|
108
|
+
return OperationsList;
|
|
109
|
+
}
|
|
110
|
+
static GetOperationsAfterTax(OperationsList, isWorkOrder, isTaxable) {
|
|
111
|
+
OperationsList.forEach((Operation) => {
|
|
112
|
+
if (!isTaxable) {
|
|
113
|
+
Operation.CustAfterTax = Operation.CustAfterLaborDisc;
|
|
114
|
+
Operation.InsAfterTax = Operation.InsAfterLaborDisc;
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
if (Operation.PBy === enums_1.PayTypeEnum.Customer) {
|
|
118
|
+
if (isWorkOrder) {
|
|
119
|
+
Operation.CustAfterTax = (0, aggregation_1.addition)(Operation.CustAfterLaborDisc, Operation.CCGST, Operation.CSGST, Operation.CIGST);
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
if (Operation.Sts !== enums_1.LaborStatusEnum.New && Operation.Sts !== enums_1.LaborStatusEnum.WtngForAppr) {
|
|
123
|
+
Operation.CustAfterTax = (0, aggregation_1.addition)(Operation.CustAfterLaborDisc, Operation.CCGST, Operation.CSGST, Operation.CIGST);
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
Operation.CustAfterTax = (0, aggregation_1.addition)(Operation.CustAfterLaborDisc, Operation.ECGST, Operation.ESGST, Operation.EIGST);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
Operation.InsAfterTax = 0;
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
if (isWorkOrder) {
|
|
133
|
+
Operation.CustAfterTax = (0, aggregation_1.addition)(Operation.CustAfterLaborDisc, Operation.CCGST, Operation.CSGST, Operation.CIGST);
|
|
134
|
+
Operation.InsAfterTax = (0, aggregation_1.addition)(Operation.InsAfterLaborDisc, Operation.ACGST, Operation.ASGST, Operation.AIGST);
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
if (Operation.Sts !== enums_1.LaborStatusEnum.New && Operation.Sts !== enums_1.LaborStatusEnum.WtngForAppr) {
|
|
138
|
+
Operation.CustAfterTax = (0, aggregation_1.addition)(Operation.CustAfterLaborDisc, Operation.CCGST, Operation.CSGST, Operation.CIGST);
|
|
139
|
+
Operation.InsAfterTax = (0, aggregation_1.addition)(Operation.InsAfterLaborDisc, Operation.ACGST, Operation.ASGST, Operation.AIGST);
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
Operation.CustAfterTax = 0;
|
|
143
|
+
Operation.InsAfterTax = (0, aggregation_1.addition)(Operation.InsAfterLaborDisc, Operation.ECGST, Operation.ESGST, Operation.EIGST);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
return OperationsList;
|
|
150
|
+
}
|
|
151
|
+
static CalculatePartValues(PartsList, LaborList, isWorkOrder, isTaxable) {
|
|
152
|
+
PartsList = this.FilterValidPartItems(PartsList);
|
|
153
|
+
PartsList = this.ResetPartValuesIfInvalid(PartsList, isWorkOrder);
|
|
154
|
+
PartsList = this.GetPartsDiscountPrice(PartsList, LaborList, isWorkOrder);
|
|
155
|
+
PartsList = this.GetPartsAfterDiscount(PartsList, LaborList, isWorkOrder);
|
|
156
|
+
PartsList = this.GetPartsAfterTax(PartsList, LaborList, isWorkOrder, isTaxable);
|
|
157
|
+
PartsList = this.GetPartsPerItemAfterTax(PartsList);
|
|
158
|
+
return PartsList;
|
|
159
|
+
}
|
|
160
|
+
static FilterValidPartItems(PartsList) {
|
|
161
|
+
PartsList = PartsList.filter((Part) => {
|
|
162
|
+
if (tr_utils_1.TrUtils.IsNull(Part.CollId)) {
|
|
163
|
+
return Part;
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
return Part.Sts !== enums_1.LaborStatusEnum.Cancelled && Part.Sts !== enums_1.LaborStatusEnum.Declined;
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
return PartsList;
|
|
170
|
+
}
|
|
171
|
+
static ResetPartValuesIfInvalid(PartsList, isWorkOrder) {
|
|
172
|
+
PartsList.forEach((Part) => {
|
|
173
|
+
Part = this.ResetPartValueIfInvalid(Part, isWorkOrder);
|
|
174
|
+
});
|
|
175
|
+
return PartsList;
|
|
176
|
+
}
|
|
177
|
+
static ResetPartValueIfInvalid(Part, isWorkOrder) {
|
|
178
|
+
Part.Perc = tr_utils_1.TrUtils.SetPercToStringIfNull(Part.Perc);
|
|
179
|
+
Part.Disc = tr_utils_1.TrUtils.SetValueToZeroIfNull(Part.Disc);
|
|
180
|
+
Part.UnPr = tr_utils_1.TrUtils.SetValueToZeroIfNull(Part.UnPr);
|
|
181
|
+
Part.AssPr = tr_utils_1.TrUtils.SetValueToZeroIfNull(Part.AssPr);
|
|
182
|
+
Part.ACGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(Part.ACGST);
|
|
183
|
+
Part.ASGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(Part.ASGST);
|
|
184
|
+
Part.AIGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(Part.AIGST);
|
|
185
|
+
Part.CCGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(Part.CCGST);
|
|
186
|
+
Part.CSGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(Part.CSGST);
|
|
187
|
+
Part.CIGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(Part.CIGST);
|
|
188
|
+
Part.UnAmt = tr_utils_1.TrUtils.SetValueToZeroIfNull(Part.UnAmt);
|
|
189
|
+
Part.AssAmt = tr_utils_1.TrUtils.SetValueToZeroIfNull(Part.AssAmt);
|
|
190
|
+
Part.NetAmt = tr_utils_1.TrUtils.SetValueToZeroIfNull(Part.NetAmt);
|
|
191
|
+
Part.RecDisc = tr_utils_1.TrUtils.SetValueToZeroIfNull(Part.RecDisc);
|
|
192
|
+
if (!isWorkOrder) {
|
|
193
|
+
Part.EstPr = tr_utils_1.TrUtils.SetValueToZeroIfNull(Part.EstPr);
|
|
194
|
+
Part.ECGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(Part.ECGST);
|
|
195
|
+
Part.ESGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(Part.ESGST);
|
|
196
|
+
Part.EIGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(Part.EIGST);
|
|
197
|
+
Part.EstAmt = tr_utils_1.TrUtils.SetValueToZeroIfNull(Part.EstAmt);
|
|
198
|
+
}
|
|
199
|
+
return Part;
|
|
200
|
+
}
|
|
201
|
+
static GetPartsDiscountPrice(PartsList, LaborList, isWorkOrder) {
|
|
202
|
+
PartsList.forEach((Part) => {
|
|
203
|
+
if (tr_utils_1.TrUtils.IsNull(Part.CollId)) {
|
|
204
|
+
if (isWorkOrder) {
|
|
205
|
+
Part.CustDiscountedPrice = (0, aggregation_1.addition)(Part.Disc, Part.RecDisc);
|
|
206
|
+
}
|
|
207
|
+
else {
|
|
208
|
+
let LaborSts = this.GetPartParentStatus(Part, LaborList);
|
|
209
|
+
if (LaborSts === enums_1.LaborStatusEnum.New || LaborSts === enums_1.LaborStatusEnum.WtngForAppr) {
|
|
210
|
+
Part.CustDiscountedPrice = 0;
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
Part.CustDiscountedPrice = (0, aggregation_1.addition)(Part.Disc, Part.RecDisc);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
else {
|
|
218
|
+
if (isWorkOrder) {
|
|
219
|
+
Part.CustDiscountedPrice = (0, aggregation_1.addition)(Part.Disc, Part.RecDisc);
|
|
220
|
+
}
|
|
221
|
+
else {
|
|
222
|
+
if (Part.Sts === enums_1.LaborStatusEnum.New || Part.Sts === enums_1.LaborStatusEnum.WtngForAppr) {
|
|
223
|
+
Part.CustDiscountedPrice = 0;
|
|
224
|
+
}
|
|
225
|
+
else {
|
|
226
|
+
Part.CustDiscountedPrice = (0, aggregation_1.addition)(Part.Disc, Part.RecDisc);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
return PartsList;
|
|
232
|
+
}
|
|
233
|
+
static GetPartParentStatus(Part, LaborList) {
|
|
234
|
+
if (!tr_utils_1.TrUtils.IsNull(Part.OpId)) {
|
|
235
|
+
let index = LaborList.findIndex((Labor) => {
|
|
236
|
+
return Labor._id === Part.OpId;
|
|
237
|
+
});
|
|
238
|
+
return LaborList[index].Sts;
|
|
239
|
+
}
|
|
240
|
+
else {
|
|
241
|
+
return Part.Sts;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
static GetPartsAfterDiscount(PartsList, LaborList, isWorkOrder) {
|
|
245
|
+
PartsList.forEach((Part) => {
|
|
246
|
+
if (tr_utils_1.TrUtils.IsNull(Part.CollId)) {
|
|
247
|
+
let CustAfterPartDisc = 0;
|
|
248
|
+
let InsAfterPartDisc = 0;
|
|
249
|
+
if (isWorkOrder) {
|
|
250
|
+
CustAfterPartDisc = Part.NetAmt;
|
|
251
|
+
if (tr_utils_1.TrUtils.IsNull(Part.OpId)) {
|
|
252
|
+
InsAfterPartDisc = Part.AssAmt;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
else {
|
|
256
|
+
let LaborSts = this.GetPartParentStatus(Part, LaborList);
|
|
257
|
+
if (LaborSts === enums_1.LaborStatusEnum.New || LaborSts === enums_1.LaborStatusEnum.WtngForAppr) {
|
|
258
|
+
CustAfterPartDisc = Part.EstAmt;
|
|
259
|
+
}
|
|
260
|
+
else {
|
|
261
|
+
CustAfterPartDisc = Part.NetAmt;
|
|
262
|
+
if (tr_utils_1.TrUtils.IsNull(Part.OpId)) {
|
|
263
|
+
InsAfterPartDisc = Part.AssAmt;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
Part.CustAfterPartDisc = CustAfterPartDisc;
|
|
268
|
+
Part.InsAfterPartDisc = InsAfterPartDisc;
|
|
269
|
+
}
|
|
270
|
+
else {
|
|
271
|
+
let CustAfterPartDisc = 0;
|
|
272
|
+
let InsAfterPartDisc = 0;
|
|
273
|
+
if (Part.PBy === enums_1.PayTypeEnum.Customer) {
|
|
274
|
+
if (isWorkOrder) {
|
|
275
|
+
CustAfterPartDisc = Part.NetAmt;
|
|
276
|
+
}
|
|
277
|
+
else {
|
|
278
|
+
if (Part.Sts === enums_1.LaborStatusEnum.New || Part.Sts === enums_1.LaborStatusEnum.WtngForAppr) {
|
|
279
|
+
CustAfterPartDisc = Part.EstAmt;
|
|
280
|
+
}
|
|
281
|
+
else {
|
|
282
|
+
CustAfterPartDisc = Part.NetAmt;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
else {
|
|
287
|
+
if (isWorkOrder) {
|
|
288
|
+
CustAfterPartDisc = Part.NetAmt;
|
|
289
|
+
InsAfterPartDisc = Part.AssAmt;
|
|
290
|
+
}
|
|
291
|
+
else {
|
|
292
|
+
if (Part.Sts === enums_1.LaborStatusEnum.New || Part.Sts === enums_1.LaborStatusEnum.WtngForAppr) {
|
|
293
|
+
InsAfterPartDisc = Part.EstAmt;
|
|
294
|
+
}
|
|
295
|
+
else {
|
|
296
|
+
CustAfterPartDisc = Part.NetAmt;
|
|
297
|
+
InsAfterPartDisc = Part.AssAmt;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
Part.CustAfterPartDisc = CustAfterPartDisc;
|
|
302
|
+
Part.InsAfterPartDisc = InsAfterPartDisc;
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
return PartsList;
|
|
306
|
+
}
|
|
307
|
+
static GetPartsAfterTax(PartsList, LaborList, isWorkOrder, isTaxable) {
|
|
308
|
+
PartsList.forEach((Part) => {
|
|
309
|
+
if (!isTaxable) {
|
|
310
|
+
Part.CustAfterTax = Part.CustAfterPartDisc;
|
|
311
|
+
Part.InsAfterTax = Part.InsAfterPartDisc;
|
|
312
|
+
}
|
|
313
|
+
else {
|
|
314
|
+
if (tr_utils_1.TrUtils.IsNull(Part.CollId)) {
|
|
315
|
+
if (isWorkOrder) {
|
|
316
|
+
Part.CustAfterTax = (0, aggregation_1.addition)(Part.CustAfterPartDisc, Part.CCGST, Part.CSGST, Part.CIGST);
|
|
317
|
+
if (tr_utils_1.TrUtils.IsNull(Part.OpId)) {
|
|
318
|
+
Part.InsAfterTax = (0, aggregation_1.addition)(Part.InsAfterPartDisc, Part.ACGST, Part.ASGST, Part.AIGST);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
else {
|
|
322
|
+
let LaborSts = this.GetPartParentStatus(Part, LaborList);
|
|
323
|
+
if (LaborSts === enums_1.LaborStatusEnum.New || LaborSts === enums_1.LaborStatusEnum.WtngForAppr) {
|
|
324
|
+
Part.CustAfterTax = (0, aggregation_1.addition)(Part.CustAfterPartDisc, Part.ECGST, Part.ESGST, Part.EIGST);
|
|
325
|
+
}
|
|
326
|
+
else {
|
|
327
|
+
Part.CustAfterTax = (0, aggregation_1.addition)(Part.CustAfterPartDisc, Part.CCGST, Part.CSGST, Part.CIGST);
|
|
328
|
+
if (tr_utils_1.TrUtils.IsNull(Part.OpId)) {
|
|
329
|
+
Part.InsAfterTax = (0, aggregation_1.addition)(Part.InsAfterPartDisc, Part.ACGST, Part.ASGST, Part.AIGST);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
// Part.InsAfterTax = 0;
|
|
334
|
+
}
|
|
335
|
+
else {
|
|
336
|
+
if (Part.PBy === enums_1.PayTypeEnum.Customer) {
|
|
337
|
+
if (isWorkOrder) {
|
|
338
|
+
Part.CustAfterTax = (0, aggregation_1.addition)(Part.CustAfterPartDisc, Part.CCGST, Part.CSGST, Part.CIGST);
|
|
339
|
+
}
|
|
340
|
+
else {
|
|
341
|
+
if (Part.Sts !== enums_1.LaborStatusEnum.New && Part.Sts !== enums_1.LaborStatusEnum.WtngForAppr) {
|
|
342
|
+
Part.CustAfterTax = (0, aggregation_1.addition)(Part.CustAfterPartDisc, Part.CCGST, Part.CSGST, Part.CIGST);
|
|
343
|
+
}
|
|
344
|
+
else {
|
|
345
|
+
Part.CustAfterTax = (0, aggregation_1.addition)(Part.CustAfterPartDisc, Part.ECGST, Part.ESGST, Part.EIGST);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
Part.InsAfterTax = 0;
|
|
349
|
+
}
|
|
350
|
+
else {
|
|
351
|
+
if (isWorkOrder) {
|
|
352
|
+
Part.CustAfterTax = (0, aggregation_1.addition)(Part.CustAfterPartDisc, Part.CCGST, Part.CSGST, Part.CIGST);
|
|
353
|
+
Part.InsAfterTax = (0, aggregation_1.addition)(Part.InsAfterPartDisc, Part.ACGST, Part.ASGST, Part.AIGST);
|
|
354
|
+
}
|
|
355
|
+
else {
|
|
356
|
+
if (Part.Sts !== enums_1.LaborStatusEnum.New && Part.Sts !== enums_1.LaborStatusEnum.WtngForAppr) {
|
|
357
|
+
Part.CustAfterTax = (0, aggregation_1.addition)(Part.CustAfterPartDisc, Part.CCGST, Part.CSGST, Part.CIGST);
|
|
358
|
+
Part.InsAfterTax = (0, aggregation_1.addition)(Part.InsAfterPartDisc, Part.ACGST, Part.ASGST, Part.AIGST);
|
|
359
|
+
}
|
|
360
|
+
else {
|
|
361
|
+
Part.CustAfterTax = 0;
|
|
362
|
+
Part.InsAfterTax = (0, aggregation_1.addition)(Part.InsAfterPartDisc, Part.ECGST, Part.ESGST, Part.EIGST);
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
});
|
|
369
|
+
return PartsList;
|
|
370
|
+
}
|
|
371
|
+
static GetPartsPerItemAfterTax(PartsList) {
|
|
372
|
+
PartsList.forEach((Part) => {
|
|
373
|
+
Part.CustAfterTaxPerItem = (0, aggregation_1.division)(Part.CustAfterTax, Part.Qty);
|
|
374
|
+
Part.InsAfterTaxPerItem = (0, aggregation_1.division)(Part.InsAfterTax, Part.Qty);
|
|
375
|
+
});
|
|
376
|
+
return PartsList;
|
|
377
|
+
}
|
|
378
|
+
static GetROTotalsData(argRecordData, dupRecordData, TaxCodes, withItems, detailedInfo, isWorkOrder, isRoundable) {
|
|
379
|
+
dupRecordData = this.ResetDiscountValuesIfInvalid(dupRecordData);
|
|
380
|
+
argRecordData = this.SetMainDiscountValues(argRecordData, dupRecordData, detailedInfo);
|
|
381
|
+
argRecordData = this.GetFinalCustomerTotalsData(argRecordData, dupRecordData, isWorkOrder, detailedInfo, isRoundable);
|
|
382
|
+
argRecordData = this.GetFinalInsuranceTotalsData(argRecordData, dupRecordData, detailedInfo, isWorkOrder);
|
|
383
|
+
if (detailedInfo) {
|
|
384
|
+
argRecordData = this.GetDetailedTotalsData(argRecordData, dupRecordData, TaxCodes, isWorkOrder);
|
|
385
|
+
}
|
|
386
|
+
if (withItems) {
|
|
387
|
+
argRecordData.Ops = dupRecordData.Ops;
|
|
388
|
+
argRecordData.Parts = dupRecordData.Parts;
|
|
389
|
+
argRecordData.Colli = dupRecordData.Colli;
|
|
390
|
+
}
|
|
391
|
+
return argRecordData;
|
|
392
|
+
}
|
|
393
|
+
static ResetDiscountValuesIfInvalid(dupRecordData) {
|
|
394
|
+
dupRecordData.LPerc = tr_utils_1.TrUtils.SetPercToStringIfNull(dupRecordData.LPerc);
|
|
395
|
+
dupRecordData.PPerc = tr_utils_1.TrUtils.SetPercToStringIfNull(dupRecordData.PPerc);
|
|
396
|
+
dupRecordData.Perc = tr_utils_1.TrUtils.SetPercToStringIfNull(dupRecordData.Perc);
|
|
397
|
+
dupRecordData.LDisc = tr_utils_1.TrUtils.SetValueToZeroIfNull(dupRecordData.LDisc);
|
|
398
|
+
dupRecordData.PDisc = tr_utils_1.TrUtils.SetValueToZeroIfNull(dupRecordData.PDisc);
|
|
399
|
+
dupRecordData.Disc = tr_utils_1.TrUtils.SetValueToZeroIfNull(dupRecordData.Disc);
|
|
400
|
+
return dupRecordData;
|
|
401
|
+
}
|
|
402
|
+
static SetMainDiscountValues(argRecordData, dupRecordData, detailedInfo) {
|
|
403
|
+
argRecordData.LDisc = dupRecordData.LDisc;
|
|
404
|
+
argRecordData.LPerc = dupRecordData.LPerc;
|
|
405
|
+
argRecordData.PDisc = dupRecordData.PDisc;
|
|
406
|
+
argRecordData.PPerc = dupRecordData.PPerc;
|
|
407
|
+
argRecordData.Disc = dupRecordData.Disc;
|
|
408
|
+
argRecordData.Perc = dupRecordData.Perc;
|
|
409
|
+
if (detailedInfo) {
|
|
410
|
+
argRecordData.FixedLDisc = dupRecordData.LDisc;
|
|
411
|
+
argRecordData.FixedPDisc = dupRecordData.PDisc;
|
|
412
|
+
argRecordData.FixedDisc = dupRecordData.Disc;
|
|
413
|
+
}
|
|
414
|
+
return argRecordData;
|
|
415
|
+
}
|
|
416
|
+
static GetFinalCustomerTotalsData(argRecordData, dupRecordData, isWorkOrder, detailedInfo, isRoundable) {
|
|
417
|
+
let CustomerAfterDiscTotals = this.GetCustSubTotal(dupRecordData.Ops, dupRecordData.Parts);
|
|
418
|
+
let CustLaborTaxTotal = this.GetCustLaborTaxTotal(dupRecordData.Ops, tr_utils_1.TrUtils.isTaxable(dupRecordData.Settings.Tax), isWorkOrder);
|
|
419
|
+
let CustPartTaxTotal = this.GetCustPartsTaxTotal(dupRecordData.Ops, dupRecordData.Parts, tr_utils_1.TrUtils.isTaxable(dupRecordData.Settings.Tax), isWorkOrder);
|
|
420
|
+
let CustLaborDiscTotal = this.GetCustLaborDiscountedTotal(dupRecordData.Ops, tr_utils_1.TrUtils.isTaxable(dupRecordData.Settings.Tax), dupRecordData);
|
|
421
|
+
let CustPartsDiscTotal = this.GetCustPartDiscountedTotal(dupRecordData.Parts, tr_utils_1.TrUtils.isTaxable(dupRecordData.Settings.Tax), dupRecordData);
|
|
422
|
+
let CustLaborTotalAfterDisc = this.GetCustLaborTotalAfterDiscount(dupRecordData.Ops);
|
|
423
|
+
let CustPartsTotalAfterDisc = this.GetCustPartsTotalAfterDiscount(dupRecordData.Parts);
|
|
424
|
+
argRecordData.STotal = (0, aggregation_1.addition)(CustLaborDiscTotal, CustPartsDiscTotal, CustLaborTotalAfterDisc, CustPartsTotalAfterDisc);
|
|
425
|
+
argRecordData.CustLaborTotalBeforeDisc = (0, aggregation_1.addition)(argRecordData.CustLaborTotalAfterDisc, argRecordData.CustLaborDiscTotal);
|
|
426
|
+
argRecordData.CustPartsTotalBeforeDisc = (0, aggregation_1.addition)(argRecordData.CustPartsTotalAfterDisc, argRecordData.CustPartsDiscTotal);
|
|
427
|
+
argRecordData.SubTotal = tr_utils_1.TrUtils.FixedTo(CustomerAfterDiscTotals);
|
|
428
|
+
let CustTotal = this.GetCustomerTotalBasedOnTaxType(dupRecordData, CustLaborTaxTotal, CustPartTaxTotal, dupRecordData.Ops, dupRecordData.Parts, tr_utils_1.TrUtils.isTaxable(dupRecordData.Settings.Tax));
|
|
429
|
+
if (detailedInfo) {
|
|
430
|
+
argRecordData.FixedSubTotal = tr_utils_1.TrUtils.FixedTo(CustomerAfterDiscTotals);
|
|
431
|
+
argRecordData.FixedTotal = tr_utils_1.TrUtils.FixedTo(CustTotal);
|
|
432
|
+
}
|
|
433
|
+
if (isRoundable) {
|
|
434
|
+
argRecordData.Round = (0, aggregation_1.subtraction)(Math.round(CustTotal), CustTotal);
|
|
435
|
+
argRecordData.Total = Math.round(CustTotal);
|
|
436
|
+
}
|
|
437
|
+
else {
|
|
438
|
+
argRecordData.Total = tr_utils_1.TrUtils.FixedTo(CustTotal);
|
|
439
|
+
}
|
|
440
|
+
return argRecordData;
|
|
441
|
+
}
|
|
442
|
+
static GetCustSubTotal(LaborList, PartsList) {
|
|
443
|
+
let LaborTotalAfterDisc = this.GetCustLaborTotalAfterDiscount(LaborList);
|
|
444
|
+
let PartsTotalAfterDisc = this.GetCustPartsTotalAfterDiscount(PartsList);
|
|
445
|
+
return (0, aggregation_1.addition)(LaborTotalAfterDisc, PartsTotalAfterDisc);
|
|
446
|
+
}
|
|
447
|
+
static GetCustLaborTotalAfterDiscount(LaborList) {
|
|
448
|
+
let LaborTotalAfterDisc = 0;
|
|
449
|
+
LaborList.forEach((Labor) => {
|
|
450
|
+
LaborTotalAfterDisc = (0, aggregation_1.addition)(LaborTotalAfterDisc, Labor.CustAfterLaborDisc);
|
|
451
|
+
});
|
|
452
|
+
return LaborTotalAfterDisc;
|
|
453
|
+
}
|
|
454
|
+
static GetCustPartsTotalAfterDiscount(PartsList) {
|
|
455
|
+
let PartsTotalAfterDisc = 0;
|
|
456
|
+
PartsList.forEach((Part) => {
|
|
457
|
+
PartsTotalAfterDisc = (0, aggregation_1.addition)(PartsTotalAfterDisc, Part.CustAfterPartDisc);
|
|
458
|
+
});
|
|
459
|
+
return PartsTotalAfterDisc;
|
|
460
|
+
}
|
|
461
|
+
static GetCustLaborTaxTotal(opCodesList, IsTaxable, isWorkOrder) {
|
|
462
|
+
let TotalTaxAmt = 0;
|
|
463
|
+
if (IsTaxable) {
|
|
464
|
+
opCodesList.forEach((Labor) => {
|
|
465
|
+
if (isWorkOrder) {
|
|
466
|
+
// if (Labor.PBy === PayTypeEnum.Customer) {
|
|
467
|
+
if ((Labor.PBy === enums_1.PayTypeEnum.Customer || Labor.PBy === enums_1.PayTypeEnum.Shared)) {
|
|
468
|
+
TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Labor.CCGST, Labor.CSGST, Labor.CIGST);
|
|
469
|
+
}
|
|
470
|
+
// }else{
|
|
471
|
+
// TotalTaxAmt = addition(TotalTaxAmt , Labor.ACGST , Labor.ASGST , Labor.AIGST);
|
|
472
|
+
// }
|
|
473
|
+
}
|
|
474
|
+
else {
|
|
475
|
+
if (Labor.Sts !== enums_1.LaborStatusEnum.New && Labor.Sts !== enums_1.LaborStatusEnum.WtngForAppr) {
|
|
476
|
+
TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Labor.CCGST, Labor.CSGST, Labor.CIGST);
|
|
477
|
+
}
|
|
478
|
+
else {
|
|
479
|
+
if (Labor.PBy === enums_1.PayTypeEnum.Customer) {
|
|
480
|
+
TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Labor.ECGST, Labor.ESGST, Labor.EIGST);
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
});
|
|
485
|
+
}
|
|
486
|
+
return TotalTaxAmt;
|
|
487
|
+
}
|
|
488
|
+
static GetCustPartsTaxTotal(OpsList, PartsList, IsTaxable, isWorkOrder) {
|
|
489
|
+
let TotalTaxAmt = 0;
|
|
490
|
+
if (IsTaxable) {
|
|
491
|
+
PartsList.forEach((Part) => {
|
|
492
|
+
if (!tr_utils_1.TrUtils.IsNull(Part.CollId)) {
|
|
493
|
+
if (isWorkOrder) {
|
|
494
|
+
if ((Part.PBy === enums_1.PayTypeEnum.Customer || Part.PBy === enums_1.PayTypeEnum.Shared)) {
|
|
495
|
+
TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Part.CCGST, Part.CSGST, Part.CIGST);
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
else {
|
|
499
|
+
if (Part.Sts !== enums_1.LaborStatusEnum.New && Part.Sts !== enums_1.LaborStatusEnum.WtngForAppr) {
|
|
500
|
+
TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Part.CCGST, Part.CSGST, Part.CIGST);
|
|
501
|
+
}
|
|
502
|
+
else {
|
|
503
|
+
if (Part.PBy === enums_1.PayTypeEnum.Customer) {
|
|
504
|
+
TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Part.ECGST, Part.ESGST, Part.EIGST);
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
else {
|
|
510
|
+
if (isWorkOrder) {
|
|
511
|
+
// if (Part.PBy === PayTypeEnum.Customer) {
|
|
512
|
+
if ((Part.PBy === enums_1.PayTypeEnum.Customer || Part.PBy === enums_1.PayTypeEnum.Shared)) {
|
|
513
|
+
TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Part.CCGST, Part.CSGST, Part.CIGST);
|
|
514
|
+
}
|
|
515
|
+
// }else{
|
|
516
|
+
// TotalTaxAmt = addition(TotalTaxAmt , Part.ACGST , Part.ASGST , Part.AIGST);
|
|
517
|
+
// }
|
|
518
|
+
}
|
|
519
|
+
else {
|
|
520
|
+
let Index = OpsList.findIndex((labor) => {
|
|
521
|
+
return labor._id === Part.OpId;
|
|
522
|
+
});
|
|
523
|
+
if (Index !== -1) {
|
|
524
|
+
if (OpsList[Index].Sts !== enums_1.LaborStatusEnum.New && OpsList[Index].Sts !== enums_1.LaborStatusEnum.WtngForAppr) {
|
|
525
|
+
TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Part.CCGST, Part.CSGST, Part.CIGST);
|
|
526
|
+
}
|
|
527
|
+
else {
|
|
528
|
+
TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Part.ECGST, Part.ESGST, Part.EIGST);
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
else {
|
|
532
|
+
TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Part.CCGST, Part.CSGST, Part.CIGST);
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
});
|
|
537
|
+
}
|
|
538
|
+
return TotalTaxAmt;
|
|
539
|
+
}
|
|
540
|
+
static GetCustomerTotalBasedOnTaxType(dupRecordData, LaborTaxAmount, PartsTaxAmount, LaborList, PartsList, IsTaxable) {
|
|
541
|
+
let SubTotalWithTax = 0;
|
|
542
|
+
let LaborTotalAfterDisc = this.GetCustLaborTotalAfterDiscount(LaborList);
|
|
543
|
+
let PartsTotalAfterDisc = this.GetCustPartsTotalAfterDiscount(PartsList);
|
|
544
|
+
if (IsTaxable) {
|
|
545
|
+
SubTotalWithTax = (0, aggregation_1.addition)(LaborTotalAfterDisc, PartsTotalAfterDisc, LaborTaxAmount, PartsTaxAmount);
|
|
546
|
+
}
|
|
547
|
+
else {
|
|
548
|
+
SubTotalWithTax = (0, aggregation_1.addition)((0, aggregation_1.subtraction)(LaborTotalAfterDisc, dupRecordData.LDisc), (0, aggregation_1.subtraction)((0, aggregation_1.subtraction)(PartsTotalAfterDisc, dupRecordData.PDisc), dupRecordData.Disc));
|
|
549
|
+
}
|
|
550
|
+
return SubTotalWithTax;
|
|
551
|
+
}
|
|
552
|
+
static GetFinalInsuranceTotalsData(argRecordData, dupRecordData, detailedInfo, isWorkOrder) {
|
|
553
|
+
let InsuranceAfterDiscTotals = this.GetInsSubTotal(dupRecordData.Ops, dupRecordData.Parts);
|
|
554
|
+
let InsLaborTaxTotal = this.GetInsLaborTaxTotal(dupRecordData.Ops, tr_utils_1.TrUtils.isTaxable(dupRecordData.Settings.Tax), isWorkOrder);
|
|
555
|
+
let InsPartTaxTotal = this.GetInsPartsTaxTotal(dupRecordData.Parts, tr_utils_1.TrUtils.isTaxable(dupRecordData.Settings.Tax), isWorkOrder);
|
|
556
|
+
let InsTotal = this.GetInsuranceTotalBasedOnTaxType(InsuranceAfterDiscTotals, InsLaborTaxTotal, InsPartTaxTotal, tr_utils_1.TrUtils.isTaxable(dupRecordData.Settings.Tax));
|
|
557
|
+
argRecordData.InsTotal = tr_utils_1.TrUtils.FixedTo(InsTotal);
|
|
558
|
+
if (detailedInfo) {
|
|
559
|
+
argRecordData.FixedInsTotal = tr_utils_1.TrUtils.FixedTo(InsTotal);
|
|
560
|
+
}
|
|
561
|
+
return argRecordData;
|
|
562
|
+
}
|
|
563
|
+
static GetInsSubTotal(LaborList, PartsList) {
|
|
564
|
+
let LaborTotalAfterDisc = this.GetInsLaborTotalAfterDiscount(LaborList);
|
|
565
|
+
let PartsTotalAfterDisc = this.GetInsPartsTotalAfterDiscount(PartsList);
|
|
566
|
+
return (0, aggregation_1.addition)(LaborTotalAfterDisc, PartsTotalAfterDisc);
|
|
567
|
+
}
|
|
568
|
+
static GetInsLaborTotalAfterDiscount(LaborList) {
|
|
569
|
+
let LaborTotalAfterDisc = 0;
|
|
570
|
+
LaborList.forEach((Labor) => {
|
|
571
|
+
LaborTotalAfterDisc = (0, aggregation_1.addition)(LaborTotalAfterDisc, Labor.InsAfterLaborDisc);
|
|
572
|
+
});
|
|
573
|
+
return LaborTotalAfterDisc;
|
|
574
|
+
}
|
|
575
|
+
static GetInsPartsTotalAfterDiscount(PartsList) {
|
|
576
|
+
let PartsTotalAfterDisc = 0;
|
|
577
|
+
PartsList.forEach((Part) => {
|
|
578
|
+
PartsTotalAfterDisc = (0, aggregation_1.addition)(PartsTotalAfterDisc, Part.InsAfterPartDisc);
|
|
579
|
+
});
|
|
580
|
+
return PartsTotalAfterDisc;
|
|
581
|
+
}
|
|
582
|
+
static GetInsLaborTaxTotal(opCodesList, IsTaxable, isWorkOrder) {
|
|
583
|
+
let TotalTaxAmt = 0;
|
|
584
|
+
if (IsTaxable) {
|
|
585
|
+
opCodesList.forEach((Labor) => {
|
|
586
|
+
if (isWorkOrder) {
|
|
587
|
+
if ((Labor.PBy === enums_1.PayTypeEnum.Insurance || Labor.PBy === enums_1.PayTypeEnum.Shared)) {
|
|
588
|
+
TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Labor.ACGST, Labor.ASGST, Labor.AIGST);
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
else {
|
|
592
|
+
if (Labor.Sts !== enums_1.LaborStatusEnum.New && Labor.Sts !== enums_1.LaborStatusEnum.WtngForAppr) {
|
|
593
|
+
TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Labor.ACGST, Labor.ASGST, Labor.AIGST);
|
|
594
|
+
}
|
|
595
|
+
else {
|
|
596
|
+
if (Labor.PBy === enums_1.PayTypeEnum.Insurance || Labor.PBy === enums_1.PayTypeEnum.Shared) {
|
|
597
|
+
TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Labor.ECGST, Labor.ESGST, Labor.EIGST);
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
});
|
|
602
|
+
}
|
|
603
|
+
return TotalTaxAmt;
|
|
604
|
+
}
|
|
605
|
+
static GetInsPartsTaxTotal(PartsList, IsTaxable, isWorkOrder) {
|
|
606
|
+
let TotalTaxAmt = 0;
|
|
607
|
+
if (IsTaxable) {
|
|
608
|
+
PartsList.forEach((Part) => {
|
|
609
|
+
if (!tr_utils_1.TrUtils.IsNull(Part.CollId) || Part.PBy === enums_1.PayTypeEnum.Insurance || Part.PBy === enums_1.PayTypeEnum.Shared) {
|
|
610
|
+
if (isWorkOrder) {
|
|
611
|
+
if ((Part.PBy === enums_1.PayTypeEnum.Insurance || Part.PBy === enums_1.PayTypeEnum.Shared)) {
|
|
612
|
+
TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Part.ACGST, Part.ASGST, Part.AIGST);
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
else {
|
|
616
|
+
if (Part.Sts !== enums_1.LaborStatusEnum.New && Part.Sts !== enums_1.LaborStatusEnum.WtngForAppr) {
|
|
617
|
+
TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Part.ACGST, Part.ASGST, Part.AIGST);
|
|
618
|
+
}
|
|
619
|
+
else {
|
|
620
|
+
if (Part.PBy === enums_1.PayTypeEnum.Insurance || Part.PBy === enums_1.PayTypeEnum.Shared) {
|
|
621
|
+
TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Part.ECGST, Part.ESGST, Part.EIGST);
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
});
|
|
627
|
+
}
|
|
628
|
+
return TotalTaxAmt;
|
|
629
|
+
}
|
|
630
|
+
static GetInsuranceTotalBasedOnTaxType(SubTotal, LaborTaxAmount, PartsTaxAmount, IsTaxable) {
|
|
631
|
+
let InsTotal = 0;
|
|
632
|
+
if (IsTaxable) {
|
|
633
|
+
InsTotal = (0, aggregation_1.addition)(SubTotal, LaborTaxAmount, PartsTaxAmount);
|
|
634
|
+
}
|
|
635
|
+
else {
|
|
636
|
+
InsTotal = (SubTotal);
|
|
637
|
+
}
|
|
638
|
+
return InsTotal;
|
|
639
|
+
}
|
|
640
|
+
static GetDetailedTotalsData(argRecordData, dupRecordData, TaxCodes, isWorkOrder) {
|
|
641
|
+
argRecordData.InsLaborDiscTotal = 0;
|
|
642
|
+
argRecordData.InsPartsDiscTotal = 0;
|
|
643
|
+
argRecordData.InsLaborTotalAfterDisc = this.GetInsLaborTotalAfterDiscount(dupRecordData.Ops);
|
|
644
|
+
argRecordData.InsPartsTotalAfterDisc = this.GetInsPartsTotalAfterDiscount(dupRecordData.Parts);
|
|
645
|
+
argRecordData.InsLaborTotalBeforeDisc = (0, aggregation_1.addition)(argRecordData.InsLaborTotalAfterDisc, argRecordData.InsLaborDiscTotal);
|
|
646
|
+
argRecordData.InsPartsTotalBeforeDisc = (0, aggregation_1.addition)(argRecordData.InsPartsTotalAfterDisc, argRecordData.InsPartsDiscTotal);
|
|
647
|
+
argRecordData.InsLaborITax = this.GetInsLaborTaxTotal(dupRecordData.Ops, tr_utils_1.TrUtils.isTaxable(dupRecordData.Settings.Tax), isWorkOrder);
|
|
648
|
+
argRecordData.InsLaborCGST = this.GetInsLaborCGSTTaxTotal(dupRecordData.Ops, tr_utils_1.TrUtils.isTaxable(dupRecordData.Settings.Tax), isWorkOrder);
|
|
649
|
+
argRecordData.InsLaborIGST = this.GetInsLaborIGSTTaxTotal(dupRecordData.Ops, tr_utils_1.TrUtils.isTaxable(dupRecordData.Settings.Tax), isWorkOrder);
|
|
650
|
+
argRecordData.InsLaborSGST = this.GetInsLaborSGSTTaxTotal(dupRecordData.Ops, tr_utils_1.TrUtils.isTaxable(dupRecordData.Settings.Tax), isWorkOrder);
|
|
651
|
+
argRecordData.InsPartITax = this.GetInsPartsTaxTotal(dupRecordData.Parts, tr_utils_1.TrUtils.isTaxable(dupRecordData.Settings.Tax), isWorkOrder);
|
|
652
|
+
argRecordData.InsPartCGST = this.GetInsPartCGSTTaxTotal(dupRecordData.Parts, tr_utils_1.TrUtils.isTaxable(dupRecordData.Settings.Tax), isWorkOrder);
|
|
653
|
+
argRecordData.InsPartIGST = this.GetInsPartIGSTTaxTotal(dupRecordData.Parts, tr_utils_1.TrUtils.isTaxable(dupRecordData.Settings.Tax), isWorkOrder);
|
|
654
|
+
argRecordData.InsPartSGST = this.GetInsPartSGSTTaxTotal(dupRecordData.Parts, tr_utils_1.TrUtils.isTaxable(dupRecordData.Settings.Tax), isWorkOrder);
|
|
655
|
+
argRecordData.InsLaborTotalAfterTax = (0, aggregation_1.addition)(argRecordData.InsLaborTotalAfterDisc, argRecordData.InsLaborITax);
|
|
656
|
+
argRecordData.InsPartsTotalAfterTax = (0, aggregation_1.addition)(argRecordData.InsPartsTotalAfterDisc, argRecordData.InsPartITax);
|
|
657
|
+
argRecordData.CustLaborDiscTotal = this.GetCustLaborDiscountedTotal(dupRecordData.Ops, tr_utils_1.TrUtils.isTaxable(dupRecordData.Settings.Tax), dupRecordData);
|
|
658
|
+
argRecordData.CustPartsDiscTotal = this.GetCustPartDiscountedTotal(dupRecordData.Parts, tr_utils_1.TrUtils.isTaxable(dupRecordData.Settings.Tax), dupRecordData);
|
|
659
|
+
argRecordData.CustLaborTotalAfterDisc = this.GetCustLaborTotalAfterDiscount(dupRecordData.Ops);
|
|
660
|
+
argRecordData.CustPartsTotalAfterDisc = this.GetCustPartsTotalAfterDiscount(dupRecordData.Parts);
|
|
661
|
+
argRecordData.CustLaborTotalBeforeDisc = (0, aggregation_1.addition)(argRecordData.CustLaborTotalAfterDisc, argRecordData.CustLaborDiscTotal);
|
|
662
|
+
argRecordData.CustPartsTotalBeforeDisc = (0, aggregation_1.addition)(argRecordData.CustPartsTotalAfterDisc, argRecordData.CustPartsDiscTotal);
|
|
663
|
+
argRecordData.CustLaborITax = this.GetCustLaborTaxTotal(dupRecordData.Ops, tr_utils_1.TrUtils.isTaxable(dupRecordData.Settings.Tax), isWorkOrder);
|
|
664
|
+
argRecordData.CustLaborSGST = this.GetCustLaborSGSTTaxTotal(dupRecordData.Ops, tr_utils_1.TrUtils.isTaxable(dupRecordData.Settings.Tax), isWorkOrder);
|
|
665
|
+
argRecordData.CustLaborCGST = this.GetCustLaborCGSTTaxTotal(dupRecordData.Ops, tr_utils_1.TrUtils.isTaxable(dupRecordData.Settings.Tax), isWorkOrder);
|
|
666
|
+
argRecordData.CustLaborIGST = this.GetCustLaborIGSTTaxTotal(dupRecordData.Ops, tr_utils_1.TrUtils.isTaxable(dupRecordData.Settings.Tax), isWorkOrder);
|
|
667
|
+
argRecordData.CustPartITax = this.GetCustPartsTaxTotal(dupRecordData.Ops, dupRecordData.Parts, tr_utils_1.TrUtils.isTaxable(dupRecordData.Settings.Tax), isWorkOrder);
|
|
668
|
+
argRecordData.CustPartCGST = this.GetCustPartCGSTTaxTotal(dupRecordData.Ops, dupRecordData.Parts, tr_utils_1.TrUtils.isTaxable(dupRecordData.Settings.Tax), isWorkOrder);
|
|
669
|
+
argRecordData.CustPartIGST = this.GetCustPartIGSTTaxTotal(dupRecordData.Ops, dupRecordData.Parts, tr_utils_1.TrUtils.isTaxable(dupRecordData.Settings.Tax), isWorkOrder);
|
|
670
|
+
argRecordData.CustPartSGST = this.GetCustPartSGSTTaxTotal(dupRecordData.Ops, dupRecordData.Parts, tr_utils_1.TrUtils.isTaxable(dupRecordData.Settings.Tax), isWorkOrder);
|
|
671
|
+
argRecordData.CustLaborLDiscAmount = this.GetLaborLDiscAmount(argRecordData.CustLaborTotalAfterDisc, argRecordData.LDisc);
|
|
672
|
+
argRecordData.CustPartsPDiscAmount = this.GetPartsPDiscAmount(argRecordData.CustPartsTotalAfterDisc, argRecordData.PDisc);
|
|
673
|
+
argRecordData.CustLaborAfterLDisc = argRecordData.CustLaborTotalAfterDisc;
|
|
674
|
+
argRecordData.CustPartsAfterPDisc = argRecordData.CustPartsTotalAfterDisc;
|
|
675
|
+
argRecordData.CustLaborAfterTax = (0, aggregation_1.addition)(argRecordData.CustLaborITax, argRecordData.CustLaborAfterLDisc);
|
|
676
|
+
argRecordData.CustPartAfterTax = (0, aggregation_1.addition)(argRecordData.CustPartITax, argRecordData.CustPartsAfterPDisc);
|
|
677
|
+
argRecordData.CustTaxGroupData = this.GetCustPartsTaxGrouping(dupRecordData.Parts, TaxCodes, isWorkOrder);
|
|
678
|
+
argRecordData.InsTaxGroupData = this.GetInsPartsTaxGrouping(dupRecordData.Parts, TaxCodes);
|
|
679
|
+
argRecordData.CustTotalRoundedBy = argRecordData.Round;
|
|
680
|
+
argRecordData.InsTotalRoundedBy = tr_utils_1.TrUtils.FixedTo((0, aggregation_1.subtraction)(Math.round(argRecordData.InsTotal), argRecordData.InsTotal));
|
|
681
|
+
argRecordData.CustRoundedTotal = argRecordData.Total;
|
|
682
|
+
argRecordData.InsRoundedTotal = Math.round(argRecordData.InsTotal);
|
|
683
|
+
for (var key in argRecordData) {
|
|
684
|
+
if (key !== 'Total' && key !== 'InsTotal' && key !== 'SubTotal' &&
|
|
685
|
+
key !== 'LDisc' && key !== 'LPerc' && key !== 'PDisc' &&
|
|
686
|
+
key !== 'PPerc' && key !== 'Disc' && key !== 'Perc' && key !== 'Tax'
|
|
687
|
+
&& typeof argRecordData[key] === 'number') {
|
|
688
|
+
argRecordData[key] = tr_utils_1.TrUtils.FixPriceValue(argRecordData[key]);
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
return argRecordData;
|
|
692
|
+
}
|
|
693
|
+
static GetCustLaborDiscountedTotal(LaborList, isTaxable, finalTotalsData) {
|
|
694
|
+
let LaborDiscountedTotal = 0;
|
|
695
|
+
let overallLaborDisc = 0;
|
|
696
|
+
if (!isTaxable) {
|
|
697
|
+
overallLaborDisc = tr_utils_1.TrUtils.SetValueToZeroIfNull(finalTotalsData.LDisc);
|
|
698
|
+
}
|
|
699
|
+
LaborList.forEach((Labor) => {
|
|
700
|
+
LaborDiscountedTotal = (0, aggregation_1.addition)(LaborDiscountedTotal, Labor.CustDiscountedPrice);
|
|
701
|
+
});
|
|
702
|
+
return (0, aggregation_1.addition)(LaborDiscountedTotal, overallLaborDisc);
|
|
703
|
+
}
|
|
704
|
+
static GetCustPartDiscountedTotal(PartsList, isTaxable, finalTotalsData) {
|
|
705
|
+
let PartsDiscountedTotal = 0;
|
|
706
|
+
let overallPartDisc = 0;
|
|
707
|
+
if (!isTaxable) {
|
|
708
|
+
overallPartDisc = tr_utils_1.TrUtils.SetValueToZeroIfNull(finalTotalsData.PDisc);
|
|
709
|
+
}
|
|
710
|
+
PartsList.forEach((Part) => {
|
|
711
|
+
PartsDiscountedTotal = (0, aggregation_1.addition)(PartsDiscountedTotal, Part.CustDiscountedPrice);
|
|
712
|
+
});
|
|
713
|
+
return (0, aggregation_1.addition)(PartsDiscountedTotal, overallPartDisc);
|
|
714
|
+
}
|
|
715
|
+
static GetCustLaborCGSTTaxTotal(opCodesList, IsTaxable, isWorkOrder) {
|
|
716
|
+
let TotalTaxAmt = 0;
|
|
717
|
+
if (IsTaxable) {
|
|
718
|
+
opCodesList.forEach((Labor) => {
|
|
719
|
+
if (isWorkOrder) {
|
|
720
|
+
TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Labor.CCGST);
|
|
721
|
+
}
|
|
722
|
+
else {
|
|
723
|
+
if (Labor.Sts !== enums_1.LaborStatusEnum.New && Labor.Sts !== enums_1.LaborStatusEnum.WtngForAppr) {
|
|
724
|
+
TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Labor.CCGST);
|
|
725
|
+
}
|
|
726
|
+
else {
|
|
727
|
+
if (Labor.PBy === enums_1.PayTypeEnum.Customer) {
|
|
728
|
+
TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Labor.ECGST);
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
});
|
|
733
|
+
}
|
|
734
|
+
return TotalTaxAmt;
|
|
735
|
+
}
|
|
736
|
+
static GetCustLaborIGSTTaxTotal(opCodesList, IsTaxable, isWorkOrder) {
|
|
737
|
+
let TotalTaxAmt = 0;
|
|
738
|
+
if (IsTaxable) {
|
|
739
|
+
opCodesList.forEach((Labor) => {
|
|
740
|
+
if (isWorkOrder) {
|
|
741
|
+
TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Labor.CIGST);
|
|
742
|
+
}
|
|
743
|
+
else {
|
|
744
|
+
if (Labor.Sts !== enums_1.LaborStatusEnum.New && Labor.Sts !== enums_1.LaborStatusEnum.WtngForAppr) {
|
|
745
|
+
TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Labor.CIGST);
|
|
746
|
+
}
|
|
747
|
+
else {
|
|
748
|
+
if (Labor.PBy === enums_1.PayTypeEnum.Customer) {
|
|
749
|
+
TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Labor.EIGST);
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
});
|
|
754
|
+
}
|
|
755
|
+
return TotalTaxAmt;
|
|
756
|
+
}
|
|
757
|
+
static GetCustLaborSGSTTaxTotal(opCodesList, IsTaxable, isWorkOrder) {
|
|
758
|
+
let TotalTaxAmt = 0;
|
|
759
|
+
if (IsTaxable) {
|
|
760
|
+
opCodesList.forEach((Labor) => {
|
|
761
|
+
if (isWorkOrder) {
|
|
762
|
+
TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Labor.CSGST);
|
|
763
|
+
}
|
|
764
|
+
else {
|
|
765
|
+
if (Labor.Sts !== enums_1.LaborStatusEnum.New && Labor.Sts !== enums_1.LaborStatusEnum.WtngForAppr) {
|
|
766
|
+
TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Labor.CSGST);
|
|
767
|
+
}
|
|
768
|
+
else {
|
|
769
|
+
if (Labor.PBy === enums_1.PayTypeEnum.Customer) {
|
|
770
|
+
TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Labor.ESGST);
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
});
|
|
775
|
+
}
|
|
776
|
+
return TotalTaxAmt;
|
|
777
|
+
}
|
|
778
|
+
static GetCustPartCGSTTaxTotal(OpsList, PartsList, IsTaxable, isWorkOrder) {
|
|
779
|
+
let TotalTaxAmt = 0;
|
|
780
|
+
if (IsTaxable) {
|
|
781
|
+
PartsList.forEach((Part) => {
|
|
782
|
+
if (!tr_utils_1.TrUtils.IsNull(Part.CollId)) {
|
|
783
|
+
if (isWorkOrder) {
|
|
784
|
+
TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Part.CCGST);
|
|
785
|
+
}
|
|
786
|
+
else {
|
|
787
|
+
if (Part.Sts !== enums_1.LaborStatusEnum.New && Part.Sts !== enums_1.LaborStatusEnum.WtngForAppr) {
|
|
788
|
+
TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Part.CCGST);
|
|
789
|
+
}
|
|
790
|
+
else {
|
|
791
|
+
if (Part.PBy === enums_1.PayTypeEnum.Customer) {
|
|
792
|
+
TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Part.ECGST);
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
else {
|
|
798
|
+
if (isWorkOrder) {
|
|
799
|
+
TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Part.CCGST);
|
|
800
|
+
}
|
|
801
|
+
else {
|
|
802
|
+
let Index = OpsList.findIndex((labor) => {
|
|
803
|
+
return labor._id === Part.OpId;
|
|
804
|
+
});
|
|
805
|
+
if (Index !== -1) {
|
|
806
|
+
if (OpsList[Index].Sts !== enums_1.LaborStatusEnum.New && OpsList[Index].Sts !== enums_1.LaborStatusEnum.WtngForAppr) {
|
|
807
|
+
TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Part.CCGST);
|
|
808
|
+
}
|
|
809
|
+
else {
|
|
810
|
+
TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Part.ECGST);
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
else {
|
|
814
|
+
TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Part.CCGST);
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
});
|
|
819
|
+
}
|
|
820
|
+
return TotalTaxAmt;
|
|
821
|
+
}
|
|
822
|
+
static GetCustPartIGSTTaxTotal(OpsList, PartsList, IsTaxable, isWorkOrder) {
|
|
823
|
+
let TotalTaxAmt = 0;
|
|
824
|
+
if (IsTaxable) {
|
|
825
|
+
PartsList.forEach((Part) => {
|
|
826
|
+
if (!tr_utils_1.TrUtils.IsNull(Part.CollId)) {
|
|
827
|
+
if (isWorkOrder) {
|
|
828
|
+
TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Part.CIGST);
|
|
829
|
+
}
|
|
830
|
+
else {
|
|
831
|
+
if (Part.Sts !== enums_1.LaborStatusEnum.New && Part.Sts !== enums_1.LaborStatusEnum.WtngForAppr) {
|
|
832
|
+
TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Part.CIGST);
|
|
833
|
+
}
|
|
834
|
+
else {
|
|
835
|
+
if (Part.PBy === enums_1.PayTypeEnum.Customer) {
|
|
836
|
+
TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Part.EIGST);
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
else {
|
|
842
|
+
if (isWorkOrder) {
|
|
843
|
+
TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Part.CIGST);
|
|
844
|
+
}
|
|
845
|
+
else {
|
|
846
|
+
let Index = OpsList.findIndex((labor) => {
|
|
847
|
+
return labor._id === Part.OpId;
|
|
848
|
+
});
|
|
849
|
+
if (Index !== -1) {
|
|
850
|
+
if (OpsList[Index].Sts !== enums_1.LaborStatusEnum.New && OpsList[Index].Sts !== enums_1.LaborStatusEnum.WtngForAppr) {
|
|
851
|
+
TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Part.CIGST);
|
|
852
|
+
}
|
|
853
|
+
else {
|
|
854
|
+
TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Part.EIGST);
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
else {
|
|
858
|
+
TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Part.CIGST);
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
});
|
|
863
|
+
}
|
|
864
|
+
return TotalTaxAmt;
|
|
865
|
+
}
|
|
866
|
+
static GetCustPartSGSTTaxTotal(OpsList, PartsList, IsTaxable, isWorkOrder) {
|
|
867
|
+
let TotalTaxAmt = 0;
|
|
868
|
+
if (IsTaxable) {
|
|
869
|
+
PartsList.forEach((Part) => {
|
|
870
|
+
if (!tr_utils_1.TrUtils.IsNull(Part.CollId)) {
|
|
871
|
+
if (isWorkOrder) {
|
|
872
|
+
TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Part.CSGST);
|
|
873
|
+
}
|
|
874
|
+
else {
|
|
875
|
+
if (Part.Sts !== enums_1.LaborStatusEnum.New && Part.Sts !== enums_1.LaborStatusEnum.WtngForAppr) {
|
|
876
|
+
TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Part.CSGST);
|
|
877
|
+
}
|
|
878
|
+
else {
|
|
879
|
+
if (Part.PBy === enums_1.PayTypeEnum.Customer) {
|
|
880
|
+
TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Part.ESGST);
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
else {
|
|
886
|
+
if (isWorkOrder) {
|
|
887
|
+
TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Part.CSGST);
|
|
888
|
+
}
|
|
889
|
+
else {
|
|
890
|
+
let Index = OpsList.findIndex((labor) => {
|
|
891
|
+
return labor._id === Part.OpId;
|
|
892
|
+
});
|
|
893
|
+
if (Index !== -1) {
|
|
894
|
+
if (OpsList[Index].Sts !== enums_1.LaborStatusEnum.New && OpsList[Index].Sts !== enums_1.LaborStatusEnum.WtngForAppr) {
|
|
895
|
+
TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Part.CSGST);
|
|
896
|
+
}
|
|
897
|
+
else {
|
|
898
|
+
TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Part.ESGST);
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
else {
|
|
902
|
+
TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Part.CSGST);
|
|
903
|
+
}
|
|
904
|
+
}
|
|
905
|
+
}
|
|
906
|
+
});
|
|
907
|
+
}
|
|
908
|
+
return TotalTaxAmt;
|
|
909
|
+
}
|
|
910
|
+
static GetInsLaborCGSTTaxTotal(opCodesList, IsTaxable, isWorkOrder) {
|
|
911
|
+
let TotalTaxAmt = 0;
|
|
912
|
+
if (IsTaxable) {
|
|
913
|
+
opCodesList.forEach((Labor) => {
|
|
914
|
+
if (isWorkOrder) {
|
|
915
|
+
TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Labor.ACGST);
|
|
916
|
+
}
|
|
917
|
+
else {
|
|
918
|
+
if (Labor.Sts !== enums_1.LaborStatusEnum.New && Labor.Sts !== enums_1.LaborStatusEnum.WtngForAppr) {
|
|
919
|
+
TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Labor.ACGST);
|
|
920
|
+
}
|
|
921
|
+
else {
|
|
922
|
+
if (Labor.PBy === enums_1.PayTypeEnum.Insurance || Labor.PBy === enums_1.PayTypeEnum.Shared) {
|
|
923
|
+
TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Labor.ECGST);
|
|
924
|
+
}
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
});
|
|
928
|
+
}
|
|
929
|
+
return TotalTaxAmt;
|
|
930
|
+
}
|
|
931
|
+
static GetInsLaborIGSTTaxTotal(opCodesList, IsTaxable, isWorkOrder) {
|
|
932
|
+
let TotalTaxAmt = 0;
|
|
933
|
+
if (IsTaxable) {
|
|
934
|
+
opCodesList.forEach((Labor) => {
|
|
935
|
+
if (isWorkOrder) {
|
|
936
|
+
TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Labor.AIGST);
|
|
937
|
+
}
|
|
938
|
+
else {
|
|
939
|
+
if (Labor.Sts !== enums_1.LaborStatusEnum.New && Labor.Sts !== enums_1.LaborStatusEnum.WtngForAppr) {
|
|
940
|
+
TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Labor.AIGST);
|
|
941
|
+
}
|
|
942
|
+
else {
|
|
943
|
+
if (Labor.PBy === enums_1.PayTypeEnum.Insurance || Labor.PBy === enums_1.PayTypeEnum.Shared) {
|
|
944
|
+
TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Labor.EIGST);
|
|
945
|
+
}
|
|
946
|
+
}
|
|
947
|
+
}
|
|
948
|
+
});
|
|
949
|
+
}
|
|
950
|
+
return TotalTaxAmt;
|
|
951
|
+
}
|
|
952
|
+
static GetInsLaborSGSTTaxTotal(opCodesList, IsTaxable, isWorkOrder) {
|
|
953
|
+
let TotalTaxAmt = 0;
|
|
954
|
+
if (IsTaxable) {
|
|
955
|
+
opCodesList.forEach((Labor) => {
|
|
956
|
+
if (isWorkOrder) {
|
|
957
|
+
TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Labor.ASGST);
|
|
958
|
+
}
|
|
959
|
+
else {
|
|
960
|
+
if (Labor.Sts !== enums_1.LaborStatusEnum.New && Labor.Sts !== enums_1.LaborStatusEnum.WtngForAppr) {
|
|
961
|
+
TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Labor.ASGST);
|
|
962
|
+
}
|
|
963
|
+
else {
|
|
964
|
+
if (Labor.PBy === enums_1.PayTypeEnum.Insurance || Labor.PBy === enums_1.PayTypeEnum.Shared) {
|
|
965
|
+
TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Labor.ESGST);
|
|
966
|
+
}
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
});
|
|
970
|
+
}
|
|
971
|
+
return TotalTaxAmt;
|
|
972
|
+
}
|
|
973
|
+
static GetInsPartCGSTTaxTotal(PartsList, IsTaxable, isWorkOrder) {
|
|
974
|
+
let TotalTaxAmt = 0;
|
|
975
|
+
if (IsTaxable) {
|
|
976
|
+
PartsList.forEach((Part) => {
|
|
977
|
+
if (!tr_utils_1.TrUtils.IsNull(Part.CollId) || Part.PBy === enums_1.PayTypeEnum.Insurance || Part.PBy === enums_1.PayTypeEnum.Shared) {
|
|
978
|
+
if (isWorkOrder) {
|
|
979
|
+
TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Part.ACGST);
|
|
980
|
+
}
|
|
981
|
+
else {
|
|
982
|
+
if (Part.Sts !== enums_1.LaborStatusEnum.New && Part.Sts !== enums_1.LaborStatusEnum.WtngForAppr) {
|
|
983
|
+
TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Part.ACGST);
|
|
984
|
+
}
|
|
985
|
+
else {
|
|
986
|
+
if (Part.PBy === enums_1.PayTypeEnum.Insurance || Part.PBy === enums_1.PayTypeEnum.Shared) {
|
|
987
|
+
TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Part.ECGST);
|
|
988
|
+
}
|
|
989
|
+
}
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
});
|
|
993
|
+
}
|
|
994
|
+
return TotalTaxAmt;
|
|
995
|
+
}
|
|
996
|
+
static GetInsPartIGSTTaxTotal(PartsList, IsTaxable, isWorkOrder) {
|
|
997
|
+
let TotalTaxAmt = 0;
|
|
998
|
+
if (IsTaxable) {
|
|
999
|
+
PartsList.forEach((Part) => {
|
|
1000
|
+
if (!tr_utils_1.TrUtils.IsNull(Part.CollId) || Part.PBy === enums_1.PayTypeEnum.Insurance || Part.PBy === enums_1.PayTypeEnum.Shared) {
|
|
1001
|
+
if (isWorkOrder) {
|
|
1002
|
+
TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Part.AIGST);
|
|
1003
|
+
}
|
|
1004
|
+
else {
|
|
1005
|
+
if (Part.Sts !== enums_1.LaborStatusEnum.New && Part.Sts !== enums_1.LaborStatusEnum.WtngForAppr) {
|
|
1006
|
+
TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Part.AIGST);
|
|
1007
|
+
}
|
|
1008
|
+
else {
|
|
1009
|
+
if (Part.PBy === enums_1.PayTypeEnum.Insurance || Part.PBy === enums_1.PayTypeEnum.Shared) {
|
|
1010
|
+
TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Part.EIGST);
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
1015
|
+
});
|
|
1016
|
+
}
|
|
1017
|
+
return TotalTaxAmt;
|
|
1018
|
+
}
|
|
1019
|
+
static GetInsPartSGSTTaxTotal(PartsList, IsTaxable, isWorkOrder) {
|
|
1020
|
+
let TotalTaxAmt = 0;
|
|
1021
|
+
if (IsTaxable) {
|
|
1022
|
+
PartsList.forEach((Part) => {
|
|
1023
|
+
if (!tr_utils_1.TrUtils.IsNull(Part.CollId) || Part.PBy === enums_1.PayTypeEnum.Insurance || Part.PBy === enums_1.PayTypeEnum.Shared) {
|
|
1024
|
+
if (isWorkOrder) {
|
|
1025
|
+
TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Part.ASGST);
|
|
1026
|
+
}
|
|
1027
|
+
else {
|
|
1028
|
+
if (Part.Sts !== enums_1.LaborStatusEnum.New && Part.Sts !== enums_1.LaborStatusEnum.WtngForAppr) {
|
|
1029
|
+
TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Part.ASGST);
|
|
1030
|
+
}
|
|
1031
|
+
else {
|
|
1032
|
+
if (Part.PBy === enums_1.PayTypeEnum.Insurance || Part.PBy === enums_1.PayTypeEnum.Shared) {
|
|
1033
|
+
TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Part.ESGST);
|
|
1034
|
+
}
|
|
1035
|
+
}
|
|
1036
|
+
}
|
|
1037
|
+
}
|
|
1038
|
+
});
|
|
1039
|
+
}
|
|
1040
|
+
return TotalTaxAmt;
|
|
1041
|
+
}
|
|
1042
|
+
static GetLaborLDiscAmount(LaborTotalAfterDisc, LDisc) {
|
|
1043
|
+
let LaborLDiscAmt = 0;
|
|
1044
|
+
if (!tr_utils_1.TrUtils.IsZero(LaborTotalAfterDisc)) {
|
|
1045
|
+
LaborLDiscAmt = LDisc;
|
|
1046
|
+
}
|
|
1047
|
+
return LaborLDiscAmt;
|
|
1048
|
+
}
|
|
1049
|
+
static GetPartsPDiscAmount(PartsTotalAfterDisc, PDisc) {
|
|
1050
|
+
let PartsPDiscAmt = 0;
|
|
1051
|
+
if (!tr_utils_1.TrUtils.IsZero(PartsTotalAfterDisc)) {
|
|
1052
|
+
PartsPDiscAmt = PDisc;
|
|
1053
|
+
}
|
|
1054
|
+
return PartsPDiscAmt;
|
|
1055
|
+
}
|
|
1056
|
+
static GetCustPartsTaxGrouping(PartsList, TaxCodes, isWorkOrder) {
|
|
1057
|
+
let FilteredPartsList = this.GetCustParts(PartsList);
|
|
1058
|
+
return this.GetCustTaxGroupingForPartsByHSN(FilteredPartsList, TaxCodes, isWorkOrder);
|
|
1059
|
+
}
|
|
1060
|
+
static GetCustParts(PartsList) {
|
|
1061
|
+
let FilteredPartsList = PartsList.filter((Part) => {
|
|
1062
|
+
return Part.PBy === enums_1.PayTypeEnum.Customer || Part.PBy === enums_1.PayTypeEnum.Shared;
|
|
1063
|
+
});
|
|
1064
|
+
return FilteredPartsList;
|
|
1065
|
+
}
|
|
1066
|
+
static GetCustTaxGroupingForPartsByHSN(Parts, TaxCodes, isWorkOrder) {
|
|
1067
|
+
Parts = this.GetCombinedTaxPercentage(Parts, TaxCodes);
|
|
1068
|
+
Parts = this.ResetPartsHSNIfInvalid(Parts);
|
|
1069
|
+
let FinalMatchedParts = this.ComparePartsByHSN(Parts, TaxCodes);
|
|
1070
|
+
return this.GetCustTaxGroupingInfoByHSN(FinalMatchedParts, TaxCodes, isWorkOrder);
|
|
1071
|
+
}
|
|
1072
|
+
static GetCustTaxGroupingInfoByHSN(FinalMatchedParts, TaxCodes, isWorkOrder) {
|
|
1073
|
+
let HSNTaxInfo = [];
|
|
1074
|
+
FinalMatchedParts.forEach((MatchedPart) => {
|
|
1075
|
+
let TaxInfo = {};
|
|
1076
|
+
let TaxOnAmount = 0;
|
|
1077
|
+
let TaxAmount = 0;
|
|
1078
|
+
let HSN = MatchedPart[0].HSN;
|
|
1079
|
+
TaxInfo.CombinedTaxPercentage = MatchedPart[0].CombinedTaxPercentage;
|
|
1080
|
+
MatchedPart.forEach((argMatchedGSTPart) => {
|
|
1081
|
+
TaxOnAmount = (0, aggregation_1.addition)(TaxOnAmount, tr_utils_1.TrUtils.FixedTo(argMatchedGSTPart.CustAfterPartDisc));
|
|
1082
|
+
if (isWorkOrder) {
|
|
1083
|
+
TaxAmount = (0, aggregation_1.addition)(TaxAmount, tr_utils_1.TrUtils.FixedTo(argMatchedGSTPart.CCGST));
|
|
1084
|
+
TaxAmount = (0, aggregation_1.addition)(TaxAmount, tr_utils_1.TrUtils.FixedTo(argMatchedGSTPart.CIGST));
|
|
1085
|
+
TaxAmount = (0, aggregation_1.addition)(TaxAmount, tr_utils_1.TrUtils.FixedTo(argMatchedGSTPart.CSGST));
|
|
1086
|
+
}
|
|
1087
|
+
else {
|
|
1088
|
+
if (argMatchedGSTPart.Sts !== enums_1.LaborStatusEnum.New && argMatchedGSTPart.Sts !== enums_1.LaborStatusEnum.WtngForAppr) {
|
|
1089
|
+
TaxAmount = (0, aggregation_1.addition)(TaxAmount, tr_utils_1.TrUtils.FixedTo(argMatchedGSTPart.CCGST));
|
|
1090
|
+
TaxAmount = (0, aggregation_1.addition)(TaxAmount, tr_utils_1.TrUtils.FixedTo(argMatchedGSTPart.CIGST));
|
|
1091
|
+
TaxAmount = (0, aggregation_1.addition)(TaxAmount, tr_utils_1.TrUtils.FixedTo(argMatchedGSTPart.CSGST));
|
|
1092
|
+
}
|
|
1093
|
+
else {
|
|
1094
|
+
if (argMatchedGSTPart.PBy === enums_1.PayTypeEnum.Customer) {
|
|
1095
|
+
TaxAmount = (0, aggregation_1.addition)(TaxAmount, tr_utils_1.TrUtils.FixedTo(argMatchedGSTPart.ECGST));
|
|
1096
|
+
TaxAmount = (0, aggregation_1.addition)(TaxAmount, tr_utils_1.TrUtils.FixedTo(argMatchedGSTPart.EIGST));
|
|
1097
|
+
TaxAmount = (0, aggregation_1.addition)(TaxAmount, tr_utils_1.TrUtils.FixedTo(argMatchedGSTPart.ESGST));
|
|
1098
|
+
}
|
|
1099
|
+
}
|
|
1100
|
+
}
|
|
1101
|
+
});
|
|
1102
|
+
TaxInfo.HSN = HSN;
|
|
1103
|
+
TaxInfo.TotalTaxableAmount = tr_utils_1.TrUtils.FixPriceValue(TaxOnAmount);
|
|
1104
|
+
TaxInfo.TotalTaxAmount = tr_utils_1.TrUtils.FixPriceValue(TaxAmount);
|
|
1105
|
+
TaxInfo.PartsCount = MatchedPart.length;
|
|
1106
|
+
let GSTValues = this.GetGSTValueBasedOnTaxCode(MatchedPart[0].TCode, TaxCodes);
|
|
1107
|
+
TaxInfo.CGST = GSTValues[0];
|
|
1108
|
+
TaxInfo.SGST = GSTValues[1];
|
|
1109
|
+
TaxInfo.IGST = GSTValues[2];
|
|
1110
|
+
if (TaxOnAmount !== 0) {
|
|
1111
|
+
HSNTaxInfo.push(TaxInfo);
|
|
1112
|
+
}
|
|
1113
|
+
});
|
|
1114
|
+
return HSNTaxInfo;
|
|
1115
|
+
}
|
|
1116
|
+
static GetInsPartsTaxGrouping(PartsList, TaxCodes) {
|
|
1117
|
+
let FilteredPartsList = this.GetInsParts(PartsList);
|
|
1118
|
+
return this.GetInsTaxGroupingForPartsByHSN(FilteredPartsList, TaxCodes);
|
|
1119
|
+
}
|
|
1120
|
+
static GetInsParts(PartsList) {
|
|
1121
|
+
let FilteredPartsList = PartsList.filter((Part) => {
|
|
1122
|
+
return Part.PBy === enums_1.PayTypeEnum.Insurance || Part.PBy === enums_1.PayTypeEnum.Shared;
|
|
1123
|
+
});
|
|
1124
|
+
return FilteredPartsList;
|
|
1125
|
+
}
|
|
1126
|
+
static GetInsTaxGroupingForPartsByHSN(Parts, TaxCodes) {
|
|
1127
|
+
Parts = this.GetCombinedTaxPercentage(Parts, TaxCodes);
|
|
1128
|
+
Parts = this.ResetPartsHSNIfInvalid(Parts);
|
|
1129
|
+
let FinalMatchedParts = this.ComparePartsByHSN(Parts, TaxCodes);
|
|
1130
|
+
return this.GetInsTaxGroupingInfoByHSN(FinalMatchedParts, TaxCodes);
|
|
1131
|
+
}
|
|
1132
|
+
static GetInsTaxGroupingInfoByHSN(FinalMatchedParts, TaxCodes) {
|
|
1133
|
+
let HSNTaxInfo = [];
|
|
1134
|
+
FinalMatchedParts.forEach((MatchedPart) => {
|
|
1135
|
+
let TaxInfo = {};
|
|
1136
|
+
let TaxOnAmount = 0;
|
|
1137
|
+
let TaxAmount = 0;
|
|
1138
|
+
let HSN = MatchedPart[0].HSN;
|
|
1139
|
+
TaxInfo.CombinedTaxPercentage = MatchedPart[0].CombinedTaxPercentage;
|
|
1140
|
+
MatchedPart.forEach((argMatchedGSTPart) => {
|
|
1141
|
+
TaxOnAmount = (0, aggregation_1.addition)(TaxOnAmount, tr_utils_1.TrUtils.FixedTo(argMatchedGSTPart.InsAfterPartDisc));
|
|
1142
|
+
if (argMatchedGSTPart.PBy === enums_1.PayTypeEnum.Insurance || argMatchedGSTPart.PBy === enums_1.PayTypeEnum.Shared) {
|
|
1143
|
+
if (argMatchedGSTPart.Sts !== enums_1.LaborStatusEnum.New && argMatchedGSTPart.Sts !== enums_1.LaborStatusEnum.WtngForAppr) {
|
|
1144
|
+
TaxAmount = (0, aggregation_1.addition)(TaxAmount, tr_utils_1.TrUtils.FixedTo(argMatchedGSTPart.ACGST));
|
|
1145
|
+
TaxAmount = (0, aggregation_1.addition)(TaxAmount, tr_utils_1.TrUtils.FixedTo(argMatchedGSTPart.AIGST));
|
|
1146
|
+
TaxAmount = (0, aggregation_1.addition)(TaxAmount, tr_utils_1.TrUtils.FixedTo(argMatchedGSTPart.ASGST));
|
|
1147
|
+
}
|
|
1148
|
+
else {
|
|
1149
|
+
TaxAmount = (0, aggregation_1.addition)(TaxAmount, tr_utils_1.TrUtils.FixedTo(argMatchedGSTPart.ECGST));
|
|
1150
|
+
TaxAmount = (0, aggregation_1.addition)(TaxAmount, tr_utils_1.TrUtils.FixedTo(argMatchedGSTPart.EIGST));
|
|
1151
|
+
TaxAmount = (0, aggregation_1.addition)(TaxAmount, tr_utils_1.TrUtils.FixedTo(argMatchedGSTPart.ESGST));
|
|
1152
|
+
}
|
|
1153
|
+
}
|
|
1154
|
+
});
|
|
1155
|
+
TaxInfo.HSN = HSN;
|
|
1156
|
+
TaxInfo.TotalTaxableAmount = tr_utils_1.TrUtils.FixPriceValue(TaxOnAmount);
|
|
1157
|
+
TaxInfo.TotalTaxAmount = tr_utils_1.TrUtils.FixPriceValue(TaxAmount);
|
|
1158
|
+
TaxInfo.PartsCount = MatchedPart.length;
|
|
1159
|
+
let GSTValues = this.GetGSTValueBasedOnTaxCode(MatchedPart[0].TCode, TaxCodes);
|
|
1160
|
+
TaxInfo.CGST = GSTValues[0];
|
|
1161
|
+
TaxInfo.SGST = GSTValues[1];
|
|
1162
|
+
TaxInfo.IGST = GSTValues[2];
|
|
1163
|
+
if (TaxOnAmount !== 0) {
|
|
1164
|
+
HSNTaxInfo.push(TaxInfo);
|
|
1165
|
+
}
|
|
1166
|
+
});
|
|
1167
|
+
return HSNTaxInfo;
|
|
1168
|
+
}
|
|
1169
|
+
static GetGSTValueBasedOnTaxCode(TCode, TaxCodes) {
|
|
1170
|
+
let CGST = 0;
|
|
1171
|
+
let SGST = 0;
|
|
1172
|
+
let IGST = 0;
|
|
1173
|
+
if (tr_utils_1.TrUtils.IsNull(TCode)) {
|
|
1174
|
+
return [CGST, SGST, IGST];
|
|
1175
|
+
}
|
|
1176
|
+
let TCodeIndex = TaxCodes.findIndex((TaxCode) => {
|
|
1177
|
+
return TaxCode._id === Number(TCode);
|
|
1178
|
+
});
|
|
1179
|
+
if (TCodeIndex !== -1) {
|
|
1180
|
+
if (TaxCodes[TCodeIndex].Type === 'Intra') {
|
|
1181
|
+
return [TaxCodes[TCodeIndex].CGST, TaxCodes[TCodeIndex].SGST, 0];
|
|
1182
|
+
}
|
|
1183
|
+
else {
|
|
1184
|
+
return [0, 0, TaxCodes[TCodeIndex].IGST];
|
|
1185
|
+
}
|
|
1186
|
+
}
|
|
1187
|
+
else {
|
|
1188
|
+
return [CGST, SGST, IGST];
|
|
1189
|
+
}
|
|
1190
|
+
}
|
|
1191
|
+
static GetCombinedTaxPercentage(Parts, TaxCodes) {
|
|
1192
|
+
Parts.forEach((Part) => {
|
|
1193
|
+
let GSTValues = this.GetGSTValueBasedOnTaxCode(Part.TCode, TaxCodes);
|
|
1194
|
+
let CGST = GSTValues[0];
|
|
1195
|
+
let SGST = GSTValues[1];
|
|
1196
|
+
let IGST = GSTValues[2];
|
|
1197
|
+
Part.CombinedTaxPercentage = (0, aggregation_1.addition)(CGST, SGST, IGST);
|
|
1198
|
+
});
|
|
1199
|
+
return Parts;
|
|
1200
|
+
}
|
|
1201
|
+
static ResetPartsHSNIfInvalid(Parts) {
|
|
1202
|
+
Parts.forEach((Part) => {
|
|
1203
|
+
if (tr_utils_1.TrUtils.IsNull(Part.HSN)) {
|
|
1204
|
+
Part.HSN = '';
|
|
1205
|
+
}
|
|
1206
|
+
});
|
|
1207
|
+
return Parts;
|
|
1208
|
+
}
|
|
1209
|
+
static ComparePartsByHSN(Parts, TaxCodes) {
|
|
1210
|
+
let FinalMatchedParts = [];
|
|
1211
|
+
Parts.forEach((Part) => {
|
|
1212
|
+
let MatchedPartsBasedOnHSN = Parts.filter((argPart) => {
|
|
1213
|
+
let PartFound = false;
|
|
1214
|
+
FinalMatchedParts.forEach((FinalArgParts) => {
|
|
1215
|
+
let PartIndex = FinalArgParts.findIndex((FinalArgPart) => {
|
|
1216
|
+
return FinalArgPart._id === argPart._id;
|
|
1217
|
+
});
|
|
1218
|
+
if (PartIndex !== -1) {
|
|
1219
|
+
PartFound = true;
|
|
1220
|
+
}
|
|
1221
|
+
});
|
|
1222
|
+
let argGSTValues = this.GetGSTValueBasedOnTaxCode(argPart.TCode, TaxCodes);
|
|
1223
|
+
let argCGST = argGSTValues[0];
|
|
1224
|
+
let argSGST = argGSTValues[1];
|
|
1225
|
+
let argIGST = argGSTValues[2];
|
|
1226
|
+
let partGSTValues = this.GetGSTValueBasedOnTaxCode(Part.TCode, TaxCodes);
|
|
1227
|
+
let partCGST = partGSTValues[0];
|
|
1228
|
+
let partSGST = partGSTValues[1];
|
|
1229
|
+
let partIGST = partGSTValues[2];
|
|
1230
|
+
return (argPart.HSN === Part.HSN) && (!PartFound) &&
|
|
1231
|
+
(argCGST === partCGST) && (argIGST === partIGST) &&
|
|
1232
|
+
(argSGST === partSGST);
|
|
1233
|
+
});
|
|
1234
|
+
if (MatchedPartsBasedOnHSN.length !== 0) {
|
|
1235
|
+
FinalMatchedParts.push(MatchedPartsBasedOnHSN);
|
|
1236
|
+
}
|
|
1237
|
+
});
|
|
1238
|
+
return FinalMatchedParts;
|
|
1239
|
+
}
|
|
1240
|
+
}
|
|
1241
|
+
exports.ROTotalsService = ROTotalsService;
|