shareneus 1.4.94 → 1.4.96
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/accounting/credit-note/credit-note-totals.service.d.ts +3 -1
- package/dist/accounting/credit-note/credit-note-totals.service.js +51 -4
- package/dist/index.d.ts +3 -0
- package/dist/index.js +7 -1
- package/dist/sales-receive/sales-receive-pdf.service.d.ts +272 -0
- package/dist/sales-receive/sales-receive-pdf.service.js +578 -0
- package/dist/sales-receive/sales-receive-print.service.d.ts +13 -0
- package/dist/sales-receive/sales-receive-print.service.js +187 -0
- package/dist/sales-receive/sales-receive-totals.service.d.ts +27 -0
- package/dist/sales-receive/sales-receive-totals.service.js +376 -0
- package/package.json +1 -1
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SalesReceivePrintService = void 0;
|
|
4
|
+
const aggregation_1 = require("../aggregation/aggregation");
|
|
5
|
+
const code_enums_1 = require("../enums/code-enums");
|
|
6
|
+
const enums_1 = require("../enums/enums");
|
|
7
|
+
const shared_print_service_1 = require("../shared/shared-print.service");
|
|
8
|
+
const my_date_1 = require("../utils/my-date");
|
|
9
|
+
const tr_utils_1 = require("../utils/tr-utils");
|
|
10
|
+
const sales_receive_totals_service_1 = require("./sales-receive-totals.service");
|
|
11
|
+
class SalesReceivePrintService {
|
|
12
|
+
static GetSalesReceivePrintInfo(OriginalSalesReceiveData, OriginalEntityData, image, IncludeGST, ConsolidateGST, TaxCodes, IsProforma) {
|
|
13
|
+
var _a, _b;
|
|
14
|
+
let ForInsurance = !tr_utils_1.TrUtils.IsNull(OriginalSalesReceiveData.BillTo.InsId);
|
|
15
|
+
let SalesReceivePrintData = {};
|
|
16
|
+
let argSalesReceiveData = tr_utils_1.TrUtils.Stringify(OriginalSalesReceiveData);
|
|
17
|
+
if (!IncludeGST) {
|
|
18
|
+
argSalesReceiveData.Settings.Tax = 'NO';
|
|
19
|
+
}
|
|
20
|
+
SalesReceivePrintData.IsProforma = IsProforma;
|
|
21
|
+
SalesReceivePrintData.Settings = tr_utils_1.TrUtils.Stringify(argSalesReceiveData.Settings);
|
|
22
|
+
SalesReceivePrintData.SType = tr_utils_1.TrUtils.Stringify(argSalesReceiveData.SType);
|
|
23
|
+
let SType = tr_utils_1.TrUtils.IsNull(argSalesReceiveData.SType) ? null : argSalesReceiveData.SType;
|
|
24
|
+
SalesReceivePrintData = this.GetPrintConditionsBasedOnInput(SalesReceivePrintData, IncludeGST, ConsolidateGST, ForInsurance, SType, argSalesReceiveData, IsProforma);
|
|
25
|
+
SalesReceivePrintData.Entity = shared_print_service_1.PrintSharedService.GetFormattedEntityDataForPrint(OriginalEntityData, "Invoice", OriginalSalesReceiveData);
|
|
26
|
+
SalesReceivePrintData = shared_print_service_1.PrintSharedService.GetEntityHeaderStyles(SalesReceivePrintData, OriginalEntityData, image);
|
|
27
|
+
SalesReceivePrintData = this.GetSalesReceiveOtherDetailsForPrint(SalesReceivePrintData, argSalesReceiveData);
|
|
28
|
+
let IsTaxable = (IncludeGST && tr_utils_1.TrUtils.isTaxable(argSalesReceiveData.Settings.Tax)) ? true : false;
|
|
29
|
+
let finalTotalsData = sales_receive_totals_service_1.SalesReceiveTotalsService.GetTotalsValue([], argSalesReceiveData.Items, IsTaxable, true, argSalesReceiveData.Disc, argSalesReceiveData.Perc, TaxCodes, true, argSalesReceiveData.Settings, SalesReceivePrintData.Entity);
|
|
30
|
+
if (ConsolidateGST) {
|
|
31
|
+
finalTotalsData.CustLaborTotalBeforeDisc = finalTotalsData.CustLaborAfterTax;
|
|
32
|
+
finalTotalsData.CustPartsTotalBeforeDisc = finalTotalsData.CustPartAfterTax;
|
|
33
|
+
}
|
|
34
|
+
SalesReceivePrintData = tr_utils_1.TrUtils.ConcatObjects(SalesReceivePrintData, finalTotalsData);
|
|
35
|
+
SalesReceivePrintData.Items = this.GetItemsPrintInfo(SalesReceivePrintData.Items, ConsolidateGST, TaxCodes, (_b = (_a = OriginalEntityData.Entity.Settings) === null || _a === void 0 ? void 0 : _a.Acc) === null || _b === void 0 ? void 0 : _b.LTot, SalesReceivePrintData.Entity.DecimalsNumber);
|
|
36
|
+
argSalesReceiveData = this.ReverseItemsForSalesReceivePrint(argSalesReceiveData);
|
|
37
|
+
SalesReceivePrintData.PrintInfo = this.PrepareFormatForSalesReceivePrint(SalesReceivePrintData, code_enums_1.ROTypeEnum.Invoice, argSalesReceiveData.Sts);
|
|
38
|
+
SalesReceivePrintData = this.GetFormattedProductDataForPrint(argSalesReceiveData, SalesReceivePrintData);
|
|
39
|
+
SalesReceivePrintData = this.GetBillNameForSalesReceivePrint(argSalesReceiveData, SalesReceivePrintData);
|
|
40
|
+
SalesReceivePrintData.Consolidate = ConsolidateGST;
|
|
41
|
+
return SalesReceivePrintData;
|
|
42
|
+
}
|
|
43
|
+
static GetPrintConditionsBasedOnInput(SalesReceivePrintData, IncludeGST, ConsolidateGST, ForInsurance, SType, OriginalSalesReceiveData, IsProforma) {
|
|
44
|
+
SalesReceivePrintData.ForInsurance = ForInsurance;
|
|
45
|
+
SalesReceivePrintData.For = ForInsurance ? enums_1.PayTypeEnum.Insurance : enums_1.PayTypeEnum.Customer;
|
|
46
|
+
SalesReceivePrintData.IncludeGST = IncludeGST;
|
|
47
|
+
SalesReceivePrintData.ConsolidateGST = ConsolidateGST;
|
|
48
|
+
SalesReceivePrintData.ShowAccParts = false;
|
|
49
|
+
SalesReceivePrintData.ShowIGST = (tr_utils_1.TrUtils.IsNull(SType) || (SType === 'Intra')) ? false : true;
|
|
50
|
+
SalesReceivePrintData.ShowTaxColumn = (IncludeGST && !ConsolidateGST) ? true : false;
|
|
51
|
+
// SalesReceivePrintData.ShowDiscountColumn = (!ForInsurance && !ConsolidateGST) ? true : false;
|
|
52
|
+
SalesReceivePrintData = this.GetSalesReceiveTypeHeading(SalesReceivePrintData, OriginalSalesReceiveData, IncludeGST, ConsolidateGST, IsProforma);
|
|
53
|
+
SalesReceivePrintData.PrDate = tr_utils_1.TrUtils.IsNull(OriginalSalesReceiveData.PrDate) ? '' : my_date_1.MyDate.ConvertUTCDateToReadable(OriginalSalesReceiveData.PrDate);
|
|
54
|
+
return SalesReceivePrintData;
|
|
55
|
+
}
|
|
56
|
+
static GetSalesReceiveTypeHeading(SalesReceivePrintData, OriginalSalesReceiveData, IncludeGST, ConsolidateGST, IsProforma) {
|
|
57
|
+
SalesReceivePrintData.HeaderName = 'Sales Receive';
|
|
58
|
+
return SalesReceivePrintData;
|
|
59
|
+
}
|
|
60
|
+
static GetSalesReceiveOtherDetailsForPrint(SalesReceivePrintData, OriginalSalesReceiveData) {
|
|
61
|
+
SalesReceivePrintData.Type = 'Sales Receive';
|
|
62
|
+
SalesReceivePrintData._id = OriginalSalesReceiveData.Code;
|
|
63
|
+
SalesReceivePrintData.Sts = OriginalSalesReceiveData.Sts;
|
|
64
|
+
SalesReceivePrintData.CrDate = my_date_1.MyDate.ConvertUTCDateToReadable(OriginalSalesReceiveData.CrDate);
|
|
65
|
+
return SalesReceivePrintData;
|
|
66
|
+
}
|
|
67
|
+
static GetItemsPrintInfo(Items, Consolidate, TaxCodes, LineTotal, DecimalsNumber) {
|
|
68
|
+
Items.forEach((Item) => {
|
|
69
|
+
if (Consolidate) {
|
|
70
|
+
let AfterDiscForEach = (0, aggregation_1.division)(Item.AfterPartDisc, Item.Qty);
|
|
71
|
+
let CTaxAmtPerItem = (0, aggregation_1.division)(Item.CGST, Item.Qty);
|
|
72
|
+
let STaxAmtPerItem = (0, aggregation_1.division)(Item.SGST, Item.Qty);
|
|
73
|
+
let ITaxAmtPerItem = (0, aggregation_1.division)(Item.IGST, Item.Qty);
|
|
74
|
+
Item.UnPr = tr_utils_1.TrUtils.FixedTo((0, aggregation_1.addition)(AfterDiscForEach, CTaxAmtPerItem, STaxAmtPerItem, ITaxAmtPerItem), DecimalsNumber);
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
Item.UnPr = tr_utils_1.TrUtils.FixPriceValue(Item.UnPr, DecimalsNumber);
|
|
78
|
+
}
|
|
79
|
+
Item.CGSTAmt = tr_utils_1.TrUtils.FixPriceValue(Item.CGST, DecimalsNumber);
|
|
80
|
+
Item.SGSTAmt = tr_utils_1.TrUtils.FixPriceValue(Item.SGST, DecimalsNumber);
|
|
81
|
+
Item.IGSTAmt = tr_utils_1.TrUtils.FixPriceValue(Item.IGST, DecimalsNumber);
|
|
82
|
+
Item.CGSTPerc = shared_print_service_1.PrintSharedService.GetCGSTValueBasedOnTaxCode(Item.TCode, TaxCodes);
|
|
83
|
+
Item.SGSTPerc = shared_print_service_1.PrintSharedService.GetSGSTValueBasedOnTaxCode(Item.TCode, TaxCodes);
|
|
84
|
+
Item.IGSTPerc = shared_print_service_1.PrintSharedService.GetIGSTValueBasedOnTaxCode(Item.TCode, TaxCodes);
|
|
85
|
+
if (LineTotal === 'AT') {
|
|
86
|
+
Item.LineTotal = tr_utils_1.TrUtils.FixPriceValue(Item.AfterPartTax, DecimalsNumber);
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
Item.LineTotal = tr_utils_1.TrUtils.FixPriceValue((0, aggregation_1.subtraction)(Item.UnAmt, Item.Disc), DecimalsNumber);
|
|
90
|
+
}
|
|
91
|
+
if (!tr_utils_1.TrUtils.IsZero(Item.Qty) && !tr_utils_1.TrUtils.CheckInvalidSelect(Item.UoM)) {
|
|
92
|
+
Item.QtyAndUoM = Item.Qty + ' ' + Item.UoM;
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
return Items;
|
|
96
|
+
}
|
|
97
|
+
static ReverseItemsForSalesReceivePrint(argSalesReceiveData) {
|
|
98
|
+
// argSalesReceiveData.Ops = argSalesReceiveData.Ops.reverse();
|
|
99
|
+
argSalesReceiveData.Items = argSalesReceiveData.Items.reverse();
|
|
100
|
+
return argSalesReceiveData;
|
|
101
|
+
}
|
|
102
|
+
static PrepareFormatForSalesReceivePrint(SalesReceivePrintData, ROType, InvoiceStatus) {
|
|
103
|
+
let PrintInfo = [];
|
|
104
|
+
let SRLaborParts = {};
|
|
105
|
+
// SRLaborParts.Ops = SalesReceivePrintData.Ops;
|
|
106
|
+
SRLaborParts.Items = SalesReceivePrintData.Items;
|
|
107
|
+
SRLaborParts.Sts = InvoiceStatus;
|
|
108
|
+
SRLaborParts.Type = ROType;
|
|
109
|
+
PrintInfo.push(SRLaborParts);
|
|
110
|
+
return PrintInfo;
|
|
111
|
+
}
|
|
112
|
+
static GetFormattedProductDataForPrint(OriginalSalesReceiveData, SalesReceivePrintData) {
|
|
113
|
+
if (!tr_utils_1.TrUtils.IsNull(OriginalSalesReceiveData.Prod)) {
|
|
114
|
+
SalesReceivePrintData.Product = OriginalSalesReceiveData.Prod;
|
|
115
|
+
if (tr_utils_1.TrUtils.IsNull(SalesReceivePrintData.Product.VIN)) {
|
|
116
|
+
SalesReceivePrintData.Product.VIN = '';
|
|
117
|
+
}
|
|
118
|
+
if (tr_utils_1.TrUtils.IsNull(SalesReceivePrintData.Product.RegNo)) {
|
|
119
|
+
SalesReceivePrintData.Product.RegNo = '';
|
|
120
|
+
}
|
|
121
|
+
if (tr_utils_1.TrUtils.IsNull(SalesReceivePrintData.Product.EngNo)) {
|
|
122
|
+
SalesReceivePrintData.Product.EngNo = '';
|
|
123
|
+
}
|
|
124
|
+
SalesReceivePrintData.MIn = OriginalSalesReceiveData.Prod.MIn;
|
|
125
|
+
SalesReceivePrintData.MOut = OriginalSalesReceiveData.Prod.MOut;
|
|
126
|
+
}
|
|
127
|
+
return SalesReceivePrintData;
|
|
128
|
+
}
|
|
129
|
+
static GetBillNameForSalesReceivePrint(OriginalSalesReceiveData, SalesReceivePrintData) {
|
|
130
|
+
let Customer = {};
|
|
131
|
+
Customer.Name = OriginalSalesReceiveData.BillTo.Name;
|
|
132
|
+
Customer.Adrs = [];
|
|
133
|
+
Customer.Cons = [];
|
|
134
|
+
if (!tr_utils_1.TrUtils.IsNull(OriginalSalesReceiveData.BillTo.Adrs)) {
|
|
135
|
+
Customer.Adrs.push(OriginalSalesReceiveData.BillTo.Adrs.A1);
|
|
136
|
+
if (!tr_utils_1.TrUtils.IsEmpty(OriginalSalesReceiveData.BillTo.Adrs.A2)) {
|
|
137
|
+
Customer.Adrs.push(OriginalSalesReceiveData.BillTo.Adrs.A2);
|
|
138
|
+
}
|
|
139
|
+
if (!tr_utils_1.TrUtils.IsEmpty(OriginalSalesReceiveData.BillTo.Adrs.Ct)) {
|
|
140
|
+
Customer.Adrs.push(OriginalSalesReceiveData.BillTo.Adrs.Ct);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
Customer.GSTIN = OriginalSalesReceiveData.BillTo.GSTIN;
|
|
144
|
+
if (!tr_utils_1.TrUtils.IsEmpty(OriginalSalesReceiveData.BillTo.Ph)) {
|
|
145
|
+
Customer.Cons = [
|
|
146
|
+
{
|
|
147
|
+
Type: 'M',
|
|
148
|
+
No: OriginalSalesReceiveData.BillTo.Ph
|
|
149
|
+
}
|
|
150
|
+
];
|
|
151
|
+
}
|
|
152
|
+
SalesReceivePrintData.Customer = Customer;
|
|
153
|
+
if (!tr_utils_1.TrUtils.IsNull(OriginalSalesReceiveData.BillTo.InsId)) {
|
|
154
|
+
SalesReceivePrintData.Cust = this.GetCustomerDetails(OriginalSalesReceiveData);
|
|
155
|
+
}
|
|
156
|
+
return SalesReceivePrintData;
|
|
157
|
+
}
|
|
158
|
+
static GetCustomerDetails(OriginalSalesReceiveData) {
|
|
159
|
+
let Customer = {};
|
|
160
|
+
Customer.Name = this.GetBillToName(OriginalSalesReceiveData.Cust.Title, OriginalSalesReceiveData.Cust.Name);
|
|
161
|
+
Customer.Cons = [];
|
|
162
|
+
if (!tr_utils_1.TrUtils.IsEmpty(OriginalSalesReceiveData.Cust.Ph)) {
|
|
163
|
+
Customer.Cons = [
|
|
164
|
+
{
|
|
165
|
+
Type: 'M',
|
|
166
|
+
No: OriginalSalesReceiveData.Cust.Ph
|
|
167
|
+
}
|
|
168
|
+
];
|
|
169
|
+
}
|
|
170
|
+
Customer.GSTIN = OriginalSalesReceiveData.Cust.GSTIN;
|
|
171
|
+
Customer.Adrs = [];
|
|
172
|
+
if (!tr_utils_1.TrUtils.IsNull(OriginalSalesReceiveData.Cust.Adrs)) {
|
|
173
|
+
Customer.Adrs.push(OriginalSalesReceiveData.Cust.Adrs.A1);
|
|
174
|
+
if (!tr_utils_1.TrUtils.IsEmpty(OriginalSalesReceiveData.Cust.Adrs.A2)) {
|
|
175
|
+
Customer.Adrs.push(OriginalSalesReceiveData.Cust.Adrs.A2);
|
|
176
|
+
}
|
|
177
|
+
Customer.Adrs.push(OriginalSalesReceiveData.Cust.Adrs.Ct);
|
|
178
|
+
}
|
|
179
|
+
Customer.ConName = OriginalSalesReceiveData.Cust.ConName;
|
|
180
|
+
Customer.ConPh = OriginalSalesReceiveData.Cust.ConPhone;
|
|
181
|
+
return Customer;
|
|
182
|
+
}
|
|
183
|
+
static GetBillToName(Title, Name) {
|
|
184
|
+
return tr_utils_1.TrUtils.IsEmpty(Title) ? Name : Title + ' ' + Name;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
exports.SalesReceivePrintService = SalesReceivePrintService;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export declare class SalesReceiveTotalsService {
|
|
2
|
+
static GetTotalsValue(opCodesList: any, PartsList: any, IsIndependentTax: boolean, DetailedInfo: boolean, Disc: any, Perc: string, TaxCodes: any, WithItems: boolean, Settings: any, EntitySettings?: any): any;
|
|
3
|
+
static CalculateLaborPartValues(PartsList: any, IsIndependentTax: boolean): any;
|
|
4
|
+
static ResetLaborPartValues(PartsList: any, IsIndependentTax: boolean): any;
|
|
5
|
+
static ResetLaborPartValueIfInvalid(Part: any): any;
|
|
6
|
+
static GetFinalRODataForSave(LaborList: any, PartsList: any, IsIndependentTax: boolean, Disc: any, Perc: string, DetailedInfo: boolean, Settings: any, DecimalsNumber: any): any;
|
|
7
|
+
static SetMainDiscountValues(Disc: string, Perc: string, finalTotalsData: any, DetailedInfo: boolean): any;
|
|
8
|
+
static GetFinalCustomerTotalsData(finalTotalsData: any, LaborList: any, PartsList: any, IsIndependentTax: boolean, DetailedInfo: boolean, DecimalsNumber?: number): any;
|
|
9
|
+
static GetSubTotalFor(LaborList: any, PartsList: any): any;
|
|
10
|
+
static GetPartsTotalAfterDiscount(PartsList: any): any;
|
|
11
|
+
static GetDetailedTotalsData(finalTotalsData: any, IsIndependentTax: boolean, opCodesList: any, PartsList: any, TaxCodes: any, DecimalsNumber?: number): any;
|
|
12
|
+
static GetTaxGroupingForPartsByPerc(Parts: any, TaxCodes: any, DecimalsNumber: any): any[];
|
|
13
|
+
static ComparePartsByPerc(Parts: any, TaxCodes: any): any[];
|
|
14
|
+
static GetPartDiscountedTotal(PartsList: any, isTaxable: boolean, finalTotalsData: any): any;
|
|
15
|
+
static GetPartsTaxTotalFor(PartsList: any, IsIndependentTax: boolean): any;
|
|
16
|
+
static GetCustomerTotalBasedOnTaxType(finalTotalsData: any, LaborTaxAmount: number, PartsTaxAmount: number, LaborList: any, PartsList: any, IsIndependentTax: boolean): any;
|
|
17
|
+
static ItemsTotalAfterDiscount(PartsTotalAfterDisc: number, PartsTaxAmount: number, MainPDisc: number, PDiscInPerc: string): number;
|
|
18
|
+
static GetLaborCGSTTaxTotal(opCodesList: any, IsIndependentTax: boolean): any;
|
|
19
|
+
static GetLaborIGSTTaxTotal(opCodesList: any, IsIndependentTax: boolean): any;
|
|
20
|
+
static GetLaborSGSTTaxTotal(opCodesList: any, IsIndependentTax: boolean): any;
|
|
21
|
+
static GetPartGSTTaxTotal(PartsList: any, IsIndependentTax: boolean): number[];
|
|
22
|
+
static GetTaxGroupingForPartsByHSN(Parts: any, TaxCodes: any, DecimalsNumber: number): any[];
|
|
23
|
+
static GetCombinedTaxPercentage(Parts: any, TaxCodes: any): any;
|
|
24
|
+
static ComparePartsByHSN(Parts: any, TaxCodes: any): any[];
|
|
25
|
+
static GetTaxGroupingInfoByHSN(FinalMatchedParts: any, TaxCodes: any, DecimalsNumber: any): any[];
|
|
26
|
+
static GetGSTValueBasedOnTaxCode(TCode: any, TaxCodes: any): any[];
|
|
27
|
+
}
|
|
@@ -0,0 +1,376 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SalesReceiveTotalsService = void 0;
|
|
4
|
+
const tr_utils_1 = require("../utils/tr-utils");
|
|
5
|
+
const aggregation_1 = require("../aggregation/aggregation");
|
|
6
|
+
class SalesReceiveTotalsService {
|
|
7
|
+
static GetTotalsValue(opCodesList, PartsList, IsIndependentTax, DetailedInfo, Disc, Perc, TaxCodes, WithItems, Settings, EntitySettings = {}) {
|
|
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(opCodesList, PartsList, IsIndependentTax, Disc, Perc, DetailedInfo, Settings, EntitySettings.DecimalsNumber);
|
|
17
|
+
if (DetailedInfo) {
|
|
18
|
+
finalTotalsData = this.GetDetailedTotalsData(finalTotalsData, IsIndependentTax, opCodesList, PartsList, TaxCodes, EntitySettings.DecimalsNumber);
|
|
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
|
+
return PartsList;
|
|
29
|
+
}
|
|
30
|
+
static ResetLaborPartValues(PartsList, IsIndependentTax) {
|
|
31
|
+
PartsList.forEach((Part) => {
|
|
32
|
+
Part = this.ResetLaborPartValueIfInvalid(Part);
|
|
33
|
+
if (tr_utils_1.TrUtils.IsZero(Part.Qty)) {
|
|
34
|
+
Part.Qty = 1;
|
|
35
|
+
}
|
|
36
|
+
Part.DiscountedPrice = (0, aggregation_1.addition)(Part.Disc, Part.RecDisc);
|
|
37
|
+
// Part.AfterPartDisc = Part.NetAmt;
|
|
38
|
+
Part.AfterPartDisc = (0, aggregation_1.subtraction)(Part.UnAmt, Part.Disc, Part.RecDisc);
|
|
39
|
+
if (IsIndependentTax) {
|
|
40
|
+
Part.AfterPartTax = (0, aggregation_1.addition)(Part.AfterPartDisc, Part.CGST, Part.SGST, Part.IGST);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
Part.AfterPartTax = Part.AfterPartDisc;
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
return PartsList;
|
|
47
|
+
}
|
|
48
|
+
static ResetLaborPartValueIfInvalid(Part) {
|
|
49
|
+
Part.UnPr = tr_utils_1.TrUtils.SetValueToZeroIfNull(Part.UnPr);
|
|
50
|
+
Part.Disc = tr_utils_1.TrUtils.SetValueToZeroIfNull(Part.Disc);
|
|
51
|
+
Part.RecDisc = tr_utils_1.TrUtils.SetValueToZeroIfNull(Part.RecDisc);
|
|
52
|
+
Part.CGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(Part.CGST);
|
|
53
|
+
Part.SGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(Part.SGST);
|
|
54
|
+
Part.IGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(Part.IGST);
|
|
55
|
+
return Part;
|
|
56
|
+
}
|
|
57
|
+
static GetFinalRODataForSave(LaborList, PartsList, IsIndependentTax, Disc, Perc, DetailedInfo, Settings, DecimalsNumber) {
|
|
58
|
+
let finalTotalsData = {};
|
|
59
|
+
finalTotalsData = this.SetMainDiscountValues(Disc, Perc, finalTotalsData, DetailedInfo);
|
|
60
|
+
finalTotalsData.Settings = Settings;
|
|
61
|
+
finalTotalsData = this.GetFinalCustomerTotalsData(finalTotalsData, [], PartsList, IsIndependentTax, DetailedInfo, DecimalsNumber);
|
|
62
|
+
return finalTotalsData;
|
|
63
|
+
}
|
|
64
|
+
static SetMainDiscountValues(Disc, Perc, finalTotalsData, DetailedInfo) {
|
|
65
|
+
// finalTotalsData.LDisc = LDisc;
|
|
66
|
+
// finalTotalsData.LPerc = LPerc;
|
|
67
|
+
// finalTotalsData.PDisc = PDisc;
|
|
68
|
+
// finalTotalsData.PPerc = PPerc;
|
|
69
|
+
finalTotalsData.Disc = Disc;
|
|
70
|
+
finalTotalsData.Perc = Perc;
|
|
71
|
+
if (DetailedInfo) {
|
|
72
|
+
// finalTotalsData.FixedLDisc = LDisc;
|
|
73
|
+
// finalTotalsData.FixedPDisc = PDisc;
|
|
74
|
+
finalTotalsData.FixedDisc = Disc;
|
|
75
|
+
}
|
|
76
|
+
return finalTotalsData;
|
|
77
|
+
}
|
|
78
|
+
static GetFinalCustomerTotalsData(finalTotalsData, LaborList, PartsList, IsIndependentTax, DetailedInfo, DecimalsNumber = 2) {
|
|
79
|
+
let CustomerAfterDiscTotals = this.GetSubTotalFor([], PartsList);
|
|
80
|
+
// let CustLaborTaxTotal = this.GetLaborTaxTotalFor([], IsIndependentTax);
|
|
81
|
+
let CustPartTaxTotal = this.GetPartsTaxTotalFor(PartsList, IsIndependentTax);
|
|
82
|
+
finalTotalsData.SubTotal = tr_utils_1.TrUtils.FixedTo(CustomerAfterDiscTotals, DecimalsNumber);
|
|
83
|
+
// let CustLaborDiscTotal = this.GetLaborDiscountedTotal(LaborList, IsIndependentTax, finalTotalsData);
|
|
84
|
+
let CustPartsDiscTotal = this.GetPartDiscountedTotal(PartsList, IsIndependentTax, finalTotalsData);
|
|
85
|
+
// let CustLaborTotalAfterDisc = this.GetLaborTotalAfterDiscount(LaborList);
|
|
86
|
+
let CustPartsTotalAfterDisc = this.GetPartsTotalAfterDiscount(PartsList);
|
|
87
|
+
finalTotalsData.STotal = (0, aggregation_1.addition)(CustPartsDiscTotal, CustPartsTotalAfterDisc);
|
|
88
|
+
let CustTotal = this.GetCustomerTotalBasedOnTaxType(finalTotalsData, 0, CustPartTaxTotal, [], PartsList, IsIndependentTax);
|
|
89
|
+
finalTotalsData.Round = (0, aggregation_1.subtraction)(Math.round(CustTotal), CustTotal);
|
|
90
|
+
finalTotalsData.Total = Math.round(CustTotal);
|
|
91
|
+
if (DetailedInfo) {
|
|
92
|
+
finalTotalsData.FixedSubTotal = tr_utils_1.TrUtils.FixedTo(CustomerAfterDiscTotals, DecimalsNumber);
|
|
93
|
+
finalTotalsData.FixedTotal = tr_utils_1.TrUtils.FixedTo(CustTotal, DecimalsNumber);
|
|
94
|
+
}
|
|
95
|
+
return finalTotalsData;
|
|
96
|
+
}
|
|
97
|
+
static GetSubTotalFor(LaborList, PartsList) {
|
|
98
|
+
// let LaborTotalAfterDisc: any = this.GetLaborTotalAfterDiscount(LaborList);
|
|
99
|
+
let PartsTotalAfterDisc = this.GetPartsTotalAfterDiscount(PartsList);
|
|
100
|
+
return PartsTotalAfterDisc;
|
|
101
|
+
}
|
|
102
|
+
static GetPartsTotalAfterDiscount(PartsList) {
|
|
103
|
+
let PartsTotalAfterDisc = 0;
|
|
104
|
+
PartsList.forEach((Part) => {
|
|
105
|
+
PartsTotalAfterDisc = (0, aggregation_1.addition)(PartsTotalAfterDisc, Part.AfterPartDisc);
|
|
106
|
+
});
|
|
107
|
+
return PartsTotalAfterDisc;
|
|
108
|
+
}
|
|
109
|
+
static GetDetailedTotalsData(finalTotalsData, IsIndependentTax, opCodesList, PartsList, TaxCodes, DecimalsNumber = 2) {
|
|
110
|
+
// finalTotalsData.CustLaborDiscTotal = this.GetLaborDiscountedTotal(opCodesList, IsIndependentTax, finalTotalsData);
|
|
111
|
+
finalTotalsData.CustPartsDiscTotal = this.GetPartDiscountedTotal(PartsList, IsIndependentTax, finalTotalsData);
|
|
112
|
+
// finalTotalsData.CustLaborTotalAfterDisc = this.GetLaborTotalAfterDiscount(opCodesList);
|
|
113
|
+
finalTotalsData.CustPartsTotalAfterDisc = this.GetPartsTotalAfterDiscount(PartsList);
|
|
114
|
+
// finalTotalsData.CustLaborTotalBeforeDisc = TrUtils.FixedTo(finalTotalsData.CustLaborTotalAfterDisc
|
|
115
|
+
// + finalTotalsData.CustLaborDiscTotal);
|
|
116
|
+
finalTotalsData.CustPartsTotalBeforeDisc = (0, aggregation_1.addition)(finalTotalsData.CustPartsTotalAfterDisc, finalTotalsData.CustPartsDiscTotal);
|
|
117
|
+
// finalTotalsData.CustLaborITax = this.GetLaborTaxTotalFor(opCodesList, IsIndependentTax);
|
|
118
|
+
// finalTotalsData.CustLaborSGST = this.GetLaborSGSTTaxTotal(opCodesList, IsIndependentTax);
|
|
119
|
+
// finalTotalsData.CustLaborCGST = this.GetLaborCGSTTaxTotal(opCodesList, IsIndependentTax);
|
|
120
|
+
// finalTotalsData.CustLaborIGST = this.GetLaborIGSTTaxTotal(opCodesList, IsIndependentTax);
|
|
121
|
+
let TaxInfo = this.GetPartGSTTaxTotal(PartsList, IsIndependentTax);
|
|
122
|
+
finalTotalsData.CustPartITax = tr_utils_1.TrUtils.SetValueToZeroIfNull(TaxInfo[3]);
|
|
123
|
+
finalTotalsData.CustPartCGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(TaxInfo[0]);
|
|
124
|
+
finalTotalsData.CustPartIGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(TaxInfo[2]);
|
|
125
|
+
finalTotalsData.CustPartSGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(TaxInfo[1]);
|
|
126
|
+
// finalTotalsData.CustLaborAfterTax = addition(finalTotalsData.CustLaborITax, finalTotalsData.CustLaborTotalAfterDisc);
|
|
127
|
+
finalTotalsData.CustPartAfterTax = (0, aggregation_1.addition)(finalTotalsData.CustPartITax, finalTotalsData.CustPartsTotalAfterDisc);
|
|
128
|
+
finalTotalsData.CustTaxGroupData = this.GetTaxGroupingForPartsByHSN(tr_utils_1.TrUtils.Stringify(PartsList), TaxCodes, DecimalsNumber);
|
|
129
|
+
finalTotalsData.CustTaxGroupDataByPerc = this.GetTaxGroupingForPartsByPerc(PartsList, TaxCodes, DecimalsNumber);
|
|
130
|
+
finalTotalsData.CustTotalRoundedBy = tr_utils_1.TrUtils.FixedTo(finalTotalsData.Round, DecimalsNumber);
|
|
131
|
+
finalTotalsData.CustRoundedTotal = tr_utils_1.TrUtils.FixedTo(finalTotalsData.Total, DecimalsNumber);
|
|
132
|
+
for (var key in finalTotalsData) {
|
|
133
|
+
if (key !== 'Total' && key !== 'SubTotal' &&
|
|
134
|
+
key !== 'LDisc' && key !== 'LPerc' && key !== 'PDisc' &&
|
|
135
|
+
key !== 'PPerc' && key !== 'Disc' && key !== 'Perc' && key !== 'Tax'
|
|
136
|
+
&& typeof finalTotalsData[key] === 'number') {
|
|
137
|
+
finalTotalsData[key] = tr_utils_1.TrUtils.FixPriceValue(finalTotalsData[key], DecimalsNumber);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return finalTotalsData;
|
|
141
|
+
}
|
|
142
|
+
static GetTaxGroupingForPartsByPerc(Parts, TaxCodes, DecimalsNumber) {
|
|
143
|
+
Parts = this.GetCombinedTaxPercentage(tr_utils_1.TrUtils.Stringify(Parts), TaxCodes);
|
|
144
|
+
// Parts = this.ResetPartsHSNIfInvalid(Parts);
|
|
145
|
+
let FinalMatchedParts = this.ComparePartsByPerc(Parts, TaxCodes);
|
|
146
|
+
return this.GetTaxGroupingInfoByHSN(FinalMatchedParts, TaxCodes, DecimalsNumber);
|
|
147
|
+
}
|
|
148
|
+
static ComparePartsByPerc(Parts, TaxCodes) {
|
|
149
|
+
let FinalMatchedParts = [];
|
|
150
|
+
Parts === null || Parts === void 0 ? void 0 : Parts.forEach((Part) => {
|
|
151
|
+
let MatchedPartsBasedOnHSN = Parts.filter((argPart) => {
|
|
152
|
+
let PartFound = false;
|
|
153
|
+
FinalMatchedParts.forEach((FinalArgParts) => {
|
|
154
|
+
let PartIndex = FinalArgParts.findIndex((FinalArgPart) => {
|
|
155
|
+
return FinalArgPart._id === argPart._id;
|
|
156
|
+
});
|
|
157
|
+
if (PartIndex !== -1) {
|
|
158
|
+
PartFound = true;
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
// let argGSTValues: any[] = this.GetGSTValueBasedOnTaxCode(argPart.TCode, TaxCodes);
|
|
162
|
+
// let argCGST = argGSTValues[0];
|
|
163
|
+
// let argSGST = argGSTValues[1];
|
|
164
|
+
// let argIGST = argGSTValues[2];
|
|
165
|
+
// let partGSTValues: any[] = this.GetGSTValueBasedOnTaxCode(Part.TCode, TaxCodes);
|
|
166
|
+
// let partCGST = partGSTValues[0];
|
|
167
|
+
// let partSGST = partGSTValues[1];
|
|
168
|
+
// let partIGST = partGSTValues[2];
|
|
169
|
+
return (!PartFound) &&
|
|
170
|
+
(argPart.CGSTAmt === Part.CGSTAmt) && (argPart.IGSTAmt === Part.IGSTAmt) &&
|
|
171
|
+
(argPart.SGSTAmt === Part.SGSTAmt);
|
|
172
|
+
});
|
|
173
|
+
if (MatchedPartsBasedOnHSN.length !== 0) {
|
|
174
|
+
FinalMatchedParts.push(MatchedPartsBasedOnHSN);
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
return FinalMatchedParts;
|
|
178
|
+
}
|
|
179
|
+
static GetPartDiscountedTotal(PartsList, isTaxable, finalTotalsData) {
|
|
180
|
+
let PartsDiscountedTotal = 0;
|
|
181
|
+
let overallPartDisc = 0;
|
|
182
|
+
if (!isTaxable) {
|
|
183
|
+
overallPartDisc = tr_utils_1.TrUtils.SetValueToZeroIfNull(finalTotalsData.PDisc);
|
|
184
|
+
}
|
|
185
|
+
PartsList.forEach((Part) => {
|
|
186
|
+
PartsDiscountedTotal = (0, aggregation_1.addition)(PartsDiscountedTotal, Part.DiscountedPrice);
|
|
187
|
+
});
|
|
188
|
+
return (0, aggregation_1.addition)(PartsDiscountedTotal, overallPartDisc);
|
|
189
|
+
}
|
|
190
|
+
static GetPartsTaxTotalFor(PartsList, IsIndependentTax) {
|
|
191
|
+
let TotalTaxAmt = 0;
|
|
192
|
+
if (IsIndependentTax) {
|
|
193
|
+
PartsList.forEach((Part) => {
|
|
194
|
+
TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Part.CGST, Part.SGST, Part.IGST);
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
return TotalTaxAmt;
|
|
198
|
+
}
|
|
199
|
+
static GetCustomerTotalBasedOnTaxType(finalTotalsData, LaborTaxAmount, PartsTaxAmount, LaborList, PartsList, IsIndependentTax) {
|
|
200
|
+
// let LaborTotalAfterDisc: any = this.GetLaborTotalAfterDiscount(LaborList);
|
|
201
|
+
let PartsTotalAfterDisc = this.GetPartsTotalAfterDiscount(PartsList);
|
|
202
|
+
if (IsIndependentTax) {
|
|
203
|
+
return (0, aggregation_1.addition)(PartsTotalAfterDisc, LaborTaxAmount, PartsTaxAmount);
|
|
204
|
+
}
|
|
205
|
+
else {
|
|
206
|
+
return (0, aggregation_1.subtraction)(PartsTotalAfterDisc, finalTotalsData.Disc);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
static ItemsTotalAfterDiscount(PartsTotalAfterDisc, PartsTaxAmount, MainPDisc, PDiscInPerc) {
|
|
210
|
+
let ItemsTotal = (0, aggregation_1.addition)(PartsTotalAfterDisc, PartsTaxAmount);
|
|
211
|
+
if (!tr_utils_1.TrUtils.IsZero(MainPDisc)) {
|
|
212
|
+
if (!tr_utils_1.TrUtils.IsEmpty(PDiscInPerc)) {
|
|
213
|
+
ItemsTotal = (0, aggregation_1.subtraction)(ItemsTotal, (0, aggregation_1.division)((0, aggregation_1.multiply)(ItemsTotal, Number(PDiscInPerc)), 100));
|
|
214
|
+
}
|
|
215
|
+
else {
|
|
216
|
+
ItemsTotal = (0, aggregation_1.subtraction)(ItemsTotal, MainPDisc);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
return ItemsTotal;
|
|
220
|
+
}
|
|
221
|
+
static GetLaborCGSTTaxTotal(opCodesList, IsIndependentTax) {
|
|
222
|
+
let TotalTaxAmt = 0;
|
|
223
|
+
if (IsIndependentTax) {
|
|
224
|
+
opCodesList.forEach((Labor) => {
|
|
225
|
+
TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Labor.CGST);
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
return TotalTaxAmt;
|
|
229
|
+
}
|
|
230
|
+
static GetLaborIGSTTaxTotal(opCodesList, IsIndependentTax) {
|
|
231
|
+
let TotalTaxAmt = 0;
|
|
232
|
+
if (IsIndependentTax) {
|
|
233
|
+
opCodesList.forEach((Labor) => {
|
|
234
|
+
TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Labor.IGST);
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
return TotalTaxAmt;
|
|
238
|
+
}
|
|
239
|
+
static GetLaborSGSTTaxTotal(opCodesList, IsIndependentTax) {
|
|
240
|
+
let TotalTaxAmt = 0;
|
|
241
|
+
if (IsIndependentTax) {
|
|
242
|
+
opCodesList.forEach((Labor) => {
|
|
243
|
+
TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Labor.SGST);
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
return TotalTaxAmt;
|
|
247
|
+
}
|
|
248
|
+
static GetPartGSTTaxTotal(PartsList, IsIndependentTax) {
|
|
249
|
+
let TotalCGSTAmt = 0;
|
|
250
|
+
let TotalSGSTAmt = 0;
|
|
251
|
+
let TotalIGSTAmt = 0;
|
|
252
|
+
let TotalTaxAmt = 0;
|
|
253
|
+
if (IsIndependentTax) {
|
|
254
|
+
PartsList.forEach((Part) => {
|
|
255
|
+
TotalCGSTAmt = (0, aggregation_1.addition)(TotalCGSTAmt, Part.CGST);
|
|
256
|
+
TotalIGSTAmt = (0, aggregation_1.addition)(TotalIGSTAmt, Part.IGST);
|
|
257
|
+
TotalSGSTAmt = (0, aggregation_1.addition)(TotalSGSTAmt, Part.SGST);
|
|
258
|
+
TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Part.CGST, Part.SGST, Part.IGST);
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
return [TotalCGSTAmt, TotalSGSTAmt, TotalIGSTAmt, TotalTaxAmt];
|
|
262
|
+
}
|
|
263
|
+
static GetTaxGroupingForPartsByHSN(Parts, TaxCodes, DecimalsNumber) {
|
|
264
|
+
Parts = this.GetCombinedTaxPercentage(Parts, TaxCodes);
|
|
265
|
+
// Parts = this.ResetPartsHSNIfInvalid(Parts);
|
|
266
|
+
let FinalMatchedParts = this.ComparePartsByHSN(Parts, TaxCodes);
|
|
267
|
+
return this.GetTaxGroupingInfoByHSN(FinalMatchedParts, TaxCodes, DecimalsNumber);
|
|
268
|
+
}
|
|
269
|
+
static GetCombinedTaxPercentage(Parts, TaxCodes) {
|
|
270
|
+
Parts.forEach((Part) => {
|
|
271
|
+
if (tr_utils_1.TrUtils.IsNull(Part.HSN)) {
|
|
272
|
+
Part.HSN = '';
|
|
273
|
+
}
|
|
274
|
+
let GSTValues = this.GetGSTValueBasedOnTaxCode(Part.TCode, TaxCodes);
|
|
275
|
+
Part.CGSTAmt = tr_utils_1.TrUtils.SetValueToZeroIfNull(GSTValues[0]);
|
|
276
|
+
Part.SGSTAmt = tr_utils_1.TrUtils.SetValueToZeroIfNull(GSTValues[1]);
|
|
277
|
+
Part.IGSTAmt = tr_utils_1.TrUtils.SetValueToZeroIfNull(GSTValues[2]);
|
|
278
|
+
Part.CombinedTaxPercentage = (0, aggregation_1.addition)(Part.CGSTAmt, Part.SGSTAmt, Part.IGSTAmt);
|
|
279
|
+
});
|
|
280
|
+
return Parts;
|
|
281
|
+
}
|
|
282
|
+
static ComparePartsByHSN(Parts, TaxCodes) {
|
|
283
|
+
let FinalMatchedParts = [];
|
|
284
|
+
Parts.forEach((Part) => {
|
|
285
|
+
let MatchedPartsBasedOnHSN = Parts.filter((argPart) => {
|
|
286
|
+
let PartFound = false;
|
|
287
|
+
FinalMatchedParts.forEach((FinalArgParts) => {
|
|
288
|
+
let PartIndex = FinalArgParts.findIndex((FinalArgPart) => {
|
|
289
|
+
return FinalArgPart._id === argPart._id;
|
|
290
|
+
});
|
|
291
|
+
if (PartIndex !== -1) {
|
|
292
|
+
PartFound = true;
|
|
293
|
+
}
|
|
294
|
+
});
|
|
295
|
+
// let argGSTValues: any[] = this.GetGSTValueBasedOnTaxCode(argPart.TCode, TaxCodes);
|
|
296
|
+
// let argCGST = argGSTValues[0];
|
|
297
|
+
// let argSGST = argGSTValues[1];
|
|
298
|
+
// let argIGST = argGSTValues[2];
|
|
299
|
+
// let partGSTValues: any[] = this.GetGSTValueBasedOnTaxCode(Part.TCode, TaxCodes);
|
|
300
|
+
// let partCGST = partGSTValues[0];
|
|
301
|
+
// let partSGST = partGSTValues[1];
|
|
302
|
+
// let partIGST = partGSTValues[2];
|
|
303
|
+
return (argPart.HSN === Part.HSN) && (!PartFound) &&
|
|
304
|
+
(argPart.CGSTAmt === Part.CGSTAmt) && (argPart.IGSTAmt === Part.IGSTAmt) &&
|
|
305
|
+
(argPart.SGSTAmt === Part.SGSTAmt);
|
|
306
|
+
});
|
|
307
|
+
if (MatchedPartsBasedOnHSN.length !== 0) {
|
|
308
|
+
FinalMatchedParts.push(MatchedPartsBasedOnHSN);
|
|
309
|
+
}
|
|
310
|
+
});
|
|
311
|
+
return FinalMatchedParts;
|
|
312
|
+
}
|
|
313
|
+
static GetTaxGroupingInfoByHSN(FinalMatchedParts, TaxCodes, DecimalsNumber) {
|
|
314
|
+
let HSNTaxInfo = [];
|
|
315
|
+
FinalMatchedParts.forEach((MatchedPart) => {
|
|
316
|
+
let TaxInfo = {};
|
|
317
|
+
let TaxOnAmount = 0;
|
|
318
|
+
let TaxAmount = 0;
|
|
319
|
+
let CGSTAmt = 0;
|
|
320
|
+
let SGSTAmt = 0;
|
|
321
|
+
let IGSTAmt = 0;
|
|
322
|
+
let HSN = MatchedPart[0].HSN;
|
|
323
|
+
TaxInfo.CombinedTaxPercentage = MatchedPart[0].CombinedTaxPercentage;
|
|
324
|
+
MatchedPart.forEach((argMatchedGSTPart) => {
|
|
325
|
+
TaxOnAmount = (0, aggregation_1.addition)(TaxOnAmount, tr_utils_1.TrUtils.FixedTo(argMatchedGSTPart.AfterPartDisc, DecimalsNumber));
|
|
326
|
+
TaxAmount = (0, aggregation_1.addition)(TaxAmount, tr_utils_1.TrUtils.FixedTo(argMatchedGSTPart.CGST, DecimalsNumber));
|
|
327
|
+
TaxAmount = (0, aggregation_1.addition)(TaxAmount, tr_utils_1.TrUtils.FixedTo(argMatchedGSTPart.IGST, DecimalsNumber));
|
|
328
|
+
TaxAmount = (0, aggregation_1.addition)(TaxAmount, tr_utils_1.TrUtils.FixedTo(argMatchedGSTPart.SGST, DecimalsNumber));
|
|
329
|
+
CGSTAmt = (0, aggregation_1.addition)(CGSTAmt, tr_utils_1.TrUtils.FixedTo(argMatchedGSTPart.CGST, DecimalsNumber));
|
|
330
|
+
SGSTAmt = (0, aggregation_1.addition)(SGSTAmt, tr_utils_1.TrUtils.FixedTo(argMatchedGSTPart.SGST, DecimalsNumber));
|
|
331
|
+
IGSTAmt = (0, aggregation_1.addition)(IGSTAmt, tr_utils_1.TrUtils.FixedTo(argMatchedGSTPart.IGST, DecimalsNumber));
|
|
332
|
+
});
|
|
333
|
+
TaxInfo.HSN = HSN;
|
|
334
|
+
TaxInfo.CGSTAmt = CGSTAmt;
|
|
335
|
+
TaxInfo.SGSTAmt = SGSTAmt;
|
|
336
|
+
TaxInfo.IGSTAmt = IGSTAmt;
|
|
337
|
+
TaxInfo.TotalTaxableAmount = tr_utils_1.TrUtils.FixPriceValue(TaxOnAmount, DecimalsNumber);
|
|
338
|
+
TaxInfo.TotalTaxAmount = tr_utils_1.TrUtils.FixPriceValue(TaxAmount, DecimalsNumber);
|
|
339
|
+
TaxInfo.ItemsCount = MatchedPart.length;
|
|
340
|
+
// let GSTValues: any[] = this.GetGSTValueBasedOnTaxCode(MatchedPart[0].TCode, TaxCodes);
|
|
341
|
+
// TaxInfo.CGST = GSTValues[0];
|
|
342
|
+
// TaxInfo.SGST = GSTValues[1];
|
|
343
|
+
// TaxInfo.IGST = GSTValues[2];
|
|
344
|
+
TaxInfo.CGST = MatchedPart[0].CGSTAmt;
|
|
345
|
+
TaxInfo.IGST = MatchedPart[0].IGSTAmt;
|
|
346
|
+
TaxInfo.SGST = MatchedPart[0].SGSTAmt;
|
|
347
|
+
if (TaxOnAmount !== 0) {
|
|
348
|
+
HSNTaxInfo.push(TaxInfo);
|
|
349
|
+
}
|
|
350
|
+
});
|
|
351
|
+
return HSNTaxInfo;
|
|
352
|
+
}
|
|
353
|
+
static GetGSTValueBasedOnTaxCode(TCode, TaxCodes) {
|
|
354
|
+
let CGST = 0;
|
|
355
|
+
let SGST = 0;
|
|
356
|
+
let IGST = 0;
|
|
357
|
+
if (tr_utils_1.TrUtils.IsNull(TCode)) {
|
|
358
|
+
return [CGST, SGST, IGST];
|
|
359
|
+
}
|
|
360
|
+
let TCodeIndex = TaxCodes.findIndex((TaxCode) => {
|
|
361
|
+
return TaxCode._id === Number(TCode);
|
|
362
|
+
});
|
|
363
|
+
if (TCodeIndex !== -1) {
|
|
364
|
+
if (TaxCodes[TCodeIndex].Type === 'Intra') {
|
|
365
|
+
return [TaxCodes[TCodeIndex].CGST, TaxCodes[TCodeIndex].SGST, 0];
|
|
366
|
+
}
|
|
367
|
+
else {
|
|
368
|
+
return [0, 0, TaxCodes[TCodeIndex].IGST];
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
else {
|
|
372
|
+
return [CGST, SGST, IGST];
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
exports.SalesReceiveTotalsService = SalesReceiveTotalsService;
|