shareneus 1.4.97 → 1.4.98
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.
|
@@ -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;
|
|
@@ -28,7 +37,7 @@ function SalesTotalCalculations(items = [], ops = [], isTaxable = false) {
|
|
|
28
37
|
let totalCGSTOnLabor = 0;
|
|
29
38
|
let totalIGSTOnLabor = 0;
|
|
30
39
|
// Calculate items totals with null safety
|
|
31
|
-
|
|
40
|
+
safeItems.forEach((item) => {
|
|
32
41
|
const itemDisc = (0, util_1.GetNumber)(item.Disc);
|
|
33
42
|
const itemRecDisc = (0, util_1.GetNumber)(item.RecDisc);
|
|
34
43
|
const itemUnAmt = (0, util_1.GetNumber)(item.UnAmt);
|
|
@@ -47,7 +56,7 @@ function SalesTotalCalculations(items = [], ops = [], isTaxable = false) {
|
|
|
47
56
|
}
|
|
48
57
|
});
|
|
49
58
|
// Calculate operations/labor totals with null safety
|
|
50
|
-
|
|
59
|
+
safeOps.forEach((op) => {
|
|
51
60
|
const opDisc = (0, util_1.GetNumber)(op.Disc);
|
|
52
61
|
const opRecDisc = (0, util_1.GetNumber)(op.RecDisc);
|
|
53
62
|
const opAmt = (0, util_1.GetNumber)(op.Amt);
|