shareneus 1.7.341 → 1.7.343
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/invoice/inv-print.service.js +2 -1
- package/dist/accounting/invoice/invoice-total.service.js +2 -1
- package/dist/services/ro-totals.service.d.ts +1 -0
- package/dist/services/ro-totals.service.js +82 -48
- package/dist/transaction-calculations/total-calculation.js +28 -9
- package/package.json +1 -1
- package/src/accounting/invoice/inv-print.service.ts +2 -1
- package/src/accounting/invoice/invoice-total.service.ts +2 -1
- package/src/services/ro-totals.service.ts +192 -157
- package/src/transaction-calculations/total-calculation.ts +33 -10
|
@@ -55,12 +55,13 @@ function buildTaxesFromTaxCode(line: any, taxCode: any, netAmount: number): any[
|
|
|
55
55
|
const taxComponents = safeArray(taxCode.Components);
|
|
56
56
|
if (taxComponents.length > 0) {
|
|
57
57
|
return taxComponents
|
|
58
|
-
.filter((component: any) => ["CGST", "SGST", "IGST"].includes(component?.Code))
|
|
58
|
+
.filter((component: any) => ["CGST", "SGST", "IGST", "CESS"].includes(component?.Code))
|
|
59
59
|
.map((component: any) => ({
|
|
60
60
|
Code: component.Code,
|
|
61
61
|
Amt: Multiply(netAmount, Divide(GetNumber(component.Rate), 100)),
|
|
62
62
|
Rate: GetNumber(component.Rate),
|
|
63
|
-
TaxCodeId: GetNumber(taxCode._id)
|
|
63
|
+
TaxCodeId: GetNumber(taxCode._id),
|
|
64
|
+
CalcMethod: component.CalcMethod || "Percent",
|
|
64
65
|
}))
|
|
65
66
|
.filter((tax: any) => tax.Amt > 0);
|
|
66
67
|
}
|
|
@@ -89,7 +90,10 @@ function getResolvedTaxes(line: any, taxCodes: any[] = []): any[] {
|
|
|
89
90
|
Code: tax?.Code,
|
|
90
91
|
Amt: GetNumber(tax?.Amt),
|
|
91
92
|
Rate: GetNumber(tax?.Rate),
|
|
92
|
-
TaxCodeId: GetNumber(tax?.TaxCodeId)
|
|
93
|
+
TaxCodeId: GetNumber(tax?.TaxCodeId),
|
|
94
|
+
CalcMethod: tax?.CalcMethod || "Percent",
|
|
95
|
+
PerUnitAmt: GetNumber(tax?.PerUnitAmt),
|
|
96
|
+
Unit: tax?.Unit,
|
|
93
97
|
})).filter((tax: any) => !!tax.Code);
|
|
94
98
|
}
|
|
95
99
|
|
|
@@ -146,14 +150,17 @@ export function TotalCalculations(items: any[] = [], ops: any[] = [], isTaxable:
|
|
|
146
150
|
let totalSGST: number = 0;
|
|
147
151
|
let totalCGST: number = 0;
|
|
148
152
|
let totalIGST: number = 0;
|
|
153
|
+
let totalCESS: number = 0;
|
|
149
154
|
|
|
150
155
|
let totalSGSTOnItems: number = 0;
|
|
151
156
|
let totalCGSTOnItems: number = 0;
|
|
152
157
|
let totalIGSTOnItems: number = 0;
|
|
158
|
+
let totalCESSOnItems: number = 0;
|
|
153
159
|
|
|
154
160
|
let totalSGSTOnLabor: number = 0;
|
|
155
161
|
let totalCGSTOnLabor: number = 0;
|
|
156
162
|
let totalIGSTOnLabor: number = 0;
|
|
163
|
+
let totalCESSOnLabor: number = 0;
|
|
157
164
|
|
|
158
165
|
|
|
159
166
|
// Calculate items totals with null safety
|
|
@@ -175,7 +182,8 @@ export function TotalCalculations(items: any[] = [], ops: any[] = [], isTaxable:
|
|
|
175
182
|
const itemSGST = getTaxAmountByCode(resolvedItemTaxes, "SGST");
|
|
176
183
|
const itemCGST = getTaxAmountByCode(resolvedItemTaxes, "CGST");
|
|
177
184
|
const itemIGST = getTaxAmountByCode(resolvedItemTaxes, "IGST");
|
|
178
|
-
const
|
|
185
|
+
const itemCESS = getTaxAmountByCode(resolvedItemTaxes, "CESS");
|
|
186
|
+
const itemTotalTax = Add(itemSGST, itemCGST, itemIGST, itemCESS);
|
|
179
187
|
|
|
180
188
|
// Add to return tax
|
|
181
189
|
returnTax = Add(returnTax, itemTotalTax);
|
|
@@ -197,13 +205,14 @@ export function TotalCalculations(items: any[] = [], ops: any[] = [], isTaxable:
|
|
|
197
205
|
const itemSGST = getTaxAmountByCode(resolvedItemTaxes, "SGST");
|
|
198
206
|
const itemCGST = getTaxAmountByCode(resolvedItemTaxes, "CGST");
|
|
199
207
|
const itemIGST = getTaxAmountByCode(resolvedItemTaxes, "IGST");
|
|
200
|
-
|
|
208
|
+
const itemCESS = getTaxAmountByCode(resolvedItemTaxes, "CESS");
|
|
201
209
|
// Add individual tax amounts for items
|
|
202
210
|
totalSGSTOnItems = Add(totalSGSTOnItems, itemSGST);
|
|
203
211
|
totalCGSTOnItems = Add(totalCGSTOnItems, itemCGST);
|
|
204
212
|
totalIGSTOnItems = Add(totalIGSTOnItems, itemIGST);
|
|
213
|
+
totalCESSOnItems = Add(totalCESSOnItems, itemCESS);
|
|
205
214
|
|
|
206
|
-
totalTaxOnItems = Add(totalTaxOnItems, itemSGST, itemCGST, itemIGST);
|
|
215
|
+
totalTaxOnItems = Add(totalTaxOnItems, itemSGST, itemCGST, itemIGST, itemCESS);
|
|
207
216
|
}
|
|
208
217
|
}
|
|
209
218
|
});
|
|
@@ -223,13 +232,15 @@ export function TotalCalculations(items: any[] = [], ops: any[] = [], isTaxable:
|
|
|
223
232
|
const opSGST = getTaxAmountByCode(resolvedOpTaxes, "SGST");
|
|
224
233
|
const opCGST = getTaxAmountByCode(resolvedOpTaxes, "CGST");
|
|
225
234
|
const opIGST = getTaxAmountByCode(resolvedOpTaxes, "IGST");
|
|
235
|
+
const opCESS = getTaxAmountByCode(resolvedOpTaxes, "CESS");
|
|
226
236
|
|
|
227
237
|
// Add individual tax amounts for operations/labor
|
|
228
238
|
totalSGSTOnLabor = Add(totalSGSTOnLabor, opSGST);
|
|
229
239
|
totalCGSTOnLabor = Add(totalCGSTOnLabor, opCGST);
|
|
230
240
|
totalIGSTOnLabor = Add(totalIGSTOnLabor, opIGST);
|
|
241
|
+
totalCESSOnLabor = Add(totalCESSOnLabor, opCESS);
|
|
231
242
|
|
|
232
|
-
totalTaxOnLabor = Add(totalTaxOnLabor, opSGST, opCGST, opIGST);
|
|
243
|
+
totalTaxOnLabor = Add(totalTaxOnLabor, opSGST, opCGST, opIGST, opCESS);
|
|
233
244
|
}
|
|
234
245
|
});
|
|
235
246
|
|
|
@@ -258,6 +269,7 @@ export function TotalCalculations(items: any[] = [], ops: any[] = [], isTaxable:
|
|
|
258
269
|
totalSGST = Add(totalSGSTOnItems, totalSGSTOnLabor);
|
|
259
270
|
totalCGST = Add(totalCGSTOnItems, totalCGSTOnLabor);
|
|
260
271
|
totalIGST = Add(totalIGSTOnItems, totalIGSTOnLabor);
|
|
272
|
+
totalCESS = Add(totalCESSOnItems, totalCESSOnLabor);
|
|
261
273
|
}
|
|
262
274
|
|
|
263
275
|
// FIXED CALCULATION: Correct order of operations
|
|
@@ -310,12 +322,15 @@ export function TotalCalculations(items: any[] = [], ops: any[] = [], isTaxable:
|
|
|
310
322
|
result.totalSGST = totalSGST;
|
|
311
323
|
result.totalCGST = totalCGST;
|
|
312
324
|
result.totalIGST = totalIGST;
|
|
325
|
+
result.totalCESS = totalCESS;
|
|
313
326
|
result.totalSGSTOnItems = totalSGSTOnItems;
|
|
314
327
|
result.totalCGSTOnItems = totalCGSTOnItems;
|
|
315
328
|
result.totalIGSTOnItems = totalIGSTOnItems;
|
|
329
|
+
result.totalCESSOnItems = totalCESSOnItems;
|
|
316
330
|
result.totalSGSTOnLabor = totalSGSTOnLabor;
|
|
317
331
|
result.totalCGSTOnLabor = totalCGSTOnLabor;
|
|
318
332
|
result.totalIGSTOnLabor = totalIGSTOnLabor;
|
|
333
|
+
result.totalCESSOnLabor = totalCESSOnLabor;
|
|
319
334
|
|
|
320
335
|
// Calculate tax summary for both new Taxes[] and legacy tax-code based records
|
|
321
336
|
// Filter out items where Ret is true (only include non-return items)
|
|
@@ -380,6 +395,9 @@ export function TotalCalculationsWithDecimals(
|
|
|
380
395
|
roundedResult.totalSGSTOnLabor = roundToDecimals(result.totalSGSTOnLabor);
|
|
381
396
|
roundedResult.totalCGSTOnLabor = roundToDecimals(result.totalCGSTOnLabor);
|
|
382
397
|
roundedResult.totalIGSTOnLabor = roundToDecimals(result.totalIGSTOnLabor);
|
|
398
|
+
roundedResult.totalCESS = roundToDecimals(result.totalCESS);
|
|
399
|
+
roundedResult.totalCESSOnItems = roundToDecimals(result.totalCESSOnItems);
|
|
400
|
+
roundedResult.totalCESSOnLabor = roundToDecimals(result.totalCESSOnLabor);
|
|
383
401
|
|
|
384
402
|
// Round tax summary only if it exists
|
|
385
403
|
if (result.itemsTaxSummary) {
|
|
@@ -389,7 +407,8 @@ export function TotalCalculationsWithDecimals(
|
|
|
389
407
|
TaxAmount: roundToDecimals(tax.TaxAmount),
|
|
390
408
|
CGSTAmount: roundToDecimals(tax.CGSTAmount),
|
|
391
409
|
SGSTAmount: roundToDecimals(tax.SGSTAmount),
|
|
392
|
-
IGSTAmount: roundToDecimals(tax.IGSTAmount)
|
|
410
|
+
IGSTAmount: roundToDecimals(tax.IGSTAmount),
|
|
411
|
+
CESSAmount: roundToDecimals(tax.CESSAmount)
|
|
393
412
|
}));
|
|
394
413
|
}
|
|
395
414
|
if (result.opsTaxSummary) {
|
|
@@ -399,7 +418,8 @@ export function TotalCalculationsWithDecimals(
|
|
|
399
418
|
TaxAmount: roundToDecimals(tax.TaxAmount),
|
|
400
419
|
CGSTAmount: roundToDecimals(tax.CGSTAmount),
|
|
401
420
|
SGSTAmount: roundToDecimals(tax.SGSTAmount),
|
|
402
|
-
IGSTAmount: roundToDecimals(tax.IGSTAmount)
|
|
421
|
+
IGSTAmount: roundToDecimals(tax.IGSTAmount),
|
|
422
|
+
CESSAmount: roundToDecimals(tax.CESSAmount)
|
|
403
423
|
}));
|
|
404
424
|
}
|
|
405
425
|
}
|
|
@@ -418,6 +438,7 @@ export function CalculateTaxSummary(items: any[], taxCodes: any[]) {
|
|
|
418
438
|
const cgstAmount = getTaxAmountByCode(taxes, "CGST");
|
|
419
439
|
const sgstAmount = getTaxAmountByCode(taxes, "SGST");
|
|
420
440
|
const igstAmount = getTaxAmountByCode(taxes, "IGST");
|
|
441
|
+
const cessAmount = getTaxAmountByCode(taxes, "CESS");
|
|
421
442
|
const totalTaxAmount = Add(cgstAmount, sgstAmount, igstAmount);
|
|
422
443
|
|
|
423
444
|
if (!acc[percent]) {
|
|
@@ -427,7 +448,8 @@ export function CalculateTaxSummary(items: any[], taxCodes: any[]) {
|
|
|
427
448
|
TaxAmount: 0,
|
|
428
449
|
CGSTAmount: 0,
|
|
429
450
|
SGSTAmount: 0,
|
|
430
|
-
IGSTAmount: 0
|
|
451
|
+
IGSTAmount: 0,
|
|
452
|
+
CESSAmount: 0
|
|
431
453
|
};
|
|
432
454
|
}
|
|
433
455
|
|
|
@@ -436,6 +458,7 @@ export function CalculateTaxSummary(items: any[], taxCodes: any[]) {
|
|
|
436
458
|
acc[percent].CGSTAmount = Add(acc[percent].CGSTAmount, cgstAmount);
|
|
437
459
|
acc[percent].SGSTAmount = Add(acc[percent].SGSTAmount, sgstAmount);
|
|
438
460
|
acc[percent].IGSTAmount = Add(acc[percent].IGSTAmount, igstAmount);
|
|
461
|
+
acc[percent].CESSAmount = Add(acc[percent].CESSAmount, cessAmount);
|
|
439
462
|
|
|
440
463
|
return acc;
|
|
441
464
|
}, {})
|