shareneus 1.6.51 → 1.6.52
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.
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
export declare class PurchaseOrderTotalsService {
|
|
2
|
+
static GetTaxAmountFromTaxes(item: any, taxCode: string): any;
|
|
3
|
+
static GetTaxRateFromTaxes(item: any, taxCode: string): any;
|
|
4
|
+
static GetTCodeFromTaxes(item: any): any;
|
|
2
5
|
static GetTotalsValue(opCodesList: any, argPartsList: any, IsTaxable: boolean, DetailedTotalsInfo: boolean, TaxCodes: any, Tax: any, ReturnPartsAlso: boolean, HasNoTax: boolean, GetSubTotal: boolean, Discount: number, DiscInPerc: boolean, Adjust: number, EntitySettings: any): any;
|
|
3
6
|
static CalculateLaborValues(opCodesList: any, IsIndependentTax: boolean, DecimalsNumber: number): any;
|
|
4
7
|
static ResetLaborValues(opCodesList: any, IsIndependentTax: boolean, DecimalsNumber: number): any;
|
|
@@ -5,6 +5,30 @@ const code_enums_1 = require("../../enums/code-enums");
|
|
|
5
5
|
const math_operations_1 = require("../../shared/math-operations");
|
|
6
6
|
const tr_utils_1 = require("../../utils/tr-utils");
|
|
7
7
|
class PurchaseOrderTotalsService {
|
|
8
|
+
static GetTaxAmountFromTaxes(item, taxCode) {
|
|
9
|
+
const taxes = Array.isArray(item === null || item === void 0 ? void 0 : item.Taxes) ? item.Taxes : [];
|
|
10
|
+
const matchedTaxes = taxes.filter((tax) => (tax === null || tax === void 0 ? void 0 : tax.Code) === taxCode);
|
|
11
|
+
if (matchedTaxes.length !== 0) {
|
|
12
|
+
return matchedTaxes.reduce((total, tax) => (0, math_operations_1.Add)(total, tax === null || tax === void 0 ? void 0 : tax.Amt), 0);
|
|
13
|
+
}
|
|
14
|
+
return 0;
|
|
15
|
+
}
|
|
16
|
+
static GetTaxRateFromTaxes(item, taxCode) {
|
|
17
|
+
const taxes = Array.isArray(item === null || item === void 0 ? void 0 : item.Taxes) ? item.Taxes : [];
|
|
18
|
+
const matchedTaxes = taxes.filter((tax) => (tax === null || tax === void 0 ? void 0 : tax.Code) === taxCode);
|
|
19
|
+
if (matchedTaxes.length !== 0) {
|
|
20
|
+
return matchedTaxes.reduce((total, tax) => (0, math_operations_1.Add)(total, tax === null || tax === void 0 ? void 0 : tax.Rate), 0);
|
|
21
|
+
}
|
|
22
|
+
return 0;
|
|
23
|
+
}
|
|
24
|
+
static GetTCodeFromTaxes(item) {
|
|
25
|
+
const taxes = Array.isArray(item === null || item === void 0 ? void 0 : item.Taxes) ? item.Taxes : [];
|
|
26
|
+
const matchedTax = taxes.find((tax) => !tr_utils_1.TrUtils.IsNull(tax === null || tax === void 0 ? void 0 : tax.TaxCodeId));
|
|
27
|
+
if (!tr_utils_1.TrUtils.IsNull(matchedTax === null || matchedTax === void 0 ? void 0 : matchedTax.TaxCodeId)) {
|
|
28
|
+
return matchedTax.TaxCodeId;
|
|
29
|
+
}
|
|
30
|
+
return item === null || item === void 0 ? void 0 : item.TCode;
|
|
31
|
+
}
|
|
8
32
|
static GetTotalsValue(opCodesList, argPartsList, IsTaxable, DetailedTotalsInfo, TaxCodes, Tax, ReturnPartsAlso, HasNoTax, GetSubTotal, Discount, DiscInPerc, Adjust, EntitySettings) {
|
|
9
33
|
let PartsList = tr_utils_1.TrUtils.IsNull(argPartsList) ? [] : tr_utils_1.TrUtils.Stringify(argPartsList);
|
|
10
34
|
// PartsList = this.ResetPartValuesIfInvalid(PartsList);
|
|
@@ -65,9 +89,10 @@ class PurchaseOrderTotalsService {
|
|
|
65
89
|
Operation.UnCo = tr_utils_1.TrUtils.SetValueToZeroIfNull(Operation.UnCo);
|
|
66
90
|
Operation.RecDisc = tr_utils_1.TrUtils.SetValueToZeroIfNull(Operation.RecDisc);
|
|
67
91
|
Operation.Disc = tr_utils_1.TrUtils.SetValueToZeroIfNull(Operation.Disc);
|
|
68
|
-
Operation.CGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(Operation.CGST);
|
|
69
|
-
Operation.SGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(Operation.SGST);
|
|
70
|
-
Operation.IGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(Operation.IGST);
|
|
92
|
+
Operation.CGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(this.GetTaxAmountFromTaxes(Operation, 'CGST') || Operation.CGST);
|
|
93
|
+
Operation.SGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(this.GetTaxAmountFromTaxes(Operation, 'SGST') || Operation.SGST);
|
|
94
|
+
Operation.IGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(this.GetTaxAmountFromTaxes(Operation, 'IGST') || Operation.IGST);
|
|
95
|
+
Operation.TCode = this.GetTCodeFromTaxes(Operation);
|
|
71
96
|
return Operation;
|
|
72
97
|
}
|
|
73
98
|
static CheckPartStatusAndReturn(PartsList) {
|
|
@@ -83,9 +108,10 @@ class PurchaseOrderTotalsService {
|
|
|
83
108
|
}
|
|
84
109
|
Part.UnCo = tr_utils_1.TrUtils.SetValueToZeroIfNull(Part.UnCo);
|
|
85
110
|
Part.Disc = tr_utils_1.TrUtils.SetValueToZeroIfNull(Part.Disc);
|
|
86
|
-
Part.SGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(Part.SGST);
|
|
87
|
-
Part.IGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(Part.IGST);
|
|
88
|
-
Part.CGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(Part.CGST);
|
|
111
|
+
Part.SGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(this.GetTaxAmountFromTaxes(Part, 'SGST') || Part.SGST);
|
|
112
|
+
Part.IGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(this.GetTaxAmountFromTaxes(Part, 'IGST') || Part.IGST);
|
|
113
|
+
Part.CGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(this.GetTaxAmountFromTaxes(Part, 'CGST') || Part.CGST);
|
|
114
|
+
Part.TCode = this.GetTCodeFromTaxes(Part);
|
|
89
115
|
// }
|
|
90
116
|
return Part;
|
|
91
117
|
}
|
|
@@ -241,9 +267,9 @@ class PurchaseOrderTotalsService {
|
|
|
241
267
|
finalTotalsData.PartSGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(TaxAmt[1]);
|
|
242
268
|
finalTotalsData.PartIGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(TaxAmt[2]);
|
|
243
269
|
let ServiceTaxAmt = this.GetServicesGSTTaxTotal(LaborList);
|
|
244
|
-
finalTotalsData.ServieCGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(
|
|
245
|
-
finalTotalsData.ServieSGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(
|
|
246
|
-
finalTotalsData.ServieIGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(
|
|
270
|
+
finalTotalsData.ServieCGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(ServiceTaxAmt[0]);
|
|
271
|
+
finalTotalsData.ServieSGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(ServiceTaxAmt[1]);
|
|
272
|
+
finalTotalsData.ServieIGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(ServiceTaxAmt[2]);
|
|
247
273
|
finalTotalsData.PartAfterTax = (0, math_operations_1.Add)(finalTotalsData.PartsTotalAfterDisc, finalTotalsData.TaxTotal);
|
|
248
274
|
finalTotalsData.ServiceAfterTax = (0, math_operations_1.Add)(finalTotalsData.ServiceTotalAfterDisc, finalTotalsData.ServiceTaxTotal);
|
|
249
275
|
finalTotalsData.IsTaxable = IsTaxable;
|
|
@@ -434,13 +460,10 @@ class PurchaseOrderTotalsService {
|
|
|
434
460
|
if (tr_utils_1.TrUtils.IsNull(Part.HSN)) {
|
|
435
461
|
Part.HSN = '';
|
|
436
462
|
}
|
|
437
|
-
|
|
438
|
-
Part.CGSTAmt = tr_utils_1.TrUtils.SetValueToZeroIfNull(
|
|
439
|
-
Part.SGSTAmt = tr_utils_1.TrUtils.SetValueToZeroIfNull(
|
|
440
|
-
Part.IGSTAmt = tr_utils_1.TrUtils.SetValueToZeroIfNull(
|
|
441
|
-
// Part.CGSTAmt = this.GetCGSTValueBasedOnTaxCode(Part.TCode, TaxCodes);
|
|
442
|
-
// Part.SGSTAmt = this.GetSGSTValueBasedOnTaxCode(Part.TCode, TaxCodes);
|
|
443
|
-
// Part.IGSTAmt = this.GetIGSTValueBasedOnTaxCode(Part.TCode, TaxCodes);
|
|
463
|
+
Part.TCode = this.GetTCodeFromTaxes(Part);
|
|
464
|
+
Part.CGSTAmt = tr_utils_1.TrUtils.SetValueToZeroIfNull(this.GetTaxRateFromTaxes(Part, 'CGST'));
|
|
465
|
+
Part.SGSTAmt = tr_utils_1.TrUtils.SetValueToZeroIfNull(this.GetTaxRateFromTaxes(Part, 'SGST'));
|
|
466
|
+
Part.IGSTAmt = tr_utils_1.TrUtils.SetValueToZeroIfNull(this.GetTaxRateFromTaxes(Part, 'IGST'));
|
|
444
467
|
Part.CombinedTaxPercentage = (0, math_operations_1.Add)(Part.CGSTAmt, Part.SGSTAmt, Part.IGSTAmt);
|
|
445
468
|
});
|
|
446
469
|
return Items;
|