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
|
@@ -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
|
-
|
|
12
|
+
IncludeGST: boolean, ConsolidateGST: boolean, TaxCodes: any, IsProforma: boolean, PartsPrint: boolean, LaborPrint: boolean) {
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
let ForInsurance: boolean = !TrUtils.IsNull(OriginalInvoiceData.BillTo) && !TrUtils.IsNull(OriginalInvoiceData.BillTo.Ins_Id);
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
let InvoicePrintData: any = {};
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
let argInvoiceData = TrUtils.Stringify(OriginalInvoiceData);
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
20
|
+
if (!IncludeGST) {
|
|
21
|
+
if (argInvoiceData.Settings.Tax === 'TI') {
|
|
22
|
+
argInvoiceData.Settings.Tax = 'NO';
|
|
24
23
|
}
|
|
24
|
+
}
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
InvoicePrintData.IsProforma = IsProforma;
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
InvoicePrintData.Settings = TrUtils.Stringify(argInvoiceData.Settings);
|
|
29
|
+
InvoicePrintData.SType = TrUtils.Stringify(argInvoiceData.SType);
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
let SType: any
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
if (!TrUtils.IsNull(argInvoiceData.SType)) {
|
|
34
|
+
SType = argInvoiceData.SType
|
|
35
|
+
}
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
InvoicePrintData = GetPrintConditionsBasedOnInput(InvoicePrintData, IncludeGST, ConsolidateGST, ForInsurance,
|
|
38
|
+
SType, argInvoiceData, IsProforma, PartsPrint, LaborPrint);
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
InvoicePrintData.Entity = PrintSharedService.GetFormattedEntityDataForPrint(OriginalEntityData, "Invoice", OriginalInvoiceData);
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
InvoicePrintData = PrintSharedService.GetEntityHeaderStyles(InvoicePrintData, OriginalEntityData, image);
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
InvoicePrintData = GetInvoiceOtherDetailsForPrint(InvoicePrintData, argInvoiceData);
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
let IsTaxable: boolean = (IncludeGST && TrUtils.isTaxable(argInvoiceData.Settings.Tax)) ? true : false;
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
52
|
+
if (ConsolidateGST) {
|
|
53
|
+
finalTotalsData.CustLaborTotalBeforeDisc = finalTotalsData.CustLaborAfterTax;
|
|
54
|
+
finalTotalsData.CustPartsTotalBeforeDisc = finalTotalsData.CustPartAfterTax;
|
|
55
|
+
}
|
|
56
56
|
|
|
57
|
-
|
|
57
|
+
InvoicePrintData = TrUtils.ConcatObjects(InvoicePrintData, finalTotalsData);
|
|
58
58
|
|
|
59
|
-
|
|
59
|
+
InvoicePrintData.Ops = GetLaborPrintInfo(InvoicePrintData.Ops, ConsolidateGST, TaxCodes, OriginalEntityData.Entity.Settings?.Acc?.LTot, InvoicePrintData.Entity.DecimalsNumber);
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
InvoicePrintData.Items = GetItemsPrintInfo(InvoicePrintData.Items, ConsolidateGST, TaxCodes, OriginalEntityData.Entity.Settings?.Acc?.LTot, InvoicePrintData.Entity.DecimalsNumber);
|
|
62
62
|
|
|
63
|
-
|
|
63
|
+
argInvoiceData = ReverseItemsForInvoicePrint(argInvoiceData);
|
|
64
64
|
|
|
65
|
-
|
|
65
|
+
InvoicePrintData.PrintInfo = PrepareFormatForInvoicePrint(InvoicePrintData, ROTypeEnum.Invoice, argInvoiceData.Sts);
|
|
66
66
|
|
|
67
|
-
|
|
67
|
+
InvoicePrintData = GetFormattedProductDataForPrint(argInvoiceData, InvoicePrintData);
|
|
68
68
|
|
|
69
|
-
|
|
69
|
+
InvoicePrintData = GetBillNameForInvoicePrint(argInvoiceData, InvoicePrintData);
|
|
70
70
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
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
|
-
|
|
93
|
-
|
|
94
|
-
|
|
92
|
+
if (OriginalInvoiceData.isCountersale) {
|
|
93
|
+
InvoicePrintData.From = 'Countersale';
|
|
94
|
+
}
|
|
95
95
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
96
|
+
if (TrUtils.IsNull(OriginalInvoiceData.BL)) {
|
|
97
|
+
OriginalInvoiceData.BL = {};
|
|
98
|
+
}
|
|
99
99
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
100
|
+
InvoicePrintData.BL = TrUtils.Stringify(OriginalInvoiceData.BL);
|
|
101
|
+
OriginalInvoiceData.BL.RefNo = OriginalInvoiceData.RefNo;
|
|
102
|
+
// console.log('InvoicePrintData', InvoicePrintData);
|
|
103
103
|
|
|
104
|
-
|
|
105
|
-
|
|
104
|
+
return InvoicePrintData;
|
|
105
|
+
}
|
|
106
106
|
|
|
107
107
|
export function GetPrintConditionsBasedOnInput(InvoicePrintData: any, IncludeGST: boolean, ConsolidateGST: boolean,
|
|
108
|
-
|
|
108
|
+
ForInsurance: boolean, SType: any, OriginalInvoiceData: any, IsProforma: boolean, PartsPrint: boolean, LaborPrint: boolean) {
|
|
109
109
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
110
|
+
InvoicePrintData.ForInsurance = ForInsurance;
|
|
111
|
+
InvoicePrintData.For = ForInsurance ? PayTypeEnum.Insurance : PayTypeEnum.Customer;
|
|
112
|
+
InvoicePrintData.IncludeGST = IncludeGST;
|
|
113
|
+
InvoicePrintData.ConsolidateGST = ConsolidateGST;
|
|
114
114
|
|
|
115
|
-
|
|
115
|
+
InvoicePrintData.ShowAccParts = true;
|
|
116
116
|
|
|
117
|
-
|
|
117
|
+
InvoicePrintData.ShowIGST = (TrUtils.IsNull(SType) || (SType === 'Intra')) ? false : true;
|
|
118
118
|
|
|
119
|
-
|
|
120
|
-
|
|
119
|
+
InvoicePrintData.ShowTaxColumn = (IncludeGST && !ConsolidateGST) ? true : false;
|
|
120
|
+
// InvoicePrintData.ShowDiscountColumn = (!ForInsurance && !ConsolidateGST) ? true : false;
|
|
121
121
|
|
|
122
|
-
|
|
122
|
+
InvoicePrintData = GetInvoiceTypeHeading(InvoicePrintData, OriginalInvoiceData, IncludeGST, ConsolidateGST, IsProforma, PartsPrint, LaborPrint);
|
|
123
123
|
|
|
124
|
-
|
|
124
|
+
InvoicePrintData.PrDate = TrUtils.IsNull(OriginalInvoiceData.PrDate) ? '' : MyDate.ConvertUTCDateToReadable(OriginalInvoiceData.PrDate);
|
|
125
125
|
|
|
126
|
-
|
|
127
|
-
|
|
126
|
+
return InvoicePrintData;
|
|
127
|
+
}
|
|
128
128
|
|
|
129
129
|
export function GetInvoiceTypeHeading(InvoicePrintData: any, OriginalInvoiceData: any, IncludeGST: boolean,
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
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.
|
|
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 (
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
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
|
-
|
|
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
|
-
|
|
164
|
-
|
|
165
|
-
|
|
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
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
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
|
-
|
|
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
|
-
}
|
|
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
|
-
|
|
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
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
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
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
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
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
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
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
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
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
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.
|
|
274
|
+
Labor.DiscPerc = 0;
|
|
288
275
|
}
|
|
289
|
-
}
|
|
290
|
-
|
|
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
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
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
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
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.
|
|
326
|
+
Item.DiscPerc = 0;
|
|
344
327
|
}
|
|
345
|
-
}
|
|
346
|
-
|
|
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
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
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
|
-
|
|
358
|
-
|
|
359
|
-
|
|
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
|
-
|
|
365
|
+
let PrintInfo: any[] = [];
|
|
364
366
|
|
|
365
|
-
|
|
367
|
+
let ROLaborParts: any = {};
|
|
366
368
|
|
|
367
|
-
|
|
369
|
+
ROLaborParts.Ops = InvoicePrintData.Ops;
|
|
368
370
|
|
|
369
|
-
|
|
371
|
+
ROLaborParts.Items = InvoicePrintData.Items;
|
|
370
372
|
|
|
371
|
-
|
|
372
|
-
|
|
373
|
+
ROLaborParts.Sts = InvoiceStatus;
|
|
374
|
+
ROLaborParts.Type = ROType;
|
|
373
375
|
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
376
|
+
PrintInfo.push(ROLaborParts);
|
|
377
|
+
return PrintInfo;
|
|
378
|
+
}
|
|
377
379
|
|
|
378
380
|
export function GetFormattedProductDataForPrint(argInvoiceData: any, InvoicePrintData: any) {
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
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
|
-
|
|
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
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
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
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
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
|
-
|
|
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
|
-
}
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
Customer.
|
|
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.
|
|
449
|
-
|
|
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
|
-
|
|
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
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
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.
|
|
467
|
+
No: argInvoiceData.ShipTo.ConPh
|
|
484
468
|
}
|
|
485
469
|
];
|
|
486
470
|
}
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
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
|
-
|
|
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.
|
|
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
|
-
|
|
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
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
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
|
+
}
|