shareneus 1.7.4 → 1.7.6

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