shareneus 1.2.6 → 1.2.7

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,787 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InvoiceLetterheadPdfService = void 0;
4
+ const my_date_1 = require("../utils/my-date");
5
+ const tr_utils_1 = require("../utils/tr-utils");
6
+ const shared_pdf_service_1 = require("./shared-pdf.service");
7
+ const shared_print_service_1 = require("./shared-print.service");
8
+ class InvoiceLetterheadPdfService {
9
+ constructor() {
10
+ this.FontSize = 8;
11
+ }
12
+ static GetInvoiceLetterheadPrint(ROPrintData, numberofCopies, isotherIndustry, withPass, isAuto) {
13
+ var contents = [];
14
+ if (tr_utils_1.TrUtils.IsNull(numberofCopies) || numberofCopies.length === 0) {
15
+ contents.push(
16
+ // this.CommonHeaderDetails(ROPrintData, null, isotherIndustry),
17
+ this.PreparesparePartsTable(ROPrintData, isAuto), this.CommonTotalDetails(ROPrintData, null, numberofCopies, withPass, isAuto));
18
+ }
19
+ else {
20
+ numberofCopies.forEach((text, index) => {
21
+ contents.push(this.CommonHeaderDetails(ROPrintData, text, isotherIndustry), this.PreparesparePartsTable(ROPrintData, isAuto), this.CommonTotalDetails(ROPrintData, index, numberofCopies, withPass, isAuto));
22
+ });
23
+ }
24
+ var dd = {
25
+ info: {
26
+ title: this.GetFileName(ROPrintData),
27
+ },
28
+ watermark: this.GetWatermark(ROPrintData, isAuto),
29
+ background: function (currentPage, pageSize) {
30
+ return shared_pdf_service_1.SharedPDFService.GetWatermarkImage(ROPrintData.Image, pageSize, ROPrintData.Entity.Wmark);
31
+ },
32
+ header: function (currentPage, pageCount) {
33
+ return { text: currentPage.toString() + ' of ' + pageCount, alignment: 'right', marginRight: 7, fontSize: 8, marginTop: 2 };
34
+ },
35
+ pageBreakBefore: function (currentNode, followingNodesOnPage, nodesOnNextPage, previousNodesOnPage) {
36
+ 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';
37
+ },
38
+ pageMargins: [10, 140, 10, 120],
39
+ content: contents,
40
+ styles: shared_pdf_service_1.SharedPDFService.GetStyles()
41
+ };
42
+ return dd;
43
+ }
44
+ static GetWatermark(ROPrintData, isAuto) {
45
+ if (isAuto && ROPrintData.IsProforma && ROPrintData.Entity.Wmark) {
46
+ return { text: 'Not a final invoice', opacity: 0.2 };
47
+ }
48
+ else {
49
+ return '';
50
+ }
51
+ }
52
+ static GetFileName(ROPrintData) {
53
+ let fileName = ROPrintData.HeaderName;
54
+ if (!tr_utils_1.TrUtils.IsNull(ROPrintData.Product) && !tr_utils_1.TrUtils.IsEmpty(ROPrintData.Product.RegNo)) {
55
+ fileName = fileName + '-' + ROPrintData.Product.RegNo;
56
+ }
57
+ return fileName;
58
+ }
59
+ static CommonHeaderDetails(ROPrintData, text, isotherIndustry) {
60
+ return [
61
+ // this.GetMainHeaderDetails(ROPrintData.Entity, ROPrintData.HeaderName, ROPrintData.Image, ROPrintData.HColor, ROPrintData.AColor, text),
62
+ 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),
63
+ shared_pdf_service_1.SharedPDFService.GetOwnerDetails(ROPrintData.Cust, ROPrintData.Type, ROPrintData.For),
64
+ shared_pdf_service_1.SharedPDFService.CustomerAndVehicleDetailsAfterLine(),
65
+ shared_pdf_service_1.SharedPDFService.GetDisplayTable(),
66
+ ];
67
+ }
68
+ static GetMainHeaderDetails(Entity, HeaderName, Image, HColor, AColor, text) {
69
+ return [
70
+ // SharedPDFService.MainHeading(Entity.CName, Entity.Header, Image, HColor, text),
71
+ shared_pdf_service_1.SharedPDFService.GetMainHeader(Entity, Image, AColor, HColor, text),
72
+ shared_pdf_service_1.SharedPDFService.GetPrintType(HeaderName),
73
+ shared_pdf_service_1.SharedPDFService.HeaderAfterLine()
74
+ ];
75
+ }
76
+ static PreparesparePartsTable(ROPrintData, isAuto) {
77
+ let List = [];
78
+ if (ROPrintData.Entity.Body === 1) {
79
+ for (let i = 0; i < ROPrintData.PrintInfo.length; i++) {
80
+ if (tr_utils_1.TrUtils.IsNull(ROPrintData.PrintInfo[i].Text)) {
81
+ ROPrintData.PrintInfo[i].Text = '';
82
+ }
83
+ List.push(ROPrintData.PrintInfo[i].Text, this.GetLaborPartsTableForView(tr_utils_1.TrUtils.Stringify(ROPrintData.PrintInfo[i].Items), tr_utils_1.TrUtils.Stringify(ROPrintData.PrintInfo[i].Ops), ROPrintData.Entity.MPN));
84
+ }
85
+ }
86
+ else {
87
+ if (ROPrintData.Entity.Body === 2) {
88
+ for (let i = 0; i < ROPrintData.PrintInfo.length; i++) {
89
+ if (tr_utils_1.TrUtils.IsNull(ROPrintData.PrintInfo[i].Text)) {
90
+ ROPrintData.PrintInfo[i].Text = '';
91
+ }
92
+ List.push(ROPrintData.PrintInfo[i].Text, this.WithOutDiscountFieldTable(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));
93
+ }
94
+ }
95
+ else {
96
+ if (ROPrintData.Summary) {
97
+ List.push('', this.GetLaborPartsTableForView(ROPrintData.Items, ROPrintData.Ops, ROPrintData.Entity.MPN));
98
+ }
99
+ else {
100
+ for (let i = 0; i < ROPrintData.PrintInfo.length; i++) {
101
+ if (tr_utils_1.TrUtils.IsNull(ROPrintData.PrintInfo[i].Text)) {
102
+ ROPrintData.PrintInfo[i].Text = '';
103
+ }
104
+ List.push(ROPrintData.PrintInfo[i].Text, this.GetWithOutDiscAndTaxFieldHeader(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));
105
+ }
106
+ }
107
+ }
108
+ }
109
+ return List;
110
+ }
111
+ static GetLaborPartsTableForView(Parts, Ops, PrintPartNo) {
112
+ if (Parts.length !== 0 || Ops.length !== 0) {
113
+ if (PrintPartNo) {
114
+ return {
115
+ style: 'tableExample',
116
+ // marginLeft: 20,
117
+ table: {
118
+ widths: [25, 30, 170, 85, 15, 20, 50, 30, 30, 50],
119
+ // headerRows: 2,
120
+ body: this.buildTableForCustomerLabor(Parts, Ops, PrintPartNo, false)
121
+ },
122
+ layout: shared_print_service_1.PrintSharedService.LayOutStyleanother()
123
+ };
124
+ }
125
+ else {
126
+ return {
127
+ style: 'tableExample',
128
+ // marginLeft: 20,
129
+ table: {
130
+ widths: [25, 200, 55, 25, 55, 55, 40, 15, 50],
131
+ // headerRows: 2,
132
+ body: this.buildTableForCustomerLabor(Parts, Ops, PrintPartNo, false)
133
+ },
134
+ layout: shared_print_service_1.PrintSharedService.LayOutStyleanother()
135
+ };
136
+ }
137
+ }
138
+ else {
139
+ let a = '';
140
+ return a;
141
+ }
142
+ }
143
+ static WithOutDiscountFieldTable(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn, isAuto) {
144
+ if (Parts.length !== 0 || Ops.length !== 0) {
145
+ if (PrintPartNo) {
146
+ return {
147
+ style: 'tableExample',
148
+ marginLeft: 20,
149
+ table: {
150
+ widths: [25, 60, 155, 30, 50, 60, 30, 50],
151
+ headerRows: 1,
152
+ body: this.BuildTableBodyForLaborAndParts(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn, isAuto)
153
+ },
154
+ layout: shared_print_service_1.PrintSharedService.LayOutStyleanother()
155
+ };
156
+ }
157
+ else {
158
+ return {
159
+ style: 'tableExample',
160
+ marginLeft: 20,
161
+ table: {
162
+ widths: [25, 215, 25, 50, 60, 45, 50],
163
+ headerRows: 1,
164
+ body: this.BuildTableBodyForLaborAndParts(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn, isAuto)
165
+ },
166
+ layout: shared_print_service_1.PrintSharedService.LayOutStyleanother()
167
+ };
168
+ }
169
+ }
170
+ else {
171
+ let a = '';
172
+ return a;
173
+ }
174
+ }
175
+ static BuildTableBodyForLaborAndParts(Parts, Labor, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn, isAuto) {
176
+ var body = [];
177
+ let columns = shared_print_service_1.PrintSharedService.GetWithOutDiscountFieldHeader(PrintPartNo, ShowTaxColumn, Body, ShowIGST, ShowDiscountColumn);
178
+ // if (ShowTaxColumn) {
179
+ for (let i = 0; i < columns.length; i++) {
180
+ body.push(columns[i]);
181
+ }
182
+ columns = columns[1];
183
+ // } else {
184
+ // body.push(columns);
185
+ // }
186
+ let DummyOps = [];
187
+ if (Parts.length !== 0) {
188
+ // console.log('Parts', Parts);
189
+ if (isAuto) {
190
+ let Qty = 0;
191
+ let CGSTAMT = 0;
192
+ let SGSTAMT = 0;
193
+ let IGSTAMT = 0;
194
+ let Taxable = 0;
195
+ let FinalTotal = 0;
196
+ Parts.forEach((part) => {
197
+ // console.log('part', part);
198
+ Qty = Qty + tr_utils_1.TrUtils.FixedTo(part.Qty);
199
+ CGSTAMT = CGSTAMT + tr_utils_1.TrUtils.FixedTo(part.CGSTAmt);
200
+ SGSTAMT = SGSTAMT + tr_utils_1.TrUtils.FixedTo(part.SGSTAmt);
201
+ IGSTAMT = IGSTAMT + tr_utils_1.TrUtils.FixedTo(part.IGSTAmt);
202
+ Taxable = Taxable + tr_utils_1.TrUtils.FixedTo(part.AfterPartDisc);
203
+ FinalTotal = FinalTotal + tr_utils_1.TrUtils.FixedTo(part.AfterPartTax);
204
+ });
205
+ let dpartadding1 = {};
206
+ dpartadding1.SNo = '';
207
+ dpartadding1.Desc = 'Spare Total';
208
+ dpartadding1.QtyAndUoM = tr_utils_1.TrUtils.FixedTo(Qty);
209
+ dpartadding1.bold = true;
210
+ dpartadding1.UnPr = tr_utils_1.TrUtils.FixedTo(Taxable);
211
+ dpartadding1.SGSTAmt = tr_utils_1.TrUtils.FixedTo(SGSTAMT);
212
+ dpartadding1.IGSTAmt = tr_utils_1.TrUtils.FixedTo(IGSTAMT);
213
+ dpartadding1.CGSTAmt = tr_utils_1.TrUtils.FixedTo(CGSTAMT);
214
+ dpartadding1.TCode = ShowTaxColumn ? 114 : undefined;
215
+ dpartadding1.LineTotal = tr_utils_1.TrUtils.FixPriceValue(FinalTotal);
216
+ Parts.push({ SNo: '' });
217
+ Parts.push(dpartadding1);
218
+ }
219
+ let dummypartadding1 = {};
220
+ dummypartadding1.SNo = '';
221
+ dummypartadding1.Desc = 'Spare Parts';
222
+ dummypartadding1.Qty = '';
223
+ dummypartadding1.UnPr = '';
224
+ dummypartadding1.LineTotal = '';
225
+ Parts.unshift(dummypartadding1);
226
+ }
227
+ let SNo = 1;
228
+ Parts.forEach((part) => {
229
+ var dataRow = [];
230
+ columns.forEach((column) => {
231
+ if ((!tr_utils_1.TrUtils.IsFixedZero(part[column.Field]) && !tr_utils_1.TrUtils.IsNull(part[column.Field]))
232
+ || (column.text === 'Line Total')) {
233
+ if (part[column.Field] === 'Spare Parts') {
234
+ dataRow.push({ text: part[column.Field].toString(), marginLeft: 50, style: 'InlineHeader' });
235
+ }
236
+ else {
237
+ if (((column.Field === 'CGSTAmt' || column.Field === 'SGSTAmt' || column.Field === 'CGSTPerc' || column.Field === 'SGSTPerc' || column.Field === 'IGSTAmt' || column.Field === 'IGSTPerc')
238
+ && tr_utils_1.TrUtils.CheckInvalidSelect(part.TCode))) {
239
+ part[column.Field] = '';
240
+ dataRow.push({ text: part[column.Field].toString(), alignment: 'center' });
241
+ }
242
+ else {
243
+ if (column.text === 'Line Total' || column.Field === 'UnPr' || column.Field === 'QtyAndUoM'
244
+ || column.text === 'Tax' || column.Field === 'Disc' || column.Field === 'Perc' || column.Field === 'CGSTAmt' || column.Field === 'SGSTAmt'
245
+ || column.Field === 'CGSTPerc' || column.Field === 'SGSTPerc' || column.Field === 'IGSTAmt' || column.Field === 'IGSTPerc') {
246
+ if (column.Field === 'Disc') {
247
+ if (column.type === 'percentage') {
248
+ if (!tr_utils_1.TrUtils.IsEmpty(part[column.Field])) {
249
+ dataRow.push({ text: part[column.Field].toString(), noWrap: true });
250
+ }
251
+ else {
252
+ dataRow.push({ text: '', noWrap: true });
253
+ }
254
+ }
255
+ else {
256
+ if (!tr_utils_1.TrUtils.IsNull(part[column.Field])) {
257
+ dataRow.push({ text: part[column.Field].toString(), noWrap: true });
258
+ }
259
+ else {
260
+ dataRow.push({ text: '', noWrap: true });
261
+ }
262
+ }
263
+ }
264
+ else {
265
+ if (!tr_utils_1.TrUtils.IsNull(part[column.Field])) {
266
+ dataRow.push({ text: part[column.Field].toString(), bold: part.bold, alignment: 'right', nowrap: true });
267
+ }
268
+ else {
269
+ dataRow.push({ text: '', noWrap: true });
270
+ }
271
+ }
272
+ }
273
+ else {
274
+ // dataRow.push(part[column.Field].toString());
275
+ if (column.Field === 'Desc') {
276
+ let DescData = [];
277
+ DescData.push({ text: part[column.Field].toString(), bold: part.bold });
278
+ if (!tr_utils_1.TrUtils.IsEmpty(part['EDesc'])) {
279
+ DescData.push({ text: part['EDesc'].toString(), color: 'grey' });
280
+ }
281
+ dataRow.push({ stack: DescData });
282
+ }
283
+ else {
284
+ dataRow.push({ text: part[column.Field].toString() });
285
+ }
286
+ }
287
+ }
288
+ }
289
+ }
290
+ else {
291
+ if (column.Field === 'SNo') {
292
+ part[column.Field] = SNo;
293
+ SNo = SNo + 1;
294
+ }
295
+ else {
296
+ if (tr_utils_1.TrUtils.IsNull(part[column.Field])) {
297
+ part[column.Field] = '';
298
+ }
299
+ }
300
+ dataRow.push({ text: part[column.Field].toString(), alignment: 'center' });
301
+ }
302
+ });
303
+ body.push(dataRow);
304
+ });
305
+ SNo = 1;
306
+ if (Labor.length !== 0) {
307
+ // let Qty: number = 0;
308
+ if (isAuto) {
309
+ let CGSTAMT = 0;
310
+ let SGSTAMT = 0;
311
+ let IGSTAMT = 0;
312
+ let Taxable = 0;
313
+ let FinalTotal = 0;
314
+ Labor.forEach((operation) => {
315
+ // console.log('operation', operation);
316
+ // Qty = Qty + operation.Qty;
317
+ CGSTAMT = CGSTAMT + tr_utils_1.TrUtils.FixedTo(operation.CGSTAmt);
318
+ SGSTAMT = SGSTAMT + tr_utils_1.TrUtils.FixedTo(operation.SGSTAmt);
319
+ IGSTAMT = IGSTAMT + tr_utils_1.TrUtils.FixedTo(operation.IGSTAmt);
320
+ Taxable = Taxable + tr_utils_1.TrUtils.FixedTo(operation.AfterLaborDisc);
321
+ FinalTotal = FinalTotal + tr_utils_1.TrUtils.FixedTo(operation.AfterLaborTax);
322
+ });
323
+ let dpartadding1 = {};
324
+ dpartadding1.SNo = '';
325
+ dpartadding1.Desc = 'Labor Total';
326
+ // dpartadding1.QtyAndUoM = Qty;
327
+ dpartadding1.UnPr = tr_utils_1.TrUtils.FixedTo(Taxable);
328
+ dpartadding1.SGSTAmt = tr_utils_1.TrUtils.FixedTo(SGSTAMT);
329
+ dpartadding1.IGSTAmt = tr_utils_1.TrUtils.FixedTo(IGSTAMT);
330
+ dpartadding1.CGSTAmt = tr_utils_1.TrUtils.FixedTo(CGSTAMT);
331
+ dpartadding1.TCode = ShowTaxColumn ? 114 : undefined;
332
+ dpartadding1.bold = true;
333
+ dpartadding1.LineTotal = tr_utils_1.TrUtils.FixPriceValue(FinalTotal);
334
+ Labor.push({ SNo: '' });
335
+ Labor.push(dpartadding1);
336
+ }
337
+ let dummypartadding1 = {};
338
+ dummypartadding1.SNo = '';
339
+ dummypartadding1.Desc = 'Labor';
340
+ dummypartadding1.Qty = '';
341
+ dummypartadding1.UnPr = '';
342
+ dummypartadding1.LineTotal = '';
343
+ Labor.unshift(dummypartadding1);
344
+ // DummyOps.unshift(dummypartadding1);
345
+ }
346
+ if (Body === 2) {
347
+ for (let i = 0; i < Labor.length; i++) {
348
+ Labor[i].UnPr = '';
349
+ }
350
+ }
351
+ Labor.forEach((Ops) => {
352
+ var dataRow = [];
353
+ columns.forEach((column) => {
354
+ if ((!tr_utils_1.TrUtils.IsFixedZero(Ops[column.Field]) && !tr_utils_1.TrUtils.IsNull(Ops[column.Field]))
355
+ || (column.text === 'Line Total')) {
356
+ if (Ops[column.Field] === 'Labor') {
357
+ dataRow.push({ text: Ops[column.Field].toString(), marginLeft: 50, style: 'InlineHeader' });
358
+ }
359
+ else {
360
+ if (((column.Field === 'CGSTAmt' || column.Field === 'SGSTAmt' || column.Field === 'CGSTPerc' || column.Field === 'SGSTPerc' || column.Field === 'IGSTAmt' || column.Field === 'IGSTPerc')
361
+ && tr_utils_1.TrUtils.CheckInvalidSelect(Ops.TCode))) {
362
+ Ops[column.Field] = '';
363
+ dataRow.push({ text: Ops[column.Field].toString(), alignment: 'center' });
364
+ }
365
+ else {
366
+ if (column.text === 'Line Total' || column.Field === 'Price' || column.text === 'Tax' || column.Field === 'UnPr'
367
+ || column.Field === 'QtyAndUoM' || column.Field === 'Disc' || column.Field === 'Perc' || column.Field === 'CGSTAmt' || column.Field === 'SGSTAmt'
368
+ || column.Field === 'CGSTPerc' || column.Field === 'SGSTPerc' || column.Field === 'IGSTAmt' || column.Field === 'IGSTPerc') {
369
+ if (column.Field === 'Disc') {
370
+ if (column.type === 'percentage') {
371
+ if (!tr_utils_1.TrUtils.IsEmpty(Ops[column.Field])) {
372
+ dataRow.push({ text: Ops[column.Field].toString(), noWrap: true });
373
+ }
374
+ else {
375
+ dataRow.push({ text: '', noWrap: true });
376
+ }
377
+ }
378
+ else {
379
+ if (!tr_utils_1.TrUtils.IsNull(Ops[column.Field])) {
380
+ dataRow.push({ text: Ops[column.Field].toString(), noWrap: true });
381
+ }
382
+ else {
383
+ dataRow.push({ text: '', noWrap: true });
384
+ }
385
+ }
386
+ }
387
+ else {
388
+ if (!tr_utils_1.TrUtils.IsNull(Ops[column.Field])) {
389
+ dataRow.push({ text: Ops[column.Field].toString(), alignment: 'right', nowrap: true, bold: Ops.bold });
390
+ }
391
+ else {
392
+ dataRow.push({ text: '', noWrap: true });
393
+ }
394
+ }
395
+ }
396
+ else {
397
+ dataRow.push({ text: Ops[column.Field].toString(), bold: Ops.bold });
398
+ }
399
+ }
400
+ }
401
+ }
402
+ else {
403
+ if (column.Field === 'SNo') {
404
+ Ops[column.Field] = SNo;
405
+ SNo = SNo + 1;
406
+ }
407
+ else {
408
+ if (tr_utils_1.TrUtils.IsNull(Ops[column.Field])) {
409
+ Ops[column.Field] = '';
410
+ }
411
+ }
412
+ dataRow.push({ text: Ops[column.Field].toString(), alignment: 'center' });
413
+ }
414
+ });
415
+ body.push(dataRow);
416
+ });
417
+ return body;
418
+ }
419
+ static GetWithOutDiscAndTaxFieldHeader(Parts, Ops, ShowTaxColumn, PrintPartNo, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn, isAuto) {
420
+ if (Parts.length !== 0 || Ops.length !== 0) {
421
+ if (ShowTaxColumn) {
422
+ return this.TaxDataTable(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn, isAuto);
423
+ }
424
+ else {
425
+ if (ConsolidateGST) {
426
+ return this.ConsolidateDataTable(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn, isAuto);
427
+ }
428
+ else {
429
+ return this.NoTaxDataTable(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn, isAuto);
430
+ }
431
+ }
432
+ }
433
+ else {
434
+ let a = '';
435
+ return a;
436
+ }
437
+ }
438
+ static TaxDataTable(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn, isAuto) {
439
+ if (PrintPartNo) {
440
+ if (ShowIGST) {
441
+ return {
442
+ style: 'tableExample',
443
+ table: {
444
+ widths: shared_print_service_1.PrintSharedService.TaxTableWidths(PrintPartNo, ShowIGST, ShowDiscountColumn),
445
+ // headerRows: 2,
446
+ body: this.BuildTableBodyForLaborAndParts(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn, isAuto)
447
+ },
448
+ layout: shared_print_service_1.PrintSharedService.LayOutStyle()
449
+ };
450
+ }
451
+ else {
452
+ return {
453
+ style: 'tableExample',
454
+ table: {
455
+ widths: shared_print_service_1.PrintSharedService.TaxTableWidths(PrintPartNo, ShowIGST, ShowDiscountColumn),
456
+ // headerRows: 2,
457
+ body: this.BuildTableBodyForLaborAndParts(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn, isAuto)
458
+ },
459
+ layout: shared_print_service_1.PrintSharedService.LayOutStyle()
460
+ };
461
+ }
462
+ }
463
+ else {
464
+ if (ShowIGST) {
465
+ return {
466
+ style: 'tableExample',
467
+ table: {
468
+ widths: shared_print_service_1.PrintSharedService.TaxTableWidths(PrintPartNo, ShowIGST, ShowDiscountColumn),
469
+ // headerRows: 2,
470
+ body: this.BuildTableBodyForLaborAndParts(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn, isAuto)
471
+ },
472
+ layout: shared_print_service_1.PrintSharedService.LayOutStyle()
473
+ };
474
+ }
475
+ else {
476
+ return {
477
+ style: 'tableExample',
478
+ table: {
479
+ widths: shared_print_service_1.PrintSharedService.TaxTableWidths(PrintPartNo, ShowIGST, ShowDiscountColumn),
480
+ // headerRows: 2,
481
+ body: this.BuildTableBodyForLaborAndParts(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn, isAuto)
482
+ },
483
+ layout: shared_print_service_1.PrintSharedService.LayOutStyle()
484
+ };
485
+ }
486
+ }
487
+ }
488
+ static ConsolidateDataTable(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn, isAuto) {
489
+ if (PrintPartNo) {
490
+ return {
491
+ style: 'tableExample',
492
+ table: {
493
+ widths: [25, 70, 263, 25, 60, 80, 10, 40],
494
+ // headerRows: 1,
495
+ body: this.BuildTableBodyForLaborAndParts(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn, isAuto)
496
+ },
497
+ layout: shared_print_service_1.PrintSharedService.LayOutStyle()
498
+ };
499
+ }
500
+ else {
501
+ return {
502
+ style: 'tableExample',
503
+ table: {
504
+ widths: [25, 295, 50, 80, 80, 10, 40],
505
+ // headerRows: 1,
506
+ body: this.BuildTableBodyForLaborAndParts(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn, isAuto)
507
+ },
508
+ layout: shared_print_service_1.PrintSharedService.LayOutStyle()
509
+ };
510
+ }
511
+ }
512
+ static NoTaxDataTable(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn, isAuto) {
513
+ if (PrintPartNo) {
514
+ return {
515
+ style: 'tableExample',
516
+ table: {
517
+ widths: shared_print_service_1.PrintSharedService.WidthForInsuranceOrNot(ShowDiscountColumn, PrintPartNo),
518
+ // headerRows: 1,
519
+ body: this.BuildTableBodyForLaborAndParts(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn, isAuto)
520
+ },
521
+ layout: shared_print_service_1.PrintSharedService.LayOutStyle()
522
+ };
523
+ }
524
+ else {
525
+ return {
526
+ style: 'tableExample',
527
+ table: {
528
+ widths: shared_print_service_1.PrintSharedService.WidthForInsuranceOrNot(ShowDiscountColumn, PrintPartNo),
529
+ // headerRows: 1,
530
+ body: this.BuildTableBodyForLaborAndParts(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn, isAuto)
531
+ },
532
+ layout: shared_print_service_1.PrintSharedService.LayOutStyle()
533
+ };
534
+ }
535
+ }
536
+ static buildTableForCustomerLabor(Parts, Ops, PrintPartNo, customerorInsurance) {
537
+ var body = [];
538
+ let columns;
539
+ columns = this.getSummaryHeaders(PrintPartNo);
540
+ body.push(columns);
541
+ if (Parts.length !== 0) {
542
+ let dummypartadding1 = {};
543
+ dummypartadding1.SNo = '';
544
+ dummypartadding1.Desc = 'Spare Parts';
545
+ dummypartadding1.Qty = '';
546
+ dummypartadding1.UnPr = '';
547
+ dummypartadding1.Price = '';
548
+ dummypartadding1.DiscountedPrice = '';
549
+ dummypartadding1.LineTotal = '';
550
+ dummypartadding1.QtyAndUoM = '';
551
+ dummypartadding1.HSN = '';
552
+ dummypartadding1.MPN = '';
553
+ Parts.unshift(dummypartadding1);
554
+ }
555
+ let SNo = 1;
556
+ Parts.forEach((part) => {
557
+ var dataRow = [];
558
+ columns.forEach((column) => {
559
+ if (!tr_utils_1.TrUtils.IsFixedZero(part[column.Field]) && !tr_utils_1.TrUtils.IsNull(part[column.Field])
560
+ || column.text === 'Line Total') {
561
+ if (part[column.Field] === 'Spare Parts') {
562
+ dataRow.push({ text: part[column.Field].toString(), marginLeft: 50, style: 'InlineHeader' });
563
+ }
564
+ else {
565
+ // tslint:disable-next-line:max-line-length
566
+ if (column.text === 'Line Total' || column.Field === 'QtyAndUoM' || column.Field === 'CustPrice' || column.Field === 'InsPrice' ||
567
+ column.Field === 'DiscountedPrice' || column.Field === 'TaxAmount' || column.Field === 'UnPr') {
568
+ if (column.Field === 'Disc Amt') {
569
+ dataRow.push({ text: part[column.Field].toString(), alignment: 'right', noWrap: true });
570
+ }
571
+ else {
572
+ dataRow.push({ text: part[column.Field].toString(), alignment: 'right', nowrap: true });
573
+ }
574
+ }
575
+ else {
576
+ if (column.Field === 'Desc') {
577
+ let DescData = [];
578
+ DescData.push(part[column.Field].toString());
579
+ if (!tr_utils_1.TrUtils.IsEmpty(part['EDesc'])) {
580
+ DescData.push({ text: part['EDesc'].toString(), color: 'grey' });
581
+ }
582
+ dataRow.push({ stack: DescData });
583
+ }
584
+ else {
585
+ dataRow.push({ text: part[column.Field].toString() });
586
+ }
587
+ }
588
+ }
589
+ }
590
+ else {
591
+ if (column.Field === 'SNo') {
592
+ part[column.Field] = SNo;
593
+ SNo = SNo + 1;
594
+ }
595
+ else {
596
+ if (tr_utils_1.TrUtils.IsNull(part[column.Field])) {
597
+ part[column.Field] = '';
598
+ }
599
+ }
600
+ dataRow.push({ text: part[column.Field].toString(), alignment: 'center' });
601
+ }
602
+ });
603
+ body.push(dataRow);
604
+ });
605
+ SNo = 1;
606
+ if (Ops.length !== 0) {
607
+ let dummypartadding1 = {};
608
+ dummypartadding1.SNo = '';
609
+ dummypartadding1.Desc = 'Labor';
610
+ dummypartadding1.Qty = '';
611
+ dummypartadding1.UnPr = '';
612
+ dummypartadding1.Price = '';
613
+ dummypartadding1.DiscountedPrice = '';
614
+ dummypartadding1.LineTotal = '';
615
+ dummypartadding1.QtyAndUoM = '';
616
+ dummypartadding1.HSN = '';
617
+ Ops.unshift(dummypartadding1);
618
+ }
619
+ Ops.forEach((labor) => {
620
+ var dataRow = [];
621
+ columns.forEach((column) => {
622
+ if (!tr_utils_1.TrUtils.IsFixedZero(labor[column.Field]) && !tr_utils_1.TrUtils.IsNull(labor[column.Field])
623
+ || column.text === 'Line Total') {
624
+ if (labor[column.Field] === 'Labor') {
625
+ dataRow.push({ text: labor[column.Field].toString(), marginLeft: 50, style: 'InlineHeader' });
626
+ }
627
+ else {
628
+ if (column.text === 'Line Total' || column.Field === 'QtyAndUoM' || column.Field === 'DiscountedPrice' || column.Field === 'TaxAmount'
629
+ || column.Field === 'UnPr' || column.Field === 'CustPrice' || column.Field === 'InsPrice') {
630
+ if (column.Field === 'Disc Amt') {
631
+ dataRow.push({ text: labor[column.Field].toString(), alignment: 'right', noWrap: true });
632
+ }
633
+ else {
634
+ dataRow.push({ text: labor[column.Field].toString(), alignment: 'right', nowrap: true });
635
+ }
636
+ }
637
+ else {
638
+ dataRow.push({ text: labor[column.Field].toString() });
639
+ }
640
+ }
641
+ }
642
+ else {
643
+ if (column.Field === 'SNo') {
644
+ labor[column.Field] = SNo;
645
+ SNo = SNo + 1;
646
+ }
647
+ else {
648
+ if (tr_utils_1.TrUtils.IsNull(labor[column.Field])) {
649
+ labor[column.Field] = '';
650
+ }
651
+ }
652
+ dataRow.push({ text: labor[column.Field].toString(), alignment: 'center' });
653
+ }
654
+ });
655
+ body.push(dataRow);
656
+ });
657
+ return body;
658
+ }
659
+ static getSummaryHeaders(permission) {
660
+ let headersNames = [{ text: 'Description', style: 'tableheader', Field: 'Desc' },
661
+ { text: 'HSN / SAC', style: 'tableheader', Field: 'SAC' },
662
+ { text: 'Qty', style: 'tableheader', Field: 'QtyAndUoM' },
663
+ // { text: 'Rate / Unit', style: 'tableheader', Field: 'UnPr' },
664
+ { text: 'Ins. Amt', style: 'tableheader', Field: 'AssPr' },
665
+ { text: 'Cust. Amt', style: 'tableheader', Field: 'Pr' },
666
+ { text: 'Disc.(Rs)', style: 'tableheader', Field: 'DiscountedPrice' },
667
+ { text: 'Tax %', style: 'tableheader', Field: 'TaxAmount' },
668
+ { text: 'Line Total', style: 'tableheader', Field: 'LineTotal' }];
669
+ if (permission) {
670
+ let sno = { text: 'S.No.', style: 'tableheader', Field: 'SNo' };
671
+ let MPN = { text: 'Part No', style: 'tableheader', Field: 'MPN' };
672
+ headersNames.unshift(sno, MPN);
673
+ }
674
+ else {
675
+ let sno = { text: 'S.No.', style: 'tableheader', Field: 'SNo' };
676
+ headersNames.unshift(sno);
677
+ }
678
+ return headersNames;
679
+ }
680
+ static CommonTotalDetails(ROPrintData, index, numberofCopies, withPass, isAuto) {
681
+ // console.log('ROPrintData', ROPrintData);
682
+ let CommonDetails = [
683
+ // SharedPDFService.GetFinalTotalDetails(ROPrintData.CustLaborTotalAfterDisc, ROPrintData.CustLaborDiscTotal, ROPrintData.CustLaborCGST,
684
+ // ROPrintData.CustLaborSGST, ROPrintData.CustLaborIGST, ROPrintData.CustPartIGST, ROPrintData.ShowIGST, ROPrintData.ShowTaxColumn,
685
+ // ROPrintData.CustPartsTotalAfterDisc, ROPrintData.CustPartsDiscTotal, ROPrintData.CustPartCGST,
686
+ // ROPrintData.CustPartSGST, ROPrintData.CustTaxGroupData, ROPrintData.ShowAccParts,
687
+ // ROPrintData.CustLaborAfterTax, ROPrintData.CustPartAfterTax, ROPrintData.FixedDisc, ROPrintData.For,
688
+ // ROPrintData.FixedTotal, ROPrintData.CustTotalRoundedBy, ROPrintData.CustRoundedTotal,
689
+ // ROPrintData.ShowTaxColumn, ROPrintData.ShowTaxColumn,
690
+ // TrUtils.isTaxable(ROPrintData.Settings.Tax), ROPrintData.CustLaborITax,
691
+ // ROPrintData.CustPartITax, ROPrintData.Consolidate, ROPrintData.From, ROPrintData.Adj,ROPrintData.STotal),
692
+ shared_pdf_service_1.SharedPDFService.GetFinalTotalDetails1(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(ROPrintData.Settings.Tax), ROPrintData.CustLaborITax, ROPrintData.CustPartITax, ROPrintData.Consolidate, ROPrintData.From, ROPrintData.Adj, ROPrintData.CustLaborTaxGroupDataByPerc, ROPrintData.STotal, isAuto),
693
+ this.GetNumberInWords(ROPrintData.CustRoundedTotal),
694
+ shared_pdf_service_1.SharedPDFService.InvoiceDueStatus(ROPrintData.Type, ROPrintData.Paid, ROPrintData.Due, ROPrintData.Sts, ROPrintData.isCountersale),
695
+ shared_pdf_service_1.SharedPDFService.GetTemsAndConditions(ROPrintData.Entity.Terms),
696
+ this.GetBanckdetailswithQRCode(ROPrintData),
697
+ shared_pdf_service_1.SharedPDFService.GetUnderLine(),
698
+ shared_pdf_service_1.SharedPDFService.GetInvSignatures(ROPrintData.Entity.CName, ROPrintData.isCountersale),
699
+ // this.PageBrake(ROPrintData, withPass),
700
+ shared_pdf_service_1.SharedPDFService.GetUnderLine1(withPass),
701
+ this.GetGatePass(withPass, ROPrintData)
702
+ ];
703
+ if (ROPrintData.Type !== 'Invoice') {
704
+ CommonDetails.splice(2, 0, shared_pdf_service_1.SharedPDFService.GetUnderLine());
705
+ }
706
+ if (!tr_utils_1.TrUtils.IsNull(numberofCopies) && numberofCopies.length !== 0 && (index !== (numberofCopies.length - 1))) {
707
+ CommonDetails.push({ text: '', pageBreak: 'after' });
708
+ }
709
+ return CommonDetails;
710
+ }
711
+ static GetBanckdetailswithQRCode(ROPrintData) {
712
+ return { columns: [shared_pdf_service_1.SharedPDFService.GetBankDetials(ROPrintData.Entity.Bank, ROPrintData.Entity.PrBank),
713
+ shared_pdf_service_1.SharedPDFService.GetEntityDetails(ROPrintData.Entity)] };
714
+ }
715
+ static GetNumberInWords(TotalAmount) {
716
+ var rupee = shared_pdf_service_1.SharedPDFService.convertNumberToWords(TotalAmount);
717
+ // console.log('rupee', rupee);
718
+ return { columns: [{ text: 'In Words :', fontSize: 9, width: 45 }, { text: rupee, bold: true, fontSize: 9, width: '*' }] };
719
+ }
720
+ static GetGatePass(isGatepass, ROPrintData) {
721
+ // console.log('ROPrintData', ROPrintData);
722
+ if (isGatepass) {
723
+ return {
724
+ columns: [{
725
+ id: '567',
726
+ text: [{ text: '', id: '1234' }],
727
+ stack: [
728
+ {
729
+ columns: [{ text: '' }, { text: 'Gate Pass', bold: true, fontSize: 9, alignment: 'center', marginTop: 5 },
730
+ { text: 'Date: ' + my_date_1.MyDate.ConvertUTCDateToReadable(my_date_1.MyDate.GetDateTimeNowInUTC()), marginTop: 5, fontSize: 9, alignment: 'right' }]
731
+ },
732
+ { text: ROPrintData.Entity.CName, alignment: 'center', bold: true, fontSize: 12, marginTop: 5, marginBottom: 5 },
733
+ {
734
+ marginTop: 5,
735
+ columns: [
736
+ // {
737
+ // stack: [{ text: 'Customer Name :' + ROPrintData.Customer.Name, fontSize: 9 }, { text: 'Service Advisor :', fontSize: 9, marginBottom: 10 },
738
+ // { text: 'Vehicle has been received from workshop and work done as per my satisfaction.', fontSize: 6 }]
739
+ // }
740
+ { text: '', width: 60 },
741
+ this.GetCustomerDetails(ROPrintData, false),
742
+ this.GetVehicleDetails(ROPrintData.Product, false)
743
+ // {
744
+ // stack: [{ text: 'Chassis No :' + ROPrintData.Product.VIN, fontSize: 9 },
745
+ // { text: 'Vehicle No :' + ROPrintData.Product.RegNo, fontSize: 9 }, { text: 'Vehicle Model :' + ROPrintData.Product.Model, fontSize: 9 }, { text: 'Repair Order No :', fontSize: 9 }]
746
+ // }
747
+ ]
748
+ },
749
+ { text: 'Vehicle has been received from workshop and work done as per my satisfaction.', fontSize: 7, marginTop: 10, marginLeft: 60 },
750
+ { columns: [shared_pdf_service_1.SharedPDFService.CustomerSignature(), { text: '' }, shared_pdf_service_1.SharedPDFService.Accountantsignature()] }
751
+ ]
752
+ }],
753
+ };
754
+ }
755
+ else {
756
+ return shared_pdf_service_1.SharedPDFService.emptyObject();
757
+ }
758
+ }
759
+ static GetCustomerDetails(ROPrintData, isOtherIndustry) {
760
+ let CustomerData = [
761
+ { name: 'Customer Name', value: ROPrintData.Customer.Name },
762
+ { name: 'Service Advisor', value: ROPrintData.Name },
763
+ ];
764
+ return shared_pdf_service_1.SharedPDFService.GetVehicleDataTable(CustomerData);
765
+ }
766
+ static GetVehicleDetails(Vehicle, isOtherIndustry) {
767
+ let vehicleData;
768
+ vehicleData = [];
769
+ if (isOtherIndustry) {
770
+ vehicleData.push({ name: 'Serial No', value: shared_pdf_service_1.SharedPDFService.CheckAndSetString(Vehicle.SNo) });
771
+ }
772
+ let a = [
773
+ { name: 'Vehicle Model', value: shared_pdf_service_1.SharedPDFService.CheckAndSetString(Vehicle.Model) },
774
+ ];
775
+ if (!isOtherIndustry) {
776
+ a.unshift({ name: 'Regn. No', value: shared_pdf_service_1.SharedPDFService.CheckAndSetString(Vehicle.RegNo) });
777
+ if (!tr_utils_1.TrUtils.IsEmpty(Vehicle.VIN)) {
778
+ a.unshift({ name: 'Chassis No', value: shared_pdf_service_1.SharedPDFService.CheckAndSetString(Vehicle.VIN) });
779
+ }
780
+ }
781
+ for (let i = 0; i < a.length; i++) {
782
+ vehicleData.push(a[i]);
783
+ }
784
+ return shared_pdf_service_1.SharedPDFService.GetVehicleDataTable(vehicleData);
785
+ }
786
+ }
787
+ exports.InvoiceLetterheadPdfService = InvoiceLetterheadPdfService;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shareneus",
3
- "version": "1.2.6",
3
+ "version": "1.2.7",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",