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.
@@ -0,0 +1,2824 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InvoicePrintService = void 0;
4
+ const enums_1 = require("../../enums/enums");
5
+ const math_operations_1 = require("../../shared/math-operations");
6
+ const shared_pdf_service_1 = require("../../shared/shared-pdf.service");
7
+ const shared_print_service_1 = require("../../shared/shared-print.service");
8
+ const my_date_1 = require("../../utils/my-date");
9
+ const tr_utils_1 = require("../../utils/tr-utils");
10
+ /**
11
+ * Unified Invoice Print Service
12
+ * Consolidates InvoicePortraitPrintService, InvoiceLandscapePdfService,
13
+ * HCInvoiceprintService, and InvoiceprintService into a single service
14
+ */
15
+ class InvoicePrintService {
16
+ constructor() {
17
+ this.FontSize = 8;
18
+ }
19
+ // ==================== UNIFIED PUBLIC API ====================
20
+ /**
21
+ * Unified Invoice Print Method - handles all invoice print types
22
+ * Automatically routes to appropriate print variant based on options
23
+ *
24
+ * @param data - Invoice data containing all necessary information
25
+ * @param options - Print options determining format and settings
26
+ * @returns PDF document definition for pdfmake
27
+ */
28
+ static GetInvoicePrint(data, options) {
29
+ const printType = options.printType || 'portrait';
30
+ switch (printType.toLowerCase()) {
31
+ case 'portrait':
32
+ return InvoicePrintService.GetPortraitPrint(data, options.size || 'full', options.printOptions || {}, options.moreDiscDetails || false);
33
+ case 'landscape':
34
+ return InvoicePrintService.GetLandscapePrint(data, options.numberofCopies || null, options.moreDiscDetails || false);
35
+ case 'hc':
36
+ case 'healthcare':
37
+ case 'hospital':
38
+ return InvoicePrintService.GetHCInvoicePrint(data, options.numberofCopies || null, options.isotherIndustry || false, options.withPass || false, options.isAuto || false, options.size || 'full', options.moreDiscDetails || false);
39
+ case 'standard':
40
+ return InvoicePrintService.GetStandardInvoicePrint(data, options.numberofCopies || null, options.isotherIndustry || false, options.withPass || false, options.isAuto || false, options.moreDiscDetails || false);
41
+ default:
42
+ // Default to portrait if type not recognized
43
+ return InvoicePrintService.GetPortraitPrint(data, options.size || 'full', options.printOptions || {}, options.moreDiscDetails || false);
44
+ }
45
+ }
46
+ // ==================== INTERNAL VARIANT METHODS ====================
47
+ /**
48
+ * Portrait invoice print (Original InvoicePortraitPrintService.GetPrint)
49
+ * @internal - Use GetInvoicePrint() instead
50
+ */
51
+ static GetPortraitPrint(InvoicePDFData, size, printOptions, moreDiscDetails) {
52
+ if (tr_utils_1.TrUtils.IsNull(InvoicePDFData.Name)) {
53
+ InvoicePDFData.Name = '';
54
+ }
55
+ let dd = {
56
+ info: {
57
+ title: 'TAX INVOICE',
58
+ },
59
+ background: function (currentPage, pageSize) {
60
+ if (size !== 'full') {
61
+ pageSize.height = pageSize.height - 435.945;
62
+ }
63
+ return shared_pdf_service_1.SharedPDFService.GetWatermarkImage(InvoicePDFData.Image, pageSize, InvoicePDFData.Entity.Wmark);
64
+ },
65
+ header: function (currentPage, pageCount, pageSize) {
66
+ return { text: currentPage.toString() + ' of ' + pageCount, alignment: 'right', marginRight: 25, fontSize: 8, marginTop: 2 };
67
+ },
68
+ pageMargins: InvoicePrintService.GetMarginsBasedOnPaperSize(size),
69
+ pageSize: 'A4',
70
+ content: [
71
+ InvoicePrintService.GetMainHeaderInfo(InvoicePDFData),
72
+ {
73
+ style: 'tableExample',
74
+ table: {
75
+ widths: [200, '*', 'auto'],
76
+ body: InvoicePrintService.GetCustomerAndBankDetails(InvoicePDFData)
77
+ },
78
+ layout: InvoicePrintService.HeaderLayOut()
79
+ },
80
+ InvoicePrintService.GetItemsTable(InvoicePDFData.Ops, InvoicePDFData.Items, InvoicePDFData.ShowTaxColumn, InvoicePDFData.SType, printOptions, size, InvoicePDFData.Entity.DecimalsNumber),
81
+ [InvoicePrintService.TotalDetails(InvoicePDFData, moreDiscDetails, InvoicePDFData.Entity.DecimalsNumber)],
82
+ [InvoicePrintService.GetNumberInWords(InvoicePDFData.CustRoundedTotal)],
83
+ [InvoicePrintService.InvoiceDueStatus(InvoicePDFData.Type, InvoicePDFData.Paid, InvoicePDFData.Due, InvoicePDFData.Sts, InvoicePDFData.isCountersale, InvoicePDFData.Entity.DecimalsNumber)],
84
+ {
85
+ style: 'tableExample',
86
+ table: {
87
+ widths: ['*', 'auto'],
88
+ body: InvoicePrintService.GetSignatures(InvoicePDFData.Entity.CName, InvoicePDFData.CustRoundedTotal)
89
+ },
90
+ layout: 'noBorders'
91
+ },
92
+ ],
93
+ styles: {
94
+ headerstyle: {
95
+ fontFamily: 'Calibri',
96
+ fontSize: 9
97
+ },
98
+ Sign: {
99
+ fontSize: 8,
100
+ margin: [0, 15, 0, 5]
101
+ },
102
+ forCompany: {
103
+ marginRight: 5,
104
+ marginTop: 10,
105
+ fontSize: 9,
106
+ alignment: 'right'
107
+ },
108
+ forCompany1: {
109
+ margin: [0, 5, 15, 0],
110
+ fontSize: 8
111
+ },
112
+ tableheader: {
113
+ bold: true,
114
+ fontFamily: 'Calibri',
115
+ margin: [0, 1, 0, 5],
116
+ alignment: 'center'
117
+ },
118
+ tableheader1: {
119
+ bold: true,
120
+ fontFamily: 'Calibri',
121
+ margin: [0, 2, 0, 2],
122
+ alignment: 'center'
123
+ },
124
+ tableExample: {
125
+ fontSize: 9
126
+ },
127
+ tableExample1: {
128
+ fontSize: 8
129
+ }
130
+ }
131
+ };
132
+ return dd;
133
+ }
134
+ /**
135
+ * Landscape invoice print (Original InvoiceLandscapePdfService.GetInvoiceLandscapePrint)
136
+ * @internal - Use GetInvoicePrint() instead
137
+ */
138
+ static GetLandscapePrint(ROPrintData, numberofCopies, moreDiscDetails) {
139
+ var contents = [];
140
+ if (tr_utils_1.TrUtils.IsNull(numberofCopies) || numberofCopies.length === 0) {
141
+ contents.push(InvoicePrintService.GetLandscapeHeaderDetails(ROPrintData, null), InvoicePrintService.PrepareLandscapePartsTable(ROPrintData), InvoicePrintService.GetLandscapeTotalDetails(ROPrintData, null, numberofCopies, moreDiscDetails));
142
+ }
143
+ else {
144
+ numberofCopies.forEach((text, index) => {
145
+ contents.push(InvoicePrintService.GetLandscapeHeaderDetails(ROPrintData, text), InvoicePrintService.PrepareLandscapePartsTable(ROPrintData), InvoicePrintService.GetLandscapeTotalDetails(ROPrintData, index, numberofCopies, moreDiscDetails));
146
+ });
147
+ }
148
+ var dd = {
149
+ info: {
150
+ title: InvoicePrintService.GetFileName(ROPrintData),
151
+ },
152
+ background: function (currentPage, pageSize) {
153
+ return shared_pdf_service_1.SharedPDFService.GetWatermarkImage(ROPrintData.Image, pageSize, ROPrintData.Entity.Wmark);
154
+ },
155
+ header: function (currentPage, pageCount) {
156
+ return { text: currentPage.toString() + ' of ' + pageCount, alignment: 'right', marginRight: 7, fontSize: 8, marginTop: 2 };
157
+ },
158
+ pageMargins: [10, 15, 10, 15],
159
+ pageOrientation: 'landscape',
160
+ content: contents,
161
+ styles: shared_pdf_service_1.SharedPDFService.GetStyles()
162
+ };
163
+ return dd;
164
+ }
165
+ /**
166
+ * Healthcare/Hospital invoice print (Original HCInvoiceprintService.GetInvoicePrint)
167
+ * @internal - Use GetInvoicePrint() instead
168
+ */
169
+ static GetHCInvoicePrint(ROPrintData, numberofCopies, isotherIndustry, withPass, isAuto, size, moreDiscDetails) {
170
+ ROPrintData.Entity.IsProforma = ROPrintData.IsProforma;
171
+ var contents = [];
172
+ if (tr_utils_1.TrUtils.IsNull(numberofCopies) || numberofCopies.length === 0) {
173
+ contents.push(InvoicePrintService.GetHCHeaderDetails(ROPrintData, null, isotherIndustry), InvoicePrintService.PrepareHCPartsTable(ROPrintData, isAuto), InvoicePrintService.GetHCTotalDetails(ROPrintData, null, numberofCopies, withPass, isAuto, moreDiscDetails));
174
+ }
175
+ else {
176
+ numberofCopies.forEach((text, index) => {
177
+ contents.push(InvoicePrintService.GetHCHeaderDetails(ROPrintData, text, isotherIndustry), InvoicePrintService.PrepareHCPartsTable(ROPrintData, isAuto), InvoicePrintService.GetHCTotalDetails(ROPrintData, index, numberofCopies, withPass, isAuto, moreDiscDetails));
178
+ });
179
+ }
180
+ var dd = {
181
+ watermark: InvoicePrintService.GetHCWatermark(ROPrintData),
182
+ info: {
183
+ title: InvoicePrintService.GetFileName(ROPrintData),
184
+ },
185
+ background: function (currentPage, pageSize) {
186
+ if (size !== 'full') {
187
+ pageSize.height = pageSize.height - 435.945;
188
+ }
189
+ return shared_pdf_service_1.SharedPDFService.GetWatermarkImage(ROPrintData.Image, pageSize, ROPrintData.Entity.Wmark);
190
+ },
191
+ header: function (currentPage, pageCount) {
192
+ return { text: currentPage.toString() + ' of ' + pageCount, alignment: 'right', marginRight: 7, fontSize: 8, marginTop: 2 };
193
+ },
194
+ pageBreakBefore: function (currentNode, followingNodesOnPage, nodesOnNextPage, previousNodesOnPage) {
195
+ return currentNode.startPosition.top >= 700 && !tr_utils_1.TrUtils.IsNull(currentNode === null || currentNode === void 0 ? void 0 : currentNode.id) && (currentNode === null || currentNode === void 0 ? void 0 : currentNode.id) === '567';
196
+ },
197
+ pageMargins: InvoicePrintService.GetHCMarginsBasedOnPaperSize(size),
198
+ pageSize: 'A4',
199
+ content: contents,
200
+ styles: shared_pdf_service_1.SharedPDFService.GetStyles()
201
+ };
202
+ return dd;
203
+ }
204
+ /**
205
+ * Standard invoice print (Original InvoiceprintService.GetInvoicePrint)
206
+ * @internal - Use GetInvoicePrint() instead
207
+ */
208
+ static GetStandardInvoicePrint(ROPrintData, numberofCopies, isotherIndustry, withPass, isAuto, moreDiscDetails) {
209
+ var contents = [];
210
+ if (tr_utils_1.TrUtils.IsNull(numberofCopies) || numberofCopies.length === 0) {
211
+ contents.push(InvoicePrintService.GetStandardHeaderDetails(ROPrintData, null, isotherIndustry), InvoicePrintService.PrepareStandardPartsTable(ROPrintData, isAuto), InvoicePrintService.GetStandardTotalDetails(ROPrintData, null, numberofCopies, withPass, isAuto, moreDiscDetails));
212
+ }
213
+ else {
214
+ numberofCopies.forEach((text, index) => {
215
+ contents.push(InvoicePrintService.GetStandardHeaderDetails(ROPrintData, text, isotherIndustry), InvoicePrintService.PrepareStandardPartsTable(ROPrintData, isAuto), InvoicePrintService.GetStandardTotalDetails(ROPrintData, index, numberofCopies, withPass, isAuto, moreDiscDetails));
216
+ });
217
+ }
218
+ var dd = {
219
+ info: {
220
+ title: InvoicePrintService.GetFileName(ROPrintData),
221
+ },
222
+ watermark: InvoicePrintService.GetStandardWatermark(ROPrintData, isAuto),
223
+ background: function (currentPage, pageSize) {
224
+ return shared_pdf_service_1.SharedPDFService.GetWatermarkImage(ROPrintData.Image, pageSize, ROPrintData.Entity.Wmark);
225
+ },
226
+ header: function (currentPage, pageCount) {
227
+ return { text: currentPage.toString() + ' of ' + pageCount, alignment: 'right', marginRight: 7, fontSize: 8, marginTop: 2 };
228
+ },
229
+ pageBreakBefore: function (currentNode, followingNodesOnPage, nodesOnNextPage, previousNodesOnPage) {
230
+ return currentNode.startPosition.top >= 700 && !tr_utils_1.TrUtils.IsNull(currentNode === null || currentNode === void 0 ? void 0 : currentNode.id) && (currentNode === null || currentNode === void 0 ? void 0 : currentNode.id) === '567';
231
+ },
232
+ pageMargins: [10, 15, 10, 15],
233
+ content: contents,
234
+ styles: shared_pdf_service_1.SharedPDFService.GetStyles()
235
+ };
236
+ return dd;
237
+ }
238
+ // ==================== COMMON UTILITY METHODS ====================
239
+ static GetFileName(ROPrintData) {
240
+ let fileName = ROPrintData.HeaderName;
241
+ if (!tr_utils_1.TrUtils.IsNull(ROPrintData.Product) && !tr_utils_1.TrUtils.IsEmpty(ROPrintData.Product.RegNo)) {
242
+ fileName = fileName + '-' + ROPrintData.Product.RegNo;
243
+ }
244
+ return fileName;
245
+ }
246
+ static emptyObject() {
247
+ let a = {};
248
+ return a;
249
+ }
250
+ // ==================== PORTRAIT-SPECIFIC METHODS ====================
251
+ static GetMarginsBasedOnPaperSize(size) {
252
+ if (size === 'full') {
253
+ return [20, 15, 20, 15];
254
+ }
255
+ else {
256
+ return [20, 15, 20, 435.945];
257
+ }
258
+ }
259
+ static GetMainHeaderInfo(InvoicePDFData) {
260
+ if (!tr_utils_1.TrUtils.IsNull(InvoicePDFData.Image)) {
261
+ return {
262
+ columns: [{ image: InvoicePDFData.Image, width: 60, height: 60, marginBottom: 5 },
263
+ {
264
+ stack: [
265
+ { text: InvoicePDFData.Entity.CName, style: ['headerstyle'], alignment: 'left', fontSize: 15 },
266
+ { text: InvoicePrintService.GetPortraitAddress(InvoicePDFData.Entity), alignment: 'left', style: ['headerstyle'] },
267
+ {
268
+ columns: InvoicePrintService.GetHeaderInfo(InvoicePDFData, 0)
269
+ },
270
+ { text: InvoicePDFData.HeaderName, alignment: 'left', style: ['Receiptheader1'], marginTop: 5 }
271
+ ]
272
+ }
273
+ ], columnGap: 10
274
+ };
275
+ }
276
+ else {
277
+ return {
278
+ stack: [
279
+ { text: InvoicePDFData.Entity.CName, style: ['headerstyle'], alignment: 'center', fontSize: 15 },
280
+ { text: InvoicePrintService.GetPortraitAddress(InvoicePDFData.Entity), alignment: 'center', style: ['headerstyle'] },
281
+ {
282
+ columns: InvoicePrintService.GetHeaderInfo(InvoicePDFData, 5)
283
+ },
284
+ { text: InvoicePDFData.HeaderName, alignment: 'center', style: ['Receiptheader1'] }
285
+ ]
286
+ };
287
+ }
288
+ }
289
+ static GetPortraitAddress(Entity) {
290
+ return Entity.Adrs1 + ', ' + Entity.Adrs2 + ', ' + Entity.City + '-' + Entity.PIN + ', Cell : ' + Entity.Phone;
291
+ }
292
+ static GetCustomerAndBankDetails(InvoicePDFData) {
293
+ let CustDetails = [];
294
+ CustDetails.push([{
295
+ marginLeft: 3,
296
+ stack: [
297
+ InvoicePrintService.GetCustomerDetails(InvoicePDFData.Customer, InvoicePDFData.Type, null, null, 'Customer Name & Address')
298
+ ]
299
+ },
300
+ {
301
+ marginLeft: 5,
302
+ marginRight: 5,
303
+ stack: [InvoicePrintService.GetCustomerGSTIN(InvoicePDFData.Customer), InvoicePrintService.GetCustomerDLNo(InvoicePDFData.Customer)]
304
+ },
305
+ {
306
+ marginRight: 5,
307
+ stack: [{ text: 'Invoice No : ' + InvoicePDFData._id, style: ['headerstyle'] },
308
+ { text: 'Date : ' + InvoicePDFData.CrDate, style: ['headerstyle'] }]
309
+ }]);
310
+ if (InvoicePDFData.Entity.PrBank) {
311
+ CustDetails.push([{ text: 'Note: OUR BANK A/C: ' + InvoicePDFData.Entity.Bank.ACNo + ', IFSC CODE: ' + InvoicePDFData.Entity.Bank.IFSC + ', Account Holder Name: ' + InvoicePDFData.Entity.Bank.ACName + ', BANK NAME: ' + InvoicePDFData.Entity.Bank.Name, colSpan: 3, fontSize: 8 }]);
312
+ }
313
+ return CustDetails;
314
+ }
315
+ static GetCustomerDetails(Customer, Type, Vehicle, Settings, CustHeader) {
316
+ if (tr_utils_1.TrUtils.IsNull(Customer)) {
317
+ return InvoicePrintService.emptyObject();
318
+ }
319
+ let Data = [{ text: CustHeader + ':', style: 'hed', bold: true },
320
+ { text: Customer.Name, marginTop: 2 },
321
+ { text: InvoicePrintService.GetAddress1(Customer), marginTop: 3, fontSize: 7 },
322
+ InvoicePrintService.GetCustPhoneNumber(Customer, Type),
323
+ InvoicePrintService.GetCustomerName(Customer.CustName)];
324
+ return {
325
+ style: 'colum1',
326
+ stack: Data
327
+ };
328
+ }
329
+ static GetAddress1(Customer) {
330
+ var Address = InvoicePrintService.GetFormatAddress(Customer);
331
+ if (Address.length !== 5) {
332
+ return Address;
333
+ }
334
+ else {
335
+ let a = '';
336
+ return a;
337
+ }
338
+ }
339
+ static GetFormatAddress(CustomerObj) {
340
+ var Addressnew = '';
341
+ if (!tr_utils_1.TrUtils.IsNull(CustomerObj.Adrs)) {
342
+ CustomerObj.Adrs.forEach((Adrs, index) => {
343
+ Addressnew = Addressnew + Adrs;
344
+ if (CustomerObj.Adrs.length > (index + 1)) {
345
+ Addressnew = Addressnew + ', ';
346
+ }
347
+ });
348
+ }
349
+ return Addressnew;
350
+ }
351
+ static GetFormatContact(CustomerObj) {
352
+ var contactnew = '';
353
+ if (!tr_utils_1.TrUtils.IsNull(CustomerObj.Cons)) {
354
+ CustomerObj.Cons.forEach((Contact) => {
355
+ contactnew = contactnew + '(' + Contact.Type + '):' + Contact.No + '\n';
356
+ });
357
+ }
358
+ return contactnew;
359
+ }
360
+ static GetCustPhoneNumber(Customer, Type) {
361
+ if (Type !== 'Technician Copy') {
362
+ var contact = InvoicePrintService.GetFormatContact(Customer);
363
+ if (contact.length !== 0) {
364
+ return { columns: [{ text: 'Phone', width: 27, style: 'hed' }, contact] };
365
+ }
366
+ else {
367
+ return InvoicePrintService.emptyObject();
368
+ }
369
+ }
370
+ else {
371
+ return InvoicePrintService.emptyObject();
372
+ }
373
+ }
374
+ static GetCustomerName(Customer) {
375
+ if (!tr_utils_1.TrUtils.IsEmpty(Customer)) {
376
+ let GSTIN = { columns: [{ text: 'Customer Name :', width: 65, bold: true }, { text: Customer }] };
377
+ return GSTIN;
378
+ }
379
+ else {
380
+ return InvoicePrintService.emptyObject();
381
+ }
382
+ }
383
+ static GetCustomerGSTIN(Customer) {
384
+ if (!tr_utils_1.TrUtils.IsEmpty(Customer.GSTIN)) {
385
+ let GSTIN = { columns: [{ text: 'GSTIN :', width: 33, style: 'hed' }, { text: Customer.GSTIN, marginTop: 1.5 }] };
386
+ return GSTIN;
387
+ }
388
+ else {
389
+ return InvoicePrintService.emptyObject();
390
+ }
391
+ }
392
+ static GetCustomerDLNo(Customer) {
393
+ if (!tr_utils_1.TrUtils.IsEmpty(Customer.DLNo)) {
394
+ let GSTIN = { columns: [{ text: 'DL No :', width: 33, style: 'hed' }, { text: Customer.DLNo, marginTop: 1.5 }] };
395
+ return GSTIN;
396
+ }
397
+ else {
398
+ return InvoicePrintService.emptyObject();
399
+ }
400
+ }
401
+ static HeaderLayOut() {
402
+ return {
403
+ hLineWidth: function (i, node) {
404
+ return (i === 0 || i === 1 || i === node.table.body.length) ? 1 : 0;
405
+ },
406
+ vLineWidth: function (i, node) {
407
+ return (i === 0 || i === node.table.widths.length) ? 1 : 0;
408
+ },
409
+ hLineColor: function (i, node) {
410
+ return 'gray';
411
+ },
412
+ vLineColor: function (i, node) {
413
+ return 'gray';
414
+ },
415
+ };
416
+ }
417
+ static GetHeaderInfo(InvoicePDFData, marginleft) {
418
+ let TaxInfo = [];
419
+ if (!tr_utils_1.TrUtils.IsEmpty(InvoicePDFData.Entity.GSTIN)) {
420
+ TaxInfo.push({ text: 'GSTIN : ' + InvoicePDFData.Entity.GSTIN, marginTop: 2, marginLeft: marginleft, alignment: 'left', fontSize: 9, width: 'auto' });
421
+ }
422
+ if (!tr_utils_1.TrUtils.IsEmpty(InvoicePDFData.Entity.DLNo)) {
423
+ TaxInfo.push({ text: 'D.L.NO : ' + InvoicePDFData.Entity.DLNo, marginTop: 2, marginLeft: 5, alignment: 'left', fontSize: 9, width: '*' });
424
+ }
425
+ TaxInfo.push(InvoicePrintService.GetBillofSupplyName(InvoicePDFData.Settings));
426
+ return TaxInfo;
427
+ }
428
+ static GetBillofSupplyName(Settings) {
429
+ return { text: Settings.Tax === 'BS' ? ' Bill of Supply' : null, alignment: 'center', marginLeft: 15, marginTop: 2, marginBottom: 3, fontSize: 9, width: 'auto' };
430
+ }
431
+ static GetItemsTable(Services, Items, ShowTaxColumn, SType, printOptions, size, DecimalsNumber) {
432
+ return {
433
+ style: 'tableExample',
434
+ marginTop: 3,
435
+ marginBottom: 5,
436
+ table: {
437
+ widths: InvoicePrintService.GetPortraitWidths(ShowTaxColumn, printOptions),
438
+ headerRows: 1,
439
+ body: InvoicePrintService.BuildPortraitTableBody(Services, Items, ShowTaxColumn, SType, printOptions, size, DecimalsNumber)
440
+ },
441
+ layout: {
442
+ hLineWidth: function (i, node) {
443
+ return (i === 0 || i === 1 || i === node.table.body.length) ? 1 : 0;
444
+ },
445
+ vLineWidth: function (i, node) {
446
+ return (i === 0 || i === node.table.widths.length) ? 1 : 0.5;
447
+ },
448
+ hLineColor: function (i, node) {
449
+ return 'gray';
450
+ },
451
+ vLineColor: function (i, node) {
452
+ return 'gray';
453
+ },
454
+ }
455
+ };
456
+ }
457
+ static GetPortraitWidths(ShowTaxColumn, printOptions) {
458
+ if (ShowTaxColumn && printOptions.ShowTax !== 'NO') {
459
+ if (printOptions.Disc === 'NO') {
460
+ return [16, '*', 40, 45, 25, 20, 20, 45, 45, 30, 50];
461
+ }
462
+ else {
463
+ return [16, '*', 40, 45, 25, 20, 20, 45, 45, 35, 35, 45];
464
+ }
465
+ }
466
+ else {
467
+ if (printOptions.Disc === 'NO') {
468
+ return [22, '*', 40, 45, 25, 20, 20, 50, 50, 50];
469
+ }
470
+ else {
471
+ return [22, '*', 40, 45, 25, 20, 20, 50, 50, 50, 50];
472
+ }
473
+ }
474
+ }
475
+ static BuildPortraitTableBody(Services, Items, ShowTaxColumn, SType, printOptions, size, DecimalsNumber) {
476
+ let body = InvoicePrintService.GetPortraitHeaderNames(ShowTaxColumn, SType, printOptions);
477
+ let j = 1;
478
+ // Process Services
479
+ if (!tr_utils_1.TrUtils.IsNull(Services) && Services.length !== 0) {
480
+ Services.forEach((item, index) => {
481
+ var _a;
482
+ let dataRow = [];
483
+ dataRow.push({ text: index + 1 });
484
+ if (!tr_utils_1.TrUtils.IsEmpty(item.EDesc)) {
485
+ let DescData = [];
486
+ DescData.push({ text: item.Desc });
487
+ DescData.push({ text: item.EDesc, color: 'grey' });
488
+ dataRow.push({ stack: DescData });
489
+ }
490
+ else {
491
+ dataRow.push({ text: item.Desc });
492
+ }
493
+ if (ShowTaxColumn) {
494
+ dataRow.push({ text: item.SAC, alignment: 'center', style: ['headerstyle'] });
495
+ }
496
+ dataRow.push({ text: '', alignment: 'center', style: ['headerstyle'] });
497
+ dataRow.push({ text: '', alignment: 'center', style: ['headerstyle'] });
498
+ dataRow.push({ text: item.Qty, alignment: 'right', style: ['headerstyle'] });
499
+ dataRow.push({ text: '', alignment: 'right', style: ['headerstyle'] });
500
+ dataRow.push({ text: '', alignment: 'right', style: ['headerstyle'] });
501
+ dataRow.push({ text: tr_utils_1.TrUtils.FixPriceValue(item.Pr, DecimalsNumber), alignment: 'right', style: ['headerstyle'] });
502
+ if (printOptions.Disc !== 'NO') {
503
+ if (printOptions.Disc === 'PERC') {
504
+ dataRow.push({ text: tr_utils_1.TrUtils.FixPriceValue(item.DiscPerc, DecimalsNumber), alignment: 'right', style: ['headerstyle'] });
505
+ }
506
+ else {
507
+ dataRow.push({ text: tr_utils_1.TrUtils.FixPriceValue(item.Disc, DecimalsNumber), alignment: 'right', style: ['headerstyle'] });
508
+ }
509
+ }
510
+ if (ShowTaxColumn && printOptions.ShowTax !== 'NO') {
511
+ let Tax = (_a = item.TaxName) === null || _a === void 0 ? void 0 : _a.split('%');
512
+ dataRow.push({ text: tr_utils_1.TrUtils.IsNull(Tax) ? '' : Tax[0], alignment: 'right', style: ['headerstyle'] });
513
+ }
514
+ dataRow.push({ text: item.Ret ? '-' + tr_utils_1.TrUtils.FixPriceValue(item.LineTotal, DecimalsNumber) : tr_utils_1.TrUtils.FixPriceValue(item.LineTotal, DecimalsNumber), alignment: 'right', style: ['headerstyle'] });
515
+ body.push(dataRow);
516
+ if (index + 1 === j * 9) {
517
+ j++;
518
+ if (size === 'diff') {
519
+ let dataRow1 = [{ text: '', pageBreak: 'after' }, '', '', '', '', ''];
520
+ if (ShowTaxColumn) {
521
+ dataRow1.push('');
522
+ dataRow1.push('');
523
+ }
524
+ body.push(dataRow1);
525
+ }
526
+ }
527
+ });
528
+ }
529
+ // Process Items
530
+ if (!tr_utils_1.TrUtils.IsNull(Items) && Items.length !== 0) {
531
+ if (!tr_utils_1.TrUtils.IsNull(Services) && Services.length !== 0) {
532
+ // Add separator row
533
+ let dataRow = [];
534
+ dataRow.push({ text: '' });
535
+ dataRow.push({ text: '' });
536
+ if (ShowTaxColumn) {
537
+ dataRow.push({ text: '', alignment: 'center', style: ['headerstyle'] });
538
+ }
539
+ dataRow.push({ text: '', alignment: 'center', style: ['headerstyle'] });
540
+ dataRow.push({ text: '', alignment: 'center', style: ['headerstyle'] });
541
+ dataRow.push({ text: '', alignment: 'right', style: ['headerstyle'] });
542
+ dataRow.push({ text: '', alignment: 'right', style: ['headerstyle'] });
543
+ dataRow.push({ text: '', alignment: 'right', style: ['headerstyle'] });
544
+ dataRow.push({ text: '', alignment: 'right', style: ['headerstyle'] });
545
+ if (printOptions.Disc !== 'NO') {
546
+ dataRow.push({ text: '', alignment: 'right', style: ['headerstyle'] });
547
+ }
548
+ if (ShowTaxColumn && printOptions.ShowTax !== 'NO') {
549
+ dataRow.push({ text: '', alignment: 'right', style: ['headerstyle'] });
550
+ }
551
+ dataRow.push({ text: '', alignment: 'right', style: ['headerstyle'] });
552
+ body.push(dataRow);
553
+ }
554
+ Items.forEach((item, index) => {
555
+ var _a, _b, _c;
556
+ let dataRow = [];
557
+ dataRow.push({ text: index + 1 });
558
+ if (!tr_utils_1.TrUtils.IsEmpty(item.EDesc)) {
559
+ let DescData = [];
560
+ DescData.push({ text: item.Desc });
561
+ DescData.push({ text: item.EDesc, color: 'grey' });
562
+ dataRow.push({ stack: DescData });
563
+ }
564
+ else {
565
+ dataRow.push({ text: item.Desc });
566
+ }
567
+ if (ShowTaxColumn) {
568
+ dataRow.push({ text: item.HSN, alignment: 'center', style: ['headerstyle'] });
569
+ }
570
+ dataRow.push({ text: (_a = item.Batch) === null || _a === void 0 ? void 0 : _a.BN, alignment: 'center', style: ['headerstyle'] });
571
+ dataRow.push({ text: my_date_1.MyDate.ConvertUTCDateToReadableExDate((_b = item['Batch']) === null || _b === void 0 ? void 0 : _b.ExDt), alignment: 'center', style: ['headerstyle'] });
572
+ dataRow.push({ text: item.QtyAndUoM, alignment: 'right', style: ['headerstyle'] });
573
+ dataRow.push({ text: item.OfQty, alignment: 'right', style: ['headerstyle'] });
574
+ dataRow.push({ text: tr_utils_1.TrUtils.FixPriceValue(item.MRP, DecimalsNumber), alignment: 'right', style: ['headerstyle'] });
575
+ dataRow.push({ text: tr_utils_1.TrUtils.FixPriceValue(item.UnPr, DecimalsNumber), alignment: 'right', style: ['headerstyle'] });
576
+ if (printOptions.Disc !== 'NO') {
577
+ if (printOptions.Disc === 'PERC') {
578
+ dataRow.push({ text: tr_utils_1.TrUtils.FixPriceValue(item.DiscPerc, DecimalsNumber), alignment: 'right', style: ['headerstyle'] });
579
+ }
580
+ else {
581
+ dataRow.push({ text: tr_utils_1.TrUtils.FixPriceValue(item.Disc, DecimalsNumber), alignment: 'right', style: ['headerstyle'] });
582
+ }
583
+ }
584
+ if (ShowTaxColumn && printOptions.ShowTax !== 'NO') {
585
+ let Tax = (_c = item.TaxName) === null || _c === void 0 ? void 0 : _c.split('%');
586
+ dataRow.push({ text: tr_utils_1.TrUtils.IsNull(Tax) ? '' : Number(Tax[0]), alignment: 'right', style: ['headerstyle'] });
587
+ }
588
+ dataRow.push({ text: item.Ret ? '-' + tr_utils_1.TrUtils.FixPriceValue(item.LineTotal, DecimalsNumber) : tr_utils_1.TrUtils.FixPriceValue(item.LineTotal, DecimalsNumber), alignment: 'right', style: ['headerstyle'] });
589
+ body.push(dataRow);
590
+ if (index + 1 === j * 9) {
591
+ j++;
592
+ if (size === 'diff') {
593
+ let dataRow1 = [{ text: '', pageBreak: 'after' }, '', '', '', '', ''];
594
+ if (ShowTaxColumn) {
595
+ dataRow1.push('');
596
+ dataRow1.push('');
597
+ }
598
+ body.push(dataRow1);
599
+ }
600
+ }
601
+ });
602
+ }
603
+ return body;
604
+ }
605
+ static GetPortraitHeaderNames(ShowTaxColumn, SType, printOptions) {
606
+ let HeadingNames;
607
+ if (ShowTaxColumn) {
608
+ HeadingNames = [[{ text: 'S.No', style: 'tableheader1', Field: 'SNo', alignment: 'left', fontSize: 7 },
609
+ { text: 'Item Name', style: 'tableheader1', Field: 'Desc', alignment: 'left', line: true },
610
+ { text: 'HSN/SAC', style: 'tableheader1', Field: 'HSN' },
611
+ { text: 'Batch No.', style: 'tableheader1', Field: 'Batches' },
612
+ { text: 'Ex.Dt', style: 'tableheader1', Field: 'ExDate' },
613
+ { text: 'Qty', style: 'tableheader1', Field: 'Qty', alignment: 'right' },
614
+ { text: 'Free', style: 'tableheader1', Field: 'OfQty', alignment: 'right' },
615
+ { text: 'MRP', style: 'tableheader1', Field: 'MRP', alignment: 'right' },
616
+ { text: 'Price', style: 'tableheader1', Field: 'UnPr', alignment: 'right' },
617
+ { text: 'Line Total', style: 'tableheader1', Field: 'LineTotal', alignment: 'right' }]];
618
+ if (printOptions.Disc !== 'NO') {
619
+ HeadingNames[0].splice(9, 0, { text: (printOptions.Disc === 'PERC') ? 'Disc(%)' : 'Disc(Rs)', style: 'tableheader1', Field: 'Disc' });
620
+ }
621
+ if (printOptions.ShowTax !== 'NO') {
622
+ HeadingNames[0].splice(10, 0, { text: (SType === 'Intra') ? 'GST(%)' : 'IGST(%)', style: 'tableheader1', Field: 'TaxAmount', alignment: 'right' });
623
+ }
624
+ }
625
+ else {
626
+ HeadingNames = [[{ text: 'S.No', style: 'tableheader1', Field: 'SNo', alignment: 'left' },
627
+ { text: 'Item Name', style: 'tableheader1', Field: 'Desc', alignment: 'left', line: true },
628
+ { text: 'Batch No.', style: 'tableheader1', Field: 'Batches', alignment: 'left' },
629
+ { text: 'Ex.Dt', style: 'tableheader1', Field: 'ExDate', alignment: 'left' },
630
+ { text: 'Qty', style: 'tableheader1', Field: 'Qty', alignment: 'right' },
631
+ { text: 'Free', style: 'tableheader1', Field: 'OfQty', alignment: 'right' },
632
+ { text: 'MRP', style: 'tableheader1', Field: 'MRP', alignment: 'right' },
633
+ { text: 'Price', style: 'tableheader1', Field: 'UnPr', alignment: 'right' },
634
+ { text: 'Line Total', style: 'tableheader1', Field: 'LineTotal', alignment: 'right' }]];
635
+ if (printOptions.Disc !== 'NO') {
636
+ HeadingNames[0].splice(8, 0, { text: (printOptions.Disc === 'PERC') ? 'Disc(%)' : 'Disc(Rs)', style: 'tableheader1', Field: 'Disc' });
637
+ }
638
+ }
639
+ return HeadingNames;
640
+ }
641
+ static TotalDetails(ROPrintData, moreDiscDetails, DecimalsNumber) {
642
+ let totalDisc;
643
+ let totalTax;
644
+ if (!ROPrintData.Consolidate) {
645
+ totalTax = tr_utils_1.TrUtils.FixPriceValue((0, math_operations_1.Add)(Number(ROPrintData.CustLaborITax), Number(ROPrintData.CustPartITax)), DecimalsNumber);
646
+ if (tr_utils_1.TrUtils.isTaxable(ROPrintData.Settings.Tax)) {
647
+ totalDisc = tr_utils_1.TrUtils.FixPriceValue((0, math_operations_1.Add)(Number(ROPrintData.CustLaborDiscTotal), Number(ROPrintData.CustPartsDiscTotal)), DecimalsNumber);
648
+ }
649
+ else {
650
+ totalDisc = tr_utils_1.TrUtils.FixPriceValue((0, math_operations_1.Add)(Number(ROPrintData.CustLaborDiscTotal), Number(ROPrintData.CustPartsDiscTotal)), DecimalsNumber);
651
+ }
652
+ }
653
+ return [
654
+ {
655
+ style: 'tableExample',
656
+ marginTop: -3,
657
+ table: {
658
+ widths: ['*', '*'],
659
+ body: [
660
+ [
661
+ {
662
+ stack: [InvoicePrintService.PartsTaxAmounts1(ROPrintData.TaxSummary, true, ROPrintData.ShowIGST, ROPrintData.ShowTaxColumn)]
663
+ },
664
+ {
665
+ columns: [{ text: '', width: moreDiscDetails ? 120 : 150 }, InvoicePrintService.GrandTotal(ROPrintData, '0.00', ROPrintData.CustPartsTotalBeforeDisc, totalDisc, totalTax, ROPrintData.For, ROPrintData.FixedTotal, ROPrintData.CustTotalRoundedBy, ROPrintData.CustRoundedTotal, null, ROPrintData.Consolidate, ROPrintData.STotal, moreDiscDetails, ROPrintData.Entity.DecimalsNumber)],
666
+ }
667
+ ],
668
+ ]
669
+ },
670
+ layout: 'noBorders'
671
+ },
672
+ ];
673
+ }
674
+ static GrandTotal(InvoiceData, LaborAfterGST, PartsAfterGST, OverAllRecordDiscount, totalTax, For, OverAllRecordTotal, Rounded, GrandTotal, Adj, Consolidate, subTotal, moreDiscDetails, DecimalsNumber) {
675
+ let AccountFields = [];
676
+ if (moreDiscDetails) {
677
+ if (!tr_utils_1.TrUtils.IsZero(InvoiceData.PDisc)) {
678
+ AccountFields.push({ name: 'Items Discount', value: tr_utils_1.TrUtils.FixPriceValue(InvoiceData.PDisc, DecimalsNumber) });
679
+ }
680
+ if (!tr_utils_1.TrUtils.IsZero(InvoiceData.LDisc)) {
681
+ AccountFields.push({ name: 'Services Discount', value: tr_utils_1.TrUtils.FixPriceValue(InvoiceData.LDisc, DecimalsNumber) });
682
+ }
683
+ if (!tr_utils_1.TrUtils.IsZero(InvoiceData.Disc)) {
684
+ AccountFields.push({ name: 'Overall Discount', value: tr_utils_1.TrUtils.FixPriceValue(InvoiceData.Disc, DecimalsNumber) });
685
+ }
686
+ }
687
+ else {
688
+ AccountFields.push({ name: 'Discount', value: OverAllRecordDiscount });
689
+ }
690
+ if (!Consolidate && !tr_utils_1.TrUtils.IsNull(subTotal)) {
691
+ AccountFields.unshift({ name: 'SubTotal', value: tr_utils_1.TrUtils.FixPriceValue(tr_utils_1.TrUtils.SetValueToZeroIfNull(Number(subTotal)), DecimalsNumber) });
692
+ }
693
+ else {
694
+ if (!Consolidate) {
695
+ AccountFields.unshift({ name: 'SubTotal', value: tr_utils_1.TrUtils.FixPriceValue((0, math_operations_1.Add)(tr_utils_1.TrUtils.SetValueToZeroIfNull(Number(LaborAfterGST)), tr_utils_1.TrUtils.SetValueToZeroIfNull(Number(PartsAfterGST))), DecimalsNumber) });
696
+ }
697
+ }
698
+ if (!tr_utils_1.TrUtils.IsEmpty(totalTax)) {
699
+ AccountFields.push({ name: 'Total Tax', value: totalTax });
700
+ }
701
+ if (!tr_utils_1.TrUtils.IsEmpty(Adj)) {
702
+ if (Adj > 0) {
703
+ Adj = '+' + tr_utils_1.TrUtils.FixPriceValue(Adj, DecimalsNumber);
704
+ }
705
+ AccountFields.push({ name: 'Adjust', value: Adj });
706
+ }
707
+ if (For === enums_1.PayTypeEnum.Insurance) {
708
+ let total = { name: 'Total', value: OverAllRecordTotal };
709
+ let Rounding = { name: 'Rounding', value: Rounded };
710
+ if (Rounding.value > 0) {
711
+ Rounding.value = '+' + Rounding.value;
712
+ }
713
+ let FinalTotal = { name: 'Final Total', value: GrandTotal, bold: true, fontSize: 12 };
714
+ AccountFields.push(total);
715
+ AccountFields.push(Rounding);
716
+ if (!tr_utils_1.TrUtils.IsFixedZero(Rounded)) {
717
+ AccountFields.push(FinalTotal);
718
+ }
719
+ }
720
+ else {
721
+ let total = { name: 'Total', value: OverAllRecordTotal };
722
+ let Rounding = { name: 'Rounding', value: Rounded };
723
+ let FinalTotal = { name: 'Final Total', value: GrandTotal };
724
+ if (Rounding.value > 0) {
725
+ Rounding.value = '+' + Rounding.value;
726
+ }
727
+ AccountFields.push(Rounding);
728
+ if (!tr_utils_1.TrUtils.IsFixedZero(Rounded)) {
729
+ AccountFields.push(FinalTotal);
730
+ }
731
+ }
732
+ return {
733
+ style: ['columnheader', 'TotalsStyles'],
734
+ lineHeight: 0.7,
735
+ marginBottom: 5,
736
+ width: 'auto',
737
+ table: {
738
+ widths: ['auto', 'auto', 60],
739
+ body: InvoicePrintService.GrandTotalTable(AccountFields)
740
+ },
741
+ layout: 'noBorders'
742
+ };
743
+ }
744
+ static GrandTotalTable(data) {
745
+ var body = [];
746
+ data.forEach((row) => {
747
+ if (!tr_utils_1.TrUtils.IsFixedZero(row.value) || row.name === 'Total') {
748
+ var dataRow = [];
749
+ dataRow.push({ text: (row.name).toString(), noWrap: true });
750
+ dataRow.push(':');
751
+ if (row.name === 'Final Total') {
752
+ dataRow.push({ text: (row.value).toString(), noWrap: true, bold: true, fontSize: 12, alignment: 'right' });
753
+ }
754
+ else if (!tr_utils_1.TrUtils.IsNull(row.value)) {
755
+ dataRow.push({ text: (row.value).toString(), noWrap: true, alignment: 'right' });
756
+ }
757
+ else {
758
+ dataRow.push({ text: '', noWrap: true, alignment: 'right' });
759
+ }
760
+ body.push(dataRow);
761
+ }
762
+ });
763
+ return body;
764
+ }
765
+ static PartsTaxAmounts1(PartsTaxInfo, ShowAccParts, ShowIGST, ShowTaxColumn) {
766
+ if (ShowTaxColumn && !tr_utils_1.TrUtils.IsNull(PartsTaxInfo) && PartsTaxInfo.length > 0) {
767
+ return {
768
+ stack: [InvoicePrintService.AllHSNPartCGSTTaxListTable1(PartsTaxInfo, ShowAccParts, ShowIGST, ShowTaxColumn)]
769
+ };
770
+ }
771
+ else {
772
+ return '';
773
+ }
774
+ }
775
+ static AllHSNPartCGSTTaxListTable1(PartsTaxInfo, ShowAccParts, ShowIGST, ShowTaxColumn) {
776
+ if (ShowIGST) {
777
+ return {
778
+ style: 'tableExample',
779
+ table: {
780
+ widths: [25, 60, 50],
781
+ headerRows: 1,
782
+ body: InvoicePrintService.CreateHSNTaxTable1(PartsTaxInfo, ShowAccParts, ShowIGST, ShowTaxColumn)
783
+ },
784
+ layout: InvoicePrintService.HeaderLineStyle(),
785
+ };
786
+ }
787
+ else {
788
+ return {
789
+ style: 'tableExample',
790
+ table: {
791
+ widths: [25, 60, 40, 40],
792
+ headerRows: 1,
793
+ body: shared_pdf_service_1.SharedPDFService.CreateHSNTaxTable1(PartsTaxInfo, ShowAccParts, ShowIGST, ShowTaxColumn)
794
+ },
795
+ layout: InvoicePrintService.HeaderLineStyle(),
796
+ };
797
+ }
798
+ }
799
+ static CreateHSNTaxTable1(PartsTaxInfo, ShowAccParts, ShowIGST, ShowTaxColumn) {
800
+ if (!tr_utils_1.TrUtils.IsNull(PartsTaxInfo) && PartsTaxInfo.length !== 0 && ShowAccParts && ShowTaxColumn) {
801
+ var body = [];
802
+ let columns = InvoicePrintService.CreateHeadingAllTaxList(ShowIGST);
803
+ body.push(columns);
804
+ PartsTaxInfo.forEach((part) => {
805
+ var dataRow = [];
806
+ columns.forEach((column) => {
807
+ if (!tr_utils_1.TrUtils.IsFixedZero(part[column.Field]) &&
808
+ !tr_utils_1.TrUtils.IsNull(part[column.Field]) || column.Field === 'SGST' || column.Field === 'CGST' || column.Field === 'SGSTAmt' || column.Field === 'CGSTAmt'
809
+ || column.Field === 'TotalTaxableAmount') {
810
+ if (column.Field === 'TotalTaxableAmount' || column.Field === 'SGSTAmt' || column.Field === 'CGSTAmt' || column.Field === 'IGSTAmt') {
811
+ dataRow.push({ text: tr_utils_1.TrUtils.FixPriceValue(part[column.Field]), alignment: 'right', opacity: 0.7, nowrap: true, fontSize: 6 });
812
+ }
813
+ else if (column.Field === 'CombinedTaxPercentage') {
814
+ dataRow.push({ text: part[column.Field].toString() + '%', alignment: 'left', opacity: 0.7, nowrap: true, fontSize: 6 });
815
+ }
816
+ else {
817
+ dataRow.push({ text: part[column.Field].toString(), alignment: 'left', opacity: 0.7, nowrap: true, fontSize: 6 });
818
+ }
819
+ }
820
+ else {
821
+ part[column.Field] = '';
822
+ dataRow.push({ text: part[column.Field].toString(), alignment: 'left', opacity: 0.7, fontSize: 6 });
823
+ }
824
+ });
825
+ body.push(dataRow);
826
+ });
827
+ return body;
828
+ }
829
+ else {
830
+ return [{}];
831
+ }
832
+ }
833
+ static CreateHeadingAllTaxList(ShowIGST) {
834
+ let HeaderNames = [
835
+ { text: 'Tax Rate', style: 'tableheader2', fontSize: 6, lineHeight: 0.8, Field: 'CombinedTaxPercentage', alignment: 'left' },
836
+ { text: 'Taxable Amount', style: 'tableheader2', fontSize: 6, lineHeight: 0.8, Field: 'TotalTaxableAmount', alignment: 'right' },
837
+ ];
838
+ if (ShowIGST) {
839
+ HeaderNames.splice(2, 0, { text: 'IGST(Rs.)', style: 'tableheader2', fontSize: 6, lineHeight: 0.8, Field: 'IGSTAmt', alignment: 'right' });
840
+ }
841
+ else {
842
+ HeaderNames.splice(2, 0, { text: 'CGST(Rs.)', style: 'tableheader2', fontSize: 6, lineHeight: 0.8, Field: 'CGSTAmt', alignment: 'right' });
843
+ HeaderNames.splice(3, 0, { text: 'SGST(Rs.)', style: 'tableheader2', fontSize: 6, lineHeight: 0.8, Field: 'SGSTAmt', alignment: 'right' });
844
+ }
845
+ return HeaderNames;
846
+ }
847
+ static HeaderLineStyle() {
848
+ return {
849
+ hLineWidth: function (i, node) {
850
+ return (i === 1) ? 0.1 : 0;
851
+ },
852
+ vLineWidth: function (i, node) {
853
+ return (i === 0 || i === node.table.widths.length) ? 0 : 0;
854
+ },
855
+ hLineColor: function (i, node) {
856
+ let color;
857
+ if (i === 0 || i === node.table.body.length) {
858
+ color = 'black';
859
+ }
860
+ else {
861
+ if (i === 1) {
862
+ color = 'lightgray';
863
+ }
864
+ else {
865
+ color = 'lightgray';
866
+ }
867
+ }
868
+ return color;
869
+ },
870
+ };
871
+ }
872
+ static GetNumberInWords(TotalAmount) {
873
+ var rupee = shared_pdf_service_1.SharedPDFService.convertNumberToWords(TotalAmount);
874
+ return { columns: [{ text: 'In Words :', fontSize: 8, width: 45 }, { text: rupee, bold: true, fontSize: 8, width: '*' }] };
875
+ }
876
+ static InvoiceDueStatus(Type, Paid, Due, Status, isCounter, DecimalsNumber) {
877
+ if (Type === 'Invoice' && !isCounter) {
878
+ return {
879
+ fontSize: InvoicePrintService.TableHeaders,
880
+ marginTop: 3,
881
+ marginBottom: 5,
882
+ table: {
883
+ widths: ['*', 'auto'],
884
+ body: [[{ text: 'Paid : ' + tr_utils_1.TrUtils.FixPriceValue(Paid, DecimalsNumber), marginLeft: 20 },
885
+ { text: 'Due : ' + tr_utils_1.TrUtils.FixPriceValue(Due, DecimalsNumber), marginRight: 20 }]]
886
+ },
887
+ layout: shared_pdf_service_1.SharedPDFService.LayOutLineStyle(),
888
+ };
889
+ }
890
+ else {
891
+ return InvoicePrintService.emptyObject();
892
+ }
893
+ }
894
+ static GetSignatures(CName, Total) {
895
+ return [['', InvoicePrintService.CompanyName(CName)]];
896
+ }
897
+ static CompanyName(CName) {
898
+ return {
899
+ style: 'forCompany1',
900
+ text: ['For ', { text: CName, bold: 'true' }],
901
+ };
902
+ }
903
+ // ==================== LANDSCAPE-SPECIFIC METHODS (placeholder - continue from original) ====================
904
+ static GetLandscapeHeaderDetails(ROPrintData, text) {
905
+ return [
906
+ { text: ROPrintData === null || ROPrintData === void 0 ? void 0 : ROPrintData.HeaderName, alignment: 'center', bold: true, fontSize: 10 },
907
+ { text: text, color: 'grey', alignment: 'right', width: 100, marginTop: (text !== null) ? -11 : 0, fontSize: 10 },
908
+ {
909
+ style: 'tableExample',
910
+ table: {
911
+ widths: ['*', '*', '*'],
912
+ body: [
913
+ [
914
+ {
915
+ stack: [
916
+ { text: ROPrintData.Entity.CName, alignment: 'center', bold: true, fontSize: 13 },
917
+ { text: ROPrintData.Entity.Adrs1 + ', ' + ROPrintData.Entity.Adrs2 + ', ', alignment: 'center', style: ['headerstyle'] },
918
+ { text: ROPrintData.Entity.City + '-' + ROPrintData.Entity.PIN + ', Cell : ' + ROPrintData.Entity.Phone, alignment: 'center', style: ['headerstyle'] },
919
+ { stack: InvoicePrintService.GetLandscapeHeaderInfo(ROPrintData) },
920
+ ]
921
+ },
922
+ shared_pdf_service_1.SharedPDFService.GetCustomer(ROPrintData.Customer, ROPrintData.Type, ROPrintData.For, ROPrintData.Product, ROPrintData.Settings, 'Customer Name & Address', false),
923
+ shared_pdf_service_1.SharedPDFService.GetVehicleDetails(ROPrintData.Type, ROPrintData._id, ROPrintData.CrDate, ROPrintData.PrDate, ROPrintData.MOut, ROPrintData.MIn, ROPrintData.Product, ROPrintData.PrintType, ROPrintData.IsProforma, ROPrintData.Settings, false, ROPrintData.BL, null, null, null, ROPrintData.DoS)
924
+ ],
925
+ ]
926
+ },
927
+ layout: shared_print_service_1.PrintSharedService.LayOutStyle()
928
+ },
929
+ ];
930
+ }
931
+ static GetLandscapeHeaderInfo(InvoicePDFData) {
932
+ let TaxInfo = [];
933
+ if (!tr_utils_1.TrUtils.IsEmpty(InvoicePDFData.Entity.GSTIN)) {
934
+ TaxInfo.push({ text: 'GSTIN : ' + InvoicePDFData.Entity.GSTIN, marginTop: 2, marginLeft: 5, alignment: 'left', fontSize: 9, width: 'auto' });
935
+ }
936
+ if (!tr_utils_1.TrUtils.IsEmpty(InvoicePDFData.Entity.DLNo)) {
937
+ TaxInfo.push({ text: 'D.L.NO : ' + InvoicePDFData.Entity.DLNo, marginTop: 2, marginLeft: 5, alignment: 'left', fontSize: 9, width: '*' });
938
+ }
939
+ TaxInfo.push({ text: InvoicePDFData.Settings.Tax === 'BS' ? 'Bill of Supply' : null, alignment: 'right', marginRight: 5, marginTop: 2, marginBottom: 3, fontSize: 9, width: 'auto' });
940
+ return TaxInfo;
941
+ }
942
+ static PrepareLandscapePartsTable(ROPrintData) {
943
+ let List = [];
944
+ if (ROPrintData.Entity.Body === 1) {
945
+ for (let i = 0; i < ROPrintData.PrintInfo.length; i++) {
946
+ if (tr_utils_1.TrUtils.IsNull(ROPrintData.PrintInfo[i].Text)) {
947
+ ROPrintData.PrintInfo[i].Text = '';
948
+ }
949
+ }
950
+ }
951
+ else {
952
+ if (ROPrintData.Entity.Body === 2) {
953
+ for (let i = 0; i < ROPrintData.PrintInfo.length; i++) {
954
+ if (tr_utils_1.TrUtils.IsNull(ROPrintData.PrintInfo[i].Text)) {
955
+ ROPrintData.PrintInfo[i].Text = '';
956
+ }
957
+ List.push(ROPrintData.PrintInfo[i].Text, InvoicePrintService.WithOutDiscountFieldTable(tr_utils_1.TrUtils.Stringify(ROPrintData.PrintInfo[i].Items), ROPrintData.ShowTaxColumn, ROPrintData.Entity.MPN, ROPrintData.Entity.Body, ROPrintData.ShowIGST, ROPrintData.ConsolidateGST, ROPrintData.ShowDiscountColumn));
958
+ }
959
+ }
960
+ else {
961
+ if (ROPrintData.Summary) {
962
+ // Summary view - empty for now
963
+ }
964
+ else {
965
+ for (let i = 0; i < ROPrintData.PrintInfo.length; i++) {
966
+ if (tr_utils_1.TrUtils.IsNull(ROPrintData.PrintInfo[i].Text)) {
967
+ ROPrintData.PrintInfo[i].Text = '';
968
+ }
969
+ List.push(ROPrintData.PrintInfo[i].Text, InvoicePrintService.GetWithOutDiscAndTaxFieldHeader(tr_utils_1.TrUtils.Stringify(ROPrintData.PrintInfo[i].Items), ROPrintData.ShowTaxColumn, ROPrintData.Entity.MPN, ROPrintData.Entity.Body, ROPrintData.ShowIGST, ROPrintData.ConsolidateGST, ROPrintData.ShowDiscountColumn));
970
+ }
971
+ }
972
+ }
973
+ }
974
+ return List;
975
+ }
976
+ static WithOutDiscountFieldTable(Parts, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn) {
977
+ if (Parts.length !== 0) {
978
+ if (PrintPartNo) {
979
+ return {
980
+ style: 'tableExample',
981
+ marginLeft: 20,
982
+ table: {
983
+ widths: [15, 67, 160, 25, 50, 60, 30, 53],
984
+ headerRows: 1,
985
+ body: InvoicePrintService.BuildLandscapeTableBodyForLaborAndParts(Parts, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn)
986
+ },
987
+ layout: shared_print_service_1.PrintSharedService.LayOutStyleanother()
988
+ };
989
+ }
990
+ else {
991
+ return {
992
+ style: 'tableExample',
993
+ marginLeft: 20,
994
+ table: {
995
+ widths: [15, 215, 25, 50, 60, 45, 60],
996
+ headerRows: 1,
997
+ body: InvoicePrintService.BuildLandscapeTableBodyForLaborAndParts(Parts, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn)
998
+ },
999
+ layout: shared_print_service_1.PrintSharedService.LayOutStyleanother()
1000
+ };
1001
+ }
1002
+ }
1003
+ else {
1004
+ let a = '';
1005
+ return a;
1006
+ }
1007
+ }
1008
+ static BuildLandscapeTableBodyForLaborAndParts(Parts, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn) {
1009
+ var body = [];
1010
+ let columns = InvoicePrintService.GetLandscapeWithOutDiscountFieldHeader(PrintPartNo, ShowTaxColumn, Body, ShowIGST, ShowDiscountColumn);
1011
+ for (let i = 0; i < columns.length; i++) {
1012
+ body.push(columns[i]);
1013
+ }
1014
+ columns = columns[1];
1015
+ let DummyOps = [];
1016
+ if (Parts.length !== 0) {
1017
+ if (Parts.length <= 15) {
1018
+ let Count = 18 - Parts.length;
1019
+ for (let i = 0; i < Count; i++) {
1020
+ Parts.push({});
1021
+ }
1022
+ }
1023
+ else {
1024
+ let Count = 58 - Parts.length;
1025
+ for (let i = 0; i < Count; i++) {
1026
+ Parts.push({});
1027
+ }
1028
+ }
1029
+ }
1030
+ let SNo = 1;
1031
+ Parts.forEach((part) => {
1032
+ var dataRow = [];
1033
+ columns.forEach((column) => {
1034
+ if ((!tr_utils_1.TrUtils.IsFixedZero(part[column.Field]) && !tr_utils_1.TrUtils.IsNull(part[column.Field]))
1035
+ || (column.text === 'Line Total' || column.text === 'Expiry')) {
1036
+ if (part[column.Field] === 'Spare Parts') {
1037
+ dataRow.push({ text: part[column.Field].toString(), marginLeft: 50, style: 'InlineHeader' });
1038
+ }
1039
+ else {
1040
+ if (((column.Field === 'CGSTAmt' || column.Field === 'SGSTAmt' || column.Field === 'CGSTPerc' || column.Field === 'SGSTPerc' || column.Field === 'IGSTAmt' || column.Field === 'IGSTPerc')
1041
+ && tr_utils_1.TrUtils.CheckInvalidSelect(part.TCode))) {
1042
+ part[column.Field] = '';
1043
+ dataRow.push({ text: part[column.Field].toString(), alignment: 'center' });
1044
+ }
1045
+ else {
1046
+ if (column.text === 'Line Total' || column.Field === 'UnPr' || column.Field === 'MRP' || column.Field === 'Batch' || column.Field === 'ExDate' || column.Field === 'QtyAndUoM'
1047
+ || column.text === 'Tax' || column.Field === 'Disc' || column.Field === 'CGSTAmt' || column.Field === 'SGSTAmt'
1048
+ || column.Field === 'CGSTPerc' || column.Field === 'SGSTPerc' || column.Field === 'IGSTAmt' || column.Field === 'IGSTPerc') {
1049
+ if (column.Field === 'Disc') {
1050
+ if (column.type === 'percentage') {
1051
+ if (!tr_utils_1.TrUtils.IsEmpty(part[column.Field])) {
1052
+ dataRow.push({ text: part[column.Field].toString(), noWrap: true });
1053
+ }
1054
+ else {
1055
+ dataRow.push({ text: '', noWrap: true });
1056
+ }
1057
+ }
1058
+ else {
1059
+ if (!tr_utils_1.TrUtils.IsZero(part[column.Field])) {
1060
+ dataRow.push({ text: part[column.Field].toString(), noWrap: true });
1061
+ }
1062
+ else {
1063
+ dataRow.push({ text: '', noWrap: true });
1064
+ }
1065
+ }
1066
+ }
1067
+ else {
1068
+ if (column.Field === 'Batch') {
1069
+ if (!tr_utils_1.TrUtils.IsNull(part[column.Field])) {
1070
+ dataRow.push({ text: part[column.Field].BN, nowrap: true });
1071
+ }
1072
+ else {
1073
+ dataRow.push({ text: '', noWrap: true });
1074
+ }
1075
+ }
1076
+ else if (column.Field === 'ExDate') {
1077
+ if (!tr_utils_1.TrUtils.IsNull(part['Batch'])) {
1078
+ dataRow.push({ text: my_date_1.MyDate.ConvertUTCDateToReadableExDate(part['Batch'].ExDt), nowrap: true });
1079
+ }
1080
+ else {
1081
+ dataRow.push({ text: '', noWrap: true });
1082
+ }
1083
+ }
1084
+ else {
1085
+ if (!tr_utils_1.TrUtils.IsZero(part[column.Field])) {
1086
+ dataRow.push({ text: part[column.Field].toString(), alignment: 'right', nowrap: true });
1087
+ }
1088
+ else {
1089
+ dataRow.push({ text: '', noWrap: true });
1090
+ }
1091
+ }
1092
+ }
1093
+ }
1094
+ else {
1095
+ if (tr_utils_1.TrUtils.IsNull(part[column.Field])) {
1096
+ part[column.Field] = '';
1097
+ }
1098
+ if (column.Field === 'Desc') {
1099
+ let DescData = [];
1100
+ DescData.push(part[column.Field].toString());
1101
+ if (!tr_utils_1.TrUtils.IsEmpty(part['EDesc'])) {
1102
+ DescData.push({ text: part['EDesc'].toString(), color: 'grey' });
1103
+ }
1104
+ dataRow.push({ stack: DescData });
1105
+ }
1106
+ else {
1107
+ dataRow.push({ text: part[column.Field].toString() });
1108
+ }
1109
+ }
1110
+ }
1111
+ }
1112
+ }
1113
+ else {
1114
+ if (column.Field === 'SNo' && !tr_utils_1.TrUtils.IsNull(part.Desc)) {
1115
+ part[column.Field] = SNo;
1116
+ SNo = SNo + 1;
1117
+ }
1118
+ else {
1119
+ part[column.Field] = '';
1120
+ }
1121
+ dataRow.push({ text: part[column.Field].toString(), alignment: 'center' });
1122
+ }
1123
+ });
1124
+ body.push(dataRow);
1125
+ });
1126
+ return body;
1127
+ }
1128
+ static GetLandscapeWithOutDiscountFieldHeader(permission, ShowTaxColumn, Body, ShowIGST, ShowDiscountColumn) {
1129
+ if (Body === 2) {
1130
+ let headersNames = [{ text: 'Description', style: 'tableheader', Field: 'Desc' },
1131
+ { text: 'Qty', style: 'tableheader', Field: 'QtyAndUoM' },
1132
+ { text: 'Unit Price', style: 'tableheader', Field: 'UnPr' },
1133
+ { text: 'Labor Charges', style: 'tableheader', Field: 'Price' },
1134
+ { text: 'Tax', style: 'tableheader', Field: 'TaxAmount' },
1135
+ { text: 'Line Total', style: 'tableheader', Field: 'LineTotal' }];
1136
+ if (permission) {
1137
+ let sno = { text: 'S.No.', style: 'tableheader', Field: 'SNo' };
1138
+ let MPN = { text: 'Part No', style: 'tableheader', Field: 'MPN' };
1139
+ headersNames.unshift(sno, MPN);
1140
+ }
1141
+ else {
1142
+ let sno = { text: 'S.No.', style: 'tableheader', Field: 'SNo' };
1143
+ headersNames.unshift(sno);
1144
+ }
1145
+ return headersNames;
1146
+ }
1147
+ else {
1148
+ if (ShowTaxColumn) {
1149
+ return InvoicePrintService.GetLandscapeWithOutDiscountFieldHeader1(permission, Body, ShowIGST, ShowDiscountColumn);
1150
+ }
1151
+ else {
1152
+ return InvoicePrintService.GetLandscapeWithOutDiscountFieldHeader2(permission, Body, ShowDiscountColumn);
1153
+ }
1154
+ }
1155
+ }
1156
+ static GetLandscapeWithOutDiscountFieldHeader1(permission, Body, ShowIGST, ShowDiscountColumn) {
1157
+ let headersNames;
1158
+ if (permission) {
1159
+ headersNames = [[{ text: 'S.No.', rowSpan: 2, style: 'tableheader', lineHeight: 0.5 },
1160
+ { text: 'Part No', rowSpan: 2, style: 'tableheader', lineHeight: 0.5 },
1161
+ { text: 'Description', rowSpan: 2, style: 'tableheader', alignment: 'center', lineHeight: 0.5 },
1162
+ { text: 'HSN/SAC', rowSpan: 2, style: 'tableheader', lineHeight: 1 },
1163
+ { text: 'Batch No', rowSpan: 2, style: 'tableheader', lineHeight: 1 },
1164
+ { text: 'Expiry', rowSpan: 2, style: 'tableheader', lineHeight: 1 },
1165
+ { text: 'Qty', style: 'tableheader', rowSpan: 2, lineHeight: 0.5 },
1166
+ { text: 'Offer Qty', style: 'tableheader', rowSpan: 2, lineHeight: 1 },
1167
+ { text: 'M.R.P', style: 'tableheader', rowSpan: 2, lineHeight: 0.5, alignment: 'center', },
1168
+ { text: 'Unit Price', style: 'tableheader', rowSpan: 2, lineHeight: 0.5, alignment: 'center', },
1169
+ { text: 'Line Total', rowSpan: 2, lineHeight: 0.5, style: 'tabFleheader' }
1170
+ ],
1171
+ [{ text: '', Field: 'SNo', lineHeight: 0.5 }, { text: '', Field: 'MPN', lineHeight: 0.5 },
1172
+ { text: '', Field: 'Desc', lineHeight: 0.5 }, { text: 'HSN/SAC', Field: 'HSN', lineHeight: 0.5 },
1173
+ { text: '', Field: 'Batch', lineHeight: 0.5 }, { text: 'Expiry', Field: 'ExDate', lineHeight: 0.5 },
1174
+ { text: '', Field: 'QtyAndUoM', lineHeight: 0.5 }, { text: '', Field: 'OfQty', lineHeight: 0.5 },
1175
+ { text: '', Field: 'MRP', lineHeight: 0.5 }, { text: '', Field: 'UnPr', lineHeight: 0.5 },
1176
+ { text: 'Line Total', Field: 'LineTotal', lineHeight: 0.5 }
1177
+ ]
1178
+ ];
1179
+ let Count = 10;
1180
+ if (ShowDiscountColumn) {
1181
+ headersNames[0].splice(Count, 0, { text: 'Discount', style: 'tableheader', colSpan: 2, alignment: 'center', lineHeight: 0.8 });
1182
+ headersNames[0].splice(Count + 1, 0, {});
1183
+ headersNames[1].splice(Count, 0, { text: '%', alignment: 'center', style: 'tableheader', Field: 'Perc', type: 'percentage', lineHeight: 0.5 });
1184
+ headersNames[1].splice(Count + 1, 0, { text: 'Rs', alignment: 'center', style: 'tableheader', Field: 'Disc', type: 'amount', lineHeight: 0.5 });
1185
+ Count = 12;
1186
+ }
1187
+ if (ShowIGST) {
1188
+ headersNames[0].splice(Count, 0, { text: 'IGST', style: 'tableheader', colSpan: 2, alignment: 'center', lineHeight: 0.8 });
1189
+ headersNames[0].splice(Count + 1, 0, {});
1190
+ headersNames[1].splice(Count, 0, { text: 'Rate %', alignment: 'center', style: 'tableheader', Field: 'IGSTPerc', type: 'percentage', lineHeight: 0.8 });
1191
+ headersNames[1].splice(Count + 1, 0, { text: 'Amount', alignment: 'center', style: 'tableheader', Field: 'IGSTAmt', type: 'amount', lineHeight: 0.5 });
1192
+ }
1193
+ else {
1194
+ headersNames[0].splice(Count, 0, { text: 'CGST', style: 'tableheader', colSpan: 2, alignment: 'center', lineHeight: 0.8 });
1195
+ headersNames[0].splice(Count + 1, 0, {});
1196
+ headersNames[1].splice(Count, 0, { text: 'Rate %', alignment: 'center', style: 'tableheader', Field: 'CGSTPerc', type: 'percentage', lineHeight: 0.8 });
1197
+ headersNames[1].splice(Count + 1, 0, { text: 'Amount', alignment: 'center', style: 'tableheader', Field: 'CGSTAmt', type: 'amount', lineHeight: 0.7 });
1198
+ headersNames[0].splice(Count + 2, 0, { text: 'SGST/UTGST', style: 'tableheader', colSpan: 2, alignment: 'center', lineHeight: 0.8 });
1199
+ headersNames[0].splice(Count + 3, 0, {});
1200
+ headersNames[1].splice(Count + 2, 0, { text: 'Rate %', alignment: 'center', style: 'tableheader', Field: 'SGSTPerc', type: 'percentage', lineHeight: 0.8 });
1201
+ headersNames[1].splice(Count + 3, 0, { text: 'Amount', alignment: 'center', style: 'tableheader', Field: 'SGSTAmt', type: 'amount', lineHeight: 0.5 });
1202
+ }
1203
+ }
1204
+ else {
1205
+ headersNames = [[{ text: 'S.No.', rowSpan: 2, style: 'tableheader', lineHeight: 0.6 },
1206
+ { text: 'Description', rowSpan: 2, style: 'tableheader', alignment: 'center', lineHeight: 0.6 },
1207
+ { text: 'HSN/SAC', rowSpan: 2, style: 'tableheader', lineHeight: 1 },
1208
+ { text: 'Batch No', rowSpan: 2, style: 'tableheader', lineHeight: 1 },
1209
+ { text: 'Expiry', rowSpan: 2, style: 'tableheader', lineHeight: 1 },
1210
+ { text: 'Qty', style: 'tableheader', rowSpan: 2, lineHeight: 0.6 },
1211
+ { text: 'Offer Qty', style: 'tableheader', rowSpan: 2, lineHeight: 1 },
1212
+ { text: 'M.R.P', style: 'tableheader', rowSpan: 2, lineHeight: 0.5, alignment: 'center', },
1213
+ { text: 'Unit Price', style: 'tableheader', rowSpan: 2, alignment: 'center', lineHeight: 0.6 },
1214
+ { text: 'Line Total', rowSpan: 2, style: 'tableheader', lineHeight: 0.6 }
1215
+ ],
1216
+ [{ text: '', Field: 'SNo', lineHeight: 0.5 },
1217
+ { text: '', Field: 'Desc', lineHeight: 0.5 }, { text: 'HSN/SAC', Field: 'HSN', lineHeight: 0.5 },
1218
+ { text: '', Field: 'Batch', lineHeight: 0.5 }, { text: 'Expiry', Field: 'ExDate', lineHeight: 0.5 },
1219
+ { text: '', Field: 'QtyAndUoM', lineHeight: 0.5 }, { text: '', Field: 'OfQty', lineHeight: 0.5 }, { text: '', Field: 'MRP', lineHeight: 0.5 },
1220
+ { text: '', Field: 'UnPr', lineHeight: 0.5 },
1221
+ { text: 'Line Total', Field: 'LineTotal', lineHeight: 0.5 }
1222
+ ]];
1223
+ let Count = 9;
1224
+ if (ShowDiscountColumn) {
1225
+ headersNames[0].splice(Count, 0, { text: 'Discount', style: 'tableheader', colSpan: 2, alignment: 'center', lineHeight: 0.8 });
1226
+ headersNames[0].splice(Count + 1, 0, {});
1227
+ headersNames[1].splice(Count, 0, { text: '%', alignment: 'center', style: 'tableheader', Field: 'Perc', type: 'percentage', lineHeight: 0.5 });
1228
+ headersNames[1].splice(Count + 1, 0, { text: 'Rs', alignment: 'center', style: 'tableheader', Field: 'Disc', type: 'amount', lineHeight: 0.5 });
1229
+ Count = 11;
1230
+ }
1231
+ if (ShowIGST) {
1232
+ headersNames[0].splice(Count, 0, { text: 'IGST', style: 'tableheader', colSpan: 2, alignment: 'center', lineHeight: 0.8 });
1233
+ headersNames[0].splice(Count + 1, 0, {});
1234
+ headersNames[1].splice(Count, 0, { text: 'Rate %', alignment: 'center', style: 'tableheader', Field: 'IGSTPerc', type: 'percentage', lineHeight: 0.8 });
1235
+ headersNames[1].splice(Count + 1, 0, { text: 'Amount', alignment: 'center', style: 'tableheader', Field: 'IGSTAmt', type: 'amount', lineHeight: 0.5 });
1236
+ }
1237
+ else {
1238
+ headersNames[0].splice(Count, 0, { text: 'CGST', style: 'tableheader', colSpan: 2, alignment: 'center', lineHeight: 0.8 });
1239
+ headersNames[0].splice(Count + 1, 0, {});
1240
+ headersNames[1].splice(Count, 0, { text: 'Rate %', alignment: 'center', style: 'tableheader', Field: 'CGSTPerc', type: 'percentage', lineHeight: 0.8 });
1241
+ headersNames[1].splice(Count + 1, 0, { text: 'Amount', alignment: 'center', style: 'tableheader', Field: 'CGSTAmt', type: 'amount', lineHeight: 0.5 });
1242
+ headersNames[0].splice(Count + 2, 0, { text: 'SGST/UTGST', style: 'tableheader', colSpan: 2, alignment: 'center', lineHeight: 0.8 });
1243
+ headersNames[0].splice(Count + 3, 0, {});
1244
+ headersNames[1].splice(Count + 2, 0, { text: 'Rate %', alignment: 'center', style: 'tableheader', Field: 'SGSTPerc', type: 'percentage', lineHeight: 0.8 });
1245
+ headersNames[1].splice(Count + 3, 0, { text: 'Amount', alignment: 'center', style: 'tableheader', Field: 'SGSTAmt', type: 'amount', lineHeight: 0.5 });
1246
+ }
1247
+ }
1248
+ return headersNames;
1249
+ }
1250
+ static GetLandscapeWithOutDiscountFieldHeader2(permission, Body, ShowDiscountColumn) {
1251
+ let headersNames = [[
1252
+ { text: 'Description', rowSpan: 2, style: 'tableheader', alignment: 'left', lineHeight: 0.5 },
1253
+ { text: 'Batch No', rowSpan: 2, style: 'tableheader', lineHeight: 1 },
1254
+ { text: 'Expiry', rowSpan: 2, style: 'tableheader', lineHeight: 1 },
1255
+ { text: 'Qty', style: 'tableheader', rowSpan: 2, lineHeight: 0.5 },
1256
+ { text: 'Offer Qty', style: 'tableheader', rowSpan: 2, lineHeight: 1 },
1257
+ { text: 'M.R.P', style: 'tableheader', rowSpan: 2, lineHeight: 0.5, alignment: 'center', },
1258
+ { text: 'Unit Price', style: 'tableheader', rowSpan: 2, lineHeight: 0.5, alignment: 'right', },
1259
+ { text: 'Line Total', rowSpan: 2, lineHeight: 0.5, style: 'tableheader' }
1260
+ ],
1261
+ [
1262
+ { text: '', Field: 'Desc', lineHeight: 0.5 },
1263
+ { text: '', Field: 'Batch', lineHeight: 0.5 },
1264
+ { text: 'Expiry', Field: 'ExDate', lineHeight: 0.5 },
1265
+ { text: '', Field: 'QtyAndUoM', lineHeight: 0.5 },
1266
+ { text: '', Field: 'OfQty', lineHeight: 0.5 },
1267
+ { text: '', Field: 'MRP', lineHeight: 0.5 },
1268
+ { text: '', Field: 'UnPr', lineHeight: 0.5 },
1269
+ { text: 'Line Total', Field: 'LineTotal', lineHeight: 0.5 }
1270
+ ]];
1271
+ if (permission) {
1272
+ let sno = { text: 'S.No.', rowSpan: 2, style: 'tableheader', lineHeight: 0.5 };
1273
+ let MPN = { text: 'Part No', rowSpan: 2, style: 'tableheader', lineHeight: 0.5 };
1274
+ let sno1 = { text: '', Field: 'SNo', lineHeight: 0.5 };
1275
+ let MPN1 = { text: '', Field: 'MPN', lineHeight: 0.5 };
1276
+ headersNames[0].unshift(sno, MPN);
1277
+ headersNames[1].unshift(sno1, MPN1);
1278
+ if (ShowDiscountColumn) {
1279
+ headersNames[0].splice(9, 0, { text: 'Discount', style: 'tableheader', colSpan: 2, alignment: 'center', lineHeight: 0.5 });
1280
+ headersNames[0].splice(10, 0, {});
1281
+ headersNames[1].splice(9, 0, { text: '%', alignment: 'center', style: 'tableheader', Field: 'Perc', type: 'percentage', lineHeight: 0.5 });
1282
+ headersNames[1].splice(10, 0, { text: 'Rs', alignment: 'center', style: 'tableheader', Field: 'Disc', type: 'amount', lineHeight: 0.5 });
1283
+ }
1284
+ }
1285
+ else {
1286
+ let sno = { text: 'S.No.', rowSpan: 2, style: 'tableheader', lineHeight: 0.5 };
1287
+ let sno1 = { text: '', Field: 'SNo', lineHeight: 0.5 };
1288
+ headersNames[0].unshift(sno);
1289
+ headersNames[1].unshift(sno1);
1290
+ if (ShowDiscountColumn) {
1291
+ headersNames[0].splice(8, 0, { text: 'Discount', style: 'tableheader', colSpan: 2, alignment: 'center', lineHeight: 0.5 });
1292
+ headersNames[0].splice(9, 0, {});
1293
+ headersNames[1].splice(8, 0, { text: '%', alignment: 'center', style: 'tableheader', Field: 'Perc', type: 'percentage', lineHeight: 0.5 });
1294
+ headersNames[1].splice(9, 0, { text: 'Rs', alignment: 'center', style: 'tableheader', Field: 'Disc', type: 'amount', lineHeight: 0.5 });
1295
+ }
1296
+ }
1297
+ return headersNames;
1298
+ }
1299
+ static GetWithOutDiscAndTaxFieldHeader(Parts, ShowTaxColumn, PrintPartNo, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn) {
1300
+ if (Parts.length !== 0) {
1301
+ if (ShowTaxColumn) {
1302
+ return InvoicePrintService.TaxDataTable(Parts, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn);
1303
+ }
1304
+ else {
1305
+ if (ConsolidateGST) {
1306
+ return InvoicePrintService.ConsolidateDataTable(Parts, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn);
1307
+ }
1308
+ else {
1309
+ return InvoicePrintService.NoTaxDataTable(Parts, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn);
1310
+ }
1311
+ }
1312
+ }
1313
+ else {
1314
+ let a = '';
1315
+ return a;
1316
+ }
1317
+ }
1318
+ static TaxTableWidths(PrintPartNo, ShowIGST, ShowDiscountColumn) {
1319
+ if (PrintPartNo) {
1320
+ if (ShowIGST) {
1321
+ if (ShowDiscountColumn) {
1322
+ return [24, 50, '*', 50, 35, 35, 30, 25, 40, 35, 20, 35, 20, 35, 45];
1323
+ }
1324
+ else {
1325
+ return [24, 50, '*', 50, 35, 35, 30, 25, 40, 40, 20, 35, 51];
1326
+ }
1327
+ }
1328
+ else {
1329
+ if (ShowDiscountColumn) {
1330
+ return [24, 45, '*', 50, 35, 35, 30, 22, 40, 40, 20, 34, 20, 32, 20, 32, 48];
1331
+ }
1332
+ else {
1333
+ return [24, 45, '*', 50, 35, 35, 30, 22, 40, 40, 20, 32, 20, 32, 54];
1334
+ }
1335
+ }
1336
+ }
1337
+ else {
1338
+ if (ShowIGST) {
1339
+ if (ShowDiscountColumn) {
1340
+ return [24, '*', 50, 41, 35, 30, 25, 40, 40, 20, 35, 20, 35, 41];
1341
+ }
1342
+ else {
1343
+ return [24, '*', 50, 50, 35, 30, 25, 40, 40, 20, 40, 50];
1344
+ }
1345
+ }
1346
+ else {
1347
+ if (ShowDiscountColumn) {
1348
+ return [24, '*', 50, 45, 35, 30, 22, 40, 40, 20, 34, 20, 35, 20, 35, 45];
1349
+ }
1350
+ else {
1351
+ return [24, '*', 50, 50, 35, 30, 22, 40, 40, 20, 35, 20, 35, 50];
1352
+ }
1353
+ }
1354
+ }
1355
+ }
1356
+ static TaxDataTable(Parts, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn) {
1357
+ if (PrintPartNo) {
1358
+ if (ShowIGST) {
1359
+ return {
1360
+ style: 'tableExample',
1361
+ marginTop: -6,
1362
+ table: {
1363
+ widths: InvoicePrintService.TaxTableWidths(PrintPartNo, ShowIGST, ShowDiscountColumn),
1364
+ body: InvoicePrintService.BuildLandscapeTableBodyForLaborAndParts(Parts, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn)
1365
+ },
1366
+ layout: shared_print_service_1.PrintSharedService.LayOutStyle()
1367
+ };
1368
+ }
1369
+ else {
1370
+ return {
1371
+ style: 'tableExample',
1372
+ marginTop: -6,
1373
+ table: {
1374
+ widths: InvoicePrintService.TaxTableWidths(PrintPartNo, ShowIGST, ShowDiscountColumn),
1375
+ body: InvoicePrintService.BuildLandscapeTableBodyForLaborAndParts(Parts, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn)
1376
+ },
1377
+ layout: shared_print_service_1.PrintSharedService.LayOutStyle()
1378
+ };
1379
+ }
1380
+ }
1381
+ else {
1382
+ if (ShowIGST) {
1383
+ return {
1384
+ style: 'tableExample',
1385
+ marginTop: -6,
1386
+ table: {
1387
+ widths: InvoicePrintService.TaxTableWidths(PrintPartNo, ShowIGST, ShowDiscountColumn),
1388
+ body: InvoicePrintService.BuildLandscapeTableBodyForLaborAndParts(Parts, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn)
1389
+ },
1390
+ layout: shared_print_service_1.PrintSharedService.LayOutStyle()
1391
+ };
1392
+ }
1393
+ else {
1394
+ return {
1395
+ style: 'tableExample',
1396
+ marginTop: -6,
1397
+ table: {
1398
+ widths: InvoicePrintService.TaxTableWidths(PrintPartNo, ShowIGST, ShowDiscountColumn),
1399
+ body: InvoicePrintService.BuildLandscapeTableBodyForLaborAndParts(Parts, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn)
1400
+ },
1401
+ layout: shared_print_service_1.PrintSharedService.LayOutStyle()
1402
+ };
1403
+ }
1404
+ }
1405
+ }
1406
+ static WidthForInsuranceOrNot(ShowDiscountColumn, PrintPartNo) {
1407
+ if (PrintPartNo) {
1408
+ if (ShowDiscountColumn) {
1409
+ return [24, 70, '*', 45, 45, 25, 25, 60, 60, 45, 45, 50];
1410
+ }
1411
+ else {
1412
+ return [25, 70, '*', 45, 45, 35, 35, 60, 60, 80];
1413
+ }
1414
+ }
1415
+ else {
1416
+ if (ShowDiscountColumn) {
1417
+ return [25, '*', 50, 50, 50, 50, 70, 70, 70, 70, 70];
1418
+ }
1419
+ else {
1420
+ return [25, '*', 45, 45, 40, 40, 60, 60, 80];
1421
+ }
1422
+ }
1423
+ }
1424
+ static ConsolidateDataTable(Parts, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn) {
1425
+ if (PrintPartNo) {
1426
+ return {
1427
+ style: 'tableExample',
1428
+ marginTop: -6,
1429
+ table: {
1430
+ widths: InvoicePrintService.WidthForInsuranceOrNot(ShowDiscountColumn, PrintPartNo),
1431
+ body: InvoicePrintService.BuildLandscapeTableBodyForLaborAndParts(Parts, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn)
1432
+ },
1433
+ layout: shared_print_service_1.PrintSharedService.LayOutStyle()
1434
+ };
1435
+ }
1436
+ else {
1437
+ return {
1438
+ style: 'tableExample',
1439
+ marginTop: -6,
1440
+ table: {
1441
+ widths: InvoicePrintService.WidthForInsuranceOrNot(ShowDiscountColumn, PrintPartNo),
1442
+ body: InvoicePrintService.BuildLandscapeTableBodyForLaborAndParts(Parts, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn)
1443
+ },
1444
+ layout: shared_print_service_1.PrintSharedService.LayOutStyle()
1445
+ };
1446
+ }
1447
+ }
1448
+ static NoTaxDataTable(Parts, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn) {
1449
+ if (PrintPartNo) {
1450
+ return {
1451
+ style: 'tableExample',
1452
+ marginTop: -6,
1453
+ table: {
1454
+ widths: InvoicePrintService.WidthForInsuranceOrNot(ShowDiscountColumn, PrintPartNo),
1455
+ body: InvoicePrintService.BuildLandscapeTableBodyForLaborAndParts(Parts, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn)
1456
+ },
1457
+ layout: shared_print_service_1.PrintSharedService.LayOutStyle()
1458
+ };
1459
+ }
1460
+ else {
1461
+ return {
1462
+ style: 'tableExample',
1463
+ marginTop: -6,
1464
+ table: {
1465
+ widths: InvoicePrintService.WidthForInsuranceOrNot(ShowDiscountColumn, PrintPartNo),
1466
+ body: InvoicePrintService.BuildLandscapeTableBodyForLaborAndParts(Parts, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn)
1467
+ },
1468
+ layout: shared_print_service_1.PrintSharedService.LayOutStyle()
1469
+ };
1470
+ }
1471
+ }
1472
+ static GetLandscapeTotalDetails(ROPrintData, index, numberofCopies, moreDiscDetails) {
1473
+ let totalDisc;
1474
+ let totalTax;
1475
+ if (!ROPrintData.Consolidate) {
1476
+ totalTax = tr_utils_1.TrUtils.FixPriceValue((0, math_operations_1.Add)(Number(ROPrintData.CustLaborITax), Number(ROPrintData.CustPartITax), ROPrintData.Entity.DecimalsNumber));
1477
+ if (tr_utils_1.TrUtils.isTaxable(ROPrintData.Settings.Tax)) {
1478
+ totalDisc = tr_utils_1.TrUtils.FixPriceValue((0, math_operations_1.Add)(Number(ROPrintData.CustLaborDiscTotal), Number(ROPrintData.CustPartsDiscTotal), ROPrintData.Entity.DecimalsNumber));
1479
+ }
1480
+ else {
1481
+ totalDisc = tr_utils_1.TrUtils.FixPriceValue((0, math_operations_1.Add)(Number(ROPrintData.CustLaborDiscTotal), Number(ROPrintData.CustPartsDiscTotal), ROPrintData.Entity.DecimalsNumber));
1482
+ }
1483
+ }
1484
+ let CommonDetails = [
1485
+ [{
1486
+ style: 'tableExample',
1487
+ marginTop: -6,
1488
+ table: {
1489
+ widths: ['*', '*', '*'],
1490
+ heights: [105, 105, 105],
1491
+ body: [
1492
+ [
1493
+ shared_pdf_service_1.SharedPDFService.PartsTaxAmounts1(ROPrintData.TaxSummary, true, ROPrintData.ShowIGST, ROPrintData.ShowTaxColumn),
1494
+ shared_pdf_service_1.SharedPDFService.GetBankDetials(ROPrintData.Entity.Bank, ROPrintData.Entity.PrBank, ROPrintData.Entity.UPIPhone),
1495
+ {
1496
+ columns: [{ text: '', width: moreDiscDetails ? 153 : 175 }, shared_pdf_service_1.SharedPDFService.GrandTotal(ROPrintData, '0.00', ROPrintData.CustPartsTotalBeforeDisc, totalDisc, totalTax, ROPrintData.For, ROPrintData.FixedTotal, ROPrintData.CustTotalRoundedBy, ROPrintData.CustRoundedTotal, null, ROPrintData.Consolidate, null, moreDiscDetails, ROPrintData.Entity.DecimalsNumber)]
1497
+ }
1498
+ ],
1499
+ ]
1500
+ },
1501
+ layout: shared_print_service_1.PrintSharedService.LayOutStyle()
1502
+ }],
1503
+ shared_pdf_service_1.SharedPDFService.GetTemsAndConditions(ROPrintData.Entity.Terms),
1504
+ InvoicePrintService.GetLandscapeSignatures(ROPrintData.Entity.CName, ROPrintData.Type, ROPrintData.For),
1505
+ ];
1506
+ if (!tr_utils_1.TrUtils.IsNull(numberofCopies) && numberofCopies.length !== 0 && (index !== (numberofCopies.length - 1))) {
1507
+ CommonDetails.push({ text: '', pageBreak: 'after' });
1508
+ }
1509
+ return CommonDetails;
1510
+ }
1511
+ static GetLandscapeSignatures(CName, For, Type) {
1512
+ return {
1513
+ columns: [{
1514
+ stack: [
1515
+ InvoicePrintService.CompanyName(CName),
1516
+ { columns: [InvoicePrintService.Authorizedsignature(), shared_pdf_service_1.SharedPDFService.SurveyorSignature(For, Type), InvoicePrintService.CustomerSignature()] }
1517
+ ]
1518
+ }],
1519
+ };
1520
+ }
1521
+ static Authorizedsignature() {
1522
+ return {
1523
+ style: 'Sign1',
1524
+ text: ['Authorized Signatory'],
1525
+ };
1526
+ }
1527
+ static CustomerSignature() {
1528
+ return {
1529
+ style: 'Sign1',
1530
+ text: ['Customer Signature'], marginLeft: 90
1531
+ };
1532
+ }
1533
+ // ==================== HC-SPECIFIC METHODS ====================
1534
+ static GetHCMarginsBasedOnPaperSize(size) {
1535
+ if (size === 'full') {
1536
+ return [25, 15, 15, 15];
1537
+ }
1538
+ else {
1539
+ return [25, 15, 15, 435.945];
1540
+ }
1541
+ }
1542
+ static GetHCWatermark(ROPrintData) {
1543
+ if (ROPrintData.IsProforma && ROPrintData.Entity.Wmark) {
1544
+ return { text: 'Not a final invoice', opacity: 0.2 };
1545
+ }
1546
+ else {
1547
+ return '';
1548
+ }
1549
+ }
1550
+ static GetHCHeaderDetails(ROPrintData, text, isotherIndustry) {
1551
+ return [
1552
+ shared_pdf_service_1.SharedPDFService.GetMainHeader(ROPrintData.Entity, ROPrintData.Image, ROPrintData.AColor, ROPrintData.HColor, text),
1553
+ InvoicePrintService.GetHCPrintType(ROPrintData.HeaderName, ROPrintData.Entity.RegNo),
1554
+ InvoicePrintService.HeaderAfterLine(),
1555
+ shared_pdf_service_1.SharedPDFService.GetCustomerAndVehicleDetails(ROPrintData._id, ROPrintData.CrDate, ROPrintData.PrDate, ROPrintData.MOut, ROPrintData.MIn, ROPrintData.Product, ROPrintData.PrintType, ROPrintData.For, ROPrintData.SurName, ROPrintData.SurPhone, ROPrintData.Type, ROPrintData.SurEmail, ROPrintData.InsComp, ROPrintData.PolNo, ROPrintData.PolType, ROPrintData.Customer, ROPrintData.IsProforma, null, ROPrintData.Location, isotherIndustry, ROPrintData.BL, ROPrintData.ROCode, ROPrintData.TypeName, ROPrintData.AdmNo, ROPrintData.DoS, ROPrintData.Entity.PrCustBar),
1556
+ shared_pdf_service_1.SharedPDFService.GetOwnerDetails(ROPrintData.Cust, ROPrintData.Type, ROPrintData.For),
1557
+ InvoicePrintService.CustomerAndVehicleDetailsAfterLine(),
1558
+ shared_pdf_service_1.SharedPDFService.GetDisplayTable(),
1559
+ ];
1560
+ }
1561
+ static GetHCPrintType(type, RegNo) {
1562
+ return {
1563
+ columns: [{ text: '', width: 120 },
1564
+ { text: type, alignment: 'center', style: 'Receiptheader1' },
1565
+ { text: 'Regn.No : ' + RegNo, alignment: 'right', width: 140, fontSize: 7 }]
1566
+ };
1567
+ }
1568
+ static HeaderAfterLine() {
1569
+ return {
1570
+ canvas: [
1571
+ {
1572
+ type: 'line',
1573
+ lineColor: 'grey',
1574
+ x1: 0,
1575
+ y1: 0,
1576
+ x2: 555,
1577
+ y2: 0,
1578
+ lineWidth: 1.5
1579
+ }
1580
+ ]
1581
+ };
1582
+ }
1583
+ static CustomerAndVehicleDetailsAfterLine() {
1584
+ return {
1585
+ canvas: [
1586
+ {
1587
+ type: 'line',
1588
+ lineColor: 'grey',
1589
+ x1: 0,
1590
+ y1: 0,
1591
+ x2: 555,
1592
+ y2: 0,
1593
+ lineWidth: 1.5
1594
+ }
1595
+ ]
1596
+ };
1597
+ }
1598
+ static PrepareHCPartsTable(ROPrintData, isAuto) {
1599
+ let List = [];
1600
+ if (ROPrintData.Entity.Body === 1) {
1601
+ for (let i = 0; i < ROPrintData.PrintInfo.length; i++) {
1602
+ if (tr_utils_1.TrUtils.IsNull(ROPrintData.PrintInfo[i].Text)) {
1603
+ ROPrintData.PrintInfo[i].Text = '';
1604
+ }
1605
+ List.push(ROPrintData.PrintInfo[i].Text, InvoicePrintService.GetHCLaborPartsTableForView(tr_utils_1.TrUtils.Stringify(ROPrintData.PrintInfo[i].Items), tr_utils_1.TrUtils.Stringify(ROPrintData.PrintInfo[i].Ops), false));
1606
+ }
1607
+ }
1608
+ else {
1609
+ if (ROPrintData.Entity.Body === 2) {
1610
+ for (let i = 0; i < ROPrintData.PrintInfo.length; i++) {
1611
+ if (tr_utils_1.TrUtils.IsNull(ROPrintData.PrintInfo[i].Text)) {
1612
+ ROPrintData.PrintInfo[i].Text = '';
1613
+ }
1614
+ List.push(ROPrintData.PrintInfo[i].Text, InvoicePrintService.GetHCWithOutDiscountFieldTable(tr_utils_1.TrUtils.Stringify(ROPrintData.PrintInfo[i].Items), tr_utils_1.TrUtils.Stringify(ROPrintData.PrintInfo[i].Ops), ROPrintData.ShowTaxColumn, false, ROPrintData.Entity.Body, ROPrintData.ShowIGST, ROPrintData.ConsolidateGST, ROPrintData.ShowDiscountColumn, isAuto, ROPrintData.Entity.DecimalsNumber));
1615
+ }
1616
+ }
1617
+ else {
1618
+ if (ROPrintData.Summary) {
1619
+ List.push('', InvoicePrintService.GetHCLaborPartsTableForView(ROPrintData.Items, ROPrintData.Ops, false));
1620
+ }
1621
+ else {
1622
+ for (let i = 0; i < ROPrintData.PrintInfo.length; i++) {
1623
+ if (tr_utils_1.TrUtils.IsNull(ROPrintData.PrintInfo[i].Text)) {
1624
+ ROPrintData.PrintInfo[i].Text = '';
1625
+ }
1626
+ List.push(ROPrintData.PrintInfo[i].Text, InvoicePrintService.GetHCWithOutDiscAndTaxFieldHeader(tr_utils_1.TrUtils.Stringify(ROPrintData.PrintInfo[i].Items), tr_utils_1.TrUtils.Stringify(ROPrintData.PrintInfo[i].Ops), ROPrintData.ShowTaxColumn, false, ROPrintData.Entity.Body, ROPrintData.ShowIGST, ROPrintData.ConsolidateGST, ROPrintData.ShowDiscountColumn, isAuto, ROPrintData.Entity.DecimalsNumber));
1627
+ }
1628
+ }
1629
+ }
1630
+ }
1631
+ return List;
1632
+ }
1633
+ static GetHCLaborPartsTableForView(Parts, Ops, PrintPartNo) {
1634
+ if (Parts.length !== 0 || Ops.length !== 0) {
1635
+ if (PrintPartNo) {
1636
+ return {
1637
+ style: 'tableExample',
1638
+ table: {
1639
+ widths: [25, 30, 170, 85, 15, 20, 50, 30, 30, 50],
1640
+ body: InvoicePrintService.BuildHCTableForCustomerLabor(Parts, Ops, PrintPartNo, false)
1641
+ },
1642
+ layout: shared_print_service_1.PrintSharedService.LayOutStyleanother()
1643
+ };
1644
+ }
1645
+ else {
1646
+ return {
1647
+ style: 'tableExample',
1648
+ table: {
1649
+ widths: [25, 200, 55, 25, 55, 55, 40, 15, 50],
1650
+ body: InvoicePrintService.BuildHCTableForCustomerLabor(Parts, Ops, PrintPartNo, false)
1651
+ },
1652
+ layout: shared_print_service_1.PrintSharedService.LayOutStyleanother()
1653
+ };
1654
+ }
1655
+ }
1656
+ else {
1657
+ let a = '';
1658
+ return a;
1659
+ }
1660
+ }
1661
+ static GetHCWithOutDiscountFieldTable(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn, isAuto, DecimalsNumber) {
1662
+ if (Parts.length !== 0 || Ops.length !== 0) {
1663
+ if (PrintPartNo) {
1664
+ return {
1665
+ style: 'tableExample',
1666
+ marginLeft: 20,
1667
+ table: {
1668
+ widths: [25, 60, 155, 30, 50, 60, 30, 50],
1669
+ headerRows: 1,
1670
+ body: InvoicePrintService.BuildHCTableBodyForLaborAndParts(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn, isAuto, DecimalsNumber)
1671
+ },
1672
+ layout: shared_print_service_1.PrintSharedService.LayOutStyleanother()
1673
+ };
1674
+ }
1675
+ else {
1676
+ return {
1677
+ style: 'tableExample',
1678
+ marginLeft: 20,
1679
+ table: {
1680
+ widths: [25, 215, 25, 50, 60, 45, 50],
1681
+ headerRows: 1,
1682
+ body: InvoicePrintService.BuildHCTableBodyForLaborAndParts(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn, isAuto, DecimalsNumber)
1683
+ },
1684
+ layout: shared_print_service_1.PrintSharedService.LayOutStyleanother()
1685
+ };
1686
+ }
1687
+ }
1688
+ else {
1689
+ let a = '';
1690
+ return a;
1691
+ }
1692
+ }
1693
+ static BuildHCTableBodyForLaborAndParts(Parts, Labor, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn, isAuto, DecimalsNumber) {
1694
+ var body = [];
1695
+ let columns = shared_print_service_1.PrintSharedService.GetWithOutDiscountFieldHeader(PrintPartNo, ShowTaxColumn, Body, ShowIGST, ShowDiscountColumn);
1696
+ for (let i = 0; i < columns.length; i++) {
1697
+ body.push(columns[i]);
1698
+ }
1699
+ columns = columns[1];
1700
+ let DummyOps = [];
1701
+ if (Parts.length !== 0) {
1702
+ if (isAuto) {
1703
+ let Qty = 0;
1704
+ let CGSTAMT = 0;
1705
+ let SGSTAMT = 0;
1706
+ let IGSTAMT = 0;
1707
+ let Taxable = 0;
1708
+ let FinalTotal = 0;
1709
+ Parts.forEach((part) => {
1710
+ Qty = Qty + part.Qty;
1711
+ CGSTAMT = CGSTAMT + part.CGSTAmt;
1712
+ SGSTAMT = SGSTAMT + part.SGSTAmt;
1713
+ IGSTAMT = IGSTAMT + part.IGSTAmt;
1714
+ Taxable = Taxable + part.AfterPartDisc;
1715
+ FinalTotal = FinalTotal + part.AfterPartTax;
1716
+ });
1717
+ let dpartadding1 = {};
1718
+ dpartadding1.SNo = '';
1719
+ dpartadding1.Desc = 'Medications Total';
1720
+ dpartadding1.QtyAndUoM = tr_utils_1.TrUtils.FixedTo(Qty, DecimalsNumber);
1721
+ dpartadding1.bold = true;
1722
+ dpartadding1.UnPr = tr_utils_1.TrUtils.FixedTo(Taxable, DecimalsNumber);
1723
+ dpartadding1.SGSTAmt = tr_utils_1.TrUtils.FixedTo(SGSTAMT, DecimalsNumber);
1724
+ dpartadding1.IGSTAmt = tr_utils_1.TrUtils.FixedTo(IGSTAMT, DecimalsNumber);
1725
+ dpartadding1.CGSTAmt = tr_utils_1.TrUtils.FixedTo(CGSTAMT, DecimalsNumber);
1726
+ dpartadding1.TCode = ShowTaxColumn ? 114 : undefined;
1727
+ dpartadding1.LineTotal = tr_utils_1.TrUtils.FixPriceValue(FinalTotal, DecimalsNumber);
1728
+ Parts.push({ SNo: '' });
1729
+ Parts.push(dpartadding1);
1730
+ }
1731
+ let dummypartadding1 = {};
1732
+ dummypartadding1.SNo = '';
1733
+ dummypartadding1.Desc = ' ';
1734
+ dummypartadding1.Qty = '';
1735
+ dummypartadding1.UnPr = '';
1736
+ dummypartadding1.LineTotal = '';
1737
+ }
1738
+ let SNo = 1;
1739
+ Parts.forEach((part) => {
1740
+ var dataRow = [];
1741
+ columns.forEach((column) => {
1742
+ if ((!tr_utils_1.TrUtils.IsNull(part[column.Field]))
1743
+ || (column.text === 'Line Total')) {
1744
+ if (((column.Field === 'CGSTAmt' || column.Field === 'SGSTAmt' || column.Field === 'CGSTPerc' || column.Field === 'SGSTPerc' || column.Field === 'IGSTAmt' || column.Field === 'IGSTPerc')
1745
+ && tr_utils_1.TrUtils.CheckInvalidSelect(part.TCode))) {
1746
+ part[column.Field] === '';
1747
+ dataRow.push({ text: part[column.Field].toString(), alignment: 'center' });
1748
+ }
1749
+ else {
1750
+ if (column.text === 'Line Total' || column.Field === 'UnPr' || column.Field === 'HSN' || column.Field === 'QtyAndUoM'
1751
+ || column.text === 'Tax' || column.Field === 'Disc' || column.Field === 'Perc' || column.Field === 'CGSTAmt' || column.Field === 'SGSTAmt'
1752
+ || column.Field === 'CGSTPerc' || column.Field === 'SGSTPerc' || column.Field === 'IGSTAmt' || column.Field === 'IGSTPerc') {
1753
+ if (column.Field === 'Disc') {
1754
+ if (column.type === 'percentage') {
1755
+ if (!tr_utils_1.TrUtils.IsEmpty(part[column.Field])) {
1756
+ dataRow.push({ text: part[column.Field].toString(), noWrap: true, alignment: 'right' });
1757
+ }
1758
+ else {
1759
+ dataRow.push({ text: '', noWrap: true });
1760
+ }
1761
+ }
1762
+ else {
1763
+ if (!tr_utils_1.TrUtils.IsNull(part[column.Field])) {
1764
+ dataRow.push({ text: tr_utils_1.TrUtils.FixPriceValue(part[column.Field]).toString(), alignment: 'right', noWrap: true });
1765
+ }
1766
+ else {
1767
+ dataRow.push({ text: '', noWrap: true });
1768
+ }
1769
+ }
1770
+ }
1771
+ else {
1772
+ if (!tr_utils_1.TrUtils.IsNull(part[column.Field])) {
1773
+ dataRow.push({ text: part[column.Field].toString(), bold: part.bold, alignment: 'right', nowrap: true });
1774
+ }
1775
+ else {
1776
+ dataRow.push({ text: '', noWrap: true });
1777
+ }
1778
+ }
1779
+ }
1780
+ else {
1781
+ if (column.Field === 'Desc') {
1782
+ let DescData = [];
1783
+ DescData.push({ text: part[column.Field].toString(), bold: part.bold });
1784
+ if (!tr_utils_1.TrUtils.IsEmpty(part['EDesc'])) {
1785
+ DescData.push({ text: part['EDesc'].toString(), color: 'grey' });
1786
+ }
1787
+ dataRow.push({ stack: DescData });
1788
+ }
1789
+ else {
1790
+ dataRow.push({ text: part[column.Field].toString() });
1791
+ }
1792
+ }
1793
+ }
1794
+ }
1795
+ else {
1796
+ if (column.Field === 'SNo') {
1797
+ part[column.Field] = SNo;
1798
+ SNo = SNo + 1;
1799
+ }
1800
+ else {
1801
+ if (tr_utils_1.TrUtils.IsNull(part[column.Field])) {
1802
+ part[column.Field] = '';
1803
+ }
1804
+ }
1805
+ dataRow.push({ text: part[column.Field].toString(), alignment: 'center' });
1806
+ }
1807
+ });
1808
+ body.push(dataRow);
1809
+ });
1810
+ SNo = 1;
1811
+ if (Labor.length !== 0 && Parts.length !== 0) {
1812
+ if (isAuto) {
1813
+ let CGSTAMT = 0;
1814
+ let SGSTAMT = 0;
1815
+ let IGSTAMT = 0;
1816
+ let Taxable = 0;
1817
+ let FinalTotal = 0;
1818
+ Labor.forEach((operation) => {
1819
+ CGSTAMT = CGSTAMT + operation.CGSTAmt;
1820
+ SGSTAMT = SGSTAMT + operation.SGSTAmt;
1821
+ IGSTAMT = IGSTAMT + operation.IGSTAmt;
1822
+ Taxable = Taxable + operation.AfterLaborDisc;
1823
+ FinalTotal = FinalTotal + operation.AfterLaborTax;
1824
+ });
1825
+ let dpartadding1 = {};
1826
+ dpartadding1.SNo = '';
1827
+ dpartadding1.Desc = 'Procedures Total';
1828
+ dpartadding1.UnPr = tr_utils_1.TrUtils.FixedTo(Taxable, DecimalsNumber);
1829
+ dpartadding1.SGSTAmt = tr_utils_1.TrUtils.FixedTo(SGSTAMT, DecimalsNumber);
1830
+ dpartadding1.IGSTAmt = tr_utils_1.TrUtils.FixedTo(IGSTAMT, DecimalsNumber);
1831
+ dpartadding1.CGSTAmt = tr_utils_1.TrUtils.FixedTo(CGSTAMT, DecimalsNumber);
1832
+ dpartadding1.TCode = ShowTaxColumn ? 114 : undefined;
1833
+ dpartadding1.bold = true;
1834
+ dpartadding1.LineTotal = tr_utils_1.TrUtils.FixPriceValue(FinalTotal, DecimalsNumber);
1835
+ Labor.push({ SNo: '' });
1836
+ Labor.push(dpartadding1);
1837
+ }
1838
+ let dummypartadding1 = {};
1839
+ dummypartadding1.SNo = '';
1840
+ dummypartadding1.Desc = ' ';
1841
+ dummypartadding1.Qty = '';
1842
+ dummypartadding1.UnPr = '';
1843
+ dummypartadding1.LineTotal = '';
1844
+ Labor.unshift(dummypartadding1);
1845
+ }
1846
+ if (Body === 2) {
1847
+ for (let i = 0; i < Labor.length; i++) {
1848
+ Labor[i].UnPr = '';
1849
+ }
1850
+ }
1851
+ Labor.forEach((Ops) => {
1852
+ var dataRow = [];
1853
+ columns.forEach((column) => {
1854
+ if ((!tr_utils_1.TrUtils.IsNull(Ops[column.Field]))
1855
+ || (column.text === 'Line Total')) {
1856
+ if (Ops[column.Field] === 'Procedures') {
1857
+ dataRow.push({ text: Ops[column.Field].toString(), marginLeft: 50, style: 'InlineHeader' });
1858
+ }
1859
+ else {
1860
+ if (((column.Field === 'CGSTAmt' || column.Field === 'SGSTAmt' || column.Field === 'CGSTPerc' || column.Field === 'SGSTPerc' || column.Field === 'IGSTAmt' || column.Field === 'IGSTPerc')
1861
+ && tr_utils_1.TrUtils.CheckInvalidSelect(Ops.TCode))) {
1862
+ Ops[column.Field] = '';
1863
+ dataRow.push({ text: Ops[column.Field].toString(), alignment: 'center' });
1864
+ }
1865
+ else {
1866
+ if (column.text === 'Line Total' || column.Field === 'Price' || column.Field === 'HSN' || column.text === 'Tax' || column.Field === 'UnPr'
1867
+ || column.Field === 'QtyAndUoM' || column.Field === 'Disc' || column.Field === 'Perc' || column.Field === 'CGSTAmt' || column.Field === 'SGSTAmt'
1868
+ || column.Field === 'CGSTPerc' || column.Field === 'SGSTPerc' || column.Field === 'IGSTAmt' || column.Field === 'IGSTPerc') {
1869
+ if (column.Field === 'Disc') {
1870
+ if (column.type === 'percentage') {
1871
+ if (!tr_utils_1.TrUtils.IsEmpty(Ops[column.Field])) {
1872
+ dataRow.push({ text: Ops[column.Field].toString(), alignment: 'right', noWrap: true });
1873
+ }
1874
+ else {
1875
+ dataRow.push({ text: '', noWrap: true });
1876
+ }
1877
+ }
1878
+ else {
1879
+ if (!tr_utils_1.TrUtils.IsNull(Ops[column.Field])) {
1880
+ dataRow.push({ text: tr_utils_1.TrUtils.FixPriceValue(Ops[column.Field]).toString(), alignment: 'right', noWrap: true });
1881
+ }
1882
+ else {
1883
+ dataRow.push({ text: '', noWrap: true });
1884
+ }
1885
+ }
1886
+ }
1887
+ else {
1888
+ if (!tr_utils_1.TrUtils.IsNull(Ops[column.Field])) {
1889
+ dataRow.push({ text: Ops[column.Field].toString(), alignment: 'right', nowrap: true, bold: Ops.bold });
1890
+ }
1891
+ else {
1892
+ dataRow.push({ text: '', noWrap: true });
1893
+ }
1894
+ }
1895
+ }
1896
+ else {
1897
+ if (column.Field === 'Desc') {
1898
+ let DescData = [];
1899
+ DescData.push({ text: Ops[column.Field].toString(), bold: Ops.bold });
1900
+ if (!tr_utils_1.TrUtils.IsEmpty(Ops['EDesc'])) {
1901
+ DescData.push({ text: Ops['EDesc'].toString(), color: 'grey' });
1902
+ }
1903
+ dataRow.push({ stack: DescData });
1904
+ }
1905
+ else {
1906
+ dataRow.push({ text: Ops[column.Field].toString(), bold: Ops.bold });
1907
+ }
1908
+ }
1909
+ }
1910
+ }
1911
+ }
1912
+ else {
1913
+ if (column.Field === 'SNo') {
1914
+ Ops[column.Field] = SNo;
1915
+ SNo = SNo + 1;
1916
+ }
1917
+ else {
1918
+ if (tr_utils_1.TrUtils.IsNull(Ops[column.Field])) {
1919
+ Ops[column.Field] = '';
1920
+ }
1921
+ }
1922
+ dataRow.push({ text: Ops[column.Field].toString(), alignment: 'center' });
1923
+ }
1924
+ });
1925
+ body.push(dataRow);
1926
+ });
1927
+ return body;
1928
+ }
1929
+ static GetHCWithOutDiscAndTaxFieldHeader(Parts, Ops, ShowTaxColumn, PrintPartNo, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn, isAuto, DecimalsNumber) {
1930
+ if (Parts.length !== 0 || Ops.length !== 0) {
1931
+ if (ShowTaxColumn) {
1932
+ return InvoicePrintService.GetHCTaxDataTable(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn, isAuto, DecimalsNumber);
1933
+ }
1934
+ else {
1935
+ if (ConsolidateGST) {
1936
+ return InvoicePrintService.GetHCConsolidateDataTable(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn, isAuto, DecimalsNumber);
1937
+ }
1938
+ else {
1939
+ return InvoicePrintService.GetHCNoTaxDataTable(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn, isAuto, DecimalsNumber);
1940
+ }
1941
+ }
1942
+ }
1943
+ else {
1944
+ let a = '';
1945
+ return a;
1946
+ }
1947
+ }
1948
+ static GetHCTaxTableWidths(PrintPartNo, ShowIGST, ShowDiscountColumn) {
1949
+ if (PrintPartNo) {
1950
+ if (ShowIGST) {
1951
+ if (ShowDiscountColumn) {
1952
+ return [22, 50, 143, 35, 25, 40, 17, 35, 17, 35, 45];
1953
+ }
1954
+ else {
1955
+ return [22, 50, 207, 37, 25, 40, 17, 35, 51];
1956
+ }
1957
+ }
1958
+ else {
1959
+ if (ShowDiscountColumn) {
1960
+ return [22, 40, 90, 35, 22, 40, 17, 34, 17, 32, 17, 32, 48];
1961
+ }
1962
+ else {
1963
+ return [22, 50, 135, 40, 22, 40, 17, 32, 17, 32, 54];
1964
+ }
1965
+ }
1966
+ }
1967
+ else {
1968
+ if (ShowIGST) {
1969
+ if (ShowDiscountColumn) {
1970
+ return [22, 200, 40, 25, 40, 17, 35, 17, 35, 41];
1971
+ }
1972
+ else {
1973
+ return [22, 255, 40, 25, 40, 20, 40, 50];
1974
+ }
1975
+ }
1976
+ else {
1977
+ if (ShowDiscountColumn) {
1978
+ return [22, 135, 34, 22, 40, 17, 34, 17, 35, 17, 35, 45];
1979
+ }
1980
+ else {
1981
+ return [22, 195, 35, 22, 40, 17, 35, 17, 35, 50];
1982
+ }
1983
+ }
1984
+ }
1985
+ }
1986
+ static GetHCTaxDataTable(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn, isAuto, DecimalsNumber) {
1987
+ return {
1988
+ style: 'tableExample',
1989
+ table: {
1990
+ widths: InvoicePrintService.GetHCTaxTableWidths(PrintPartNo, ShowIGST, ShowDiscountColumn),
1991
+ body: InvoicePrintService.BuildHCTableBodyForLaborAndParts(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn, isAuto, DecimalsNumber)
1992
+ },
1993
+ layout: shared_print_service_1.PrintSharedService.LayOutStyle1()
1994
+ };
1995
+ }
1996
+ static GetHCConsolidateDataTable(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn, isAuto, DecimalsNumber) {
1997
+ if (PrintPartNo) {
1998
+ return {
1999
+ style: 'tableExample',
2000
+ table: {
2001
+ widths: [25, 70, 263, 25, 60, 80, 10, 40],
2002
+ body: InvoicePrintService.BuildHCTableBodyForLaborAndParts(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn, isAuto, DecimalsNumber)
2003
+ },
2004
+ layout: shared_print_service_1.PrintSharedService.LayOutStyle1()
2005
+ };
2006
+ }
2007
+ else {
2008
+ return {
2009
+ style: 'tableExample',
2010
+ table: {
2011
+ widths: [25, 295, 50, 80, 80, 10, 40],
2012
+ body: InvoicePrintService.BuildHCTableBodyForLaborAndParts(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn, isAuto, DecimalsNumber)
2013
+ },
2014
+ layout: shared_print_service_1.PrintSharedService.LayOutStyle1()
2015
+ };
2016
+ }
2017
+ }
2018
+ static GetHCNoTaxDataTable(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn, isAuto, DecimalsNumber) {
2019
+ return {
2020
+ style: 'tableExample',
2021
+ table: {
2022
+ widths: shared_print_service_1.PrintSharedService.WidthForInsuranceOrNot(ShowDiscountColumn, PrintPartNo),
2023
+ body: InvoicePrintService.BuildHCTableBodyForLaborAndParts(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn, isAuto, DecimalsNumber)
2024
+ },
2025
+ layout: shared_print_service_1.PrintSharedService.LayOutStyle1()
2026
+ };
2027
+ }
2028
+ static BuildHCTableForCustomerLabor(Parts, Ops, PrintPartNo, customerorInsurance) {
2029
+ var body = [];
2030
+ let columns;
2031
+ columns = InvoicePrintService.GetHCSummaryHeaders(PrintPartNo);
2032
+ body.push(columns);
2033
+ if (Parts.length !== 0) {
2034
+ let dummypartadding1 = {};
2035
+ dummypartadding1.SNo = '';
2036
+ dummypartadding1.Desc = ' ';
2037
+ dummypartadding1.Qty = '';
2038
+ dummypartadding1.UnPr = '';
2039
+ dummypartadding1.Price = '';
2040
+ dummypartadding1.DiscountedPrice = '';
2041
+ dummypartadding1.LineTotal = '';
2042
+ dummypartadding1.QtyAndUoM = '';
2043
+ dummypartadding1.HSN = '';
2044
+ dummypartadding1.MPN = '';
2045
+ }
2046
+ let SNo = 1;
2047
+ Parts.forEach((part) => {
2048
+ var dataRow = [];
2049
+ columns.forEach((column) => {
2050
+ if (!tr_utils_1.TrUtils.IsNull(part[column.Field])
2051
+ || column.text === 'Line Total') {
2052
+ if (column.text === 'Line Total' || column.Field === 'QtyAndUoM' || column.Field === 'CustPrice' || column.Field === 'InsPrice' ||
2053
+ column.Field === 'DiscountedPrice' || column.Field === 'TaxAmount' || column.Field === 'UnPr') {
2054
+ if (column.Field === 'Disc Amt') {
2055
+ dataRow.push({ text: part[column.Field].toString(), alignment: 'right', noWrap: true });
2056
+ }
2057
+ else {
2058
+ dataRow.push({ text: part[column.Field].toString(), alignment: 'right', nowrap: true });
2059
+ }
2060
+ }
2061
+ else {
2062
+ if (column.Field === 'Desc') {
2063
+ let DescData = [];
2064
+ DescData.push(part[column.Field].toString());
2065
+ if (!tr_utils_1.TrUtils.IsEmpty(part['EDesc'])) {
2066
+ DescData.push({ text: part['EDesc'].toString(), color: 'grey' });
2067
+ }
2068
+ dataRow.push({ stack: DescData });
2069
+ }
2070
+ else {
2071
+ dataRow.push({ text: part[column.Field].toString() });
2072
+ }
2073
+ }
2074
+ }
2075
+ else {
2076
+ if (column.Field === 'SNo') {
2077
+ part[column.Field] = SNo;
2078
+ SNo = SNo + 1;
2079
+ }
2080
+ else {
2081
+ if (tr_utils_1.TrUtils.IsNull(part[column.Field])) {
2082
+ part[column.Field] = '';
2083
+ }
2084
+ }
2085
+ dataRow.push({ text: part[column.Field].toString(), alignment: 'center' });
2086
+ }
2087
+ });
2088
+ body.push(dataRow);
2089
+ });
2090
+ SNo = 1;
2091
+ if (Ops.length !== 0 && Parts.length !== 0) {
2092
+ let dummypartadding1 = {};
2093
+ dummypartadding1.SNo = '';
2094
+ dummypartadding1.Desc = ' ';
2095
+ dummypartadding1.Qty = '';
2096
+ dummypartadding1.UnPr = '';
2097
+ dummypartadding1.Price = '';
2098
+ dummypartadding1.DiscountedPrice = '';
2099
+ dummypartadding1.LineTotal = '';
2100
+ dummypartadding1.QtyAndUoM = '';
2101
+ dummypartadding1.HSN = '';
2102
+ Ops.unshift(dummypartadding1);
2103
+ }
2104
+ Ops.forEach((labor) => {
2105
+ var dataRow = [];
2106
+ columns.forEach((column) => {
2107
+ if (!tr_utils_1.TrUtils.IsNull(labor[column.Field])
2108
+ || column.text === 'Line Total') {
2109
+ if (labor[column.Field] === 'Procedures') {
2110
+ dataRow.push({ text: labor[column.Field].toString(), marginLeft: 50, style: 'InlineHeader' });
2111
+ }
2112
+ else {
2113
+ if (column.text === 'Line Total' || column.Field === 'QtyAndUoM' || column.Field === 'DiscountedPrice' || column.Field === 'TaxAmount'
2114
+ || column.Field === 'UnPr' || column.Field === 'CustPrice' || column.Field === 'InsPrice') {
2115
+ if (column.Field === 'Disc Amt') {
2116
+ dataRow.push({ text: labor[column.Field].toString(), alignment: 'right', noWrap: true });
2117
+ }
2118
+ else {
2119
+ dataRow.push({ text: labor[column.Field].toString(), alignment: 'right', nowrap: true });
2120
+ }
2121
+ }
2122
+ else {
2123
+ if (column.Field === 'Desc') {
2124
+ let DescData = [];
2125
+ DescData.push(labor[column.Field].toString());
2126
+ if (!tr_utils_1.TrUtils.IsEmpty(labor['EDesc'])) {
2127
+ DescData.push({ text: labor['EDesc'].toString(), color: 'grey' });
2128
+ }
2129
+ dataRow.push({ stack: DescData });
2130
+ }
2131
+ else {
2132
+ dataRow.push({ text: labor[column.Field].toString() });
2133
+ }
2134
+ }
2135
+ }
2136
+ }
2137
+ else {
2138
+ if (column.Field === 'SNo') {
2139
+ labor[column.Field] = SNo;
2140
+ SNo = SNo + 1;
2141
+ }
2142
+ else {
2143
+ if (tr_utils_1.TrUtils.IsNull(labor[column.Field])) {
2144
+ labor[column.Field] = '';
2145
+ }
2146
+ }
2147
+ dataRow.push({ text: labor[column.Field].toString(), alignment: 'center' });
2148
+ }
2149
+ });
2150
+ body.push(dataRow);
2151
+ });
2152
+ return body;
2153
+ }
2154
+ static GetHCSummaryHeaders(permission) {
2155
+ let headersNames = [{ text: 'Description', style: 'tableheader', Field: 'Desc' },
2156
+ { text: 'HSN / SAC', style: 'tableheader', Field: 'SAC' },
2157
+ { text: 'Qty', style: 'tableheader', Field: 'QtyAndUoM' },
2158
+ { text: 'Ins. Amt', style: 'tableheader', Field: 'AssPr' },
2159
+ { text: 'Cust. Amt', style: 'tableheader', Field: 'Pr' },
2160
+ { text: 'Disc.(Rs)', style: 'tableheader', Field: 'DiscountedPrice' },
2161
+ { text: 'Tax %', style: 'tableheader', Field: 'TaxAmount' },
2162
+ { text: 'Line Total', style: 'tableheader', Field: 'LineTotal' }];
2163
+ if (permission) {
2164
+ let sno = { text: 'S.No.', style: 'tableheader', Field: 'SNo' };
2165
+ let MPN = { text: 'Part No', style: 'tableheader', Field: 'MPN' };
2166
+ headersNames.unshift(sno, MPN);
2167
+ }
2168
+ else {
2169
+ let sno = { text: 'S.No.', style: 'tableheader', Field: 'SNo' };
2170
+ headersNames.unshift(sno);
2171
+ }
2172
+ return headersNames;
2173
+ }
2174
+ static GetHCTotalDetails(ROPrintData, index, numberofCopies, withPass, isAuto, moreDiscDetails) {
2175
+ var _a;
2176
+ let CommonDetails = [
2177
+ shared_pdf_service_1.SharedPDFService.GetFinalTotalDetails1(ROPrintData, ROPrintData.CustLaborTotalAfterDisc, ROPrintData.CustLaborDiscTotal, ROPrintData.CustLaborCGST, ROPrintData.CustLaborSGST, ROPrintData.CustLaborIGST, ROPrintData.CustPartIGST, ROPrintData.ShowIGST, ROPrintData.ShowTaxColumn, ROPrintData.CustPartsTotalAfterDisc, ROPrintData.CustPartsDiscTotal, ROPrintData.CustPartCGST, ROPrintData.CustPartSGST, ROPrintData.CustTaxGroupDataByPerc, ROPrintData.ShowAccParts, ROPrintData.CustLaborAfterTax, ROPrintData.CustPartAfterTax, ROPrintData.FixedDisc, ROPrintData.For, ROPrintData.FixedTotal, ROPrintData.CustTotalRoundedBy, ROPrintData.CustRoundedTotal, ROPrintData.ShowTaxColumn, ROPrintData.ShowTaxColumn, tr_utils_1.TrUtils.isTaxable((_a = ROPrintData.Settings) === null || _a === void 0 ? void 0 : _a.Tax), ROPrintData.CustLaborITax, ROPrintData.CustPartITax, ROPrintData.Consolidate, ROPrintData.From, ROPrintData.Adj, ROPrintData.CustTaxGroupDataByPerc, ROPrintData.STotal, isAuto, moreDiscDetails),
2178
+ InvoicePrintService.GetNumberInWords(ROPrintData.CustRoundedTotal),
2179
+ InvoicePrintService.InvoiceDueStatus(ROPrintData.Type, ROPrintData.Paid, ROPrintData.Due, ROPrintData.Sts, ROPrintData.isCountersale, ROPrintData.Entity.DecimalsNumber),
2180
+ shared_pdf_service_1.SharedPDFService.GetTemsAndConditions(ROPrintData.Entity.Terms),
2181
+ shared_pdf_service_1.SharedPDFService.GetBankDetials(ROPrintData.Entity.Bank, ROPrintData.Entity.PrBank, ROPrintData.Entity.UPIPhone),
2182
+ shared_pdf_service_1.SharedPDFService.GetHCInvSignatures(ROPrintData.Entity.CName, ROPrintData.isCountersale),
2183
+ ];
2184
+ if (ROPrintData.Type !== 'Invoice') {
2185
+ CommonDetails.splice(2, 0, shared_pdf_service_1.SharedPDFService.GetUnderLine());
2186
+ }
2187
+ if (!tr_utils_1.TrUtils.IsNull(numberofCopies) && numberofCopies.length !== 0 && (index !== (numberofCopies.length - 1))) {
2188
+ CommonDetails.push({ text: '', pageBreak: 'after' });
2189
+ }
2190
+ return CommonDetails;
2191
+ }
2192
+ // ==================== STANDARD-SPECIFIC METHODS ====================
2193
+ static GetStandardWatermark(ROPrintData, isAuto) {
2194
+ if (isAuto && ROPrintData.IsProforma && ROPrintData.Entity.Wmark) {
2195
+ return { text: 'Not a final invoice', opacity: 0.2 };
2196
+ }
2197
+ else {
2198
+ return '';
2199
+ }
2200
+ }
2201
+ static GetStandardHeaderDetails(ROPrintData, text, isotherIndustry) {
2202
+ return [
2203
+ shared_pdf_service_1.SharedPDFService.GetMainHeader(ROPrintData.Entity, ROPrintData.Image, ROPrintData.AColor, ROPrintData.HColor, text),
2204
+ shared_pdf_service_1.SharedPDFService.GetPrintType(ROPrintData.HeaderName),
2205
+ shared_pdf_service_1.SharedPDFService.HeaderAfterLine(),
2206
+ shared_pdf_service_1.SharedPDFService.GetCustomerAndVehicleDetails(ROPrintData._id, ROPrintData.CrDate, ROPrintData.PrDate, ROPrintData.MOut, ROPrintData.MIn, ROPrintData.Product, ROPrintData.PrintType, ROPrintData.For, ROPrintData.SurName, ROPrintData.SurPhone, ROPrintData.Type, ROPrintData.SurEmail, ROPrintData.InsComp, ROPrintData.PolNo, ROPrintData.PolType, ROPrintData.Customer, ROPrintData.IsProforma, ROPrintData.Settings, ROPrintData.Location, isotherIndustry, ROPrintData.BL, ROPrintData.ROCode, ROPrintData.TypeName, ROPrintData.AdmNo, ROPrintData.DoS),
2207
+ shared_pdf_service_1.SharedPDFService.GetOwnerDetails(ROPrintData.Cust, ROPrintData.Type, ROPrintData.For),
2208
+ shared_pdf_service_1.SharedPDFService.CustomerAndVehicleDetailsAfterLine(),
2209
+ shared_pdf_service_1.SharedPDFService.GetDisplayTable(),
2210
+ ];
2211
+ }
2212
+ static PrepareStandardPartsTable(ROPrintData, isAuto) {
2213
+ let List = [];
2214
+ if (ROPrintData.Entity.Body === 1) {
2215
+ for (let i = 0; i < ROPrintData.PrintInfo.length; i++) {
2216
+ if (tr_utils_1.TrUtils.IsNull(ROPrintData.PrintInfo[i].Text)) {
2217
+ ROPrintData.PrintInfo[i].Text = '';
2218
+ }
2219
+ List.push(ROPrintData.PrintInfo[i].Text, InvoicePrintService.GetStandardLaborPartsTableForView(tr_utils_1.TrUtils.Stringify(ROPrintData.PrintInfo[i].Items), tr_utils_1.TrUtils.Stringify(ROPrintData.PrintInfo[i].Ops), ROPrintData.Entity.MPN));
2220
+ }
2221
+ }
2222
+ else {
2223
+ if (ROPrintData.Entity.Body === 2) {
2224
+ for (let i = 0; i < ROPrintData.PrintInfo.length; i++) {
2225
+ if (tr_utils_1.TrUtils.IsNull(ROPrintData.PrintInfo[i].Text)) {
2226
+ ROPrintData.PrintInfo[i].Text = '';
2227
+ }
2228
+ List.push(ROPrintData.PrintInfo[i].Text, InvoicePrintService.GetStandardWithOutDiscountFieldTable(tr_utils_1.TrUtils.Stringify(ROPrintData.PrintInfo[i].Items), tr_utils_1.TrUtils.Stringify(ROPrintData.PrintInfo[i].Ops), ROPrintData.ShowTaxColumn, ROPrintData.Entity.MPN, ROPrintData.Entity.Body, ROPrintData.ShowIGST, ROPrintData.ConsolidateGST, ROPrintData.ShowDiscountColumn, isAuto, ROPrintData.Entity.DecimalsNumber));
2229
+ }
2230
+ }
2231
+ else {
2232
+ if (ROPrintData.Summary) {
2233
+ List.push('', InvoicePrintService.GetStandardLaborPartsTableForView(ROPrintData.Items, ROPrintData.Ops, ROPrintData.Entity.MPN));
2234
+ }
2235
+ else {
2236
+ for (let i = 0; i < ROPrintData.PrintInfo.length; i++) {
2237
+ if (tr_utils_1.TrUtils.IsNull(ROPrintData.PrintInfo[i].Text)) {
2238
+ ROPrintData.PrintInfo[i].Text = '';
2239
+ }
2240
+ List.push(ROPrintData.PrintInfo[i].Text, InvoicePrintService.GetStandardWithOutDiscAndTaxFieldHeader(tr_utils_1.TrUtils.Stringify(ROPrintData.PrintInfo[i].Items), tr_utils_1.TrUtils.Stringify(ROPrintData.PrintInfo[i].Ops), ROPrintData.ShowTaxColumn, ROPrintData.Entity.MPN, ROPrintData.Entity.Body, ROPrintData.ShowIGST, ROPrintData.ConsolidateGST, ROPrintData.ShowDiscountColumn, isAuto, ROPrintData.Entity.DecimalsNumber));
2241
+ }
2242
+ }
2243
+ }
2244
+ }
2245
+ return List;
2246
+ }
2247
+ static GetStandardLaborPartsTableForView(Parts, Ops, PrintPartNo) {
2248
+ if (Parts.length !== 0 || Ops.length !== 0) {
2249
+ if (PrintPartNo) {
2250
+ return {
2251
+ style: 'tableExample',
2252
+ table: {
2253
+ widths: [25, 30, 170, 85, 15, 20, 50, 30, 30, 50],
2254
+ body: InvoicePrintService.BuildStandardTableForCustomerLabor(Parts, Ops, PrintPartNo, false)
2255
+ },
2256
+ layout: shared_print_service_1.PrintSharedService.LayOutStyleanother()
2257
+ };
2258
+ }
2259
+ else {
2260
+ return {
2261
+ style: 'tableExample',
2262
+ table: {
2263
+ widths: [25, 200, 55, 25, 55, 55, 40, 15, 50],
2264
+ body: InvoicePrintService.BuildStandardTableForCustomerLabor(Parts, Ops, PrintPartNo, false)
2265
+ },
2266
+ layout: shared_print_service_1.PrintSharedService.LayOutStyleanother()
2267
+ };
2268
+ }
2269
+ }
2270
+ else {
2271
+ let a = '';
2272
+ return a;
2273
+ }
2274
+ }
2275
+ static GetStandardWithOutDiscountFieldTable(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn, isAuto, DecimalsNumber) {
2276
+ if (Parts.length !== 0 || Ops.length !== 0) {
2277
+ if (PrintPartNo) {
2278
+ return {
2279
+ style: 'tableExample',
2280
+ marginLeft: 20,
2281
+ table: {
2282
+ widths: [25, 60, 155, 30, 50, 60, 30, 50],
2283
+ headerRows: 1,
2284
+ body: InvoicePrintService.BuildStandardTableBodyForLaborAndParts(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn, isAuto, DecimalsNumber)
2285
+ },
2286
+ layout: shared_print_service_1.PrintSharedService.LayOutStyleanother()
2287
+ };
2288
+ }
2289
+ else {
2290
+ return {
2291
+ style: 'tableExample',
2292
+ marginLeft: 20,
2293
+ table: {
2294
+ widths: [25, 215, 25, 50, 60, 45, 50],
2295
+ headerRows: 1,
2296
+ body: InvoicePrintService.BuildStandardTableBodyForLaborAndParts(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn, isAuto, DecimalsNumber)
2297
+ },
2298
+ layout: shared_print_service_1.PrintSharedService.LayOutStyleanother()
2299
+ };
2300
+ }
2301
+ }
2302
+ else {
2303
+ let a = '';
2304
+ return a;
2305
+ }
2306
+ }
2307
+ static BuildStandardTableBodyForLaborAndParts(Parts, Labor, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn, isAuto, DecimalsNumber) {
2308
+ var body = [];
2309
+ let columns = shared_print_service_1.PrintSharedService.GetWithOutDiscountFieldHeader(PrintPartNo, ShowTaxColumn, Body, ShowIGST, ShowDiscountColumn);
2310
+ for (let i = 0; i < columns.length; i++) {
2311
+ body.push(columns[i]);
2312
+ }
2313
+ columns = columns[1];
2314
+ let DummyOps = [];
2315
+ if (Parts.length !== 0) {
2316
+ if (isAuto) {
2317
+ let Qty = 0;
2318
+ let CGSTAMT = 0;
2319
+ let SGSTAMT = 0;
2320
+ let IGSTAMT = 0;
2321
+ let Taxable = 0;
2322
+ let FinalTotal = 0;
2323
+ Parts.forEach((part) => {
2324
+ Qty = (0, math_operations_1.Add)(Qty, tr_utils_1.TrUtils.FixedTo(part.Qty, DecimalsNumber));
2325
+ CGSTAMT = (0, math_operations_1.Add)(CGSTAMT, tr_utils_1.TrUtils.FixedTo(part.CGSTAmt, DecimalsNumber));
2326
+ SGSTAMT = (0, math_operations_1.Add)(SGSTAMT, tr_utils_1.TrUtils.FixedTo(part.SGSTAmt, DecimalsNumber));
2327
+ IGSTAMT = (0, math_operations_1.Add)(IGSTAMT, tr_utils_1.TrUtils.FixedTo(part.IGSTAmt, DecimalsNumber));
2328
+ Taxable = (0, math_operations_1.Add)(Taxable, tr_utils_1.TrUtils.FixedTo(part.AfterPartDisc, DecimalsNumber));
2329
+ FinalTotal = (0, math_operations_1.Add)(FinalTotal, tr_utils_1.TrUtils.FixedTo(part.AfterPartTax, DecimalsNumber));
2330
+ });
2331
+ let dpartadding1 = {};
2332
+ dpartadding1.SNo = '';
2333
+ dpartadding1.Desc = 'Spare Total';
2334
+ dpartadding1.QtyAndUoM = tr_utils_1.TrUtils.FixedTo(Qty, DecimalsNumber);
2335
+ dpartadding1.bold = true;
2336
+ dpartadding1.UnPr = tr_utils_1.TrUtils.FixedTo(Taxable, DecimalsNumber);
2337
+ dpartadding1.SGSTAmt = tr_utils_1.TrUtils.FixedTo(SGSTAMT, DecimalsNumber);
2338
+ dpartadding1.IGSTAmt = tr_utils_1.TrUtils.FixedTo(IGSTAMT, DecimalsNumber);
2339
+ dpartadding1.CGSTAmt = tr_utils_1.TrUtils.FixedTo(CGSTAMT, DecimalsNumber);
2340
+ dpartadding1.TCode = ShowTaxColumn ? 114 : undefined;
2341
+ dpartadding1.LineTotal = tr_utils_1.TrUtils.FixPriceValue(FinalTotal, DecimalsNumber);
2342
+ Parts.push({ SNo: '' });
2343
+ Parts.push(dpartadding1);
2344
+ }
2345
+ let dummypartadding1 = {};
2346
+ dummypartadding1.SNo = '';
2347
+ dummypartadding1.Desc = 'Spare Parts';
2348
+ dummypartadding1.Qty = '';
2349
+ dummypartadding1.UnPr = '';
2350
+ dummypartadding1.LineTotal = '';
2351
+ Parts.unshift(dummypartadding1);
2352
+ }
2353
+ let SNo = 1;
2354
+ Parts.forEach((part) => {
2355
+ var dataRow = [];
2356
+ columns.forEach((column) => {
2357
+ if ((!tr_utils_1.TrUtils.IsFixedZero(part[column.Field]) && !tr_utils_1.TrUtils.IsNull(part[column.Field]))
2358
+ || (column.text === 'Line Total')) {
2359
+ if (part[column.Field] === 'Spare Parts') {
2360
+ dataRow.push({ text: part[column.Field].toString(), marginLeft: 50, style: 'InlineHeader' });
2361
+ }
2362
+ else {
2363
+ if (((column.Field === 'CGSTAmt' || column.Field === 'SGSTAmt' || column.Field === 'CGSTPerc' || column.Field === 'SGSTPerc' || column.Field === 'IGSTAmt' || column.Field === 'IGSTPerc')
2364
+ && tr_utils_1.TrUtils.CheckInvalidSelect(part.TCode))) {
2365
+ part[column.Field] = '';
2366
+ dataRow.push({ text: part[column.Field].toString(), alignment: 'center' });
2367
+ }
2368
+ else {
2369
+ if (column.text === 'Line Total' || column.Field === 'UnPr' || column.Field === 'QtyAndUoM'
2370
+ || column.text === 'Tax' || column.Field === 'Disc' || column.Field === 'Perc' || column.Field === 'CGSTAmt' || column.Field === 'SGSTAmt'
2371
+ || column.Field === 'CGSTPerc' || column.Field === 'SGSTPerc' || column.Field === 'IGSTAmt' || column.Field === 'IGSTPerc') {
2372
+ if (column.Field === 'Disc') {
2373
+ if (column.type === 'percentage') {
2374
+ if (!tr_utils_1.TrUtils.IsEmpty(part[column.Field])) {
2375
+ dataRow.push({ text: part[column.Field].toString(), noWrap: true, alignment: 'center' });
2376
+ }
2377
+ else {
2378
+ dataRow.push({ text: '', noWrap: true });
2379
+ }
2380
+ }
2381
+ else {
2382
+ if (!tr_utils_1.TrUtils.IsNull(part[column.Field])) {
2383
+ dataRow.push({ text: part[column.Field].toString(), noWrap: true, alignment: 'right' });
2384
+ }
2385
+ else {
2386
+ dataRow.push({ text: '', noWrap: true });
2387
+ }
2388
+ }
2389
+ }
2390
+ else {
2391
+ if (!tr_utils_1.TrUtils.IsNull(part[column.Field])) {
2392
+ dataRow.push({ text: part[column.Field].toString(), bold: part.bold, alignment: 'right', nowrap: true });
2393
+ }
2394
+ else {
2395
+ dataRow.push({ text: '', noWrap: true });
2396
+ }
2397
+ }
2398
+ }
2399
+ else {
2400
+ if (column.Field === 'Desc') {
2401
+ let DescData = [];
2402
+ DescData.push({ text: part[column.Field].toString(), bold: part.bold });
2403
+ if (!tr_utils_1.TrUtils.IsEmpty(part['EDesc'])) {
2404
+ DescData.push({ text: part['EDesc'].toString(), color: 'grey' });
2405
+ }
2406
+ dataRow.push({ stack: DescData });
2407
+ }
2408
+ else {
2409
+ dataRow.push({ text: part[column.Field].toString() });
2410
+ }
2411
+ }
2412
+ }
2413
+ }
2414
+ }
2415
+ else {
2416
+ if (column.Field === 'SNo') {
2417
+ part[column.Field] = SNo;
2418
+ SNo = SNo + 1;
2419
+ }
2420
+ else {
2421
+ if (tr_utils_1.TrUtils.IsNull(part[column.Field])) {
2422
+ part[column.Field] = '';
2423
+ }
2424
+ }
2425
+ dataRow.push({ text: part[column.Field].toString(), alignment: 'center' });
2426
+ }
2427
+ });
2428
+ body.push(dataRow);
2429
+ });
2430
+ SNo = 1;
2431
+ if (Labor.length !== 0) {
2432
+ if (isAuto) {
2433
+ let CGSTAMT = 0;
2434
+ let SGSTAMT = 0;
2435
+ let IGSTAMT = 0;
2436
+ let Taxable = 0;
2437
+ let FinalTotal = 0;
2438
+ Labor.forEach((operation) => {
2439
+ CGSTAMT = (0, math_operations_1.Add)(CGSTAMT, tr_utils_1.TrUtils.FixedTo(operation.CGSTAmt, DecimalsNumber));
2440
+ SGSTAMT = (0, math_operations_1.Add)(SGSTAMT, tr_utils_1.TrUtils.FixedTo(operation.SGSTAmt, DecimalsNumber));
2441
+ IGSTAMT = (0, math_operations_1.Add)(IGSTAMT, tr_utils_1.TrUtils.FixedTo(operation.IGSTAmt, DecimalsNumber));
2442
+ Taxable = (0, math_operations_1.Add)(Taxable, tr_utils_1.TrUtils.FixedTo(operation.AfterLaborDisc, DecimalsNumber));
2443
+ FinalTotal = (0, math_operations_1.Add)(FinalTotal, tr_utils_1.TrUtils.FixedTo(operation.AfterLaborTax, DecimalsNumber));
2444
+ });
2445
+ let dpartadding1 = {};
2446
+ dpartadding1.SNo = '';
2447
+ dpartadding1.Desc = 'Labor Total';
2448
+ dpartadding1.UnPr = tr_utils_1.TrUtils.FixedTo(Taxable, DecimalsNumber);
2449
+ dpartadding1.SGSTAmt = tr_utils_1.TrUtils.FixedTo(SGSTAMT, DecimalsNumber);
2450
+ dpartadding1.IGSTAmt = tr_utils_1.TrUtils.FixedTo(IGSTAMT, DecimalsNumber);
2451
+ dpartadding1.CGSTAmt = tr_utils_1.TrUtils.FixedTo(CGSTAMT, DecimalsNumber);
2452
+ dpartadding1.TCode = ShowTaxColumn ? 114 : undefined;
2453
+ dpartadding1.bold = true;
2454
+ dpartadding1.LineTotal = tr_utils_1.TrUtils.FixPriceValue(FinalTotal, DecimalsNumber);
2455
+ Labor.push({ SNo: '' });
2456
+ Labor.push(dpartadding1);
2457
+ }
2458
+ let dummypartadding1 = {};
2459
+ dummypartadding1.SNo = '';
2460
+ dummypartadding1.Desc = 'Labor';
2461
+ dummypartadding1.Qty = '';
2462
+ dummypartadding1.UnPr = '';
2463
+ dummypartadding1.LineTotal = '';
2464
+ Labor.unshift(dummypartadding1);
2465
+ }
2466
+ if (Body === 2) {
2467
+ for (let i = 0; i < Labor.length; i++) {
2468
+ Labor[i].UnPr = '';
2469
+ }
2470
+ }
2471
+ Labor.forEach((Ops) => {
2472
+ var dataRow = [];
2473
+ columns.forEach((column) => {
2474
+ if ((!tr_utils_1.TrUtils.IsFixedZero(Ops[column.Field]) && !tr_utils_1.TrUtils.IsNull(Ops[column.Field]))
2475
+ || (column.text === 'Line Total')) {
2476
+ if (Ops[column.Field] === 'Labor') {
2477
+ dataRow.push({ text: Ops[column.Field].toString(), marginLeft: 50, style: 'InlineHeader' });
2478
+ }
2479
+ else {
2480
+ if (((column.Field === 'CGSTAmt' || column.Field === 'SGSTAmt' || column.Field === 'CGSTPerc' || column.Field === 'SGSTPerc' || column.Field === 'IGSTAmt' || column.Field === 'IGSTPerc')
2481
+ && tr_utils_1.TrUtils.CheckInvalidSelect(Ops.TCode))) {
2482
+ Ops[column.Field] = '';
2483
+ dataRow.push({ text: Ops[column.Field].toString(), alignment: 'center' });
2484
+ }
2485
+ else {
2486
+ if (column.text === 'Line Total' || column.Field === 'Price' || column.text === 'Tax' || column.Field === 'UnPr'
2487
+ || column.Field === 'QtyAndUoM' || column.Field === 'Disc' || column.Field === 'Perc' || column.Field === 'CGSTAmt' || column.Field === 'SGSTAmt'
2488
+ || column.Field === 'CGSTPerc' || column.Field === 'SGSTPerc' || column.Field === 'IGSTAmt' || column.Field === 'IGSTPerc') {
2489
+ if (column.Field === 'Disc') {
2490
+ if (column.type === 'percentage') {
2491
+ if (!tr_utils_1.TrUtils.IsEmpty(Ops[column.Field])) {
2492
+ dataRow.push({ text: Ops[column.Field].toString(), noWrap: true, alignment: 'center' });
2493
+ }
2494
+ else {
2495
+ dataRow.push({ text: '', noWrap: true });
2496
+ }
2497
+ }
2498
+ else {
2499
+ if (!tr_utils_1.TrUtils.IsNull(Ops[column.Field])) {
2500
+ dataRow.push({ text: Ops[column.Field].toString(), noWrap: true, alignment: 'right' });
2501
+ }
2502
+ else {
2503
+ dataRow.push({ text: '', noWrap: true });
2504
+ }
2505
+ }
2506
+ }
2507
+ else {
2508
+ if (!tr_utils_1.TrUtils.IsNull(Ops[column.Field])) {
2509
+ dataRow.push({ text: Ops[column.Field].toString(), alignment: 'right', nowrap: true, bold: Ops.bold });
2510
+ }
2511
+ else {
2512
+ dataRow.push({ text: '', noWrap: true });
2513
+ }
2514
+ }
2515
+ }
2516
+ else {
2517
+ dataRow.push({ text: Ops[column.Field].toString(), bold: Ops.bold });
2518
+ }
2519
+ }
2520
+ }
2521
+ }
2522
+ else {
2523
+ if (column.Field === 'SNo') {
2524
+ Ops[column.Field] = SNo;
2525
+ SNo = SNo + 1;
2526
+ }
2527
+ else {
2528
+ if (tr_utils_1.TrUtils.IsNull(Ops[column.Field])) {
2529
+ Ops[column.Field] = '';
2530
+ }
2531
+ }
2532
+ dataRow.push({ text: Ops[column.Field].toString(), alignment: 'center' });
2533
+ }
2534
+ });
2535
+ body.push(dataRow);
2536
+ });
2537
+ return body;
2538
+ }
2539
+ static GetStandardWithOutDiscAndTaxFieldHeader(Parts, Ops, ShowTaxColumn, PrintPartNo, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn, isAuto, DecimalsNumber) {
2540
+ if (Parts.length !== 0 || Ops.length !== 0) {
2541
+ if (ShowTaxColumn) {
2542
+ return InvoicePrintService.GetStandardTaxDataTable(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn, isAuto, DecimalsNumber);
2543
+ }
2544
+ else {
2545
+ if (ConsolidateGST) {
2546
+ return InvoicePrintService.GetStandardConsolidateDataTable(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn, isAuto, DecimalsNumber);
2547
+ }
2548
+ else {
2549
+ return InvoicePrintService.GetStandardNoTaxDataTable(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn, isAuto, DecimalsNumber);
2550
+ }
2551
+ }
2552
+ }
2553
+ else {
2554
+ let a = '';
2555
+ return a;
2556
+ }
2557
+ }
2558
+ static GetStandardTaxDataTable(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn, isAuto, DecimalsNumber) {
2559
+ return {
2560
+ style: 'tableExample',
2561
+ table: {
2562
+ widths: shared_print_service_1.PrintSharedService.TaxTableWidths(PrintPartNo, ShowIGST, ShowDiscountColumn),
2563
+ body: InvoicePrintService.BuildStandardTableBodyForLaborAndParts(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn, isAuto, DecimalsNumber)
2564
+ },
2565
+ layout: shared_print_service_1.PrintSharedService.LayOutStyle()
2566
+ };
2567
+ }
2568
+ static GetStandardConsolidateDataTable(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn, isAuto, DecimalsNumber) {
2569
+ if (PrintPartNo) {
2570
+ return {
2571
+ style: 'tableExample',
2572
+ table: {
2573
+ widths: [25, 70, 263, 25, 60, 80, 10, 40],
2574
+ body: InvoicePrintService.BuildStandardTableBodyForLaborAndParts(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn, isAuto, DecimalsNumber)
2575
+ },
2576
+ layout: shared_print_service_1.PrintSharedService.LayOutStyle()
2577
+ };
2578
+ }
2579
+ else {
2580
+ return {
2581
+ style: 'tableExample',
2582
+ table: {
2583
+ widths: [25, 295, 50, 80, 80, 10, 40],
2584
+ body: InvoicePrintService.BuildStandardTableBodyForLaborAndParts(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn, isAuto, DecimalsNumber)
2585
+ },
2586
+ layout: shared_print_service_1.PrintSharedService.LayOutStyle()
2587
+ };
2588
+ }
2589
+ }
2590
+ static GetStandardNoTaxDataTable(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn, isAuto, DecimalsNumber) {
2591
+ return {
2592
+ style: 'tableExample',
2593
+ table: {
2594
+ widths: shared_print_service_1.PrintSharedService.WidthForInsuranceOrNot(ShowDiscountColumn, PrintPartNo),
2595
+ body: InvoicePrintService.BuildStandardTableBodyForLaborAndParts(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn, isAuto, DecimalsNumber)
2596
+ },
2597
+ layout: shared_print_service_1.PrintSharedService.LayOutStyle()
2598
+ };
2599
+ }
2600
+ static BuildStandardTableForCustomerLabor(Parts, Ops, PrintPartNo, customerorInsurance) {
2601
+ var body = [];
2602
+ let columns;
2603
+ columns = InvoicePrintService.GetStandardSummaryHeaders(PrintPartNo);
2604
+ body.push(columns);
2605
+ if (Parts.length !== 0) {
2606
+ let dummypartadding1 = {};
2607
+ dummypartadding1.SNo = '';
2608
+ dummypartadding1.Desc = 'Spare Parts';
2609
+ dummypartadding1.Qty = '';
2610
+ dummypartadding1.UnPr = '';
2611
+ dummypartadding1.Price = '';
2612
+ dummypartadding1.DiscountedPrice = '';
2613
+ dummypartadding1.LineTotal = '';
2614
+ dummypartadding1.QtyAndUoM = '';
2615
+ dummypartadding1.HSN = '';
2616
+ dummypartadding1.MPN = '';
2617
+ Parts.unshift(dummypartadding1);
2618
+ }
2619
+ let SNo = 1;
2620
+ Parts.forEach((part) => {
2621
+ var dataRow = [];
2622
+ columns.forEach((column) => {
2623
+ if (!tr_utils_1.TrUtils.IsFixedZero(part[column.Field]) && !tr_utils_1.TrUtils.IsNull(part[column.Field])
2624
+ || column.text === 'Line Total') {
2625
+ if (part[column.Field] === 'Spare Parts') {
2626
+ dataRow.push({ text: part[column.Field].toString(), marginLeft: 50, style: 'InlineHeader' });
2627
+ }
2628
+ else {
2629
+ if (column.text === 'Line Total' || column.Field === 'QtyAndUoM' || column.Field === 'CustPrice' || column.Field === 'InsPrice' ||
2630
+ column.Field === 'DiscountedPrice' || column.Field === 'TaxAmount' || column.Field === 'UnPr') {
2631
+ if (column.Field === 'Disc Amt') {
2632
+ dataRow.push({ text: part[column.Field].toString(), alignment: 'right', noWrap: true });
2633
+ }
2634
+ else {
2635
+ dataRow.push({ text: part[column.Field].toString(), alignment: 'right', nowrap: true });
2636
+ }
2637
+ }
2638
+ else {
2639
+ if (column.Field === 'Desc') {
2640
+ let DescData = [];
2641
+ DescData.push(part[column.Field].toString());
2642
+ if (!tr_utils_1.TrUtils.IsEmpty(part['EDesc'])) {
2643
+ DescData.push({ text: part['EDesc'].toString(), color: 'grey' });
2644
+ }
2645
+ dataRow.push({ stack: DescData });
2646
+ }
2647
+ else {
2648
+ dataRow.push({ text: part[column.Field].toString() });
2649
+ }
2650
+ }
2651
+ }
2652
+ }
2653
+ else {
2654
+ if (column.Field === 'SNo') {
2655
+ part[column.Field] = SNo;
2656
+ SNo = SNo + 1;
2657
+ }
2658
+ else {
2659
+ if (tr_utils_1.TrUtils.IsNull(part[column.Field])) {
2660
+ part[column.Field] = '';
2661
+ }
2662
+ }
2663
+ dataRow.push({ text: part[column.Field].toString(), alignment: 'center' });
2664
+ }
2665
+ });
2666
+ body.push(dataRow);
2667
+ });
2668
+ SNo = 1;
2669
+ if (Ops.length !== 0) {
2670
+ let dummypartadding1 = {};
2671
+ dummypartadding1.SNo = '';
2672
+ dummypartadding1.Desc = 'Labor';
2673
+ dummypartadding1.Qty = '';
2674
+ dummypartadding1.UnPr = '';
2675
+ dummypartadding1.Price = '';
2676
+ dummypartadding1.DiscountedPrice = '';
2677
+ dummypartadding1.LineTotal = '';
2678
+ dummypartadding1.QtyAndUoM = '';
2679
+ dummypartadding1.HSN = '';
2680
+ Ops.unshift(dummypartadding1);
2681
+ }
2682
+ Ops.forEach((labor) => {
2683
+ var dataRow = [];
2684
+ columns.forEach((column) => {
2685
+ if (!tr_utils_1.TrUtils.IsFixedZero(labor[column.Field]) && !tr_utils_1.TrUtils.IsNull(labor[column.Field])
2686
+ || column.text === 'Line Total') {
2687
+ if (labor[column.Field] === 'Labor') {
2688
+ dataRow.push({ text: labor[column.Field].toString(), marginLeft: 50, style: 'InlineHeader' });
2689
+ }
2690
+ else {
2691
+ if (column.text === 'Line Total' || column.Field === 'QtyAndUoM' || column.Field === 'DiscountedPrice' || column.Field === 'TaxAmount'
2692
+ || column.Field === 'UnPr' || column.Field === 'CustPrice' || column.Field === 'InsPrice') {
2693
+ if (column.Field === 'Disc Amt') {
2694
+ dataRow.push({ text: labor[column.Field].toString(), alignment: 'right', noWrap: true });
2695
+ }
2696
+ else {
2697
+ dataRow.push({ text: labor[column.Field].toString(), alignment: 'right', nowrap: true });
2698
+ }
2699
+ }
2700
+ else {
2701
+ dataRow.push({ text: labor[column.Field].toString() });
2702
+ }
2703
+ }
2704
+ }
2705
+ else {
2706
+ if (column.Field === 'SNo') {
2707
+ labor[column.Field] = SNo;
2708
+ SNo = SNo + 1;
2709
+ }
2710
+ else {
2711
+ if (tr_utils_1.TrUtils.IsNull(labor[column.Field])) {
2712
+ labor[column.Field] = '';
2713
+ }
2714
+ }
2715
+ dataRow.push({ text: labor[column.Field].toString(), alignment: 'center' });
2716
+ }
2717
+ });
2718
+ body.push(dataRow);
2719
+ });
2720
+ return body;
2721
+ }
2722
+ static GetStandardSummaryHeaders(permission) {
2723
+ let headersNames = [{ text: 'Description', style: 'tableheader', Field: 'Desc' },
2724
+ { text: 'HSN / SAC', style: 'tableheader', Field: 'SAC' },
2725
+ { text: 'Qty', style: 'tableheader', Field: 'QtyAndUoM' },
2726
+ { text: 'Ins. Amt', style: 'tableheader', Field: 'AssPr' },
2727
+ { text: 'Cust. Amt', style: 'tableheader', Field: 'Pr' },
2728
+ { text: 'Disc.(Rs)', style: 'tableheader', Field: 'DiscountedPrice' },
2729
+ { text: 'Tax %', style: 'tableheader', Field: 'TaxAmount' },
2730
+ { text: 'Line Total', style: 'tableheader', Field: 'LineTotal' }];
2731
+ if (permission) {
2732
+ let sno = { text: 'S.No.', style: 'tableheader', Field: 'SNo' };
2733
+ let MPN = { text: 'Part No', style: 'tableheader', Field: 'MPN' };
2734
+ headersNames.unshift(sno, MPN);
2735
+ }
2736
+ else {
2737
+ let sno = { text: 'S.No.', style: 'tableheader', Field: 'SNo' };
2738
+ headersNames.unshift(sno);
2739
+ }
2740
+ return headersNames;
2741
+ }
2742
+ static GetStandardTotalDetails(ROPrintData, index, numberofCopies, withPass, isAuto, moreDiscDetails) {
2743
+ let CommonDetails = [
2744
+ shared_pdf_service_1.SharedPDFService.GetFinalTotalDetails1(ROPrintData, ROPrintData.CustLaborTotalAfterDisc, ROPrintData.CustLaborDiscTotal, ROPrintData.CustLaborCGST, ROPrintData.CustLaborSGST, ROPrintData.CustLaborIGST, ROPrintData.CustPartIGST, ROPrintData.ShowIGST, ROPrintData.ShowTaxColumn, ROPrintData.CustPartsTotalAfterDisc, ROPrintData.CustPartsDiscTotal, ROPrintData.CustPartCGST, ROPrintData.CustPartSGST, ROPrintData.TaxSummary, ROPrintData.ShowAccParts, ROPrintData.CustLaborAfterTax, ROPrintData.CustPartAfterTax, ROPrintData.FixedDisc, ROPrintData.For, ROPrintData.FixedTotal, ROPrintData.CustTotalRoundedBy, ROPrintData.CustRoundedTotal, ROPrintData.ShowTaxColumn, ROPrintData.ShowTaxColumn, tr_utils_1.TrUtils.isTaxable(ROPrintData.Settings.Tax), ROPrintData.CustLaborITax, ROPrintData.CustPartITax, ROPrintData.Consolidate, ROPrintData.From, ROPrintData.Adj, ROPrintData.TaxSummary, ROPrintData.STotal, isAuto, moreDiscDetails),
2745
+ InvoicePrintService.GetNumberInWords(ROPrintData.CustRoundedTotal),
2746
+ shared_pdf_service_1.SharedPDFService.InvoiceDueStatus(ROPrintData.Type, ROPrintData.Paid, ROPrintData.Due, ROPrintData.Sts, ROPrintData.isCountersale, ROPrintData.Entity.DecimalsNumber),
2747
+ shared_pdf_service_1.SharedPDFService.GetTemsAndConditions(ROPrintData.Entity.Terms),
2748
+ InvoicePrintService.GetBanckdetailswithQRCode(ROPrintData),
2749
+ shared_pdf_service_1.SharedPDFService.GetUnderLine(),
2750
+ shared_pdf_service_1.SharedPDFService.GetInvSignatures(ROPrintData.Entity.CName, ROPrintData.isCountersale),
2751
+ shared_pdf_service_1.SharedPDFService.GetUnderLine1(withPass),
2752
+ InvoicePrintService.GetGatePass(withPass, ROPrintData)
2753
+ ];
2754
+ if (ROPrintData.Type !== 'Invoice') {
2755
+ CommonDetails.splice(2, 0, shared_pdf_service_1.SharedPDFService.GetUnderLine());
2756
+ }
2757
+ if (!tr_utils_1.TrUtils.IsNull(numberofCopies) && numberofCopies.length !== 0 && (index !== (numberofCopies.length - 1))) {
2758
+ CommonDetails.push({ text: '', pageBreak: 'after' });
2759
+ }
2760
+ return CommonDetails;
2761
+ }
2762
+ static GetBanckdetailswithQRCode(ROPrintData) {
2763
+ return { columns: [shared_pdf_service_1.SharedPDFService.GetBankDetials(ROPrintData.Entity.Bank, ROPrintData.Entity.PrBank, ROPrintData.Entity.UPIPhone),
2764
+ shared_pdf_service_1.SharedPDFService.GetEntityDetails(ROPrintData.Entity)] };
2765
+ }
2766
+ static GetGatePass(isGatepass, ROPrintData) {
2767
+ if (isGatepass) {
2768
+ return {
2769
+ columns: [{
2770
+ id: '567',
2771
+ text: [{ text: '', id: '1234' }],
2772
+ stack: [
2773
+ {
2774
+ columns: [{ text: '' }, { text: 'Gate Pass', bold: true, fontSize: 9, alignment: 'center', marginTop: 5 },
2775
+ { text: 'Date: ' + my_date_1.MyDate.ConvertUTCDateToReadable(my_date_1.MyDate.GetDateTimeNowInUTC(ROPrintData.Entity.User.TZ)), marginTop: 5, fontSize: 9, alignment: 'right' }]
2776
+ },
2777
+ { text: ROPrintData.Entity.CName, alignment: 'center', bold: true, fontSize: 12, marginTop: 5, marginBottom: 5 },
2778
+ {
2779
+ marginTop: 5,
2780
+ columns: [
2781
+ { text: '', width: 60 },
2782
+ InvoicePrintService.GetGatePassCustomerDetails(ROPrintData, false),
2783
+ InvoicePrintService.GetGatePassVehicleDetails(ROPrintData.Product, false)
2784
+ ]
2785
+ },
2786
+ { text: 'Vehicle has been received from workshop and work done as per my satisfaction.', fontSize: 7, marginTop: 10, marginLeft: 60 },
2787
+ { columns: [shared_pdf_service_1.SharedPDFService.CustomerSignature(), { text: '' }, shared_pdf_service_1.SharedPDFService.Accountantsignature()] }
2788
+ ]
2789
+ }],
2790
+ };
2791
+ }
2792
+ else {
2793
+ return shared_pdf_service_1.SharedPDFService.emptyObject();
2794
+ }
2795
+ }
2796
+ static GetGatePassCustomerDetails(ROPrintData, isOtherIndustry) {
2797
+ let CustomerData = [
2798
+ { name: 'Customer Name', value: ROPrintData.Customer.Name },
2799
+ { name: 'Service Advisor', value: ROPrintData.Name },
2800
+ ];
2801
+ return shared_pdf_service_1.SharedPDFService.GetVehicleDataTable(CustomerData);
2802
+ }
2803
+ static GetGatePassVehicleDetails(Vehicle, isOtherIndustry) {
2804
+ let vehicleData = [];
2805
+ if (isOtherIndustry) {
2806
+ vehicleData.push({ name: 'Serial No', value: shared_pdf_service_1.SharedPDFService.CheckAndSetString(Vehicle.SNo) });
2807
+ }
2808
+ let a = [
2809
+ { name: 'Vehicle Model', value: shared_pdf_service_1.SharedPDFService.CheckAndSetString(Vehicle.Model) },
2810
+ ];
2811
+ if (!isOtherIndustry) {
2812
+ a.unshift({ name: 'Regn. No', value: shared_pdf_service_1.SharedPDFService.CheckAndSetString(Vehicle.RegNo) });
2813
+ if (!tr_utils_1.TrUtils.IsEmpty(Vehicle.VIN)) {
2814
+ a.unshift({ name: 'Chassis No', value: shared_pdf_service_1.SharedPDFService.CheckAndSetString(Vehicle.VIN) });
2815
+ }
2816
+ }
2817
+ for (let i = 0; i < a.length; i++) {
2818
+ vehicleData.push(a[i]);
2819
+ }
2820
+ return shared_pdf_service_1.SharedPDFService.GetVehicleDataTable(vehicleData);
2821
+ }
2822
+ }
2823
+ exports.InvoicePrintService = InvoicePrintService;
2824
+ InvoicePrintService.TableHeaders = 9;