shareneus 1.7.333 → 1.7.334

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