shareneus 1.6.17 → 1.6.19
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/enums/country-enums.d.ts +9 -0
- package/dist/enums/country-enums.js +13 -0
- package/dist/enums/treatment-enums.d.ts +9 -0
- package/dist/enums/treatment-enums.js +13 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +5 -1
- package/dist/sales-receive/sales-total-calculation.js +107 -23
- package/package.json +1 -1
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CountryEnum = void 0;
|
|
4
|
+
var CountryEnum;
|
|
5
|
+
(function (CountryEnum) {
|
|
6
|
+
CountryEnum["India"] = "IN";
|
|
7
|
+
CountryEnum["Australia"] = "AU";
|
|
8
|
+
CountryEnum["UnitedStates"] = "US";
|
|
9
|
+
CountryEnum["UnitedKingdom"] = "GB";
|
|
10
|
+
CountryEnum["Canada"] = "CA";
|
|
11
|
+
CountryEnum["Japan"] = "JP";
|
|
12
|
+
CountryEnum["Brazil"] = "BR";
|
|
13
|
+
})(CountryEnum || (exports.CountryEnum = CountryEnum = {}));
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TaxTreatmentEnum = void 0;
|
|
4
|
+
var TaxTreatmentEnum;
|
|
5
|
+
(function (TaxTreatmentEnum) {
|
|
6
|
+
TaxTreatmentEnum["REGULAR"] = "REGULAR";
|
|
7
|
+
TaxTreatmentEnum["COMPOSITION"] = "COMPOSITION";
|
|
8
|
+
TaxTreatmentEnum["UNREGISTERED"] = "UNREGISTERED";
|
|
9
|
+
TaxTreatmentEnum["CONSUMER"] = "CONSUMER";
|
|
10
|
+
TaxTreatmentEnum["OVERSEAS"] = "OVERSEAS";
|
|
11
|
+
TaxTreatmentEnum["SEZ"] = "SEZ";
|
|
12
|
+
TaxTreatmentEnum["DEEMED_EXPORT"] = "DEEMED_EXPORT";
|
|
13
|
+
})(TaxTreatmentEnum || (exports.TaxTreatmentEnum = TaxTreatmentEnum = {}));
|
package/dist/index.d.ts
CHANGED
|
@@ -141,5 +141,7 @@ export { GetBillPdfDataUrl } from "./purchases/bills/bill-pdf/bill-pdf.service";
|
|
|
141
141
|
export { GetInvoicePrintInfo } from "./accounting/invoice/inv-print.service";
|
|
142
142
|
export { CreateReceiptPDFService } from "./accounting/payment-receive/payment-receipt-pdf/receipt-pdf.service";
|
|
143
143
|
export { CreateInvoicePDFService } from "./accounting/invoice/invoice-pdf/invoice-pdf.service";
|
|
144
|
+
export { CountryEnum } from "./enums/country-enums";
|
|
145
|
+
export { TaxTreatmentEnum } from "./enums/treatment-enums";
|
|
144
146
|
export { CalculateLineTax, ExtractNetFromInclusive, SumTaxComponents, ComputeTaxSummary, DetermineSupplyType, FindTaxCodeByRateAndSupplyType, CalculateWithholding, RoundAmount, ValidateTaxId, ValidateHSNSACLength, ConvertFlatToTaxes, } from "./tax";
|
|
145
147
|
export type { TaxComponentType, CalcMethod, AppliedOn, RoundingMethod, TaxCategory, SupplyType, ResolvedSupplyType, WithholdingType, ResolverType, IRegimeComponent, IRegimeFeatures, IRounding, ITreatment, ITaxRegime, ITaxCodeComponent, ITaxCode, ITaxComponent, ITaxSummaryLine, ITaxSummary, IWithholding, IWithholdingCalcInput, ITaxCalcLineInput, ITaxSummaryInput, IRoundingConfig, IInclusiveResult, ITaxExemption, ITaxAuthority, IExternalProvider, } from "./tax";
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.DebitNotePdfService = exports.DCWithoutPricePdfService = exports.DCLandscapeWithoutPricePdfService = exports.DCLandscapePdfService = exports.CustomerBalancesService = exports.SalesByCustomerPDFService = exports.CustWiseSalesDetailsService = exports.CreditNoteTotalsService = exports.CreditNotePdfService = exports.ConsultationPDFService = exports.ConsultationFullPrintService = exports.ConsultationFeeReceiptPrintService = exports.CNPrintService = exports.ChecklistsPDFService = exports.CheckListPrintService = exports.CategoryWiseItemPDFService = exports.SalesReceiptprintService = exports.AppointmentTotalsService = exports.AnalysisPDFService = exports.VenBalanceXlsxFileService = exports.TallySalesImportXlsxFileService = exports.StockXlsxFileService = exports.IssueSparesXlsxFileService = exports.ScheduledDrugXlsxFileService = exports.ScheduledDrugSummaryXlsxFileService = exports.SalesByServiceSummaryXlsxFileService = exports.SummaryXlsxFileService = exports.ServiceAdvisorWisePartXlsxFileService = exports.ServiceAdvisorWiseLaborXlsxFileService = exports.RepairOrdersXlsxFileService = exports.PaymentsMadeXlsxFileService = exports.PaymentReceiveXlsxFileService = exports.OperatorWiseSummaryXlsxFileService = exports.OperatorWiseDetailsXlsxFileService = exports.ManfWiseSalesXlsxFileService = exports.ItemsWiseSalesXlsxFileService = exports.ItemWiseMOSummaryXlsxFileService = exports.ItemWiseMODetailsXlsxFileService = exports.ItemWiseDoctorSaleXlsxFileService = exports.InvoicesWiseXlsxFileService = exports.InsuranceExpireXlsxFileService = exports.GSTR2ExcelService = exports.GSTR1ExcelService = exports.GSTROXlsxFileService = exports.ExpiringDrugsXlsxFileService = exports.SalesByCustomerXlsxFileService = exports.CustWiseSalesXlsxFileService = exports.CustBalanceXlsxFileService = exports.CategoryWiseItemXlsxFileService = exports.AnalysisXlsxFileService = void 0;
|
|
4
4
|
exports.TaskPDfService = exports.PrintSharedService = exports.SharedPDFService = exports.SharedInvoiceprintService = exports.WOPrintService = exports.ScheduledDrugSummaryPDFService = exports.ScheduledDrugPDFService = exports.SalesTotalsService = exports.SaleReceiptPrintService = exports.SalesReceiptpdfService = exports.SalesPrintService = exports.SalesPdfService = exports.SalesByServiceSummaryPDF = exports.ROTotalsService = exports.ROPrintService = exports.RoprintService = exports.RepairOrdersReportsPDFService = exports.ReorderPointPDFService = exports.ReceiptPrintService = exports.PurchaseOrderPDFService = exports.PurchaseOrderTotalsService = exports.PurchaseOrderPrintService = exports.PosReceiptPrintService = exports.POTotalsService = exports.PaymentsReportPDFService = exports.ReceiptPDFService = exports.PackShipPrintService = exports.PackShipPDFService = exports.OperatorWiseSalesSummaryPDF = exports.OperatorWiseSalesDetailsPDF = exports.MaterialOutprintService = exports.MeetingPdfService = exports.ManfWiseSalesService = exports.ItemWiseSalesPDFService = exports.ItemWiseMOSummaryPDF = exports.ItemWiseMODetailsPDF = exports.ItemWiseDoctorSalePDFService = exports.ItemDetaisPdf = exports.IssuePartsprintService = exports.InvoiceTotalsService = exports.InvoiceLandscapePdfService = exports.InsuranceExpirePDF = exports.ExpiringDrugPDFService = exports.EstPrintService = exports.EquipmentDesignPdf = exports.DeliveryChallanTotalsService = exports.DeliveryChallanPrintService = exports.DeliveryChallanPdfService = exports.DebitNoteTotalsService = exports.DebitNotePrintService = void 0;
|
|
5
5
|
exports.CreateInvoicePDFService = exports.CreateReceiptPDFService = exports.GetInvoicePrintInfo = exports.GetBillPdfDataUrl = exports.GetBillPDF = exports.GetInvoicePDF = exports.ProductWithoutOwnerPDFService = exports.ProductWithoutOwnerXlsxFileService = exports.Divide = exports.Multiply = exports.Subtract = exports.Add = exports.ServiceHistoryPDFService = exports.SalesTotalCalculationsWithDecimals = exports.GetNumber = exports.GetAgeString = exports.IsNull = exports.IsNotNull = exports.GetServicePriceForPriceList = exports.ApplyServicePriceListToOpcode = exports.ApplyServicePriceListToProcedure = exports.CalcItemFinalSalePrice = exports.GetItemPriceForPriceList = exports.SalesReceiveTotalsService = exports.SalesReceivePrintService = exports.SalesReceivePdfService = exports.AdjustmentDrugPDFService = exports.HSNSummaryPDFService = exports.HSNSummaryExcelService = exports.ItemBarCodeLabelPdf = exports.NextServiceDatePDFService = exports.NextServiceDateXlsxFileService = exports.ConsultationLetterHeadPDFService = exports.InvoiceLetterheadPdfService = exports.InvoicePortraitPrintService = exports.HCInvoiceprintService = exports.InvoiceprintService = exports.MyDate = exports.TrUtils = exports.VendorDebitNoteTotalsService = exports.VendorDebitNotePrintService = exports.VendorDebitNotePdfService = exports.VendorCreditNoteTotalsService = exports.VendorCreditNotePrintService = exports.VendorCreditNotePDFService = exports.VendorBalancesService = exports.TransferOrderPrintService = exports.TechnicianPrintService = exports.TechnicianpdfService = exports.TaskReportsPDfService = void 0;
|
|
6
|
-
exports.ConvertFlatToTaxes = exports.ValidateHSNSACLength = exports.ValidateTaxId = exports.RoundAmount = exports.CalculateWithholding = exports.FindTaxCodeByRateAndSupplyType = exports.DetermineSupplyType = exports.ComputeTaxSummary = exports.SumTaxComponents = exports.ExtractNetFromInclusive = exports.CalculateLineTax = void 0;
|
|
6
|
+
exports.ConvertFlatToTaxes = exports.ValidateHSNSACLength = exports.ValidateTaxId = exports.RoundAmount = exports.CalculateWithholding = exports.FindTaxCodeByRateAndSupplyType = exports.DetermineSupplyType = exports.ComputeTaxSummary = exports.SumTaxComponents = exports.ExtractNetFromInclusive = exports.CalculateLineTax = exports.TaxTreatmentEnum = exports.CountryEnum = void 0;
|
|
7
7
|
var analysis_excel_service_1 = require("./accounting/invoice/reports/excel/analysis-excel.service");
|
|
8
8
|
Object.defineProperty(exports, "AnalysisXlsxFileService", { enumerable: true, get: function () { return analysis_excel_service_1.AnalysisXlsxFileService; } });
|
|
9
9
|
var category_wise_item_excel_service_1 = require("./accounting/invoice/reports/excel/category-wise-item-excel.service");
|
|
@@ -298,6 +298,10 @@ var receipt_pdf_service_1 = require("./accounting/payment-receive/payment-receip
|
|
|
298
298
|
Object.defineProperty(exports, "CreateReceiptPDFService", { enumerable: true, get: function () { return receipt_pdf_service_1.CreateReceiptPDFService; } });
|
|
299
299
|
var invoice_pdf_service_2 = require("./accounting/invoice/invoice-pdf/invoice-pdf.service");
|
|
300
300
|
Object.defineProperty(exports, "CreateInvoicePDFService", { enumerable: true, get: function () { return invoice_pdf_service_2.CreateInvoicePDFService; } });
|
|
301
|
+
var country_enums_1 = require("./enums/country-enums");
|
|
302
|
+
Object.defineProperty(exports, "CountryEnum", { enumerable: true, get: function () { return country_enums_1.CountryEnum; } });
|
|
303
|
+
var treatment_enums_1 = require("./enums/treatment-enums");
|
|
304
|
+
Object.defineProperty(exports, "TaxTreatmentEnum", { enumerable: true, get: function () { return treatment_enums_1.TaxTreatmentEnum; } });
|
|
301
305
|
// Tax System — Calculation functions
|
|
302
306
|
var tax_1 = require("./tax");
|
|
303
307
|
Object.defineProperty(exports, "CalculateLineTax", { enumerable: true, get: function () { return tax_1.CalculateLineTax; } });
|
|
@@ -11,6 +11,86 @@ const util_1 = require("../shared/util");
|
|
|
11
11
|
function safeArray(arr) {
|
|
12
12
|
return Array.isArray(arr) ? arr : [];
|
|
13
13
|
}
|
|
14
|
+
function getLineNetAmount(line) {
|
|
15
|
+
return (0, math_operations_1.Subtract)((0, util_1.GetNumber)(line.UnAmt || line.Amt), (0, math_operations_1.Add)((0, util_1.GetNumber)(line.Disc), (0, util_1.GetNumber)(line.RecDisc)));
|
|
16
|
+
}
|
|
17
|
+
function getTaxCodeById(taxCodes, taxCodeId) {
|
|
18
|
+
const normalizedTaxCodeId = Number(taxCodeId);
|
|
19
|
+
if (!normalizedTaxCodeId) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
return taxCodes.find((taxCode) => Number(taxCode._id) === normalizedTaxCodeId) || null;
|
|
23
|
+
}
|
|
24
|
+
function getTaxComponentRate(taxCode, code) {
|
|
25
|
+
const component = safeArray(taxCode === null || taxCode === void 0 ? void 0 : taxCode.Components).find((item) => (item === null || item === void 0 ? void 0 : item.Code) === code);
|
|
26
|
+
if (component) {
|
|
27
|
+
return (0, util_1.GetNumber)(component.Rate);
|
|
28
|
+
}
|
|
29
|
+
return (0, util_1.GetNumber)(taxCode === null || taxCode === void 0 ? void 0 : taxCode[code]);
|
|
30
|
+
}
|
|
31
|
+
function buildTaxesFromFlatFields(line, taxCode, netAmount) {
|
|
32
|
+
const flatTaxes = [
|
|
33
|
+
{ Code: "CGST", Amt: (0, util_1.GetNumber)(line.CGST) },
|
|
34
|
+
{ Code: "SGST", Amt: (0, util_1.GetNumber)(line.SGST) },
|
|
35
|
+
{ Code: "IGST", Amt: (0, util_1.GetNumber)(line.IGST) }
|
|
36
|
+
];
|
|
37
|
+
return flatTaxes
|
|
38
|
+
.filter((tax) => tax.Amt > 0)
|
|
39
|
+
.map((tax) => ({
|
|
40
|
+
Code: tax.Code,
|
|
41
|
+
Amt: tax.Amt,
|
|
42
|
+
Rate: getTaxComponentRate(taxCode, tax.Code) || (netAmount > 0 ? (0, math_operations_1.Multiply)((0, math_operations_1.Divide)(tax.Amt, netAmount), 100) : 0),
|
|
43
|
+
TaxCodeId: (0, util_1.GetNumber)(line.TCode) || (0, util_1.GetNumber)(taxCode === null || taxCode === void 0 ? void 0 : taxCode._id)
|
|
44
|
+
}));
|
|
45
|
+
}
|
|
46
|
+
function buildTaxesFromTaxCode(line, taxCode, netAmount) {
|
|
47
|
+
if (!taxCode) {
|
|
48
|
+
return [];
|
|
49
|
+
}
|
|
50
|
+
const taxComponents = safeArray(taxCode.Components);
|
|
51
|
+
if (taxComponents.length > 0) {
|
|
52
|
+
return taxComponents
|
|
53
|
+
.filter((component) => ["CGST", "SGST", "IGST"].includes(component === null || component === void 0 ? void 0 : component.Code))
|
|
54
|
+
.map((component) => ({
|
|
55
|
+
Code: component.Code,
|
|
56
|
+
Amt: (0, math_operations_1.Multiply)(netAmount, (0, math_operations_1.Divide)((0, util_1.GetNumber)(component.Rate), 100)),
|
|
57
|
+
Rate: (0, util_1.GetNumber)(component.Rate),
|
|
58
|
+
TaxCodeId: (0, util_1.GetNumber)(taxCode._id)
|
|
59
|
+
}))
|
|
60
|
+
.filter((tax) => tax.Amt > 0);
|
|
61
|
+
}
|
|
62
|
+
const legacyTaxes = [
|
|
63
|
+
{ Code: "CGST", Rate: (0, util_1.GetNumber)(taxCode.CGST) },
|
|
64
|
+
{ Code: "SGST", Rate: (0, util_1.GetNumber)(taxCode.SGST) },
|
|
65
|
+
{ Code: "IGST", Rate: (0, util_1.GetNumber)(taxCode.IGST) }
|
|
66
|
+
];
|
|
67
|
+
return legacyTaxes
|
|
68
|
+
.filter((tax) => tax.Rate > 0)
|
|
69
|
+
.map((tax) => ({
|
|
70
|
+
Code: tax.Code,
|
|
71
|
+
Amt: (0, math_operations_1.Multiply)(netAmount, (0, math_operations_1.Divide)(tax.Rate, 100)),
|
|
72
|
+
Rate: tax.Rate,
|
|
73
|
+
TaxCodeId: (0, util_1.GetNumber)(taxCode._id)
|
|
74
|
+
}));
|
|
75
|
+
}
|
|
76
|
+
function getResolvedTaxes(line, taxCodes = []) {
|
|
77
|
+
const lineTaxes = safeArray(line === null || line === void 0 ? void 0 : line.Taxes);
|
|
78
|
+
if (lineTaxes.length > 0) {
|
|
79
|
+
return lineTaxes.map((tax) => (Object.assign(Object.assign({}, tax), { Code: tax === null || tax === void 0 ? void 0 : tax.Code, Amt: (0, util_1.GetNumber)(tax === null || tax === void 0 ? void 0 : tax.Amt), Rate: (0, util_1.GetNumber)(tax === null || tax === void 0 ? void 0 : tax.Rate), TaxCodeId: (0, util_1.GetNumber)(tax === null || tax === void 0 ? void 0 : tax.TaxCodeId) }))).filter((tax) => !!tax.Code);
|
|
80
|
+
}
|
|
81
|
+
const netAmount = getLineNetAmount(line);
|
|
82
|
+
const taxCode = getTaxCodeById(taxCodes, line === null || line === void 0 ? void 0 : line.TCode);
|
|
83
|
+
const taxesFromFlatFields = buildTaxesFromFlatFields(line, taxCode, netAmount);
|
|
84
|
+
if (taxesFromFlatFields.length > 0) {
|
|
85
|
+
return taxesFromFlatFields;
|
|
86
|
+
}
|
|
87
|
+
return buildTaxesFromTaxCode(line, taxCode, netAmount);
|
|
88
|
+
}
|
|
89
|
+
function getTaxAmountByCode(taxes, code) {
|
|
90
|
+
return taxes
|
|
91
|
+
.filter((tax) => tax.Code === code)
|
|
92
|
+
.reduce((sum, tax) => (0, math_operations_1.Add)(sum, (0, util_1.GetNumber)(tax.Amt)), 0);
|
|
93
|
+
}
|
|
14
94
|
function SalesTotalCalculations(items = [], ops = [], isTaxable = false, taxCodes = [], Adjust = 0) {
|
|
15
95
|
// Handle null/undefined arrays
|
|
16
96
|
const safeItems = safeArray(items);
|
|
@@ -60,9 +140,10 @@ function SalesTotalCalculations(items = [], ops = [], isTaxable = false, taxCode
|
|
|
60
140
|
// Add to return subtotal (net amount after discounts)
|
|
61
141
|
returnSubtotal = (0, math_operations_1.Add)(returnSubtotal, itemUnAmt);
|
|
62
142
|
if (isTaxable) {
|
|
63
|
-
const
|
|
64
|
-
const
|
|
65
|
-
const
|
|
143
|
+
const resolvedItemTaxes = getResolvedTaxes(item, safeTaxCodes);
|
|
144
|
+
const itemSGST = getTaxAmountByCode(resolvedItemTaxes, "SGST");
|
|
145
|
+
const itemCGST = getTaxAmountByCode(resolvedItemTaxes, "CGST");
|
|
146
|
+
const itemIGST = getTaxAmountByCode(resolvedItemTaxes, "IGST");
|
|
66
147
|
const itemTotalTax = (0, math_operations_1.Add)(itemSGST, itemCGST, itemIGST);
|
|
67
148
|
// Add to return tax
|
|
68
149
|
returnTax = (0, math_operations_1.Add)(returnTax, itemTotalTax);
|
|
@@ -80,9 +161,10 @@ function SalesTotalCalculations(items = [], ops = [], isTaxable = false, taxCode
|
|
|
80
161
|
subtotalOnItems = (0, math_operations_1.Add)(subtotalOnItems, itemUnAmt);
|
|
81
162
|
// Only calculate tax if taxable
|
|
82
163
|
if (isTaxable) {
|
|
83
|
-
const
|
|
84
|
-
const
|
|
85
|
-
const
|
|
164
|
+
const resolvedItemTaxes = getResolvedTaxes(item, safeTaxCodes);
|
|
165
|
+
const itemSGST = getTaxAmountByCode(resolvedItemTaxes, "SGST");
|
|
166
|
+
const itemCGST = getTaxAmountByCode(resolvedItemTaxes, "CGST");
|
|
167
|
+
const itemIGST = getTaxAmountByCode(resolvedItemTaxes, "IGST");
|
|
86
168
|
// Add individual tax amounts for items
|
|
87
169
|
totalSGSTOnItems = (0, math_operations_1.Add)(totalSGSTOnItems, itemSGST);
|
|
88
170
|
totalCGSTOnItems = (0, math_operations_1.Add)(totalCGSTOnItems, itemCGST);
|
|
@@ -100,9 +182,10 @@ function SalesTotalCalculations(items = [], ops = [], isTaxable = false, taxCode
|
|
|
100
182
|
subtotalOnLabor = (0, math_operations_1.Add)(subtotalOnLabor, opAmt);
|
|
101
183
|
// Only calculate tax if taxable
|
|
102
184
|
if (isTaxable) {
|
|
103
|
-
const
|
|
104
|
-
const
|
|
105
|
-
const
|
|
185
|
+
const resolvedOpTaxes = getResolvedTaxes(op, safeTaxCodes);
|
|
186
|
+
const opSGST = getTaxAmountByCode(resolvedOpTaxes, "SGST");
|
|
187
|
+
const opCGST = getTaxAmountByCode(resolvedOpTaxes, "CGST");
|
|
188
|
+
const opIGST = getTaxAmountByCode(resolvedOpTaxes, "IGST");
|
|
106
189
|
// Add individual tax amounts for operations/labor
|
|
107
190
|
totalSGSTOnLabor = (0, math_operations_1.Add)(totalSGSTOnLabor, opSGST);
|
|
108
191
|
totalCGSTOnLabor = (0, math_operations_1.Add)(totalCGSTOnLabor, opCGST);
|
|
@@ -180,11 +263,11 @@ function SalesTotalCalculations(items = [], ops = [], isTaxable = false, taxCode
|
|
|
180
263
|
result.totalSGSTOnLabor = totalSGSTOnLabor;
|
|
181
264
|
result.totalCGSTOnLabor = totalCGSTOnLabor;
|
|
182
265
|
result.totalIGSTOnLabor = totalIGSTOnLabor;
|
|
183
|
-
// Calculate tax summary
|
|
266
|
+
// Calculate tax summary for both new Taxes[] and legacy tax-code based records
|
|
184
267
|
// Filter out items where Ret is true (only include non-return items)
|
|
185
268
|
const nonReturnItems = safeItems.filter((item) => item.Ret !== true);
|
|
186
|
-
result.itemsTaxSummary =
|
|
187
|
-
result.opsTaxSummary =
|
|
269
|
+
result.itemsTaxSummary = CalculateTaxSummary(nonReturnItems, safeTaxCodes);
|
|
270
|
+
result.opsTaxSummary = CalculateTaxSummary(safeOps, safeTaxCodes);
|
|
188
271
|
}
|
|
189
272
|
return result;
|
|
190
273
|
}
|
|
@@ -242,15 +325,16 @@ function SalesTotalCalculationsWithDecimals(items = [], ops = [], isTaxable = fa
|
|
|
242
325
|
return roundedResult;
|
|
243
326
|
}
|
|
244
327
|
function CalculateTaxSummary(items, taxCodes) {
|
|
245
|
-
// Create lookup for tax codes
|
|
246
|
-
const taxMap = Object.fromEntries(taxCodes.map(tc => [tc._id, tc]));
|
|
247
328
|
return Object.values(items.reduce((acc, item) => {
|
|
248
|
-
const
|
|
249
|
-
if (
|
|
329
|
+
const taxes = getResolvedTaxes(item, taxCodes);
|
|
330
|
+
if (taxes.length === 0)
|
|
250
331
|
return acc;
|
|
251
|
-
const percent = (((tax
|
|
252
|
-
|
|
253
|
-
const
|
|
332
|
+
const percent = (taxes.reduce((sum, tax) => (0, math_operations_1.Add)(sum, (0, util_1.GetNumber)(tax.Rate)), 0) + "%");
|
|
333
|
+
const taxable = getLineNetAmount(item);
|
|
334
|
+
const cgstAmount = getTaxAmountByCode(taxes, "CGST");
|
|
335
|
+
const sgstAmount = getTaxAmountByCode(taxes, "SGST");
|
|
336
|
+
const igstAmount = getTaxAmountByCode(taxes, "IGST");
|
|
337
|
+
const totalTaxAmount = (0, math_operations_1.Add)(cgstAmount, sgstAmount, igstAmount);
|
|
254
338
|
if (!acc[percent]) {
|
|
255
339
|
acc[percent] = {
|
|
256
340
|
Tax: percent,
|
|
@@ -262,10 +346,10 @@ function CalculateTaxSummary(items, taxCodes) {
|
|
|
262
346
|
};
|
|
263
347
|
}
|
|
264
348
|
acc[percent].TaxableAmount = (0, math_operations_1.Add)(acc[percent].TaxableAmount, taxable);
|
|
265
|
-
acc[percent].TaxAmount = (0, math_operations_1.Add)(acc[percent].TaxAmount,
|
|
266
|
-
acc[percent].CGSTAmount = (0, math_operations_1.Add)(acc[percent].CGSTAmount,
|
|
267
|
-
acc[percent].SGSTAmount = (0, math_operations_1.Add)(acc[percent].SGSTAmount,
|
|
268
|
-
acc[percent].IGSTAmount = (0, math_operations_1.Add)(acc[percent].IGSTAmount,
|
|
349
|
+
acc[percent].TaxAmount = (0, math_operations_1.Add)(acc[percent].TaxAmount, totalTaxAmount);
|
|
350
|
+
acc[percent].CGSTAmount = (0, math_operations_1.Add)(acc[percent].CGSTAmount, cgstAmount);
|
|
351
|
+
acc[percent].SGSTAmount = (0, math_operations_1.Add)(acc[percent].SGSTAmount, sgstAmount);
|
|
352
|
+
acc[percent].IGSTAmount = (0, math_operations_1.Add)(acc[percent].IGSTAmount, igstAmount);
|
|
269
353
|
return acc;
|
|
270
354
|
}, {}));
|
|
271
355
|
}
|