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.
@@ -1,6 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.InvPrintService = void 0;
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
- class InvPrintService {
12
- static GetInvoicePrintInfo(OriginalInvoiceData, OriginalEntityData, image, IncludeGST, ConsolidateGST, TaxCodes, IsProforma, PartsPrint, LaborPrint) {
13
- var _a, _b, _c, _d;
14
- let ForInsurance = !tr_utils_1.TrUtils.IsNull(OriginalInvoiceData.BillTo) && !tr_utils_1.TrUtils.IsNull(OriginalInvoiceData.BillTo.Ins_Id);
15
- let InvoicePrintData = {};
16
- let argInvoiceData = tr_utils_1.TrUtils.Stringify(OriginalInvoiceData);
17
- if (!IncludeGST) {
18
- if (argInvoiceData.Settings.Tax === 'TI') {
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
- InvoicePrintData.IsProforma = IsProforma;
23
- InvoicePrintData.Settings = tr_utils_1.TrUtils.Stringify(argInvoiceData.Settings);
24
- InvoicePrintData.SType = tr_utils_1.TrUtils.Stringify(argInvoiceData.SType);
25
- let SType;
26
- if (!tr_utils_1.TrUtils.IsNull(argInvoiceData.SType)) {
27
- SType = argInvoiceData.SType;
28
- }
29
- InvoicePrintData = this.GetPrintConditionsBasedOnInput(InvoicePrintData, IncludeGST, ConsolidateGST, ForInsurance, SType, argInvoiceData, IsProforma, PartsPrint, LaborPrint);
30
- InvoicePrintData.Entity = shared_print_service_1.PrintSharedService.GetFormattedEntityDataForPrint(OriginalEntityData, "Invoice", OriginalInvoiceData);
31
- InvoicePrintData = shared_print_service_1.PrintSharedService.GetEntityHeaderStyles(InvoicePrintData, OriginalEntityData, image);
32
- InvoicePrintData = this.GetInvoiceOtherDetailsForPrint(InvoicePrintData, argInvoiceData);
33
- let IsTaxable = (IncludeGST && tr_utils_1.TrUtils.isTaxable(argInvoiceData.Settings.Tax)) ? true : false;
34
- 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);
35
- if (ConsolidateGST) {
36
- finalTotalsData.CustLaborTotalBeforeDisc = finalTotalsData.CustLaborAfterTax;
37
- finalTotalsData.CustPartsTotalBeforeDisc = finalTotalsData.CustPartAfterTax;
38
- }
39
- InvoicePrintData = tr_utils_1.TrUtils.ConcatObjects(InvoicePrintData, finalTotalsData);
40
- InvoicePrintData.Ops = this.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);
41
- InvoicePrintData.Items = this.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);
42
- argInvoiceData = this.ReverseItemsForInvoicePrint(argInvoiceData);
43
- InvoicePrintData.PrintInfo = this.PrepareFormatForInvoicePrint(InvoicePrintData, code_enums_1.ROTypeEnum.Invoice, argInvoiceData.Sts);
44
- InvoicePrintData = this.GetFormattedProductDataForPrint(argInvoiceData, InvoicePrintData);
45
- InvoicePrintData = this.GetBillNameForInvoicePrint(argInvoiceData, InvoicePrintData);
46
- let PaymentData = this.GetPaymentsTotal(argInvoiceData.Credits, argInvoiceData.Payments, InvoicePrintData.Total, argInvoiceData.Sts, InvoicePrintData.Entity.DecimalsNumber);
47
- // if (argInvoiceData.Settings.DiscLvl !== 'REC') {
48
- // InvoicePrintData.FixedDisc = null;
49
- // }
50
- InvoicePrintData.Due = PaymentData.Due;
51
- InvoicePrintData.Paid = argInvoiceData.Receipt ? argInvoiceData.Total : PaymentData.Paid;
52
- if (!tr_utils_1.TrUtils.IsNull(PaymentData.Sts)) {
53
- InvoicePrintData.Sts = PaymentData.Sts;
54
- }
55
- InvoicePrintData.Consolidate = ConsolidateGST;
56
- InvoicePrintData.ShowDiscountColumn = false;
57
- if (!ForInsurance && !ConsolidateGST) {
58
- if (shared_print_service_1.PrintSharedService.CheckItemIndexWithDisc(InvoicePrintData) !== -1) {
59
- // InvoicePrintData.ShowDiscountColumn = (InvoicePrintData.Settings.DiscLvl === 'ITM' || InvoicePrintData.Settings.DiscLvl === 'RECITM') ? true : false;
60
- InvoicePrintData.ShowDiscountColumn = true;
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
- if (OriginalInvoiceData.Type === '1') {
64
- InvoicePrintData.From = 'Sales';
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 (OriginalInvoiceData.isCountersale) {
67
- InvoicePrintData.From = 'Countersale';
115
+ else if (LaborPrint) {
116
+ InvoicePrintData.HeaderName = 'PRO-FORMA INVOICE (LABOR)';
68
117
  }
69
- if (tr_utils_1.TrUtils.IsNull(OriginalInvoiceData.BL)) {
70
- OriginalInvoiceData.BL = {};
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
- static GetInvoiceTypeHeading(InvoicePrintData, OriginalInvoiceData, IncludeGST, ConsolidateGST, IsProforma, PartsPrint, LaborPrint) {
91
- // console.log(IsProforma,PartsPrint,LaborPrint);
92
- if (OriginalInvoiceData.CheckParts) {
93
- InvoicePrintData.HeaderName = "Spares Issue";
94
- }
95
- else if (OriginalInvoiceData.isCountersale) {
96
- InvoicePrintData.HeaderName = 'Counter Sale Invoice';
97
- }
98
- else if (IsProforma) {
99
- // InvoicePrintData.HeaderName = 'PRO-FORMA INVOICE';
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.HeaderName = 'PRO-FORMA INVOICE';
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 (OriginalInvoiceData.Type === 'Sales') {
112
- // if (IncludeGST && !ConsolidateGST) {
113
- // InvoicePrintData.HeaderName = 'Parts Tax Invoice';
114
- // } else {
115
- // InvoicePrintData.HeaderName = 'Parts Invoice';
116
- // }
117
- InvoicePrintData.PrintType = 'PARTS ORDER';
118
- if (InvoicePrintData.Settings.Tax === 'BS' || ConsolidateGST) {
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
- if (InvoicePrintData.Settings.Tax === 'TI') {
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
- // if (IncludeGST && !ConsolidateGST) {
132
- // InvoicePrintData.HeaderName = 'Tax Invoice';
133
- // } else {
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
- InvoicePrintData.HeaderName = 'BILL OF SUPPLY';
146
- }
147
- }
148
- else {
149
- if (InvoicePrintData.Settings.Tax === 'TI') {
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
- if (PartsPrint) {
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
- if (OriginalInvoiceData.Receipt) {
167
- InvoicePrintData.HeaderName = 'SALES RECEIPT';
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
- // InvoicePrintData.HeaderName = 'INVOICE';
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
- static GetLaborPrintInfo(LaborList, Consolidate, TaxCodes, LineTotal, DecimalsNumber) {
199
- LaborList.forEach((Labor) => {
200
- Labor.HSN = Labor.SAC;
201
- if (tr_utils_1.TrUtils.IsNull(Labor.Qty)) {
202
- Labor.Qty = 1;
203
- }
204
- if (Consolidate) {
205
- Labor.UnPr = tr_utils_1.TrUtils.FixedTo(Labor.AfterLaborTax, DecimalsNumber);
206
- }
207
- else {
208
- Labor.UnPr = tr_utils_1.TrUtils.FixPriceValue(Labor.Pr, DecimalsNumber);
209
- }
210
- Labor.TaxName = this.getTaxName(Labor.TCode, TaxCodes);
211
- if (!tr_utils_1.TrUtils.IsEmpty(Labor.Perc)) {
212
- Labor.DiscPerc = Labor.Perc;
213
- }
214
- else {
215
- Labor.DiscPerc = Labor.Perc;
216
- if (!tr_utils_1.TrUtils.IsZero(Number(Labor.UnPr))) {
217
- Labor.DiscPerc = (0, math_operations_1.Divide)((0, math_operations_1.Multiply)(100, Labor.Disc), Labor.UnPr);
218
- }
219
- else {
220
- Labor.DiscPerc = 0;
221
- }
222
- }
223
- Labor.CGSTAmt = tr_utils_1.TrUtils.FixPriceValue(Labor.CGST, DecimalsNumber);
224
- Labor.SGSTAmt = tr_utils_1.TrUtils.FixPriceValue(Labor.SGST, DecimalsNumber);
225
- Labor.IGSTAmt = tr_utils_1.TrUtils.FixPriceValue(Labor.IGST, DecimalsNumber);
226
- Labor.QtyAndUoM = Labor.Qty.toString();
227
- Labor.CGSTPerc = shared_print_service_1.PrintSharedService.GetCGSTValueBasedOnTaxCode(Labor.TCode, TaxCodes);
228
- Labor.SGSTPerc = shared_print_service_1.PrintSharedService.GetSGSTValueBasedOnTaxCode(Labor.TCode, TaxCodes);
229
- Labor.IGSTPerc = shared_print_service_1.PrintSharedService.GetIGSTValueBasedOnTaxCode(Labor.TCode, TaxCodes);
230
- if (LineTotal === 'AT') {
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
- Item.QtyAndUoM = Item.Qty + '';
232
+ Labor.DiscPerc = 0;
288
233
  }
289
- if (!tr_utils_1.TrUtils.IsZero(Item.OfQty) && !tr_utils_1.TrUtils.CheckInvalidSelect(Item.UoM)) {
290
- Item.OfQtyAndUoM = Item.OfQty + ' ' + Item.UoM;
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.OfQtyAndUoM = Item.OfQty + '';
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
- return InvoicePrintData;
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
- static GetBillNameForInvoicePrint(argInvoiceData, InvoicePrintData) {
337
- var _a;
338
- let Customer = {};
339
- if (!tr_utils_1.TrUtils.IsNull(argInvoiceData.BillTo)) {
340
- Customer.Name = argInvoiceData.BillTo.Name;
341
- if (!tr_utils_1.TrUtils.IsNull(argInvoiceData.BillTo.Sltn)) {
342
- Customer.Name = argInvoiceData.BillTo.Sltn + ' ' + Customer.Name;
343
- }
344
- Customer.Code = (_a = argInvoiceData.Cust) === null || _a === void 0 ? void 0 : _a.Code;
345
- Customer.Adrs = [];
346
- Customer.Cons = [];
347
- if (!tr_utils_1.TrUtils.IsNull(argInvoiceData.BillTo.Adrs)) {
348
- Customer.Adrs.push(argInvoiceData.BillTo.Adrs.A1);
349
- if (!tr_utils_1.TrUtils.IsEmpty(argInvoiceData.BillTo.Adrs.A2)) {
350
- Customer.Adrs.push(argInvoiceData.BillTo.Adrs.A2);
351
- }
352
- if (!tr_utils_1.TrUtils.IsEmpty(argInvoiceData.BillTo.Adrs.Ct)) {
353
- let city = argInvoiceData.BillTo.Adrs.Ct;
354
- if (!tr_utils_1.TrUtils.IsEmpty(argInvoiceData.BillTo.Adrs.Pin)) {
355
- city = city + ', ' + argInvoiceData.BillTo.Adrs.StCode + '-' + argInvoiceData.BillTo.Adrs.Pin;
356
- }
357
- Customer.Adrs.push(city);
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
- else if (!tr_utils_1.TrUtils.IsNull(argInvoiceData.Cust)) {
379
- Customer.Name = argInvoiceData.Cust.Name;
380
- Customer.Code = argInvoiceData.Cust.Code;
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
- return InvoicePrintData;
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.Cust.Ph
380
+ No: argInvoiceData.BillTo.Ph
420
381
  }
421
382
  ];
422
383
  }
423
- Customer.GSTIN = argInvoiceData.Cust.GSTIN;
424
- Customer.Adrs = [];
425
- if (!tr_utils_1.TrUtils.IsNull(argInvoiceData.Cust.Adrs)) {
426
- Customer.Adrs.push(argInvoiceData.Cust.Adrs.A1);
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
- static GetBillToName(Title, Name) {
437
- return tr_utils_1.TrUtils.IsEmpty(Title) ? Name : Title + ' ' + Name;
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
- static GetPaymentsTotal(Credits, InvoicePayments, Total, InvoiceStatus, DecimalsNumber) {
440
- var i = 0;
441
- let Data = {};
442
- let PaidTotal = 0;
443
- if (tr_utils_1.TrUtils.IsNull(InvoicePayments)) {
444
- InvoicePayments = [];
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
- Data.Due = tr_utils_1.TrUtils.FixedTo((0, math_operations_1.Subtract)(Total, PaidTotal), DecimalsNumber);
405
+ Name = argInvoiceData.ShipTo.Name;
406
+ }
407
+ if (tr_utils_1.TrUtils.IsNull(Name)) {
408
+ Name = '';
460
409
  }
461
- if (Data.Due < 0) {
462
- Data.Due = 0;
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
- if (Data.Due === 0) {
465
- Data.Sts = enums_1.InvoiceStatusEnum.Closed;
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
- Data.Paid = tr_utils_1.TrUtils.FixedTo(PaidTotal, DecimalsNumber);
468
- return Data;
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;