shareneus 1.4.85 → 1.4.86
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.
|
@@ -13,6 +13,12 @@ export declare class PurchaseOrderTotalsService {
|
|
|
13
13
|
static GetPartsTotalTaxAndAfterDiscount(PartsList: any): any[];
|
|
14
14
|
static GetTotalBasedOnTaxType(PartsTotalAfterDisc: number, PartsTaxAmount: number, ServicesTotalAfterDisc: number, ServicesTaxTotal: number, IsTaxable: boolean, Adjust: number, DecimalsNumber: number): number;
|
|
15
15
|
static GetDetailedTotalsData(finalTotalsData: any, IsTaxable: boolean, PartsList: any, LaborList: any, TaxCodes: any, Tax: any, HasNoTax: boolean, DecimalsNumber: number): any;
|
|
16
|
+
static groupTaxData(items: any[], ops: any[]): any[];
|
|
17
|
+
static GetTaxGroupingForLaborByPerc(opCodesList: any, TaxCodes: any, DecimalsNumber: any): any[];
|
|
18
|
+
static GetTaxGroupingForPartsByPerc(Parts: any, TaxCodes: any, DecimalsNumber: any): any[];
|
|
19
|
+
static GetTaxGroupingInfoBySAC(FinalMatchedLabors: any, TaxCodes: any, DecimalsNumber: any): any[];
|
|
20
|
+
static CompareLaborByPerc(opCodesList: any, TaxCodes: any): any[];
|
|
21
|
+
static ComparePartsByPerc(Parts: any, TaxCodes: any): any[];
|
|
16
22
|
static GetPartGSTTaxTotal(PartsList: Array<any>): number[];
|
|
17
23
|
static GetServicesGSTTaxTotal(ServicesList: Array<any>): number[];
|
|
18
24
|
static GetPartsTaxGroupingFor(PartsList: any, TaxCodes: any, DecimalsNumber: number): any[];
|
|
@@ -250,12 +250,148 @@ class PurchaseOrderTotalsService {
|
|
|
250
250
|
finalTotalsData.Tax = Tax;
|
|
251
251
|
finalTotalsData.HasNoTax = HasNoTax;
|
|
252
252
|
finalTotalsData.TaxGroupData = this.GetPartsTaxGroupingFor(PartsList, TaxCodes, DecimalsNumber);
|
|
253
|
+
finalTotalsData.CustTaxGroupDataByPerc = this.GetTaxGroupingForPartsByPerc(PartsList, TaxCodes, DecimalsNumber);
|
|
254
|
+
finalTotalsData.CustLaborTaxGroupDataByPerc = this.GetTaxGroupingForLaborByPerc(LaborList, TaxCodes, DecimalsNumber);
|
|
255
|
+
finalTotalsData.TaxSummary = this.groupTaxData(finalTotalsData.CustTaxGroupData, finalTotalsData.CustLaborTaxGroupDataByPerc);
|
|
253
256
|
// finalTotalsData.TotalRoundedBy = TrUtils.FixedTo(Math.round(finalTotalsData.Total) - finalTotalsData.Total);
|
|
254
257
|
finalTotalsData.RoundedTotal = Math.round(finalTotalsData.Total);
|
|
255
258
|
// finalTotalsData.Round = TrUtils.FixedTo(Math.round(finalTotalsData.Total) - finalTotalsData.Total);
|
|
256
259
|
// finalTotalsData.Total = Math.round(finalTotalsData.Total);
|
|
257
260
|
return finalTotalsData;
|
|
258
261
|
}
|
|
262
|
+
static groupTaxData(items, ops) {
|
|
263
|
+
const combined = [...items, ...ops];
|
|
264
|
+
const groupedMap = new Map();
|
|
265
|
+
combined.forEach(item => {
|
|
266
|
+
if (groupedMap.has(item.CombinedTaxPercentage)) {
|
|
267
|
+
const existing = groupedMap.get(item.CombinedTaxPercentage);
|
|
268
|
+
existing.CGSTAmt = (0, aggregation_1.addition)(existing.CGSTAmt, item.CGSTAmt);
|
|
269
|
+
existing.SGSTAmt = (0, aggregation_1.addition)(existing.SGSTAmt, item.SGSTAmt);
|
|
270
|
+
// Sum IGST if present
|
|
271
|
+
if (item.IGSTAmt !== undefined) {
|
|
272
|
+
existing.IGSTAmt = (0, aggregation_1.addition)(existing.IGSTAmt || 0, item.IGSTAmt);
|
|
273
|
+
}
|
|
274
|
+
existing.TotalTaxAmount = (0, aggregation_1.addition)(existing.TotalTaxAmount || 0, item.TotalTaxAmount || 0);
|
|
275
|
+
existing.TotalTaxableAmount = (0, aggregation_1.addition)(existing.TotalTaxableAmount || 0, item.TotalTaxableAmount || 0);
|
|
276
|
+
}
|
|
277
|
+
else {
|
|
278
|
+
// Clone the object to avoid mutation
|
|
279
|
+
groupedMap.set(item.CombinedTaxPercentage, Object.assign({}, item));
|
|
280
|
+
}
|
|
281
|
+
});
|
|
282
|
+
return Array.from(groupedMap.values());
|
|
283
|
+
}
|
|
284
|
+
static GetTaxGroupingForLaborByPerc(opCodesList, TaxCodes, DecimalsNumber) {
|
|
285
|
+
opCodesList = this.GetCombinedTaxPercentage(tr_utils_1.TrUtils.Stringify(opCodesList), TaxCodes);
|
|
286
|
+
// opCodesList = this.ResetPartsHSNIfInvalid(opCodesList);
|
|
287
|
+
let FinalMatchedParts = this.CompareLaborByPerc(opCodesList, TaxCodes);
|
|
288
|
+
return this.GetTaxGroupingInfoBySAC(FinalMatchedParts, TaxCodes, DecimalsNumber);
|
|
289
|
+
}
|
|
290
|
+
static GetTaxGroupingForPartsByPerc(Parts, TaxCodes, DecimalsNumber) {
|
|
291
|
+
Parts = this.GetCombinedTaxPercentage(tr_utils_1.TrUtils.Stringify(Parts), TaxCodes);
|
|
292
|
+
// Parts = this.ResetPartsHSNIfInvalid(Parts);
|
|
293
|
+
let FinalMatchedParts = this.ComparePartsByPerc(Parts, TaxCodes);
|
|
294
|
+
return this.GetTaxGroupingInfoByHSN(FinalMatchedParts, TaxCodes, DecimalsNumber);
|
|
295
|
+
}
|
|
296
|
+
static GetTaxGroupingInfoBySAC(FinalMatchedLabors, TaxCodes, DecimalsNumber) {
|
|
297
|
+
let SACTaxInfo = [];
|
|
298
|
+
FinalMatchedLabors === null || FinalMatchedLabors === void 0 ? void 0 : FinalMatchedLabors.forEach((MatchedLabor) => {
|
|
299
|
+
let TaxInfo = {};
|
|
300
|
+
let TaxOnAmount = 0;
|
|
301
|
+
let TaxAmount = 0;
|
|
302
|
+
let CGSTAmt = 0;
|
|
303
|
+
let SGSTAmt = 0;
|
|
304
|
+
let IGSTAmt = 0;
|
|
305
|
+
let SAC = MatchedLabor[0].SAC;
|
|
306
|
+
TaxInfo.CombinedTaxPercentage = MatchedLabor[0].CombinedTaxPercentage;
|
|
307
|
+
MatchedLabor === null || MatchedLabor === void 0 ? void 0 : MatchedLabor.forEach((argMatchedGSTLabor) => {
|
|
308
|
+
TaxOnAmount = (0, aggregation_1.addition)(TaxOnAmount, tr_utils_1.TrUtils.FixedTo(argMatchedGSTLabor.AfterLaborDisc, DecimalsNumber));
|
|
309
|
+
TaxAmount = (0, aggregation_1.addition)(TaxAmount, tr_utils_1.TrUtils.FixedTo(argMatchedGSTLabor.CGST, DecimalsNumber));
|
|
310
|
+
TaxAmount = (0, aggregation_1.addition)(TaxAmount, tr_utils_1.TrUtils.FixedTo(argMatchedGSTLabor.IGST, DecimalsNumber));
|
|
311
|
+
TaxAmount = (0, aggregation_1.addition)(TaxAmount, tr_utils_1.TrUtils.FixedTo(argMatchedGSTLabor.SGST, DecimalsNumber));
|
|
312
|
+
CGSTAmt = (0, aggregation_1.addition)(CGSTAmt, tr_utils_1.TrUtils.FixedTo(argMatchedGSTLabor.CGST, DecimalsNumber));
|
|
313
|
+
SGSTAmt = (0, aggregation_1.addition)(SGSTAmt, tr_utils_1.TrUtils.FixedTo(argMatchedGSTLabor.SGST, DecimalsNumber));
|
|
314
|
+
IGSTAmt = (0, aggregation_1.addition)(IGSTAmt, tr_utils_1.TrUtils.FixedTo(argMatchedGSTLabor.IGST, DecimalsNumber));
|
|
315
|
+
});
|
|
316
|
+
TaxInfo.SAC = SAC;
|
|
317
|
+
TaxInfo.CGSTAmt = CGSTAmt;
|
|
318
|
+
TaxInfo.SGSTAmt = SGSTAmt;
|
|
319
|
+
TaxInfo.IGSTAmt = IGSTAmt;
|
|
320
|
+
TaxInfo.TotalTaxableAmount = tr_utils_1.TrUtils.FixPriceValue(TaxOnAmount, DecimalsNumber);
|
|
321
|
+
TaxInfo.TotalTaxAmount = tr_utils_1.TrUtils.FixPriceValue(TaxAmount, DecimalsNumber);
|
|
322
|
+
TaxInfo.ItemsCount = MatchedLabor.length;
|
|
323
|
+
let GSTValues = this.GetGSTValueBasedOnTaxCode(MatchedLabor[0].TCode, TaxCodes);
|
|
324
|
+
TaxInfo.CGST = GSTValues[0];
|
|
325
|
+
TaxInfo.SGST = GSTValues[1];
|
|
326
|
+
TaxInfo.IGST = GSTValues[2];
|
|
327
|
+
if (TaxOnAmount !== 0) {
|
|
328
|
+
SACTaxInfo.push(TaxInfo);
|
|
329
|
+
}
|
|
330
|
+
});
|
|
331
|
+
return SACTaxInfo;
|
|
332
|
+
}
|
|
333
|
+
static CompareLaborByPerc(opCodesList, TaxCodes) {
|
|
334
|
+
let FinalMatchedLabors = [];
|
|
335
|
+
opCodesList === null || opCodesList === void 0 ? void 0 : opCodesList.forEach((Labor) => {
|
|
336
|
+
let MatchedLaborsBasedOnPerc = opCodesList.filter((argLabor) => {
|
|
337
|
+
let PartFound = false;
|
|
338
|
+
FinalMatchedLabors.forEach((FinalArgLabors) => {
|
|
339
|
+
let PartIndex = FinalArgLabors.findIndex((FinalArgPart) => {
|
|
340
|
+
return FinalArgPart._id === argLabor._id;
|
|
341
|
+
});
|
|
342
|
+
if (PartIndex !== -1) {
|
|
343
|
+
PartFound = true;
|
|
344
|
+
}
|
|
345
|
+
});
|
|
346
|
+
// let argGSTValues: any[] = this.GetGSTValueBasedOnTaxCode(argLabor.TCode, TaxCodes);
|
|
347
|
+
// let argCGST = argGSTValues[0];
|
|
348
|
+
// let argSGST = argGSTValues[1];
|
|
349
|
+
// let argIGST = argGSTValues[2];
|
|
350
|
+
// let laborGSTValues: any[] = this.GetGSTValueBasedOnTaxCode(Labor.TCode, TaxCodes);
|
|
351
|
+
// let laborCGST = laborGSTValues[0];
|
|
352
|
+
// let laborSGST = laborGSTValues[1];
|
|
353
|
+
// let laborIGST = laborGSTValues[2];
|
|
354
|
+
return (!PartFound) &&
|
|
355
|
+
(argLabor.CGSTAmt === Labor.CGSTAmt) && (argLabor.IGSTAmt === Labor.IGSTAmt) &&
|
|
356
|
+
(argLabor.SGSTAmt === Labor.SGSTAmt);
|
|
357
|
+
});
|
|
358
|
+
if (MatchedLaborsBasedOnPerc.length !== 0) {
|
|
359
|
+
FinalMatchedLabors.push(MatchedLaborsBasedOnPerc);
|
|
360
|
+
}
|
|
361
|
+
});
|
|
362
|
+
return FinalMatchedLabors;
|
|
363
|
+
}
|
|
364
|
+
static ComparePartsByPerc(Parts, TaxCodes) {
|
|
365
|
+
let FinalMatchedParts = [];
|
|
366
|
+
Parts === null || Parts === void 0 ? void 0 : Parts.forEach((Part) => {
|
|
367
|
+
let MatchedPartsBasedOnHSN = Parts.filter((argPart) => {
|
|
368
|
+
let PartFound = false;
|
|
369
|
+
FinalMatchedParts.forEach((FinalArgParts) => {
|
|
370
|
+
let PartIndex = FinalArgParts.findIndex((FinalArgPart) => {
|
|
371
|
+
return FinalArgPart._id === argPart._id;
|
|
372
|
+
});
|
|
373
|
+
if (PartIndex !== -1) {
|
|
374
|
+
PartFound = true;
|
|
375
|
+
}
|
|
376
|
+
});
|
|
377
|
+
// let argGSTValues: any[] = this.GetGSTValueBasedOnTaxCode(argPart.TCode, TaxCodes);
|
|
378
|
+
// let argCGST = argGSTValues[0];
|
|
379
|
+
// let argSGST = argGSTValues[1];
|
|
380
|
+
// let argIGST = argGSTValues[2];
|
|
381
|
+
// let partGSTValues: any[] = this.GetGSTValueBasedOnTaxCode(Part.TCode, TaxCodes);
|
|
382
|
+
// let partCGST = partGSTValues[0];
|
|
383
|
+
// let partSGST = partGSTValues[1];
|
|
384
|
+
// let partIGST = partGSTValues[2];
|
|
385
|
+
return (!PartFound) &&
|
|
386
|
+
(argPart.CGSTAmt === Part.CGSTAmt) && (argPart.IGSTAmt === Part.IGSTAmt) &&
|
|
387
|
+
(argPart.SGSTAmt === Part.SGSTAmt);
|
|
388
|
+
});
|
|
389
|
+
if (MatchedPartsBasedOnHSN.length !== 0) {
|
|
390
|
+
FinalMatchedParts.push(MatchedPartsBasedOnHSN);
|
|
391
|
+
}
|
|
392
|
+
});
|
|
393
|
+
return FinalMatchedParts;
|
|
394
|
+
}
|
|
259
395
|
static GetPartGSTTaxTotal(PartsList) {
|
|
260
396
|
let CGSTAmt = 0;
|
|
261
397
|
let SGSTAmt = 0;
|