shareneus 1.4.97 → 1.4.99
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.
|
@@ -563,7 +563,7 @@ class SalesReceivePdfService {
|
|
|
563
563
|
}
|
|
564
564
|
static CommonTotalDetails(SRPrintData, moreDiscDetails) {
|
|
565
565
|
let CommonDetails = [
|
|
566
|
-
shared_pdf_service_1.SharedPDFService.GetDebitTotalDetails(SRPrintData, 0, 0, 0, 0, 0, SRPrintData.
|
|
566
|
+
shared_pdf_service_1.SharedPDFService.GetDebitTotalDetails(SRPrintData, 0, 0, 0, 0, 0, SRPrintData.totalIGST, SRPrintData.ShowIGST, SRPrintData.ShowTaxColumn, SRPrintData.subtotal, SRPrintData.totalDiscount, SRPrintData.totalCGST, SRPrintData.totalSGST, SRPrintData.CustTaxGroupData, SRPrintData.ShowAccParts, SRPrintData.CustLaborAfterTax, SRPrintData.CustPartAfterTax, SRPrintData.FixedDisc, SRPrintData.For, SRPrintData.total, SRPrintData.roundOff, SRPrintData.totalAfterRounded, SRPrintData.ShowTaxColumn, SRPrintData.ShowTaxColumn, tr_utils_1.TrUtils.isTaxable(SRPrintData.Settings.Tax), SRPrintData.CustLaborITax, SRPrintData.totalTax, SRPrintData.Consolidate, SRPrintData.From, moreDiscDetails),
|
|
567
567
|
shared_pdf_service_1.SharedPDFService.InvoiceDueStatus(SRPrintData.Type, SRPrintData.Paid, SRPrintData.Due, SRPrintData.Sts, false, SRPrintData.Entity.DecimalsNumber),
|
|
568
568
|
shared_pdf_service_1.SharedPDFService.GetTemsAndConditions(SRPrintData.Entity.Terms),
|
|
569
569
|
shared_pdf_service_1.SharedPDFService.GetUnderLine(),
|
|
@@ -4,10 +4,11 @@ exports.SalesReceivePrintService = void 0;
|
|
|
4
4
|
const aggregation_1 = require("../aggregation/aggregation");
|
|
5
5
|
const code_enums_1 = require("../enums/code-enums");
|
|
6
6
|
const enums_1 = require("../enums/enums");
|
|
7
|
+
const math_operations_1 = require("../shared/math-operations");
|
|
7
8
|
const shared_print_service_1 = require("../shared/shared-print.service");
|
|
8
9
|
const my_date_1 = require("../utils/my-date");
|
|
9
10
|
const tr_utils_1 = require("../utils/tr-utils");
|
|
10
|
-
const
|
|
11
|
+
const sales_total_calculation_1 = require("./sales-total-calculation");
|
|
11
12
|
class SalesReceivePrintService {
|
|
12
13
|
static GetSalesReceivePrintInfo(OriginalSalesReceiveData, OriginalEntityData, image, IncludeGST, ConsolidateGST, TaxCodes, IsProforma) {
|
|
13
14
|
var _a, _b;
|
|
@@ -26,10 +27,14 @@ class SalesReceivePrintService {
|
|
|
26
27
|
SalesReceivePrintData = shared_print_service_1.PrintSharedService.GetEntityHeaderStyles(SalesReceivePrintData, OriginalEntityData, image);
|
|
27
28
|
SalesReceivePrintData = this.GetSalesReceiveOtherDetailsForPrint(SalesReceivePrintData, argSalesReceiveData);
|
|
28
29
|
let IsTaxable = (IncludeGST && tr_utils_1.TrUtils.isTaxable(argSalesReceiveData.Settings.Tax)) ? true : false;
|
|
29
|
-
let finalTotalsData =
|
|
30
|
+
// let finalTotalsData: any = SalesReceiveTotalsService.GetTotalsValue([], argSalesReceiveData.Items, IsTaxable,
|
|
31
|
+
// true,
|
|
32
|
+
// argSalesReceiveData.Disc, argSalesReceiveData.Perc, TaxCodes, true, argSalesReceiveData.Settings, SalesReceivePrintData.Entity);
|
|
33
|
+
let finalTotalsData = (0, sales_total_calculation_1.SalesTotalCalculationsWithDecimals)(argSalesReceiveData.Items, [], IsTaxable, argSalesReceiveData.DecimalsNumber);
|
|
30
34
|
if (ConsolidateGST) {
|
|
31
|
-
finalTotalsData.CustLaborTotalBeforeDisc = finalTotalsData.CustLaborAfterTax;
|
|
32
|
-
finalTotalsData.CustPartsTotalBeforeDisc = finalTotalsData.CustPartAfterTax;
|
|
35
|
+
// finalTotalsData.CustLaborTotalBeforeDisc = finalTotalsData.CustLaborAfterTax;
|
|
36
|
+
// finalTotalsData.CustPartsTotalBeforeDisc = finalTotalsData.CustPartAfterTax;
|
|
37
|
+
finalTotalsData.CustPartsTotalBeforeDisc = (0, math_operations_1.Add)(finalTotalsData.totalTaxOnItems, (0, math_operations_1.Subtract)(finalTotalsData.subtotalOnItems, finalTotalsData.totalDiscountOnItems));
|
|
33
38
|
}
|
|
34
39
|
SalesReceivePrintData = tr_utils_1.TrUtils.ConcatObjects(SalesReceivePrintData, finalTotalsData);
|
|
35
40
|
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);
|
|
@@ -4,7 +4,16 @@ exports.SalesTotalCalculations = SalesTotalCalculations;
|
|
|
4
4
|
exports.SalesTotalCalculationsWithDecimals = SalesTotalCalculationsWithDecimals;
|
|
5
5
|
const math_operations_1 = require("../shared/math-operations");
|
|
6
6
|
const util_1 = require("../shared/util");
|
|
7
|
+
/**
|
|
8
|
+
* Safely handles null/undefined arrays and returns empty array
|
|
9
|
+
*/
|
|
10
|
+
function safeArray(arr) {
|
|
11
|
+
return Array.isArray(arr) ? arr : [];
|
|
12
|
+
}
|
|
7
13
|
function SalesTotalCalculations(items = [], ops = [], isTaxable = false) {
|
|
14
|
+
// Handle null/undefined arrays
|
|
15
|
+
const safeItems = safeArray(items);
|
|
16
|
+
const safeOps = safeArray(ops);
|
|
8
17
|
// Initialize all totals
|
|
9
18
|
let total = 0;
|
|
10
19
|
let subtotalOnItems = 0;
|
|
@@ -17,6 +26,7 @@ function SalesTotalCalculations(items = [], ops = [], isTaxable = false) {
|
|
|
17
26
|
let totalDiscountOnItems = 0;
|
|
18
27
|
let totalDiscountOnLabor = 0;
|
|
19
28
|
let roundOff = 0;
|
|
29
|
+
let totalAfterRounded = 0;
|
|
20
30
|
// Tax breakdown totals - only calculate if taxable
|
|
21
31
|
let totalSGST = 0;
|
|
22
32
|
let totalCGST = 0;
|
|
@@ -28,7 +38,7 @@ function SalesTotalCalculations(items = [], ops = [], isTaxable = false) {
|
|
|
28
38
|
let totalCGSTOnLabor = 0;
|
|
29
39
|
let totalIGSTOnLabor = 0;
|
|
30
40
|
// Calculate items totals with null safety
|
|
31
|
-
|
|
41
|
+
safeItems.forEach((item) => {
|
|
32
42
|
const itemDisc = (0, util_1.GetNumber)(item.Disc);
|
|
33
43
|
const itemRecDisc = (0, util_1.GetNumber)(item.RecDisc);
|
|
34
44
|
const itemUnAmt = (0, util_1.GetNumber)(item.UnAmt);
|
|
@@ -47,7 +57,7 @@ function SalesTotalCalculations(items = [], ops = [], isTaxable = false) {
|
|
|
47
57
|
}
|
|
48
58
|
});
|
|
49
59
|
// Calculate operations/labor totals with null safety
|
|
50
|
-
|
|
60
|
+
safeOps.forEach((op) => {
|
|
51
61
|
const opDisc = (0, util_1.GetNumber)(op.Disc);
|
|
52
62
|
const opRecDisc = (0, util_1.GetNumber)(op.RecDisc);
|
|
53
63
|
const opAmt = (0, util_1.GetNumber)(op.Amt);
|
|
@@ -80,6 +90,7 @@ function SalesTotalCalculations(items = [], ops = [], isTaxable = false) {
|
|
|
80
90
|
const netAmountAfterDiscount = (0, math_operations_1.Subtract)(subtotal, totalDiscount);
|
|
81
91
|
// Step 2: Add tax if taxable
|
|
82
92
|
total = isTaxable ? (0, math_operations_1.Add)(netAmountAfterDiscount, totalTax) : netAmountAfterDiscount;
|
|
93
|
+
totalAfterRounded = isTaxable ? (0, math_operations_1.Add)(netAmountAfterDiscount, totalTax) : netAmountAfterDiscount;
|
|
83
94
|
// FIXED ROUNDING: Use Math.round instead of Math.floor
|
|
84
95
|
const roundedTotal = Math.round(total);
|
|
85
96
|
roundOff = (0, math_operations_1.Subtract)(roundedTotal, total);
|
|
@@ -88,6 +99,7 @@ function SalesTotalCalculations(items = [], ops = [], isTaxable = false) {
|
|
|
88
99
|
// Base return object
|
|
89
100
|
const result = {
|
|
90
101
|
total,
|
|
102
|
+
totalAfterRounded,
|
|
91
103
|
subtotal,
|
|
92
104
|
totalDiscount,
|
|
93
105
|
roundOff,
|
|
@@ -100,6 +112,7 @@ function SalesTotalCalculations(items = [], ops = [], isTaxable = false) {
|
|
|
100
112
|
// Only include tax fields if taxable
|
|
101
113
|
if (isTaxable) {
|
|
102
114
|
result.totalTax = totalTax;
|
|
115
|
+
result.totalAfterRounded = totalAfterRounded;
|
|
103
116
|
result.totalTaxOnItems = totalTaxOnItems;
|
|
104
117
|
result.totalTaxOnLabor = totalTaxOnLabor;
|
|
105
118
|
result.totalSGST = totalSGST;
|
|
@@ -124,6 +137,7 @@ function SalesTotalCalculationsWithDecimals(items = [], ops = [], isTaxable = fa
|
|
|
124
137
|
// Base rounded result
|
|
125
138
|
const roundedResult = {
|
|
126
139
|
total: roundToDecimals(result.total),
|
|
140
|
+
totalAfterRounded: roundToDecimals(result.totalAfterRounded),
|
|
127
141
|
subtotal: roundToDecimals(result.subtotal),
|
|
128
142
|
totalDiscount: roundToDecimals(result.totalDiscount),
|
|
129
143
|
roundOff: roundToDecimals(result.roundOff),
|