shareneus 1.5.48 → 1.5.49
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.d.ts +14 -16
- package/dist/accounting/invoice/inv-print.service.js +413 -403
- package/dist/accounting/invoice/invoice-pdf.service.js +1 -1
- package/dist/accounting/invoice/invoice-print.service.d.ts +597 -0
- package/dist/accounting/invoice/invoice-print.service.js +2824 -0
- package/dist/index.d.ts +0 -1
- package/dist/index.js +2 -4
- package/dist/shared/shared-pdf.service.js +2 -2
- package/package.json +1 -1
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.GetInvoicePrintInfo = GetInvoicePrintInfo;
|
|
4
|
+
exports.GetPrintConditionsBasedOnInput = GetPrintConditionsBasedOnInput;
|
|
5
|
+
exports.GetInvoiceTypeHeading = GetInvoiceTypeHeading;
|
|
6
|
+
exports.GetInvoiceOtherDetailsForPrint = GetInvoiceOtherDetailsForPrint;
|
|
7
|
+
exports.GetLaborPrintInfo = GetLaborPrintInfo;
|
|
8
|
+
exports.GetItemsPrintInfo = GetItemsPrintInfo;
|
|
9
|
+
exports.getTaxName = getTaxName;
|
|
10
|
+
exports.ReverseItemsForInvoicePrint = ReverseItemsForInvoicePrint;
|
|
11
|
+
exports.PrepareFormatForInvoicePrint = PrepareFormatForInvoicePrint;
|
|
12
|
+
exports.GetFormattedProductDataForPrint = GetFormattedProductDataForPrint;
|
|
13
|
+
exports.GetBillNameForInvoicePrint = GetBillNameForInvoicePrint;
|
|
14
|
+
exports.GetCustomerDetails = GetCustomerDetails;
|
|
15
|
+
exports.GetBillToName = GetBillToName;
|
|
16
|
+
exports.GetPaymentsTotal = GetPaymentsTotal;
|
|
4
17
|
const code_enums_1 = require("../../enums/code-enums");
|
|
5
18
|
const enums_1 = require("../../enums/enums");
|
|
6
19
|
const math_operations_1 = require("../../shared/math-operations");
|
|
@@ -8,464 +21,461 @@ const shared_print_service_1 = require("../../shared/shared-print.service");
|
|
|
8
21
|
const my_date_1 = require("../../utils/my-date");
|
|
9
22
|
const tr_utils_1 = require("../../utils/tr-utils");
|
|
10
23
|
const invoice_total_service_1 = require("./invoice-total.service");
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
if (
|
|
18
|
-
|
|
19
|
-
argInvoiceData.Settings.Tax = 'NO';
|
|
20
|
-
}
|
|
24
|
+
function GetInvoicePrintInfo(OriginalInvoiceData, OriginalEntityData, image, IncludeGST, ConsolidateGST, TaxCodes, IsProforma, PartsPrint, LaborPrint) {
|
|
25
|
+
var _a, _b, _c, _d;
|
|
26
|
+
let ForInsurance = !tr_utils_1.TrUtils.IsNull(OriginalInvoiceData.BillTo) && !tr_utils_1.TrUtils.IsNull(OriginalInvoiceData.BillTo.Ins_Id);
|
|
27
|
+
let InvoicePrintData = {};
|
|
28
|
+
let argInvoiceData = tr_utils_1.TrUtils.Stringify(OriginalInvoiceData);
|
|
29
|
+
if (!IncludeGST) {
|
|
30
|
+
if (argInvoiceData.Settings.Tax === 'TI') {
|
|
31
|
+
argInvoiceData.Settings.Tax = 'NO';
|
|
21
32
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
33
|
+
}
|
|
34
|
+
InvoicePrintData.IsProforma = IsProforma;
|
|
35
|
+
InvoicePrintData.Settings = tr_utils_1.TrUtils.Stringify(argInvoiceData.Settings);
|
|
36
|
+
InvoicePrintData.SType = tr_utils_1.TrUtils.Stringify(argInvoiceData.SType);
|
|
37
|
+
let SType;
|
|
38
|
+
if (!tr_utils_1.TrUtils.IsNull(argInvoiceData.SType)) {
|
|
39
|
+
SType = argInvoiceData.SType;
|
|
40
|
+
}
|
|
41
|
+
InvoicePrintData = GetPrintConditionsBasedOnInput(InvoicePrintData, IncludeGST, ConsolidateGST, ForInsurance, SType, argInvoiceData, IsProforma, PartsPrint, LaborPrint);
|
|
42
|
+
InvoicePrintData.Entity = shared_print_service_1.PrintSharedService.GetFormattedEntityDataForPrint(OriginalEntityData, "Invoice", OriginalInvoiceData);
|
|
43
|
+
InvoicePrintData = shared_print_service_1.PrintSharedService.GetEntityHeaderStyles(InvoicePrintData, OriginalEntityData, image);
|
|
44
|
+
InvoicePrintData = GetInvoiceOtherDetailsForPrint(InvoicePrintData, argInvoiceData);
|
|
45
|
+
let IsTaxable = (IncludeGST && tr_utils_1.TrUtils.isTaxable(argInvoiceData.Settings.Tax)) ? true : false;
|
|
46
|
+
let finalTotalsData = invoice_total_service_1.InvoiceTotalsService.GetTotalsValue(argInvoiceData.Ops, argInvoiceData.Items, IsTaxable, true, argInvoiceData.LDisc, argInvoiceData.LPerc, argInvoiceData.PDisc, argInvoiceData.PPerc, argInvoiceData.Disc, argInvoiceData.Perc, TaxCodes, true, argInvoiceData.Settings, argInvoiceData.Adjust, InvoicePrintData.Entity.Round, InvoicePrintData.Entity);
|
|
47
|
+
if (ConsolidateGST) {
|
|
48
|
+
finalTotalsData.CustLaborTotalBeforeDisc = finalTotalsData.CustLaborAfterTax;
|
|
49
|
+
finalTotalsData.CustPartsTotalBeforeDisc = finalTotalsData.CustPartAfterTax;
|
|
50
|
+
}
|
|
51
|
+
InvoicePrintData = tr_utils_1.TrUtils.ConcatObjects(InvoicePrintData, finalTotalsData);
|
|
52
|
+
InvoicePrintData.Ops = GetLaborPrintInfo(InvoicePrintData.Ops, ConsolidateGST, TaxCodes, (_b = (_a = OriginalEntityData.Entity.Settings) === null || _a === void 0 ? void 0 : _a.Acc) === null || _b === void 0 ? void 0 : _b.LTot, InvoicePrintData.Entity.DecimalsNumber);
|
|
53
|
+
InvoicePrintData.Items = GetItemsPrintInfo(InvoicePrintData.Items, ConsolidateGST, TaxCodes, (_d = (_c = OriginalEntityData.Entity.Settings) === null || _c === void 0 ? void 0 : _c.Acc) === null || _d === void 0 ? void 0 : _d.LTot, InvoicePrintData.Entity.DecimalsNumber);
|
|
54
|
+
argInvoiceData = ReverseItemsForInvoicePrint(argInvoiceData);
|
|
55
|
+
InvoicePrintData.PrintInfo = PrepareFormatForInvoicePrint(InvoicePrintData, code_enums_1.ROTypeEnum.Invoice, argInvoiceData.Sts);
|
|
56
|
+
InvoicePrintData = GetFormattedProductDataForPrint(argInvoiceData, InvoicePrintData);
|
|
57
|
+
InvoicePrintData = GetBillNameForInvoicePrint(argInvoiceData, InvoicePrintData);
|
|
58
|
+
let PaymentData = GetPaymentsTotal(argInvoiceData.Credits, argInvoiceData.Payments, InvoicePrintData.Total, argInvoiceData.Sts, InvoicePrintData.Entity.DecimalsNumber);
|
|
59
|
+
// if (argInvoiceData.Settings.DiscLvl !== 'REC') {
|
|
60
|
+
// InvoicePrintData.FixedDisc = null;
|
|
61
|
+
// }
|
|
62
|
+
InvoicePrintData.Due = PaymentData.Due;
|
|
63
|
+
InvoicePrintData.Paid = argInvoiceData.Receipt ? argInvoiceData.Total : PaymentData.Paid;
|
|
64
|
+
if (!tr_utils_1.TrUtils.IsNull(PaymentData.Sts)) {
|
|
65
|
+
InvoicePrintData.Sts = PaymentData.Sts;
|
|
66
|
+
}
|
|
67
|
+
InvoicePrintData.Consolidate = ConsolidateGST;
|
|
68
|
+
InvoicePrintData.ShowDiscountColumn = false;
|
|
69
|
+
if (!ForInsurance && !ConsolidateGST) {
|
|
70
|
+
if (shared_print_service_1.PrintSharedService.CheckItemIndexWithDisc(InvoicePrintData) !== -1) {
|
|
71
|
+
// InvoicePrintData.ShowDiscountColumn = (InvoicePrintData.Settings.DiscLvl === 'ITM' || InvoicePrintData.Settings.DiscLvl === 'RECITM') ? true : false;
|
|
72
|
+
InvoicePrintData.ShowDiscountColumn = true;
|
|
62
73
|
}
|
|
63
|
-
|
|
64
|
-
|
|
74
|
+
}
|
|
75
|
+
if (OriginalInvoiceData.Type === '1') {
|
|
76
|
+
InvoicePrintData.From = 'Sales';
|
|
77
|
+
}
|
|
78
|
+
if (OriginalInvoiceData.isCountersale) {
|
|
79
|
+
InvoicePrintData.From = 'Countersale';
|
|
80
|
+
}
|
|
81
|
+
if (tr_utils_1.TrUtils.IsNull(OriginalInvoiceData.BL)) {
|
|
82
|
+
OriginalInvoiceData.BL = {};
|
|
83
|
+
}
|
|
84
|
+
InvoicePrintData.BL = tr_utils_1.TrUtils.Stringify(OriginalInvoiceData.BL);
|
|
85
|
+
OriginalInvoiceData.BL.RefNo = OriginalInvoiceData.RefNo;
|
|
86
|
+
// console.log('InvoicePrintData', InvoicePrintData);
|
|
87
|
+
return InvoicePrintData;
|
|
88
|
+
}
|
|
89
|
+
function GetPrintConditionsBasedOnInput(InvoicePrintData, IncludeGST, ConsolidateGST, ForInsurance, SType, OriginalInvoiceData, IsProforma, PartsPrint, LaborPrint) {
|
|
90
|
+
InvoicePrintData.ForInsurance = ForInsurance;
|
|
91
|
+
InvoicePrintData.For = ForInsurance ? enums_1.PayTypeEnum.Insurance : enums_1.PayTypeEnum.Customer;
|
|
92
|
+
InvoicePrintData.IncludeGST = IncludeGST;
|
|
93
|
+
InvoicePrintData.ConsolidateGST = ConsolidateGST;
|
|
94
|
+
InvoicePrintData.ShowAccParts = true;
|
|
95
|
+
InvoicePrintData.ShowIGST = (tr_utils_1.TrUtils.IsNull(SType) || (SType === 'Intra')) ? false : true;
|
|
96
|
+
InvoicePrintData.ShowTaxColumn = (IncludeGST && !ConsolidateGST) ? true : false;
|
|
97
|
+
// InvoicePrintData.ShowDiscountColumn = (!ForInsurance && !ConsolidateGST) ? true : false;
|
|
98
|
+
InvoicePrintData = GetInvoiceTypeHeading(InvoicePrintData, OriginalInvoiceData, IncludeGST, ConsolidateGST, IsProforma, PartsPrint, LaborPrint);
|
|
99
|
+
InvoicePrintData.PrDate = tr_utils_1.TrUtils.IsNull(OriginalInvoiceData.PrDate) ? '' : my_date_1.MyDate.ConvertUTCDateToReadable(OriginalInvoiceData.PrDate);
|
|
100
|
+
return InvoicePrintData;
|
|
101
|
+
}
|
|
102
|
+
function GetInvoiceTypeHeading(InvoicePrintData, OriginalInvoiceData, IncludeGST, ConsolidateGST, IsProforma, PartsPrint, LaborPrint) {
|
|
103
|
+
// console.log(IsProforma,PartsPrint,LaborPrint);
|
|
104
|
+
if (OriginalInvoiceData.CheckParts) {
|
|
105
|
+
InvoicePrintData.HeaderName = "Spares Issue";
|
|
106
|
+
}
|
|
107
|
+
else if (OriginalInvoiceData.isCountersale) {
|
|
108
|
+
InvoicePrintData.HeaderName = 'Counter Sale Invoice';
|
|
109
|
+
}
|
|
110
|
+
else if (IsProforma) {
|
|
111
|
+
// InvoicePrintData.HeaderName = 'PRO-FORMA INVOICE';
|
|
112
|
+
if (PartsPrint) {
|
|
113
|
+
InvoicePrintData.HeaderName = 'PRO-FORMA INVOICE (PARTS)';
|
|
65
114
|
}
|
|
66
|
-
if (
|
|
67
|
-
InvoicePrintData.
|
|
115
|
+
else if (LaborPrint) {
|
|
116
|
+
InvoicePrintData.HeaderName = 'PRO-FORMA INVOICE (LABOR)';
|
|
68
117
|
}
|
|
69
|
-
|
|
70
|
-
|
|
118
|
+
else {
|
|
119
|
+
InvoicePrintData.HeaderName = 'PRO-FORMA INVOICE';
|
|
71
120
|
}
|
|
72
|
-
InvoicePrintData.BL = tr_utils_1.TrUtils.Stringify(OriginalInvoiceData.BL);
|
|
73
|
-
OriginalInvoiceData.BL.RefNo = OriginalInvoiceData.RefNo;
|
|
74
|
-
// console.log('InvoicePrintData', InvoicePrintData);
|
|
75
|
-
return InvoicePrintData;
|
|
76
|
-
}
|
|
77
|
-
static GetPrintConditionsBasedOnInput(InvoicePrintData, IncludeGST, ConsolidateGST, ForInsurance, SType, OriginalInvoiceData, IsProforma, PartsPrint, LaborPrint) {
|
|
78
|
-
InvoicePrintData.ForInsurance = ForInsurance;
|
|
79
|
-
InvoicePrintData.For = ForInsurance ? enums_1.PayTypeEnum.Insurance : enums_1.PayTypeEnum.Customer;
|
|
80
|
-
InvoicePrintData.IncludeGST = IncludeGST;
|
|
81
|
-
InvoicePrintData.ConsolidateGST = ConsolidateGST;
|
|
82
|
-
InvoicePrintData.ShowAccParts = true;
|
|
83
|
-
InvoicePrintData.ShowIGST = (tr_utils_1.TrUtils.IsNull(SType) || (SType === 'Intra')) ? false : true;
|
|
84
|
-
InvoicePrintData.ShowTaxColumn = (IncludeGST && !ConsolidateGST) ? true : false;
|
|
85
|
-
// InvoicePrintData.ShowDiscountColumn = (!ForInsurance && !ConsolidateGST) ? true : false;
|
|
86
|
-
InvoicePrintData = this.GetInvoiceTypeHeading(InvoicePrintData, OriginalInvoiceData, IncludeGST, ConsolidateGST, IsProforma, PartsPrint, LaborPrint);
|
|
87
|
-
InvoicePrintData.PrDate = tr_utils_1.TrUtils.IsNull(OriginalInvoiceData.PrDate) ? '' : my_date_1.MyDate.ConvertUTCDateToReadable(OriginalInvoiceData.PrDate);
|
|
88
|
-
return InvoicePrintData;
|
|
89
121
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
InvoicePrintData.HeaderName =
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
if (PartsPrint) {
|
|
101
|
-
InvoicePrintData.HeaderName = 'PRO-FORMA INVOICE (PARTS)';
|
|
102
|
-
}
|
|
103
|
-
else if (LaborPrint) {
|
|
104
|
-
InvoicePrintData.HeaderName = 'PRO-FORMA INVOICE (LABOR)';
|
|
122
|
+
else {
|
|
123
|
+
if (OriginalInvoiceData.Type === 'Sales') {
|
|
124
|
+
// if (IncludeGST && !ConsolidateGST) {
|
|
125
|
+
// InvoicePrintData.HeaderName = 'Parts Tax Invoice';
|
|
126
|
+
// } else {
|
|
127
|
+
// InvoicePrintData.HeaderName = 'Parts Invoice';
|
|
128
|
+
// }
|
|
129
|
+
InvoicePrintData.PrintType = 'PARTS ORDER';
|
|
130
|
+
if (InvoicePrintData.Settings.Tax === 'BS' || ConsolidateGST) {
|
|
131
|
+
InvoicePrintData.HeaderName = 'BILL OF SUPPLY';
|
|
105
132
|
}
|
|
106
133
|
else {
|
|
107
|
-
InvoicePrintData.
|
|
134
|
+
if (InvoicePrintData.Settings.Tax === 'TI') {
|
|
135
|
+
InvoicePrintData.HeaderName = 'PARTS TAX INVOICE';
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
InvoicePrintData.HeaderName = 'PARTS INVOICE';
|
|
139
|
+
}
|
|
108
140
|
}
|
|
109
141
|
}
|
|
110
142
|
else {
|
|
111
|
-
if (
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
InvoicePrintData.
|
|
118
|
-
if (
|
|
119
|
-
InvoicePrintData.HeaderName = 'BILL OF SUPPLY';
|
|
143
|
+
// if (IncludeGST && !ConsolidateGST) {
|
|
144
|
+
// InvoicePrintData.HeaderName = 'Tax Invoice';
|
|
145
|
+
// } else {
|
|
146
|
+
// InvoicePrintData.HeaderName = 'Invoice';
|
|
147
|
+
// }
|
|
148
|
+
if (InvoicePrintData.Settings.Tax === 'BS') {
|
|
149
|
+
// InvoicePrintData.HeaderName = 'BILL OF SUPPLY';
|
|
150
|
+
if (PartsPrint) {
|
|
151
|
+
InvoicePrintData.HeaderName = 'BILL OF SUPPLY (PARTS)';
|
|
152
|
+
}
|
|
153
|
+
else if (LaborPrint) {
|
|
154
|
+
InvoicePrintData.HeaderName = 'BILL OF SUPPLY (LABOR)';
|
|
120
155
|
}
|
|
121
156
|
else {
|
|
122
|
-
|
|
123
|
-
InvoicePrintData.HeaderName = 'PARTS TAX INVOICE';
|
|
124
|
-
}
|
|
125
|
-
else {
|
|
126
|
-
InvoicePrintData.HeaderName = 'PARTS INVOICE';
|
|
127
|
-
}
|
|
157
|
+
InvoicePrintData.HeaderName = 'BILL OF SUPPLY';
|
|
128
158
|
}
|
|
129
159
|
}
|
|
130
160
|
else {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
// InvoicePrintData.HeaderName = 'Invoice';
|
|
135
|
-
// }
|
|
136
|
-
if (InvoicePrintData.Settings.Tax === 'BS') {
|
|
137
|
-
// InvoicePrintData.HeaderName = 'BILL OF SUPPLY';
|
|
138
|
-
if (PartsPrint) {
|
|
139
|
-
InvoicePrintData.HeaderName = 'BILL OF SUPPLY (PARTS)';
|
|
140
|
-
}
|
|
141
|
-
else if (LaborPrint) {
|
|
142
|
-
InvoicePrintData.HeaderName = 'BILL OF SUPPLY (LABOR)';
|
|
161
|
+
if (InvoicePrintData.Settings.Tax === 'TI') {
|
|
162
|
+
if (OriginalInvoiceData.Receipt) {
|
|
163
|
+
InvoicePrintData.HeaderName = 'TAX SALES RECEIPT';
|
|
143
164
|
}
|
|
144
165
|
else {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
if (OriginalInvoiceData.Receipt) {
|
|
151
|
-
InvoicePrintData.HeaderName = 'TAX SALES RECEIPT';
|
|
166
|
+
if (PartsPrint) {
|
|
167
|
+
InvoicePrintData.HeaderName = 'TAX INVOICE (PARTS)';
|
|
168
|
+
}
|
|
169
|
+
else if (LaborPrint) {
|
|
170
|
+
InvoicePrintData.HeaderName = 'TAX INVOICE (LABOR)';
|
|
152
171
|
}
|
|
153
172
|
else {
|
|
154
|
-
|
|
155
|
-
InvoicePrintData.HeaderName = 'TAX INVOICE (PARTS)';
|
|
156
|
-
}
|
|
157
|
-
else if (LaborPrint) {
|
|
158
|
-
InvoicePrintData.HeaderName = 'TAX INVOICE (LABOR)';
|
|
159
|
-
}
|
|
160
|
-
else {
|
|
161
|
-
InvoicePrintData.HeaderName = 'TAX INVOICE';
|
|
162
|
-
}
|
|
173
|
+
InvoicePrintData.HeaderName = 'TAX INVOICE';
|
|
163
174
|
}
|
|
164
175
|
}
|
|
176
|
+
}
|
|
177
|
+
else {
|
|
178
|
+
if (OriginalInvoiceData.Receipt) {
|
|
179
|
+
InvoicePrintData.HeaderName = 'SALES RECEIPT';
|
|
180
|
+
}
|
|
165
181
|
else {
|
|
166
|
-
|
|
167
|
-
|
|
182
|
+
// InvoicePrintData.HeaderName = 'INVOICE';
|
|
183
|
+
if (PartsPrint) {
|
|
184
|
+
InvoicePrintData.HeaderName = 'INVOICE (PARTS)';
|
|
185
|
+
}
|
|
186
|
+
else if (LaborPrint) {
|
|
187
|
+
InvoicePrintData.HeaderName = 'INVOICE (LABOR)';
|
|
168
188
|
}
|
|
169
189
|
else {
|
|
170
|
-
|
|
171
|
-
if (PartsPrint) {
|
|
172
|
-
InvoicePrintData.HeaderName = 'INVOICE (PARTS)';
|
|
173
|
-
}
|
|
174
|
-
else if (LaborPrint) {
|
|
175
|
-
InvoicePrintData.HeaderName = 'INVOICE (LABOR)';
|
|
176
|
-
}
|
|
177
|
-
else {
|
|
178
|
-
InvoicePrintData.HeaderName = 'INVOICE';
|
|
179
|
-
}
|
|
190
|
+
InvoicePrintData.HeaderName = 'INVOICE';
|
|
180
191
|
}
|
|
181
192
|
}
|
|
182
193
|
}
|
|
183
194
|
}
|
|
184
195
|
}
|
|
185
|
-
return InvoicePrintData;
|
|
186
|
-
}
|
|
187
|
-
static GetInvoiceOtherDetailsForPrint(InvoicePrintData, argInvoiceData) {
|
|
188
|
-
InvoicePrintData.Type = argInvoiceData.isCountersale ? 'SalesReceipt' : argInvoiceData.CheckParts ? 'Work Order' : 'Invoice';
|
|
189
|
-
InvoicePrintData._id = argInvoiceData.Code;
|
|
190
|
-
InvoicePrintData.ROCode = argInvoiceData.OrdCode;
|
|
191
|
-
InvoicePrintData.ROCode = argInvoiceData.OrdCode;
|
|
192
|
-
InvoicePrintData.TypeName = argInvoiceData.TypeName;
|
|
193
|
-
InvoicePrintData.Sts = argInvoiceData.Sts;
|
|
194
|
-
InvoicePrintData.AdmNo = argInvoiceData.AdmNo;
|
|
195
|
-
InvoicePrintData.CrDate = my_date_1.MyDate.ConvertUTCDateToReadable(argInvoiceData.CrDate);
|
|
196
|
-
return InvoicePrintData;
|
|
197
196
|
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
Labor.
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
Labor.
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
Labor.LineTotal = tr_utils_1.TrUtils.FixPriceValue(Labor.AfterLaborTax, DecimalsNumber);
|
|
232
|
-
}
|
|
233
|
-
else {
|
|
234
|
-
Labor.LineTotal = tr_utils_1.TrUtils.FixPriceValue((0, math_operations_1.Subtract)(Labor.Amt, Labor.Disc), DecimalsNumber);
|
|
235
|
-
}
|
|
236
|
-
});
|
|
237
|
-
return LaborList;
|
|
238
|
-
}
|
|
239
|
-
static GetItemsPrintInfo(Items, Consolidate, TaxCodes, LineTotal, DecimalsNumber) {
|
|
240
|
-
Items.forEach((Item) => {
|
|
241
|
-
if (Consolidate) {
|
|
242
|
-
let AfterDiscForEach = (0, math_operations_1.Divide)(Item.AfterPartDisc, Item.Qty);
|
|
243
|
-
let CTaxAmtPerItem = (0, math_operations_1.Divide)(Item.CGST, Item.Qty);
|
|
244
|
-
let STaxAmtPerItem = (0, math_operations_1.Divide)(Item.SGST, Item.Qty);
|
|
245
|
-
let ITaxAmtPerItem = (0, math_operations_1.Divide)(Item.IGST, Item.Qty);
|
|
246
|
-
Item.UnPr = tr_utils_1.TrUtils.FixedTo((0, math_operations_1.Add)(AfterDiscForEach, CTaxAmtPerItem, STaxAmtPerItem, ITaxAmtPerItem), DecimalsNumber);
|
|
247
|
-
}
|
|
248
|
-
else {
|
|
249
|
-
Item.UnPr = tr_utils_1.TrUtils.FixPriceValue(Item.UnPr, DecimalsNumber);
|
|
250
|
-
}
|
|
251
|
-
// let Index = Item['Desc'].indexOf('#{');
|
|
252
|
-
// if (Index !== -1) {
|
|
253
|
-
// Item.Desc1 = Item['Desc'].substring(Item['Desc'].indexOf('#{') + 2,
|
|
254
|
-
// Item['Desc'].lastIndexOf('}#'));
|
|
255
|
-
// }
|
|
256
|
-
// Item.Desc = Item['Desc'].split(' #{')[0];
|
|
257
|
-
Item.MRP = tr_utils_1.TrUtils.FixPriceValue(Item.MRP, DecimalsNumber);
|
|
258
|
-
Item.CGSTAmt = tr_utils_1.TrUtils.FixPriceValue(Item.CGST, DecimalsNumber);
|
|
259
|
-
Item.SGSTAmt = tr_utils_1.TrUtils.FixPriceValue(Item.SGST, DecimalsNumber);
|
|
260
|
-
Item.IGSTAmt = tr_utils_1.TrUtils.FixPriceValue(Item.IGST, DecimalsNumber);
|
|
261
|
-
Item.TaxName = this.getTaxName(Item.TCode, TaxCodes);
|
|
262
|
-
if (!tr_utils_1.TrUtils.IsEmpty(Item.Perc)) {
|
|
263
|
-
Item.DiscPerc = Item.Perc;
|
|
264
|
-
}
|
|
265
|
-
else {
|
|
266
|
-
Item.DiscPerc = Item.Perc;
|
|
267
|
-
if (!tr_utils_1.TrUtils.IsZero(Number(Item.UnPr))) {
|
|
268
|
-
Item.DiscPerc = (0, math_operations_1.Divide)((0, math_operations_1.Multiply)(100, Item.Disc), Item.UnPr);
|
|
269
|
-
}
|
|
270
|
-
else {
|
|
271
|
-
Item.DiscPerc = 0;
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
Item.CGSTPerc = shared_print_service_1.PrintSharedService.GetCGSTValueBasedOnTaxCode(Item.TCode, TaxCodes);
|
|
275
|
-
Item.SGSTPerc = shared_print_service_1.PrintSharedService.GetSGSTValueBasedOnTaxCode(Item.TCode, TaxCodes);
|
|
276
|
-
Item.IGSTPerc = shared_print_service_1.PrintSharedService.GetIGSTValueBasedOnTaxCode(Item.TCode, TaxCodes);
|
|
277
|
-
if (LineTotal === 'AT') {
|
|
278
|
-
Item.LineTotal = tr_utils_1.TrUtils.FixPriceValue(Item.AfterPartTax, DecimalsNumber);
|
|
279
|
-
}
|
|
280
|
-
else {
|
|
281
|
-
Item.LineTotal = tr_utils_1.TrUtils.FixPriceValue((0, math_operations_1.Subtract)(Item.UnAmt, Item.Disc), DecimalsNumber);
|
|
282
|
-
}
|
|
283
|
-
if (!tr_utils_1.TrUtils.IsZero(Item.Qty) && !tr_utils_1.TrUtils.CheckInvalidSelect(Item.UoM)) {
|
|
284
|
-
Item.QtyAndUoM = Item.Qty + ' ' + Item.UoM;
|
|
197
|
+
return InvoicePrintData;
|
|
198
|
+
}
|
|
199
|
+
function GetInvoiceOtherDetailsForPrint(InvoicePrintData, argInvoiceData) {
|
|
200
|
+
InvoicePrintData.Type = argInvoiceData.isCountersale ? 'SalesReceipt' : argInvoiceData.CheckParts ? 'Work Order' : 'Invoice';
|
|
201
|
+
InvoicePrintData._id = argInvoiceData.Code;
|
|
202
|
+
InvoicePrintData.ROCode = argInvoiceData.OrdCode;
|
|
203
|
+
InvoicePrintData.ROCode = argInvoiceData.OrdCode;
|
|
204
|
+
InvoicePrintData.TypeName = argInvoiceData.TypeName;
|
|
205
|
+
InvoicePrintData.Sts = argInvoiceData.Sts;
|
|
206
|
+
InvoicePrintData.AdmNo = argInvoiceData.AdmNo;
|
|
207
|
+
InvoicePrintData.CrDate = my_date_1.MyDate.ConvertUTCDateToReadable(argInvoiceData.CrDate);
|
|
208
|
+
return InvoicePrintData;
|
|
209
|
+
}
|
|
210
|
+
function GetLaborPrintInfo(LaborList, Consolidate, TaxCodes, LineTotal, DecimalsNumber) {
|
|
211
|
+
LaborList.forEach((Labor) => {
|
|
212
|
+
Labor.HSN = Labor.SAC;
|
|
213
|
+
if (tr_utils_1.TrUtils.IsNull(Labor.Qty)) {
|
|
214
|
+
Labor.Qty = 1;
|
|
215
|
+
}
|
|
216
|
+
if (Consolidate) {
|
|
217
|
+
Labor.UnPr = tr_utils_1.TrUtils.FixedTo(Labor.AfterLaborTax, DecimalsNumber);
|
|
218
|
+
}
|
|
219
|
+
else {
|
|
220
|
+
Labor.UnPr = tr_utils_1.TrUtils.FixPriceValue(Labor.Pr, DecimalsNumber);
|
|
221
|
+
}
|
|
222
|
+
Labor.TaxName = getTaxName(Labor.TCode, TaxCodes);
|
|
223
|
+
if (!tr_utils_1.TrUtils.IsEmpty(Labor.Perc)) {
|
|
224
|
+
Labor.DiscPerc = Labor.Perc;
|
|
225
|
+
}
|
|
226
|
+
else {
|
|
227
|
+
Labor.DiscPerc = Labor.Perc;
|
|
228
|
+
if (!tr_utils_1.TrUtils.IsZero(Number(Labor.UnPr))) {
|
|
229
|
+
Labor.DiscPerc = (0, math_operations_1.Divide)((0, math_operations_1.Multiply)(100, Labor.Disc), Labor.UnPr);
|
|
285
230
|
}
|
|
286
231
|
else {
|
|
287
|
-
|
|
232
|
+
Labor.DiscPerc = 0;
|
|
288
233
|
}
|
|
289
|
-
|
|
290
|
-
|
|
234
|
+
}
|
|
235
|
+
Labor.CGSTAmt = tr_utils_1.TrUtils.FixPriceValue(Labor.CGST, DecimalsNumber);
|
|
236
|
+
Labor.SGSTAmt = tr_utils_1.TrUtils.FixPriceValue(Labor.SGST, DecimalsNumber);
|
|
237
|
+
Labor.IGSTAmt = tr_utils_1.TrUtils.FixPriceValue(Labor.IGST, DecimalsNumber);
|
|
238
|
+
Labor.QtyAndUoM = Labor.Qty.toString();
|
|
239
|
+
Labor.CGSTPerc = shared_print_service_1.PrintSharedService.GetCGSTValueBasedOnTaxCode(Labor.TCode, TaxCodes);
|
|
240
|
+
Labor.SGSTPerc = shared_print_service_1.PrintSharedService.GetSGSTValueBasedOnTaxCode(Labor.TCode, TaxCodes);
|
|
241
|
+
Labor.IGSTPerc = shared_print_service_1.PrintSharedService.GetIGSTValueBasedOnTaxCode(Labor.TCode, TaxCodes);
|
|
242
|
+
if (LineTotal === 'AT') {
|
|
243
|
+
Labor.LineTotal = tr_utils_1.TrUtils.FixPriceValue(Labor.AfterLaborTax, DecimalsNumber);
|
|
244
|
+
}
|
|
245
|
+
else {
|
|
246
|
+
Labor.LineTotal = tr_utils_1.TrUtils.FixPriceValue((0, math_operations_1.Subtract)(Labor.Amt, Labor.Disc), DecimalsNumber);
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
return LaborList;
|
|
250
|
+
}
|
|
251
|
+
function GetItemsPrintInfo(Items, Consolidate, TaxCodes, LineTotal, DecimalsNumber) {
|
|
252
|
+
Items.forEach((Item) => {
|
|
253
|
+
if (Consolidate) {
|
|
254
|
+
let AfterDiscForEach = (0, math_operations_1.Divide)(Item.AfterPartDisc, Item.Qty);
|
|
255
|
+
let CTaxAmtPerItem = (0, math_operations_1.Divide)(Item.CGST, Item.Qty);
|
|
256
|
+
let STaxAmtPerItem = (0, math_operations_1.Divide)(Item.SGST, Item.Qty);
|
|
257
|
+
let ITaxAmtPerItem = (0, math_operations_1.Divide)(Item.IGST, Item.Qty);
|
|
258
|
+
Item.UnPr = tr_utils_1.TrUtils.FixedTo((0, math_operations_1.Add)(AfterDiscForEach, CTaxAmtPerItem, STaxAmtPerItem, ITaxAmtPerItem), DecimalsNumber);
|
|
259
|
+
}
|
|
260
|
+
else {
|
|
261
|
+
Item.UnPr = tr_utils_1.TrUtils.FixPriceValue(Item.UnPr, DecimalsNumber);
|
|
262
|
+
}
|
|
263
|
+
// let Index = Item['Desc'].indexOf('#{');
|
|
264
|
+
// if (Index !== -1) {
|
|
265
|
+
// Item.Desc1 = Item['Desc'].substring(Item['Desc'].indexOf('#{') + 2,
|
|
266
|
+
// Item['Desc'].lastIndexOf('}#'));
|
|
267
|
+
// }
|
|
268
|
+
// Item.Desc = Item['Desc'].split(' #{')[0];
|
|
269
|
+
Item.MRP = tr_utils_1.TrUtils.FixPriceValue(Item.MRP, DecimalsNumber);
|
|
270
|
+
Item.CGSTAmt = tr_utils_1.TrUtils.FixPriceValue(Item.CGST, DecimalsNumber);
|
|
271
|
+
Item.SGSTAmt = tr_utils_1.TrUtils.FixPriceValue(Item.SGST, DecimalsNumber);
|
|
272
|
+
Item.IGSTAmt = tr_utils_1.TrUtils.FixPriceValue(Item.IGST, DecimalsNumber);
|
|
273
|
+
Item.TaxName = getTaxName(Item.TCode, TaxCodes);
|
|
274
|
+
if (!tr_utils_1.TrUtils.IsEmpty(Item.Perc)) {
|
|
275
|
+
Item.DiscPerc = Item.Perc;
|
|
276
|
+
}
|
|
277
|
+
else {
|
|
278
|
+
Item.DiscPerc = Item.Perc;
|
|
279
|
+
if (!tr_utils_1.TrUtils.IsZero(Number(Item.UnPr))) {
|
|
280
|
+
Item.DiscPerc = (0, math_operations_1.Divide)((0, math_operations_1.Multiply)(100, Item.Disc), Item.UnPr);
|
|
291
281
|
}
|
|
292
282
|
else {
|
|
293
|
-
Item.
|
|
283
|
+
Item.DiscPerc = 0;
|
|
294
284
|
}
|
|
295
|
-
});
|
|
296
|
-
return Items;
|
|
297
|
-
}
|
|
298
|
-
static getTaxName(TCode, TaxCodes) {
|
|
299
|
-
let Index = TaxCodes.findIndex((TaxCode) => {
|
|
300
|
-
return Number(TCode) === TaxCode._id;
|
|
301
|
-
});
|
|
302
|
-
return (Index !== -1) ? TaxCodes[Index].Name : '';
|
|
303
|
-
}
|
|
304
|
-
static ReverseItemsForInvoicePrint(argInvoiceData) {
|
|
305
|
-
argInvoiceData.Ops = argInvoiceData.Ops;
|
|
306
|
-
argInvoiceData.Items = argInvoiceData.Items;
|
|
307
|
-
return argInvoiceData;
|
|
308
|
-
}
|
|
309
|
-
static PrepareFormatForInvoicePrint(InvoicePrintData, ROType, InvoiceStatus) {
|
|
310
|
-
let PrintInfo = [];
|
|
311
|
-
let ROLaborParts = {};
|
|
312
|
-
ROLaborParts.Ops = InvoicePrintData.Ops;
|
|
313
|
-
ROLaborParts.Items = InvoicePrintData.Items;
|
|
314
|
-
ROLaborParts.Sts = InvoiceStatus;
|
|
315
|
-
ROLaborParts.Type = ROType;
|
|
316
|
-
PrintInfo.push(ROLaborParts);
|
|
317
|
-
return PrintInfo;
|
|
318
|
-
}
|
|
319
|
-
static GetFormattedProductDataForPrint(argInvoiceData, InvoicePrintData) {
|
|
320
|
-
if (!tr_utils_1.TrUtils.IsNull(argInvoiceData.Prod)) {
|
|
321
|
-
InvoicePrintData.Product = argInvoiceData.Prod;
|
|
322
|
-
if (tr_utils_1.TrUtils.IsNull(InvoicePrintData.Product.VIN)) {
|
|
323
|
-
InvoicePrintData.Product.VIN = '';
|
|
324
|
-
}
|
|
325
|
-
if (tr_utils_1.TrUtils.IsNull(InvoicePrintData.Product.RegNo)) {
|
|
326
|
-
InvoicePrintData.Product.RegNo = '';
|
|
327
|
-
}
|
|
328
|
-
if (tr_utils_1.TrUtils.IsNull(InvoicePrintData.Product.EngNo)) {
|
|
329
|
-
InvoicePrintData.Product.EngNo = '';
|
|
330
|
-
}
|
|
331
|
-
InvoicePrintData.MIn = argInvoiceData.Prod.MIn;
|
|
332
|
-
InvoicePrintData.MOut = argInvoiceData.Prod.MOut;
|
|
333
285
|
}
|
|
334
|
-
|
|
286
|
+
Item.CGSTPerc = shared_print_service_1.PrintSharedService.GetCGSTValueBasedOnTaxCode(Item.TCode, TaxCodes);
|
|
287
|
+
Item.SGSTPerc = shared_print_service_1.PrintSharedService.GetSGSTValueBasedOnTaxCode(Item.TCode, TaxCodes);
|
|
288
|
+
Item.IGSTPerc = shared_print_service_1.PrintSharedService.GetIGSTValueBasedOnTaxCode(Item.TCode, TaxCodes);
|
|
289
|
+
if (LineTotal === 'AT') {
|
|
290
|
+
Item.LineTotal = tr_utils_1.TrUtils.FixPriceValue(Item.AfterPartTax, DecimalsNumber);
|
|
291
|
+
}
|
|
292
|
+
else {
|
|
293
|
+
Item.LineTotal = tr_utils_1.TrUtils.FixPriceValue((0, math_operations_1.Subtract)(Item.UnAmt, Item.Disc), DecimalsNumber);
|
|
294
|
+
}
|
|
295
|
+
if (!tr_utils_1.TrUtils.IsZero(Item.Qty) && !tr_utils_1.TrUtils.CheckInvalidSelect(Item.UoM)) {
|
|
296
|
+
Item.QtyAndUoM = Item.Qty + ' ' + Item.UoM;
|
|
297
|
+
}
|
|
298
|
+
else {
|
|
299
|
+
Item.QtyAndUoM = Item.Qty + '';
|
|
300
|
+
}
|
|
301
|
+
if (!tr_utils_1.TrUtils.IsZero(Item.OfQty) && !tr_utils_1.TrUtils.CheckInvalidSelect(Item.UoM)) {
|
|
302
|
+
Item.OfQtyAndUoM = Item.OfQty + ' ' + Item.UoM;
|
|
303
|
+
}
|
|
304
|
+
else {
|
|
305
|
+
Item.OfQtyAndUoM = Item.OfQty + '';
|
|
306
|
+
}
|
|
307
|
+
});
|
|
308
|
+
return Items;
|
|
309
|
+
}
|
|
310
|
+
function getTaxName(TCode, TaxCodes) {
|
|
311
|
+
let Index = TaxCodes.findIndex((TaxCode) => {
|
|
312
|
+
return Number(TCode) === TaxCode._id;
|
|
313
|
+
});
|
|
314
|
+
return (Index !== -1) ? TaxCodes[Index].Name : '';
|
|
315
|
+
}
|
|
316
|
+
function ReverseItemsForInvoicePrint(argInvoiceData) {
|
|
317
|
+
argInvoiceData.Ops = argInvoiceData.Ops;
|
|
318
|
+
argInvoiceData.Items = argInvoiceData.Items;
|
|
319
|
+
return argInvoiceData;
|
|
320
|
+
}
|
|
321
|
+
function PrepareFormatForInvoicePrint(InvoicePrintData, ROType, InvoiceStatus) {
|
|
322
|
+
let PrintInfo = [];
|
|
323
|
+
let ROLaborParts = {};
|
|
324
|
+
ROLaborParts.Ops = InvoicePrintData.Ops;
|
|
325
|
+
ROLaborParts.Items = InvoicePrintData.Items;
|
|
326
|
+
ROLaborParts.Sts = InvoiceStatus;
|
|
327
|
+
ROLaborParts.Type = ROType;
|
|
328
|
+
PrintInfo.push(ROLaborParts);
|
|
329
|
+
return PrintInfo;
|
|
330
|
+
}
|
|
331
|
+
function GetFormattedProductDataForPrint(argInvoiceData, InvoicePrintData) {
|
|
332
|
+
if (!tr_utils_1.TrUtils.IsNull(argInvoiceData.Prod)) {
|
|
333
|
+
InvoicePrintData.Product = argInvoiceData.Prod;
|
|
334
|
+
if (tr_utils_1.TrUtils.IsNull(InvoicePrintData.Product.VIN)) {
|
|
335
|
+
InvoicePrintData.Product.VIN = '';
|
|
336
|
+
}
|
|
337
|
+
if (tr_utils_1.TrUtils.IsNull(InvoicePrintData.Product.RegNo)) {
|
|
338
|
+
InvoicePrintData.Product.RegNo = '';
|
|
339
|
+
}
|
|
340
|
+
if (tr_utils_1.TrUtils.IsNull(InvoicePrintData.Product.EngNo)) {
|
|
341
|
+
InvoicePrintData.Product.EngNo = '';
|
|
342
|
+
}
|
|
343
|
+
InvoicePrintData.MIn = argInvoiceData.Prod.MIn;
|
|
344
|
+
InvoicePrintData.MOut = argInvoiceData.Prod.MOut;
|
|
335
345
|
}
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
Customer.
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
346
|
+
return InvoicePrintData;
|
|
347
|
+
}
|
|
348
|
+
function GetBillNameForInvoicePrint(argInvoiceData, InvoicePrintData) {
|
|
349
|
+
var _a;
|
|
350
|
+
let Customer = {};
|
|
351
|
+
if (!tr_utils_1.TrUtils.IsNull(argInvoiceData.BillTo)) {
|
|
352
|
+
Customer.Name = argInvoiceData.BillTo.Name;
|
|
353
|
+
if (!tr_utils_1.TrUtils.IsNull(argInvoiceData.BillTo.Sltn)) {
|
|
354
|
+
Customer.Name = argInvoiceData.BillTo.Sltn + ' ' + Customer.Name;
|
|
355
|
+
}
|
|
356
|
+
Customer.Code = (_a = argInvoiceData.Cust) === null || _a === void 0 ? void 0 : _a.Code;
|
|
357
|
+
Customer.Adrs = [];
|
|
358
|
+
Customer.Cons = [];
|
|
359
|
+
if (!tr_utils_1.TrUtils.IsNull(argInvoiceData.BillTo.Adrs)) {
|
|
360
|
+
Customer.Adrs.push(argInvoiceData.BillTo.Adrs.A1);
|
|
361
|
+
if (!tr_utils_1.TrUtils.IsEmpty(argInvoiceData.BillTo.Adrs.A2)) {
|
|
362
|
+
Customer.Adrs.push(argInvoiceData.BillTo.Adrs.A2);
|
|
363
|
+
}
|
|
364
|
+
if (!tr_utils_1.TrUtils.IsEmpty(argInvoiceData.BillTo.Adrs.Ct)) {
|
|
365
|
+
let city = argInvoiceData.BillTo.Adrs.Ct;
|
|
366
|
+
if (!tr_utils_1.TrUtils.IsEmpty(argInvoiceData.BillTo.Adrs.Pin)) {
|
|
367
|
+
city = city + ', ' + argInvoiceData.BillTo.Adrs.StCode + '-' + argInvoiceData.BillTo.Adrs.Pin;
|
|
358
368
|
}
|
|
359
|
-
|
|
360
|
-
Customer.GSTIN = argInvoiceData.BillTo.GSTIN;
|
|
361
|
-
if (!tr_utils_1.TrUtils.IsNull(argInvoiceData.BillTo.DLNo)) {
|
|
362
|
-
Customer.DLNo = argInvoiceData.BillTo.DLNo;
|
|
363
|
-
}
|
|
364
|
-
if (!tr_utils_1.TrUtils.IsEmpty(argInvoiceData.BillTo.Ph)) {
|
|
365
|
-
Customer.Cons = [
|
|
366
|
-
{
|
|
367
|
-
Type: 'M',
|
|
368
|
-
No: argInvoiceData.BillTo.Ph
|
|
369
|
-
}
|
|
370
|
-
];
|
|
371
|
-
}
|
|
372
|
-
InvoicePrintData.Customer = Customer;
|
|
373
|
-
InvoicePrintData.Name = argInvoiceData.Name;
|
|
374
|
-
if (!tr_utils_1.TrUtils.IsNull(argInvoiceData.BillTo.Ins_Id)) {
|
|
375
|
-
InvoicePrintData.Cust = this.GetCustomerDetails(argInvoiceData);
|
|
369
|
+
Customer.Adrs.push(city);
|
|
376
370
|
}
|
|
377
371
|
}
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
Customer.
|
|
381
|
-
Customer.Adrs = [];
|
|
382
|
-
Customer.Cons = [];
|
|
383
|
-
InvoicePrintData.Customer = Customer;
|
|
384
|
-
}
|
|
385
|
-
if (!tr_utils_1.TrUtils.IsNull(argInvoiceData.ShipTo)) {
|
|
386
|
-
let location = {};
|
|
387
|
-
location.Adrs = shared_print_service_1.PrintSharedService.GetAddress(argInvoiceData.ShipTo.Adrs);
|
|
388
|
-
let Name;
|
|
389
|
-
if (tr_utils_1.TrUtils.IsNull(argInvoiceData.ShipTo.Name)) {
|
|
390
|
-
Name = argInvoiceData.ShipTo.ConName;
|
|
391
|
-
}
|
|
392
|
-
else {
|
|
393
|
-
Name = argInvoiceData.ShipTo.Name;
|
|
394
|
-
}
|
|
395
|
-
if (tr_utils_1.TrUtils.IsNull(Name)) {
|
|
396
|
-
Name = '';
|
|
397
|
-
}
|
|
398
|
-
location.Name = Name;
|
|
399
|
-
if (!tr_utils_1.TrUtils.IsNull(argInvoiceData.ShipTo.ConPh)) {
|
|
400
|
-
location.Cons = [
|
|
401
|
-
{
|
|
402
|
-
Type: 'M',
|
|
403
|
-
No: argInvoiceData.ShipTo.ConPh
|
|
404
|
-
}
|
|
405
|
-
];
|
|
406
|
-
}
|
|
407
|
-
InvoicePrintData.Location = location;
|
|
372
|
+
Customer.GSTIN = argInvoiceData.BillTo.GSTIN;
|
|
373
|
+
if (!tr_utils_1.TrUtils.IsNull(argInvoiceData.BillTo.DLNo)) {
|
|
374
|
+
Customer.DLNo = argInvoiceData.BillTo.DLNo;
|
|
408
375
|
}
|
|
409
|
-
|
|
410
|
-
}
|
|
411
|
-
static GetCustomerDetails(argInvoiceData) {
|
|
412
|
-
let Customer = {};
|
|
413
|
-
Customer.Name = this.GetBillToName(argInvoiceData.Cust.Title, argInvoiceData.Cust.Name);
|
|
414
|
-
Customer.Cons = [];
|
|
415
|
-
if (!tr_utils_1.TrUtils.IsEmpty(argInvoiceData.Cust.Ph)) {
|
|
376
|
+
if (!tr_utils_1.TrUtils.IsEmpty(argInvoiceData.BillTo.Ph)) {
|
|
416
377
|
Customer.Cons = [
|
|
417
378
|
{
|
|
418
379
|
Type: 'M',
|
|
419
|
-
No: argInvoiceData.
|
|
380
|
+
No: argInvoiceData.BillTo.Ph
|
|
420
381
|
}
|
|
421
382
|
];
|
|
422
383
|
}
|
|
423
|
-
Customer
|
|
424
|
-
|
|
425
|
-
if (!tr_utils_1.TrUtils.IsNull(argInvoiceData.
|
|
426
|
-
|
|
427
|
-
if (!tr_utils_1.TrUtils.IsEmpty(argInvoiceData.Cust.Adrs.A2)) {
|
|
428
|
-
Customer.Adrs.push(argInvoiceData.Cust.Adrs.A2);
|
|
429
|
-
}
|
|
430
|
-
Customer.Adrs.push(argInvoiceData.Cust.Adrs.Ct);
|
|
384
|
+
InvoicePrintData.Customer = Customer;
|
|
385
|
+
InvoicePrintData.Name = argInvoiceData.Name;
|
|
386
|
+
if (!tr_utils_1.TrUtils.IsNull(argInvoiceData.BillTo.Ins_Id)) {
|
|
387
|
+
InvoicePrintData.Cust = GetCustomerDetails(argInvoiceData);
|
|
431
388
|
}
|
|
432
|
-
Customer.ConName = argInvoiceData.Cust.ConName;
|
|
433
|
-
Customer.ConPh = argInvoiceData.Cust.ConPhone;
|
|
434
|
-
return Customer;
|
|
435
389
|
}
|
|
436
|
-
|
|
437
|
-
|
|
390
|
+
else if (!tr_utils_1.TrUtils.IsNull(argInvoiceData.Cust)) {
|
|
391
|
+
Customer.Name = argInvoiceData.Cust.Name;
|
|
392
|
+
Customer.Code = argInvoiceData.Cust.Code;
|
|
393
|
+
Customer.Adrs = [];
|
|
394
|
+
Customer.Cons = [];
|
|
395
|
+
InvoicePrintData.Customer = Customer;
|
|
438
396
|
}
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
let
|
|
443
|
-
if (tr_utils_1.TrUtils.IsNull(
|
|
444
|
-
|
|
445
|
-
}
|
|
446
|
-
if (tr_utils_1.TrUtils.IsNull(Credits)) {
|
|
447
|
-
Credits = [];
|
|
448
|
-
}
|
|
449
|
-
for (i = 0; i < InvoicePayments.length; i++) {
|
|
450
|
-
PaidTotal += InvoicePayments[i].Paid;
|
|
451
|
-
}
|
|
452
|
-
for (i = 0; i < Credits.length; i++) {
|
|
453
|
-
PaidTotal += Credits[i].Amt;
|
|
454
|
-
}
|
|
455
|
-
if (InvoiceStatus === enums_1.InvoiceStatusEnum.Closed) {
|
|
456
|
-
Data.Due = 0;
|
|
397
|
+
if (!tr_utils_1.TrUtils.IsNull(argInvoiceData.ShipTo)) {
|
|
398
|
+
let location = {};
|
|
399
|
+
location.Adrs = shared_print_service_1.PrintSharedService.GetAddress(argInvoiceData.ShipTo.Adrs);
|
|
400
|
+
let Name;
|
|
401
|
+
if (tr_utils_1.TrUtils.IsNull(argInvoiceData.ShipTo.Name)) {
|
|
402
|
+
Name = argInvoiceData.ShipTo.ConName;
|
|
457
403
|
}
|
|
458
404
|
else {
|
|
459
|
-
|
|
405
|
+
Name = argInvoiceData.ShipTo.Name;
|
|
406
|
+
}
|
|
407
|
+
if (tr_utils_1.TrUtils.IsNull(Name)) {
|
|
408
|
+
Name = '';
|
|
460
409
|
}
|
|
461
|
-
|
|
462
|
-
|
|
410
|
+
location.Name = Name;
|
|
411
|
+
if (!tr_utils_1.TrUtils.IsNull(argInvoiceData.ShipTo.ConPh)) {
|
|
412
|
+
location.Cons = [
|
|
413
|
+
{
|
|
414
|
+
Type: 'M',
|
|
415
|
+
No: argInvoiceData.ShipTo.ConPh
|
|
416
|
+
}
|
|
417
|
+
];
|
|
463
418
|
}
|
|
464
|
-
|
|
465
|
-
|
|
419
|
+
InvoicePrintData.Location = location;
|
|
420
|
+
}
|
|
421
|
+
return InvoicePrintData;
|
|
422
|
+
}
|
|
423
|
+
function GetCustomerDetails(argInvoiceData) {
|
|
424
|
+
let Customer = {};
|
|
425
|
+
Customer.Name = GetBillToName(argInvoiceData.Cust.Title, argInvoiceData.Cust.Name);
|
|
426
|
+
Customer.Cons = [];
|
|
427
|
+
if (!tr_utils_1.TrUtils.IsEmpty(argInvoiceData.Cust.Ph)) {
|
|
428
|
+
Customer.Cons = [
|
|
429
|
+
{
|
|
430
|
+
Type: 'M',
|
|
431
|
+
No: argInvoiceData.Cust.Ph
|
|
432
|
+
}
|
|
433
|
+
];
|
|
434
|
+
}
|
|
435
|
+
Customer.GSTIN = argInvoiceData.Cust.GSTIN;
|
|
436
|
+
Customer.Adrs = [];
|
|
437
|
+
if (!tr_utils_1.TrUtils.IsNull(argInvoiceData.Cust.Adrs)) {
|
|
438
|
+
Customer.Adrs.push(argInvoiceData.Cust.Adrs.A1);
|
|
439
|
+
if (!tr_utils_1.TrUtils.IsEmpty(argInvoiceData.Cust.Adrs.A2)) {
|
|
440
|
+
Customer.Adrs.push(argInvoiceData.Cust.Adrs.A2);
|
|
466
441
|
}
|
|
467
|
-
|
|
468
|
-
|
|
442
|
+
Customer.Adrs.push(argInvoiceData.Cust.Adrs.Ct);
|
|
443
|
+
}
|
|
444
|
+
Customer.ConName = argInvoiceData.Cust.ConName;
|
|
445
|
+
Customer.ConPh = argInvoiceData.Cust.ConPhone;
|
|
446
|
+
return Customer;
|
|
447
|
+
}
|
|
448
|
+
function GetBillToName(Title, Name) {
|
|
449
|
+
return tr_utils_1.TrUtils.IsEmpty(Title) ? Name : Title + ' ' + Name;
|
|
450
|
+
}
|
|
451
|
+
function GetPaymentsTotal(Credits, InvoicePayments, Total, InvoiceStatus, DecimalsNumber) {
|
|
452
|
+
var i = 0;
|
|
453
|
+
let Data = {};
|
|
454
|
+
let PaidTotal = 0;
|
|
455
|
+
if (tr_utils_1.TrUtils.IsNull(InvoicePayments)) {
|
|
456
|
+
InvoicePayments = [];
|
|
457
|
+
}
|
|
458
|
+
if (tr_utils_1.TrUtils.IsNull(Credits)) {
|
|
459
|
+
Credits = [];
|
|
460
|
+
}
|
|
461
|
+
for (i = 0; i < InvoicePayments.length; i++) {
|
|
462
|
+
PaidTotal += InvoicePayments[i].Paid;
|
|
463
|
+
}
|
|
464
|
+
for (i = 0; i < Credits.length; i++) {
|
|
465
|
+
PaidTotal += Credits[i].Amt;
|
|
466
|
+
}
|
|
467
|
+
if (InvoiceStatus === enums_1.InvoiceStatusEnum.Closed) {
|
|
468
|
+
Data.Due = 0;
|
|
469
|
+
}
|
|
470
|
+
else {
|
|
471
|
+
Data.Due = tr_utils_1.TrUtils.FixedTo((0, math_operations_1.Subtract)(Total, PaidTotal), DecimalsNumber);
|
|
472
|
+
}
|
|
473
|
+
if (Data.Due < 0) {
|
|
474
|
+
Data.Due = 0;
|
|
475
|
+
}
|
|
476
|
+
if (Data.Due === 0) {
|
|
477
|
+
Data.Sts = enums_1.InvoiceStatusEnum.Closed;
|
|
469
478
|
}
|
|
479
|
+
Data.Paid = tr_utils_1.TrUtils.FixedTo(PaidTotal, DecimalsNumber);
|
|
480
|
+
return Data;
|
|
470
481
|
}
|
|
471
|
-
exports.InvPrintService = InvPrintService;
|