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,881 @@
1
+
2
+ import { ROTypeEnum } from '../enums/code-enums';
3
+ import { LaborStatusEnum, PayTypeEnum, ROStatusEnum } from '../enums/enums';
4
+ import { Add } from '../shared/math-operations';
5
+ import { PrintSharedService } from '../shared/shared-print.service';
6
+ import { MyDate } from '../utils/my-date';
7
+ import { TrUtils } from '../utils/tr-utils';
8
+ import { ROTotalsService } from './ro-totals.service';
9
+
10
+ export class ROPrintService {
11
+
12
+ static GetTaxAmountFromGroup(item: any, taxGroupKey: string, taxCode: string, fallbackKey: string) {
13
+ const groupedTaxes = item?.[taxGroupKey];
14
+ if (Array.isArray(groupedTaxes)) {
15
+ const matchedTaxes = groupedTaxes.filter((tax: any) => tax?.Code === taxCode);
16
+ if (matchedTaxes.length !== 0) {
17
+ return matchedTaxes.reduce((total: number, tax: any) => Add(total, tax?.Amt), 0);
18
+ }
19
+ }
20
+ return TrUtils.SetValueToZeroIfNull(item?.[fallbackKey]);
21
+ }
22
+
23
+ static GetTCode(item: any) {
24
+ const taxGroupKeys: string[] = ['CTaxes', 'ATaxes', 'ETaxes'];
25
+
26
+ for (const taxGroupKey of taxGroupKeys) {
27
+ const groupedTaxes = item?.[taxGroupKey];
28
+ if (!Array.isArray(groupedTaxes)) {
29
+ continue;
30
+ }
31
+
32
+ const matchedTax = groupedTaxes.find((tax: any) => !TrUtils.IsNull(tax?.TaxCodeId));
33
+ if (!TrUtils.IsNull(matchedTax?.TaxCodeId)) {
34
+ return matchedTax.TaxCodeId;
35
+ }
36
+ }
37
+
38
+ return item?.TCode;
39
+ }
40
+
41
+ static GetTaxRateFromGroup(item: any, taxGroupKey: string, taxCode: string) {
42
+ const groupedTaxes = item?.[taxGroupKey];
43
+ if (Array.isArray(groupedTaxes)) {
44
+ const matchedTaxes = groupedTaxes.filter((tax: any) => tax?.Code === taxCode);
45
+ if (matchedTaxes.length !== 0) {
46
+ return TrUtils.FixedTo(matchedTaxes.reduce((total: number, tax: any) => Add(total, tax?.Rate), 0));
47
+ }
48
+ }
49
+ return 0;
50
+ }
51
+
52
+ static GetTaxRate(item: any, taxCode: string, preferredTaxGroupKey?: string) {
53
+ const taxGroupKeys: string[] = [];
54
+
55
+ if (typeof preferredTaxGroupKey === 'string' && preferredTaxGroupKey.length !== 0) {
56
+ taxGroupKeys.push(preferredTaxGroupKey);
57
+ }
58
+ ['CTaxes', 'ATaxes', 'ETaxes'].forEach((groupKey: string) => {
59
+ if (taxGroupKeys.indexOf(groupKey) === -1) {
60
+ taxGroupKeys.push(groupKey);
61
+ }
62
+ });
63
+
64
+ for (const taxGroupKey of taxGroupKeys) {
65
+ const rate = this.GetTaxRateFromGroup(item, taxGroupKey, taxCode);
66
+ if (!TrUtils.IsZero(rate)) {
67
+ return rate;
68
+ }
69
+ }
70
+ return 0;
71
+ }
72
+
73
+ static GetRepairOrderPrintInfo(OriginalROData: any, OriginalCustomerData: any, OriginalVehicleData: any,
74
+ OriginalEntityData: any, image: any,
75
+ IncludeGST: boolean, ConsolidateGST: boolean, Payee: any, InsCompanyName: any, AsCustomerOnly: boolean,
76
+ AsInsuranceOnly: boolean, TaxCodes: any, OrderType: any, isReverse:boolean) {
77
+
78
+ let ROPrintData: any = {};
79
+
80
+ let argROData = TrUtils.Stringify(OriginalROData);
81
+ argROData.Comps = TrUtils.IsNull(argROData.Comps) ? [] : argROData.Comps;
82
+ argROData.Ops = TrUtils.IsNull(argROData.Ops) ? [] : argROData.Ops;
83
+ argROData.Parts = TrUtils.IsNull(argROData.Parts) ? [] : argROData.Parts;
84
+ argROData.Colli = TrUtils.IsNull(argROData.Colli) ? [] : argROData.Colli;
85
+
86
+ if (!IncludeGST) {
87
+ argROData.Settings.Tax = 'NO';
88
+ }
89
+
90
+ let SType: any
91
+
92
+ if (!TrUtils.IsNull(OriginalROData.SType)) {
93
+ SType = OriginalROData.SType
94
+ }
95
+
96
+ ROPrintData = this.GetROBasicDetailsForPrint(ROPrintData, argROData, OriginalVehicleData, OrderType);
97
+
98
+ ROPrintData = this.GetPrintConditionsBasedOnInput(ROPrintData, IncludeGST, ConsolidateGST, Payee,
99
+ AsCustomerOnly, AsInsuranceOnly, SType);
100
+
101
+ ROPrintData.Entity = PrintSharedService.GetFormattedEntityDataForPrint(OriginalEntityData, "Work Order", OriginalROData);
102
+
103
+ ROPrintData = PrintSharedService.GetEntityHeaderStyles(ROPrintData, OriginalEntityData, image);
104
+
105
+ if (Payee === PayTypeEnum.Insurance) {
106
+ ROPrintData = this.GetInsDetailsForPrint(ROPrintData, InsCompanyName, argROData);
107
+ }
108
+
109
+ argROData = this.CheckStatusAndChangeDeclinedItemsToNew(argROData);
110
+
111
+ argROData = this.GetValidItemsForTotals(argROData);
112
+
113
+ argROData.Ops = this.SeparateROLaborByPType(argROData.Ops, Payee, AsCustomerOnly,
114
+ AsInsuranceOnly);
115
+
116
+ argROData.Parts = this.SeparateROPartsByPType(argROData.Parts, Payee, AsCustomerOnly,
117
+ AsInsuranceOnly);
118
+
119
+ argROData.Colli = this.SeparateROCollisionsByPType(argROData.Colli, argROData.Ops, argROData.Parts);
120
+
121
+ // argROData = this.ResetDescForPrint(argROData);
122
+
123
+ argROData.Parts = this.ResetQtyAndUoM(argROData.Parts);
124
+
125
+ if (AsInsuranceOnly) {
126
+ ROPrintData.ShowAccParts = true;
127
+ } else {
128
+ ROPrintData.ShowAccParts = this.CheckAndShowItemsAsAR(argROData);
129
+ }
130
+
131
+ argROData = this.ReverseItemsForROPrint(argROData, isReverse);
132
+
133
+ let finalTotalsData: any = ROTotalsService.GetTotalsValue(argROData, TaxCodes, true, true, true, ROPrintData.Entity.Round, ROPrintData.Entity);
134
+
135
+ finalTotalsData.Settings = TrUtils.Stringify(argROData.Settings);
136
+
137
+ finalTotalsData = this.GetDetailedInfoForItems(finalTotalsData, IncludeGST, ConsolidateGST, AsCustomerOnly,
138
+ AsInsuranceOnly, TaxCodes, ROPrintData.Entity.DecimalsNumber);
139
+
140
+ if (ConsolidateGST) {
141
+ finalTotalsData.CustLaborTotalBeforeDisc = finalTotalsData.CustLaborAfterTax;
142
+ finalTotalsData.CustPartsTotalBeforeDisc = finalTotalsData.CustPartAfterTax;
143
+ }
144
+
145
+ ROPrintData = TrUtils.ConcatObjects(ROPrintData, finalTotalsData);
146
+
147
+ if (ROPrintData.ShowAccParts) {
148
+ ROPrintData = this.ConvertItemsAsAR(ROPrintData);
149
+ }
150
+
151
+ ROPrintData.Colli = this.EmptyInvalidCollisionRepairItems(ROPrintData.Colli);
152
+ ROPrintData.Comps = TrUtils.Stringify(argROData.Comps);
153
+ ROPrintData.EstTotal = TrUtils.Stringify(argROData.EstTotal);
154
+ ROPrintData.Advisor = this.GetEmployeeData(argROData.EmpData);
155
+ ROPrintData.VehMore = TrUtils.Stringify(argROData.VehMore);
156
+ ROPrintData.SANotes = TrUtils.Stringify(argROData.SANotes);
157
+ ROPrintData.OrdType = TrUtils.Stringify(argROData.OrdType);
158
+
159
+ ROPrintData = this.GetLineTotals(ROPrintData, IncludeGST, ConsolidateGST, AsCustomerOnly, AsInsuranceOnly, ROPrintData.Entity.DecimalsNumber);
160
+
161
+ ROPrintData.PrintInfo = this.PrepareFormatForROPrint(ROPrintData, Payee, ROTypeEnum.RepairOrder);
162
+
163
+ ROPrintData = this.CheckAndCombineDescMPNForAR(ROPrintData.Entity.MPN, ROPrintData);
164
+
165
+ ROPrintData.Vehicle = PrintSharedService.GetVehicleFromServiceAndFormatData(OriginalVehicleData);
166
+ ROPrintData.Customer = PrintSharedService.GetCustomerFromServiceAndFormatData(OriginalCustomerData);
167
+ if (!TrUtils.IsNull(OriginalROData.SrvLoc)) {
168
+ let location: any = {};
169
+ location.Adrs = PrintSharedService.GetAddress(OriginalROData.SrvLoc.Adrs);
170
+ location.Name = OriginalROData.SrvLoc.ConName;
171
+ if (!TrUtils.IsNull(OriginalROData.SrvLoc.ConPh)) {
172
+ location.Cons = [
173
+ {
174
+ Type: 'M',
175
+ No: OriginalROData.SrvLoc.ConPh
176
+ }
177
+ ];
178
+ }
179
+
180
+ ROPrintData.Location = location;
181
+ }
182
+ ROPrintData.Consolidate = ConsolidateGST;
183
+ ROPrintData.ShowDiscountColumn = false;
184
+ if ((Payee === PayTypeEnum.Customer || AsCustomerOnly) && !ROPrintData.ConsolidateGST) {
185
+ if (PrintSharedService.CheckItemIndexWithDisc(ROPrintData) !== -1) {
186
+ ROPrintData.ShowDiscountColumn = (ROPrintData.Settings.DiscLvl === 'ITM' || ROPrintData.Settings.DiscLvl === 'RECITM') ? true : false;
187
+
188
+ }
189
+ }
190
+
191
+ return ROPrintData;
192
+ }
193
+
194
+ static GetEmployeeData(empData: any) {
195
+ let SA: any = {};
196
+ if (!TrUtils.IsNull(empData)) {
197
+ SA.Name = empData.DName;
198
+ SA.Ph = empData.Cons.Phones.Main;
199
+ }
200
+
201
+ return SA;
202
+
203
+ }
204
+
205
+ static GetROBasicDetailsForPrint(ROPrintData: any, argROData: any, Product: any, OrderType: any) {
206
+ ROPrintData.CrDate = MyDate.ConvertUTCDateToReadable(argROData.CrDate);
207
+ ROPrintData.PrDate = MyDate.ConvertUTCDateToReadable(argROData.PrDate);
208
+ ROPrintData.MIn = Product.MIn;
209
+ ROPrintData._id = argROData.Code;
210
+ ROPrintData.Type = 'Work Order';
211
+ ROPrintData.HeaderName = OrderType;
212
+ return ROPrintData;
213
+ }
214
+
215
+ static GetPrintConditionsBasedOnInput(ROPrintData: any, IncludeGST: boolean, ConsolidateGST: boolean, Payee: any,
216
+ AsCustomerOnly: boolean, AsInsuranceOnly: boolean,
217
+ SType: any) {
218
+
219
+ ROPrintData.Payee = Payee;
220
+ ROPrintData.AsCustomerOnly = AsCustomerOnly;
221
+ ROPrintData.AsInsuranceOnly = AsInsuranceOnly;
222
+
223
+ ROPrintData.IncludeGST = IncludeGST;
224
+ ROPrintData.ConsolidateGST = ConsolidateGST;
225
+
226
+ ROPrintData.ShowIGST = (TrUtils.IsNull(SType) || (SType === 'Intra')) ? false : true;
227
+
228
+ ROPrintData.ShowTaxColumn = (IncludeGST && !ConsolidateGST) ? true : false;
229
+ // ROPrintData.ShowDiscountColumn = ((Payee === PayTypeEnum.Customer || AsCustomerOnly) && !ConsolidateGST) ? true : false;
230
+ return ROPrintData;
231
+ }
232
+
233
+ static GetInsDetailsForPrint(ROPrintData: any, InsCompanyName: any, argROData: any) {
234
+ if (TrUtils.IsNull(argROData.Ins)) {
235
+ argROData.Ins = this.GetDefualtInsData();
236
+ }
237
+ ROPrintData.InsComp = InsCompanyName;
238
+ ROPrintData.SurName = argROData.Ins.SName;
239
+ ROPrintData.SurEmail = argROData.Ins.SEmail;
240
+ ROPrintData.SurPhone = argROData.Ins.SPhone;
241
+ ROPrintData.PolType = argROData.Ins.Type;
242
+ ROPrintData.PolNo = argROData.Ins.PolNo;
243
+ return ROPrintData;
244
+ }
245
+
246
+ static GetDefualtInsData() {
247
+ let ROInsData: any = {
248
+ SName: '',
249
+ SEmail: '',
250
+ SPhone: '',
251
+ PolNo: ''
252
+ };
253
+ return ROInsData;
254
+ }
255
+
256
+ static CheckStatusAndChangeDeclinedItemsToNew(argROData: any) {
257
+ if (argROData.Sts === ROStatusEnum.New || argROData.Sts === ROStatusEnum.WtngForAppr) {
258
+ argROData = this.ChangeDeclinedStatusToNew(argROData);
259
+ }
260
+ return argROData;
261
+ }
262
+
263
+ static ChangeDeclinedStatusToNew(argROData: any) {
264
+ argROData.Ops = this.ChangeDeclinedLaborStatusToNew(argROData.Ops);
265
+ argROData.Parts = this.ChangeDeclinedPartStatusToNew(argROData.Parts);
266
+ argROData.Colli = this.ChangeDeclinedColliStatusToNew(argROData.Colli);
267
+ return argROData;
268
+ }
269
+
270
+ static ChangeDeclinedLaborStatusToNew(Operations: any) {
271
+ Operations.forEach((Labor: any) => {
272
+ if (Labor.Sts === LaborStatusEnum.Declined) {
273
+ Labor.Sts = LaborStatusEnum.New;
274
+ }
275
+ });
276
+ return Operations;
277
+ }
278
+
279
+ static ChangeDeclinedPartStatusToNew(Parts: any) {
280
+ Parts.forEach((Part: any) => {
281
+ if (!TrUtils.IsNull(Part.CollId) && Part.Sts === LaborStatusEnum.Declined) {
282
+ Part.Sts = LaborStatusEnum.New;
283
+ }
284
+ });
285
+ return Parts;
286
+ }
287
+
288
+ static ChangeDeclinedColliStatusToNew(Collisions: any) {
289
+ Collisions.forEach((Collision: any) => {
290
+ if (Collision.Sts === LaborStatusEnum.Declined) {
291
+ Collision.Sts = LaborStatusEnum.New;
292
+ }
293
+ });
294
+ return Collisions;
295
+ }
296
+
297
+ static GetValidItemsForTotals(RecordData: any) {
298
+ let RecordStatus: string = RecordData.Sts;
299
+ RecordData.Ops = this.GetLaborByRecordAndLaborStatus(RecordStatus, RecordData.Ops);
300
+ RecordData.Parts = this.GetPartsByRecordAndPartStatus(RecordStatus, RecordData.Parts);
301
+ RecordData.Colli = this.GetCollisionByRecordAndColliStatus(RecordStatus, RecordData.Colli);
302
+ return RecordData;
303
+ }
304
+
305
+ static GetLaborByRecordAndLaborStatus(RecordStatus: string, Operations: any) {
306
+ if (RecordStatus === ROStatusEnum.Cancelled || RecordStatus === ROStatusEnum.Declined) {
307
+ return Operations;
308
+ } else {
309
+ return this.GetValidROLaborListByStatus(Operations);
310
+ }
311
+ }
312
+
313
+ static GetValidROLaborListByStatus(Operations: any) {
314
+ let opCodesList: any[] = Operations.filter((Operation: any) => {
315
+ if (this.CheckOperationHasActiveStatus(Operation.Sts)) {
316
+ return Operation;
317
+ }
318
+ });
319
+ return opCodesList;
320
+ }
321
+
322
+ static CheckOperationHasActiveStatus(Status: string) {
323
+ return (Status !== LaborStatusEnum.Cancelled && Status !== LaborStatusEnum.Declined) ? true : false;
324
+ }
325
+
326
+ static GetPartsByRecordAndPartStatus(RecordStatus: any, Parts: any) {
327
+ if (RecordStatus === ROStatusEnum.Cancelled || RecordStatus === ROStatusEnum.Declined) {
328
+ return Parts;
329
+ } else {
330
+ return this.GetValidROPartsListByStatus(Parts);
331
+ }
332
+ }
333
+
334
+ static GetValidROPartsListByStatus(Parts: any) {
335
+ let PartsList: any[] = Parts.filter((Part: any) => {
336
+ if (TrUtils.IsNull(Part.CollId)) {
337
+ return Part;
338
+ } else {
339
+ if (this.CheckOperationHasActiveStatus(Part.Sts)) {
340
+ return Part;
341
+ }
342
+ }
343
+ });
344
+ return PartsList;
345
+ }
346
+
347
+ static GetCollisionByRecordAndColliStatus(RecordStatus: string, Collisions: any) {
348
+ if (RecordStatus === ROStatusEnum.Cancelled || RecordStatus === ROStatusEnum.Declined) {
349
+ return Collisions;
350
+ } else {
351
+ return this.GetValidROCollisionListByStatus(Collisions);
352
+ }
353
+ }
354
+
355
+ static GetValidROCollisionListByStatus(Collisions: any) {
356
+ let collList: any[] = Collisions.filter((Collision: any) => {
357
+ if (this.CheckOperationHasActiveStatus(Collision.Sts)) {
358
+ return Collision;
359
+ }
360
+ });
361
+ return collList;
362
+ }
363
+
364
+ static SeparateROLaborByPType(Labors: any, PType: any, CustomerOnly: boolean, InsuranceOnly: boolean) {
365
+ let LaborList: any[] = [];
366
+ LaborList = Labors.filter((Labor: any) => {
367
+ if (PType === PayTypeEnum.Customer) {
368
+ return !TrUtils.IsZero(Labor.Pr);
369
+ } else {
370
+ return !TrUtils.IsZero(Labor.AssPr);
371
+ }
372
+ });
373
+ return LaborList;
374
+ }
375
+
376
+ static SeparateROPartsByPType(Parts: any, PType: any, CustomerOnly: boolean, InsuranceOnly: boolean) {
377
+ let PartsList: any[] = [];
378
+ PartsList = Parts.filter((Part: any) => {
379
+ if (PType === PayTypeEnum.Customer) {
380
+ return !TrUtils.IsZero(Part.UnPr);
381
+ } else {
382
+ return !TrUtils.IsZero(Part.AssPr);
383
+ }
384
+ });
385
+ return PartsList;
386
+ }
387
+
388
+ static SeparateROCollisionsByPType(Collisions: any, Ops: any, Parts: any) {
389
+ let CollisionList: any[] = Collisions.filter((Collision: any) => {
390
+ let LaborIndex: any = Ops.findIndex((Labor: any) => {
391
+ return Labor.CollId === Collision._id;
392
+ });
393
+ let PartIndex: any = Parts.findIndex((Part: any) => {
394
+ return Part.CollId === Collision._id;
395
+ });
396
+ if (LaborIndex !== -1 || PartIndex !== -1) {
397
+ return Collision;
398
+ }
399
+ });
400
+ return CollisionList;
401
+ }
402
+
403
+ static ResetQtyAndUoM(Parts: any) {
404
+ Parts.forEach((Item: any) => {
405
+ if (!TrUtils.IsZero(Item.Qty) && !TrUtils.CheckInvalidSelect(Item.UoM)) {
406
+ Item.QtyAndUoM = Item.Qty + ' ' + Item.UoM;
407
+ }
408
+ });
409
+ return Parts;
410
+ }
411
+
412
+ static CheckAndShowItemsAsAR(argROData: any) {
413
+ let AccPartsIndex: any = argROData.Parts.findIndex((Part: any) => {
414
+ return !TrUtils.IsNull((Part.CollId));
415
+ });
416
+ let InsLaborIndex: any = argROData.Ops.findIndex((Labor: any) => {
417
+ return !TrUtils.IsNull((Labor.CollId));
418
+ });
419
+ if (AccPartsIndex !== -1 || InsLaborIndex !== -1) {
420
+ return true;
421
+ } else {
422
+ return false;
423
+ }
424
+ }
425
+
426
+ static ConvertItemsAsAR(ROPrintData: any) {
427
+
428
+ ROPrintData.Colli.forEach((Collision: any) => {
429
+ Collision = this.ResetItemsDataById(Collision, ROPrintData.Ops, ROPrintData.Parts);
430
+ });
431
+
432
+ ROPrintData.Ops.forEach((Labor: any) => {
433
+ if (TrUtils.IsNull(Labor.CollId)) {
434
+ let LaborColli: any = {
435
+ _id: Labor._id,
436
+ Desc: Labor.Desc,
437
+ PBy: Labor.PBy,
438
+ Op_Id: Labor.Op_Id,
439
+ Qty: 0,
440
+ Sts: Labor.Sts
441
+ };
442
+ LaborColli.RRFData = Labor;
443
+ ROPrintData.Colli.push(LaborColli);
444
+ }
445
+ });
446
+
447
+ ROPrintData.Parts.forEach((Part: any) => {
448
+ if (TrUtils.IsNull(Part.CollId)) {
449
+ let LaborIndex: any = ROPrintData.Ops.findIndex((Labor: any) => {
450
+ return Labor._id === Part.OpId;
451
+ });
452
+ let OpsStatus: string = ROPrintData.Ops[LaborIndex].Sts;
453
+
454
+ let PartColli: any = {
455
+ _id: Part._id,
456
+ Desc: Part.Desc,
457
+ PBy: Part.PBy,
458
+ Sts: OpsStatus
459
+ };
460
+ PartColli.PartData = Part;
461
+ ROPrintData.Colli.push(PartColli);
462
+ }
463
+ });
464
+
465
+ ROPrintData.Ops = [];
466
+ ROPrintData.Parts = [];
467
+
468
+ return ROPrintData;
469
+ }
470
+
471
+ static ResetItemsDataById(Collision: any, AddedOperations: any[], AddedParts: any[]) {
472
+ Collision.PartData = TrUtils.IsNull(Collision.PartId)
473
+ ? null : this.GetPartDataById(Collision.PartId, AddedParts);
474
+ Collision.RRFData = TrUtils.IsNull(Collision.RRFId)
475
+ ? null : this.GetLaborDataById(Collision.RRFId, AddedOperations);
476
+ Collision.PtngData = TrUtils.IsNull(Collision.PainId)
477
+ ? null : this.GetLaborDataById(Collision.PainId, AddedOperations);
478
+ Collision.DtngData = TrUtils.IsNull(Collision.RepId)
479
+ ? null : this.GetLaborDataById(Collision.RepId, AddedOperations);
480
+ }
481
+
482
+ static GetPartDataById(PartId: any, AddedParts: any[]) {
483
+ let partIndex: any = AddedParts.findIndex((Part: any) => {
484
+ return Part._id === PartId;
485
+ });
486
+ return (partIndex !== -1) ? AddedParts[partIndex] : null;
487
+ }
488
+
489
+ static GetLaborDataById(LaborId: any, AddedOperations: any[]) {
490
+ let laborIndex: any = AddedOperations.findIndex((Labor: any) => {
491
+ return Labor._id === LaborId;
492
+ });
493
+ return (laborIndex !== -1) ? AddedOperations[laborIndex] : null;
494
+ }
495
+
496
+ static EmptyInvalidCollisionRepairItems(Colli: any) {
497
+ Colli.forEach((CollisionItem: any) => {
498
+ if (!TrUtils.IsNull(CollisionItem.PartData) && !this.CheckOperationHasActiveStatus(CollisionItem.PartData.Sts)) {
499
+ CollisionItem.PartData.AssPr = null;
500
+ CollisionItem.PartData.UnPr = null;
501
+ CollisionItem.PartData.Disc = 0;
502
+ CollisionItem.PartData.RecDisc = 0;
503
+ }
504
+ if (!TrUtils.IsNull(CollisionItem.RRFData) && !this.CheckOperationHasActiveStatus(CollisionItem.RRFData.Sts)) {
505
+ CollisionItem.RRFData.AssPr = null;
506
+ CollisionItem.RRFData.Pr = null;
507
+ CollisionItem.RRFData.Disc = 0;
508
+ CollisionItem.RRFData.RecDisc = 0;
509
+ }
510
+ if (!TrUtils.IsNull(CollisionItem.DtngData) && !this.CheckOperationHasActiveStatus(CollisionItem.DtngData.Sts)) {
511
+ CollisionItem.DtngData.AssPr = null;
512
+ CollisionItem.DtngData.Pr = null;
513
+ CollisionItem.DtngData.Disc = 0;
514
+ CollisionItem.DtngData.RecDisc = 0;
515
+ }
516
+ if (!TrUtils.IsNull(CollisionItem.PtngData) && !this.CheckOperationHasActiveStatus(CollisionItem.PtngData.Sts)) {
517
+ CollisionItem.PtngData.AssPr = null;
518
+ CollisionItem.PtngData.Pr = null;
519
+ CollisionItem.PtngData.Disc = 0;
520
+ CollisionItem.PtngData.RecDisc = 0;
521
+ }
522
+ });
523
+ return Colli;
524
+ }
525
+
526
+ static GetLineTotals(ROPrintData: any, IncludeGST: boolean, ConsolidateGST: boolean, AsCustomerOnly: boolean, AsInsuranceOnly: boolean, DecimalsNumber: number) {
527
+
528
+ ROPrintData.Ops.forEach((Labor: any) => {
529
+ Labor.LineTotal = this.GetLaborLineTotal(Labor, IncludeGST, AsCustomerOnly, AsInsuranceOnly, DecimalsNumber);
530
+ });
531
+
532
+ ROPrintData.Parts.forEach((Part: any) => {
533
+ Part.LineTotal = this.GetPartLineTotal(Part, IncludeGST, AsCustomerOnly, AsInsuranceOnly, DecimalsNumber);
534
+ });
535
+
536
+ ROPrintData.Colli.forEach((Collision: any) => {
537
+ let LineTotal: number = 0;
538
+ if (!TrUtils.IsNull(Collision.PartData)) {
539
+ LineTotal = Add(LineTotal,this.GetCollisionPartLineTotal(Collision.PartData, ConsolidateGST, AsCustomerOnly, AsInsuranceOnly));
540
+ }
541
+ if (!TrUtils.IsNull(Collision.RRFData)) {
542
+ LineTotal = Add(LineTotal,this.GetCollisionLaborLineTotal(Collision.RRFData, ConsolidateGST, AsCustomerOnly, AsInsuranceOnly));
543
+ }
544
+ if (!TrUtils.IsNull(Collision.PtngData)) {
545
+ LineTotal = Add(LineTotal,this.GetCollisionLaborLineTotal(Collision.PtngData, ConsolidateGST, AsCustomerOnly, AsInsuranceOnly));
546
+ }
547
+ if (!TrUtils.IsNull(Collision.DtngData)) {
548
+ LineTotal = Add(LineTotal,this.GetCollisionLaborLineTotal(Collision.DtngData, ConsolidateGST, AsCustomerOnly, AsInsuranceOnly));
549
+ }
550
+ Collision.LineTotal = TrUtils.FixPriceValue(LineTotal, DecimalsNumber);
551
+ });
552
+
553
+ return ROPrintData;
554
+ }
555
+
556
+ static GetCollisionPartLineTotal(PartData: any, ConsolidateGST: boolean, AsCustomerOnly: boolean, AsInsuranceOnly: boolean) {
557
+ let LineTotal: number = 0;
558
+ if (AsCustomerOnly) {
559
+ if (ConsolidateGST) {
560
+ LineTotal = PartData.CustAfterTaxPerItem;
561
+ } else {
562
+ LineTotal = PartData.CustAfterPartDisc;
563
+ }
564
+ } else if (AsInsuranceOnly) {
565
+ if (ConsolidateGST) {
566
+ LineTotal = PartData.InsAfterTaxPerItem;
567
+ } else {
568
+ LineTotal = PartData.InsAfterPartDisc;
569
+ }
570
+ } else {
571
+ if (ConsolidateGST) {
572
+ LineTotal = Add(PartData.InsAfterTaxPerItem , PartData.CustAfterTaxPerItem);
573
+ } else {
574
+ LineTotal = Add(PartData.InsAfterPartDisc , PartData.CustAfterPartDisc);
575
+ }
576
+ }
577
+ return Number(LineTotal);
578
+ }
579
+
580
+ static GetCollisionLaborLineTotal(LaborData: any, ConsolidateGST: boolean, AsCustomerOnly: boolean, AsInsuranceOnly: boolean) {
581
+ let LineTotal: number = 0;
582
+ if (AsCustomerOnly) {
583
+ if (ConsolidateGST) {
584
+ LineTotal = LaborData.CustAfterTax;
585
+ } else {
586
+ LineTotal = LaborData.CustAfterLaborDisc;
587
+ }
588
+ } else if (AsInsuranceOnly) {
589
+ if (ConsolidateGST) {
590
+ LineTotal = LaborData.InsAfterTax;
591
+ } else {
592
+ LineTotal = LaborData.InsAfterLaborDisc;
593
+ }
594
+ } else {
595
+ if (ConsolidateGST) {
596
+ LineTotal = Add(LaborData.CustAfterTax , LaborData.InsAfterTax);
597
+ } else {
598
+ LineTotal = Add(LaborData.InsAfterLaborDisc , LaborData.CustAfterLaborDisc);
599
+ }
600
+ }
601
+ return Number(LineTotal);
602
+ }
603
+
604
+ static GetLaborLineTotal(LaborData: any, IncludeGST: boolean, AsCustomerOnly: boolean, AsInsuranceOnly: boolean, DecimalsNumber: number) {
605
+ let LineTotal: number = 0;
606
+ if (AsCustomerOnly) {
607
+ if (IncludeGST) {
608
+ LineTotal = LaborData.CustAfterTax;
609
+ } else {
610
+ LineTotal = LaborData.CustAfterLaborDisc;
611
+ }
612
+ } else if (AsInsuranceOnly) {
613
+ if (IncludeGST) {
614
+ LineTotal = LaborData.InsAfterTax;
615
+ } else {
616
+ LineTotal = LaborData.InsAfterLaborDisc;
617
+ }
618
+ } else {
619
+ if (IncludeGST) {
620
+ LineTotal = Add(LaborData.CustAfterTax , LaborData.InsAfterTax);
621
+ } else {
622
+ LineTotal = Add(LaborData.InsAfterLaborDisc , LaborData.CustAfterLaborDisc);
623
+ }
624
+ }
625
+ return TrUtils.FixPriceValue(LineTotal, DecimalsNumber);
626
+ }
627
+
628
+ static GetPartLineTotal(PartData: any, IncludeGST: boolean, AsCustomerOnly: boolean, AsInsuranceOnly: boolean, DecimalsNumber: number) {
629
+ let LineTotal: number = 0;
630
+ if (AsCustomerOnly) {
631
+ if (IncludeGST) {
632
+ LineTotal = PartData.CustAfterTax;
633
+ } else {
634
+ LineTotal = PartData.CustAfterPartDisc;
635
+ }
636
+ } else if (AsInsuranceOnly) {
637
+ if (IncludeGST) {
638
+ LineTotal = PartData.InsAfterTax;
639
+ } else {
640
+ LineTotal = PartData.InsAfterPartDisc;
641
+ }
642
+ } else {
643
+ if (IncludeGST) {
644
+ LineTotal = Add(PartData.InsAfterTax , PartData.CustAfterTax);
645
+ } else {
646
+ LineTotal = Add(PartData.InsAfterPartDisc , PartData.CustAfterPartDisc);
647
+ }
648
+ }
649
+ return TrUtils.FixPriceValue(LineTotal, DecimalsNumber);
650
+ }
651
+
652
+ static ReverseItemsForROPrint(argROData: any, isReverse:boolean) {
653
+ if(isReverse){
654
+ argROData.Comps = TrUtils.IsNull(argROData.Comps) ? [] : argROData.Comps.reverse();
655
+ argROData.Ops = TrUtils.IsNull(argROData.Ops) ? [] : argROData.Ops.reverse();
656
+ argROData.Parts = TrUtils.IsNull(argROData.Parts) ? [] : argROData.Parts.reverse();
657
+ argROData.Colli = TrUtils.IsNull(argROData.Colli) ? [] : argROData.Colli.reverse();
658
+ }else{
659
+ argROData.Comps = TrUtils.IsNull(argROData.Comps) ? [] : argROData.Comps;
660
+ argROData.Ops = TrUtils.IsNull(argROData.Ops) ? [] : argROData.Ops;
661
+ argROData.Parts = TrUtils.IsNull(argROData.Parts) ? [] : argROData.Parts;
662
+ argROData.Colli = TrUtils.IsNull(argROData.Colli) ? [] : argROData.Colli;
663
+ }
664
+
665
+
666
+ let ReversedLabors: any[] = [];
667
+ argROData.Comps.forEach((Complaint: any) => {
668
+ argROData.Ops.forEach((Labor: any) => {
669
+ if (Labor.CompId === Complaint._id) {
670
+ ReversedLabors.push(Labor);
671
+ }
672
+ });
673
+ });
674
+
675
+ argROData.Ops.forEach((Labor: any) => {
676
+ if (TrUtils.IsNull(Labor.CompId)) {
677
+ ReversedLabors.push(Labor);
678
+ }
679
+ });
680
+
681
+ argROData.Ops = ReversedLabors;
682
+
683
+ let ReversedParts: any[] = [];
684
+ argROData.Ops.forEach((Labor: any) => {
685
+ argROData.Parts.forEach((Part: any) => {
686
+ if (TrUtils.IsNull(Part.CollId) && (Part.OpId === Labor._id)) {
687
+ ReversedParts.push(Part);
688
+ }
689
+ });
690
+ });
691
+
692
+ argROData.Parts.forEach((Part: any) => {
693
+ if (!TrUtils.IsNull(Part.CollId)) {
694
+ ReversedParts.push(Part);
695
+ }
696
+ });
697
+ argROData.Parts = ReversedParts;
698
+
699
+ return argROData;
700
+ }
701
+
702
+ static GetDetailedInfoForItems(ROTotalsData: any, IncludeGST: boolean, ConsolidateGST: boolean,
703
+ AsCustomerOnly: boolean, AsInsuranceOnly: boolean, TaxCodes: any[], DecimalsNumber: number) {
704
+ ROTotalsData.Ops = this.GetLaborPrintInfo(ROTotalsData.Ops, ConsolidateGST, IncludeGST, AsCustomerOnly,
705
+ AsInsuranceOnly, TaxCodes, DecimalsNumber);
706
+ ROTotalsData.Parts = this.GetItemsPrintInfo(TrUtils.Stringify(ROTotalsData.Parts), ConsolidateGST, IncludeGST, AsCustomerOnly,
707
+ AsInsuranceOnly, TaxCodes, DecimalsNumber);
708
+ if (IncludeGST && !ConsolidateGST) {
709
+ ROTotalsData.ShowDetailedLaborTaxInfo = this.CheckLaborTaxItemIndex(ROTotalsData.Ops) !== -1;
710
+ ROTotalsData.ShowDetailedPartTaxInfo = this.CheckPartTaxItemIndex(ROTotalsData.Parts) !== -1;
711
+ } else {
712
+ ROTotalsData.ShowDetailedLaborTaxInfo = false;
713
+ ROTotalsData.ShowDetailedPartTaxInfo = false;
714
+ }
715
+ return ROTotalsData;
716
+ }
717
+
718
+ static GetLaborPrintInfo(LaborList: any, ConsolidateGST: boolean,
719
+ IncludeGST: boolean, AsCustomerOnly: boolean, AsInsuranceOnly: boolean, _TaxCodes: any[], DecimalsNumber:number) {
720
+ LaborList.forEach((Labor: any) => {
721
+ Labor.HSN = Labor.SAC;
722
+ let taxGroupKey = 'CTaxes';
723
+ if (AsCustomerOnly) {
724
+ if (IncludeGST) {
725
+ if (ConsolidateGST) {
726
+ Labor.UnPr = TrUtils.FixedTo(Labor.CustAfterTax, DecimalsNumber);
727
+ } else {
728
+ Labor.UnPr = TrUtils.FixedTo(Labor.Pr, DecimalsNumber);
729
+ }
730
+ Labor.CGSTAmt = TrUtils.FixedTo(this.GetTaxAmountFromGroup(Labor, 'CTaxes', 'CGST', 'CCGST'), DecimalsNumber);
731
+ Labor.SGSTAmt = TrUtils.FixedTo(this.GetTaxAmountFromGroup(Labor, 'CTaxes', 'SGST', 'CSGST'), DecimalsNumber);
732
+ Labor.IGSTAmt = TrUtils.FixedTo(this.GetTaxAmountFromGroup(Labor, 'CTaxes', 'IGST', 'CIGST'), DecimalsNumber);
733
+ } else {
734
+ Labor.UnPr = TrUtils.FixedTo(Labor.Pr, DecimalsNumber);
735
+ Labor.CGSTAmt = 0;
736
+ Labor.SGSTAmt = 0;
737
+ Labor.IGSTAmt = 0;
738
+ }
739
+ } else if (AsInsuranceOnly) {
740
+ taxGroupKey = 'ATaxes';
741
+ if (IncludeGST) {
742
+ if (ConsolidateGST) {
743
+ Labor.UnPr = TrUtils.FixedTo(Labor.InsAfterTax, DecimalsNumber);
744
+ } else {
745
+ Labor.UnPr = TrUtils.FixedTo(Labor.AssPr, DecimalsNumber);
746
+ }
747
+ Labor.CGSTAmt = TrUtils.FixedTo(this.GetTaxAmountFromGroup(Labor, 'ATaxes', 'CGST', 'ACGST'), DecimalsNumber);
748
+ Labor.SGSTAmt = TrUtils.FixedTo(this.GetTaxAmountFromGroup(Labor, 'ATaxes', 'SGST', 'ASGST'), DecimalsNumber);
749
+ Labor.IGSTAmt = TrUtils.FixedTo(this.GetTaxAmountFromGroup(Labor, 'ATaxes', 'IGST', 'AIGST'), DecimalsNumber);
750
+ Labor.AssPr = TrUtils.FixedTo(Labor.AssPr, DecimalsNumber);
751
+ } else {
752
+ Labor.UnPr = TrUtils.FixedTo(Labor.AssPr, DecimalsNumber);
753
+ Labor.AssPr = TrUtils.FixedTo(Labor.AssPr, DecimalsNumber);
754
+ Labor.CGSTAmt = 0;
755
+ Labor.SGSTAmt = 0;
756
+ Labor.IGSTAmt = 0;
757
+ }
758
+ }
759
+ Labor.TCode = this.GetTCode(Labor);
760
+ Labor.CGSTPerc = this.GetTaxRate(Labor, 'CGST', taxGroupKey);
761
+ Labor.SGSTPerc = this.GetTaxRate(Labor, 'SGST', taxGroupKey);
762
+ Labor.IGSTPerc = this.GetTaxRate(Labor, 'IGST', taxGroupKey);
763
+ });
764
+ return LaborList;
765
+ }
766
+
767
+ static GetItemsPrintInfo(Items: any, ConsolidateGST: boolean, IncludeGST: boolean,
768
+ AsCustomerOnly: boolean, AsInsuranceOnly: boolean, _TaxCodes: any[], DecimalsNumber: number) {
769
+ Items.forEach((Item: any) => {
770
+ let taxGroupKey = 'CTaxes';
771
+ if (AsCustomerOnly) {
772
+ if (IncludeGST) {
773
+ if (ConsolidateGST) {
774
+ Item.UnPr = TrUtils.FixedTo(Item.CustAfterTaxPerItem, DecimalsNumber);
775
+ } else {
776
+ Item.UnPr = TrUtils.FixedTo(Item.UnPr, DecimalsNumber);
777
+ }
778
+ Item.CGSTAmt = TrUtils.FixedTo(this.GetTaxAmountFromGroup(Item, 'CTaxes', 'CGST', 'CCGST'), DecimalsNumber);
779
+ Item.SGSTAmt = TrUtils.FixedTo(this.GetTaxAmountFromGroup(Item, 'CTaxes', 'SGST', 'CSGST'), DecimalsNumber);
780
+ Item.IGSTAmt = TrUtils.FixedTo(this.GetTaxAmountFromGroup(Item, 'CTaxes', 'IGST', 'CIGST'), DecimalsNumber);
781
+ } else {
782
+ Item.UnPr = TrUtils.FixedTo(Item.UnPr, DecimalsNumber);
783
+ Item.CGSTAmt = 0;
784
+ Item.SGSTAmt = 0;
785
+ Item.IGSTAmt = 0;
786
+ }
787
+ } else if (AsInsuranceOnly) {
788
+ taxGroupKey = 'ATaxes';
789
+ if (IncludeGST) {
790
+ if (ConsolidateGST) {
791
+ Item.UnPr = TrUtils.FixedTo(Item.InsAfterTaxPerItem, DecimalsNumber);
792
+ } else {
793
+ Item.UnPr = TrUtils.FixedTo(Item.AssPr, DecimalsNumber);
794
+ }
795
+ Item.CGSTAmt = TrUtils.FixedTo(this.GetTaxAmountFromGroup(Item, 'ATaxes', 'CGST', 'ACGST'), DecimalsNumber);
796
+ Item.SGSTAmt = TrUtils.FixedTo(this.GetTaxAmountFromGroup(Item, 'ATaxes', 'SGST', 'ASGST'), DecimalsNumber);
797
+ Item.IGSTAmt = TrUtils.FixedTo(this.GetTaxAmountFromGroup(Item, 'ATaxes', 'IGST', 'AIGST'), DecimalsNumber);
798
+ Item.AssPr = TrUtils.FixedTo(Item.AssPr, DecimalsNumber);
799
+ } else {
800
+ Item.UnPr = TrUtils.FixedTo(Item.AssPr, DecimalsNumber);
801
+ Item.AssPr = TrUtils.FixedTo(Item.AssPr, DecimalsNumber);
802
+ Item.CGSTAmt = 0;
803
+ Item.SGSTAmt = 0;
804
+ Item.IGSTAmt = 0;
805
+ }
806
+ }
807
+ if (!TrUtils.IsZero(Item.Qty) && !TrUtils.CheckInvalidSelect(Item.UoM)) {
808
+ Item.QtyAndUoM = Item.Qty + ' ' + Item.UoM;
809
+ }
810
+ Item.TCode = this.GetTCode(Item);
811
+ Item.CGSTPerc = this.GetTaxRate(Item, 'CGST', taxGroupKey);
812
+ Item.SGSTPerc = this.GetTaxRate(Item, 'SGST', taxGroupKey);
813
+ Item.IGSTPerc = this.GetTaxRate(Item, 'IGST', taxGroupKey);
814
+ });
815
+ return Items;
816
+ }
817
+
818
+ static CheckLaborTaxItemIndex(LaborList: any[]) {
819
+ let TaxIndex: any = LaborList.findIndex((Labor: any) => {
820
+ if (!TrUtils.IsNull(this.GetTCode(Labor))) {
821
+ return Labor;
822
+ }
823
+ });
824
+ return TaxIndex;
825
+ }
826
+
827
+ static CheckPartTaxItemIndex(PartsList: any[]) {
828
+ let TaxIndex: any = PartsList.findIndex((Part: any) => {
829
+ if (!TrUtils.IsNull(this.GetTCode(Part))) {
830
+ return Part;
831
+ }
832
+ });
833
+ return TaxIndex;
834
+ }
835
+
836
+ static PrepareFormatForROPrint(ROPrintData: any, For: string, argROType: any) {
837
+ let PrintInfo: any[] = [];
838
+ let ROLaborParts: any = this.GetFormatForROPrint(For, ROPrintData, argROType);
839
+ PrintInfo.push(ROLaborParts);
840
+ return PrintInfo;
841
+
842
+ }
843
+
844
+ static GetFormatForROPrint(For: any, ROPrintData: any, argROType: any) {
845
+ let ROLaborParts: any = {};
846
+ ROLaborParts.Ops = ROPrintData.Ops;
847
+ ROLaborParts.Parts = ROPrintData.Parts;
848
+ ROLaborParts.Colli = ROPrintData.Colli;
849
+
850
+ let NewOpFound: any = ROLaborParts.Ops.findIndex((Labor: any) => {
851
+ return Labor.Sts === LaborStatusEnum.New || Labor.Sts === LaborStatusEnum.WtngForAppr;
852
+ });
853
+ let NewPartFound: any = ROLaborParts.Parts.findIndex((Part: any) => {
854
+ return !TrUtils.IsNull(Part.CollId) && (Part.Sts === LaborStatusEnum.New || Part.Sts === LaborStatusEnum.WtngForAppr);
855
+ });
856
+ let NewIndPartFound: any = ROLaborParts.Colli.findIndex((IndPart: any) => {
857
+ return IndPart.Sts === LaborStatusEnum.New || IndPart.Sts === LaborStatusEnum.WtngForAppr;
858
+ });
859
+ if (NewOpFound !== -1 || NewIndPartFound !== -1 || NewPartFound !== -1) {
860
+ ROLaborParts.Sts = ROStatusEnum.New;
861
+ } else {
862
+ ROLaborParts.Sts = ROStatusEnum.Approved;
863
+ }
864
+ ROLaborParts.Type = argROType;
865
+ return ROLaborParts;
866
+ }
867
+
868
+ static CheckAndCombineDescMPNForAR(PrintPartNo: boolean, ROPrintData: any) {
869
+ if (PrintPartNo) {
870
+ ROPrintData.PrintInfo.forEach((PrintData: any) => {
871
+ PrintData.Colli.forEach((Collision: any) => {
872
+ if (!TrUtils.IsNull(Collision.PartData) && !TrUtils.IsEmpty(Collision.PartData.MPN)) {
873
+ Collision.Desc = Collision.Desc + '/' + Collision.PartData.MPN;
874
+ }
875
+ });
876
+ });
877
+ }
878
+ return ROPrintData;
879
+ }
880
+
881
+ }