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,424 @@
1
+ import { Add, Divide, Multiply, Subtract } from "../../shared/math-operations";
2
+ import { TrUtils } from "../../utils/tr-utils";
3
+
4
+ export class CreditNoteTotalsService {
5
+
6
+ static GetTotalsValue(opCodesList: any, PartsList: any, IsIndependentTax: boolean, DetailedInfo: boolean,
7
+ Disc: any, Perc: string,
8
+ TaxCodes: any, WithItems: boolean, Settings: any, EntitySettings: any = {}) {
9
+
10
+ // LPerc = TrUtils.SetPercToStringIfNull(LPerc);
11
+ // PPerc = TrUtils.SetPercToStringIfNull(PPerc);
12
+ Perc = TrUtils.SetPercToStringIfNull(Perc);
13
+ // LDisc = TrUtils.SetValueToZeroIfNull(LDisc);
14
+ // PDisc = TrUtils.SetValueToZeroIfNull(PDisc);
15
+ Disc = TrUtils.SetValueToZeroIfNull(Disc);
16
+
17
+
18
+ // opCodesList = this.CalculateLaborValues(opCodesList, IsIndependentTax);
19
+
20
+ PartsList = this.CalculateLaborPartValues(PartsList, IsIndependentTax);
21
+
22
+ let finalTotalsData: any = this.GetFinalRODataForSave(opCodesList, PartsList, IsIndependentTax, Disc, Perc, DetailedInfo, Settings, EntitySettings.DecimalsNumber);
23
+
24
+ if (DetailedInfo) {
25
+ finalTotalsData = this.GetDetailedTotalsData(finalTotalsData,
26
+ IsIndependentTax, opCodesList, PartsList, TaxCodes, EntitySettings.DecimalsNumber);
27
+ }
28
+
29
+ if (WithItems) {
30
+ // finalTotalsData.Ops = opCodesList;
31
+ finalTotalsData.Items = PartsList;
32
+ }
33
+ return finalTotalsData;
34
+ }
35
+
36
+ static CalculateLaborPartValues(PartsList: any, IsIndependentTax: boolean) {
37
+ PartsList = this.ResetLaborPartValues(PartsList, IsIndependentTax);
38
+ return PartsList;
39
+ }
40
+
41
+ static ResetLaborPartValues(PartsList: any, IsIndependentTax: boolean) {
42
+ PartsList.forEach((Part: any) => {
43
+ Part = this.ResetLaborPartValueIfInvalid(Part);
44
+ if (TrUtils.IsZero(Part.Qty)) {
45
+ Part.Qty = 1;
46
+ }
47
+ Part.DiscountedPrice = Add(Part.Disc, Part.RecDisc);
48
+ // Part.AfterPartDisc = Part.NetAmt;
49
+ Part.AfterPartDisc = Subtract(Part.UnAmt, Part.Disc, Part.RecDisc);
50
+ if (IsIndependentTax) {
51
+ Part.AfterPartTax = Add(Part.AfterPartDisc, Part.CGST, Part.SGST, Part.IGST);
52
+ } else {
53
+ Part.AfterPartTax = Part.AfterPartDisc;
54
+ }
55
+ });
56
+ return PartsList;
57
+ }
58
+
59
+ static ResetLaborPartValueIfInvalid(Part: any) {
60
+ Part.UnPr = TrUtils.SetValueToZeroIfNull(Part.UnPr);
61
+ Part.Disc = TrUtils.SetValueToZeroIfNull(Part.Disc);
62
+ Part.RecDisc = TrUtils.SetValueToZeroIfNull(Part.RecDisc);
63
+ Part.CGST = TrUtils.SetValueToZeroIfNull(Part.CGST);
64
+ Part.SGST = TrUtils.SetValueToZeroIfNull(Part.SGST);
65
+ Part.IGST = TrUtils.SetValueToZeroIfNull(Part.IGST);
66
+ return Part;
67
+ }
68
+
69
+ static GetFinalRODataForSave(LaborList: any, PartsList: any, IsIndependentTax: boolean, Disc: any, Perc: string,
70
+ DetailedInfo: boolean, Settings: any, DecimalsNumber: any) {
71
+ let finalTotalsData: any = {};
72
+ finalTotalsData = this.SetMainDiscountValues(Disc, Perc, finalTotalsData, DetailedInfo);
73
+ finalTotalsData.Settings = Settings;
74
+ finalTotalsData = this.GetFinalCustomerTotalsData(finalTotalsData, [], PartsList,
75
+ IsIndependentTax, DetailedInfo, DecimalsNumber);
76
+ return finalTotalsData;
77
+ }
78
+
79
+ static SetMainDiscountValues(Disc: string, Perc: string, finalTotalsData: any, DetailedInfo: boolean) {
80
+ // finalTotalsData.LDisc = LDisc;
81
+ // finalTotalsData.LPerc = LPerc;
82
+ // finalTotalsData.PDisc = PDisc;
83
+ // finalTotalsData.PPerc = PPerc;
84
+ finalTotalsData.Disc = Disc;
85
+ finalTotalsData.Perc = Perc;
86
+ if (DetailedInfo) {
87
+ // finalTotalsData.FixedLDisc = LDisc;
88
+ // finalTotalsData.FixedPDisc = PDisc;
89
+ finalTotalsData.FixedDisc = Disc;
90
+ }
91
+ return finalTotalsData;
92
+ }
93
+
94
+ static GetFinalCustomerTotalsData(finalTotalsData: any, LaborList: any, PartsList: any, IsIndependentTax: boolean,
95
+ DetailedInfo: boolean, DecimalsNumber: number = 2) {
96
+ let CustomerAfterDiscTotals: number = this.GetSubTotalFor([], PartsList);
97
+ // let CustLaborTaxTotal = this.GetLaborTaxTotalFor([], IsIndependentTax);
98
+ let CustPartTaxTotal = this.GetPartsTaxTotalFor(PartsList, IsIndependentTax);
99
+ finalTotalsData.SubTotal = TrUtils.FixedTo(CustomerAfterDiscTotals, DecimalsNumber);
100
+ // let CustLaborDiscTotal = this.GetLaborDiscountedTotal(LaborList, IsIndependentTax, finalTotalsData);
101
+ let CustPartsDiscTotal = this.GetPartDiscountedTotal(PartsList, IsIndependentTax, finalTotalsData);
102
+ // let CustLaborTotalAfterDisc = this.GetLaborTotalAfterDiscount(LaborList);
103
+ let CustPartsTotalAfterDisc = this.GetPartsTotalAfterDiscount(PartsList);
104
+ finalTotalsData.STotal = Add(CustPartsDiscTotal, CustPartsTotalAfterDisc);
105
+ let CustTotal: any = this.GetCustomerTotalBasedOnTaxType(finalTotalsData, 0, CustPartTaxTotal, [], PartsList, IsIndependentTax);
106
+ finalTotalsData.Round = Subtract(Math.round(CustTotal), CustTotal);
107
+ finalTotalsData.Total = Math.round(CustTotal);
108
+ if (DetailedInfo) {
109
+ finalTotalsData.FixedSubTotal = TrUtils.FixedTo(CustomerAfterDiscTotals, DecimalsNumber);
110
+ finalTotalsData.FixedTotal = TrUtils.FixedTo(CustTotal, DecimalsNumber);
111
+ }
112
+ return finalTotalsData;
113
+ }
114
+
115
+ static GetSubTotalFor(LaborList: any, PartsList: any) {
116
+ // let LaborTotalAfterDisc: any = this.GetLaborTotalAfterDiscount(LaborList);
117
+ let PartsTotalAfterDisc: any = this.GetPartsTotalAfterDiscount(PartsList);
118
+ return PartsTotalAfterDisc;
119
+ }
120
+
121
+ static GetPartsTotalAfterDiscount(PartsList: any) {
122
+ let PartsTotalAfterDisc: any = 0;
123
+ PartsList.forEach((Part: any) => {
124
+ PartsTotalAfterDisc = Add(PartsTotalAfterDisc, Part.AfterPartDisc);
125
+ });
126
+ return PartsTotalAfterDisc;
127
+ }
128
+
129
+ static GetDetailedTotalsData(finalTotalsData: any, IsIndependentTax: boolean, opCodesList: any, PartsList: any, TaxCodes: any, DecimalsNumber: number = 2) {
130
+ // finalTotalsData.CustLaborDiscTotal = this.GetLaborDiscountedTotal(opCodesList, IsIndependentTax, finalTotalsData);
131
+ finalTotalsData.CustPartsDiscTotal = this.GetPartDiscountedTotal(PartsList, IsIndependentTax, finalTotalsData);
132
+ // finalTotalsData.CustLaborTotalAfterDisc = this.GetLaborTotalAfterDiscount(opCodesList);
133
+ finalTotalsData.CustPartsTotalAfterDisc = this.GetPartsTotalAfterDiscount(PartsList);
134
+ // finalTotalsData.CustLaborTotalBeforeDisc = TrUtils.FixedTo(finalTotalsData.CustLaborTotalAfterDisc
135
+ // + finalTotalsData.CustLaborDiscTotal);
136
+ finalTotalsData.CustPartsTotalBeforeDisc = Add(finalTotalsData.CustPartsTotalAfterDisc
137
+ , finalTotalsData.CustPartsDiscTotal);
138
+ // finalTotalsData.CustLaborITax = this.GetLaborTaxTotalFor(opCodesList, IsIndependentTax);
139
+ // finalTotalsData.CustLaborSGST = this.GetLaborSGSTTaxTotal(opCodesList, IsIndependentTax);
140
+ // finalTotalsData.CustLaborCGST = this.GetLaborCGSTTaxTotal(opCodesList, IsIndependentTax);
141
+ // finalTotalsData.CustLaborIGST = this.GetLaborIGSTTaxTotal(opCodesList, IsIndependentTax);
142
+ let TaxInfo: any = this.GetPartGSTTaxTotal(PartsList, IsIndependentTax);
143
+ finalTotalsData.CustPartITax = TrUtils.SetValueToZeroIfNull(TaxInfo[3]);
144
+ finalTotalsData.CustPartCGST = TrUtils.SetValueToZeroIfNull(TaxInfo[0]);
145
+ finalTotalsData.CustPartIGST = TrUtils.SetValueToZeroIfNull(TaxInfo[2]);
146
+ finalTotalsData.CustPartSGST = TrUtils.SetValueToZeroIfNull(TaxInfo[1]);
147
+ // finalTotalsData.CustLaborAfterTax = Add(finalTotalsData.CustLaborITax, finalTotalsData.CustLaborTotalAfterDisc);
148
+ finalTotalsData.CustPartAfterTax = Add(finalTotalsData.CustPartITax, finalTotalsData.CustPartsTotalAfterDisc);
149
+ finalTotalsData.CustTaxGroupData = this.GetTaxGroupingForPartsByHSN(TrUtils.Stringify(PartsList), TaxCodes, DecimalsNumber);
150
+ finalTotalsData.CustTaxGroupDataByPerc = this.GetTaxGroupingForPartsByPerc(PartsList, TaxCodes, DecimalsNumber);
151
+ finalTotalsData.CustTotalRoundedBy = TrUtils.FixedTo(finalTotalsData.Round, DecimalsNumber);
152
+ finalTotalsData.CustRoundedTotal = TrUtils.FixedTo(finalTotalsData.Total, DecimalsNumber);
153
+ for (var key in finalTotalsData) {
154
+ if (key !== 'Total' && key !== 'SubTotal' &&
155
+ key !== 'LDisc' && key !== 'LPerc' && key !== 'PDisc' &&
156
+ key !== 'PPerc' && key !== 'Disc' && key !== 'Perc' && key !== 'Tax'
157
+ && typeof finalTotalsData[key] === 'number') {
158
+ finalTotalsData[key] = TrUtils.FixPriceValue(finalTotalsData[key], DecimalsNumber);
159
+ }
160
+ }
161
+
162
+ return finalTotalsData;
163
+ }
164
+
165
+ static GetTaxGroupingForPartsByPerc(Parts: any, TaxCodes: any, DecimalsNumber: any) {
166
+ Parts = this.GetCombinedTaxPercentage(TrUtils.Stringify(Parts), TaxCodes);
167
+ // Parts = this.ResetPartsHSNIfInvalid(Parts);
168
+
169
+ let FinalMatchedParts: any[] = this.ComparePartsByPerc(Parts, TaxCodes);
170
+
171
+ return this.GetTaxGroupingInfoByHSN(FinalMatchedParts, TaxCodes, DecimalsNumber);
172
+ }
173
+
174
+ static ComparePartsByPerc(Parts: any, TaxCodes: any) {
175
+ let FinalMatchedParts: any[] = [];
176
+ Parts?.forEach((Part: any) => {
177
+ let MatchedPartsBasedOnHSN = Parts.filter((argPart: any) => {
178
+ let PartFound: boolean = false;
179
+ FinalMatchedParts.forEach((FinalArgParts: any) => {
180
+ let PartIndex: any = FinalArgParts.findIndex((FinalArgPart: any) => {
181
+ return FinalArgPart._id === argPart._id;
182
+ });
183
+ if (PartIndex !== -1) {
184
+ PartFound = true;
185
+ }
186
+ });
187
+
188
+ // let argGSTValues: any[] = this.GetGSTValueBasedOnTaxCode(argPart.TCode, TaxCodes);
189
+ // let argCGST = argGSTValues[0];
190
+ // let argSGST = argGSTValues[1];
191
+ // let argIGST = argGSTValues[2];
192
+
193
+ // let partGSTValues: any[] = this.GetGSTValueBasedOnTaxCode(Part.TCode, TaxCodes);
194
+ // let partCGST = partGSTValues[0];
195
+ // let partSGST = partGSTValues[1];
196
+ // let partIGST = partGSTValues[2];
197
+
198
+ return (!PartFound) &&
199
+ (argPart.CGSTAmt === Part.CGSTAmt) && (argPart.IGSTAmt === Part.IGSTAmt) &&
200
+ (argPart.SGSTAmt === Part.SGSTAmt);
201
+ });
202
+ if (MatchedPartsBasedOnHSN.length !== 0) {
203
+ FinalMatchedParts.push(MatchedPartsBasedOnHSN);
204
+ }
205
+ });
206
+ return FinalMatchedParts;
207
+ }
208
+
209
+ static GetPartDiscountedTotal(PartsList: any, isTaxable: boolean, finalTotalsData: any) {
210
+ let PartsDiscountedTotal: any = 0;
211
+ let overallPartDisc: number = 0;
212
+ if (!isTaxable) {
213
+ overallPartDisc = TrUtils.SetValueToZeroIfNull(finalTotalsData.PDisc)
214
+ }
215
+ PartsList.forEach((Part: any) => {
216
+ PartsDiscountedTotal = Add(PartsDiscountedTotal, Part.DiscountedPrice);
217
+ });
218
+ return Add(PartsDiscountedTotal, overallPartDisc);
219
+ }
220
+
221
+ static GetPartsTaxTotalFor(PartsList: any, IsIndependentTax: boolean) {
222
+ let TotalTaxAmt: any = 0;
223
+ if (IsIndependentTax) {
224
+ PartsList.forEach((Part: any) => {
225
+ TotalTaxAmt = Add(TotalTaxAmt, Part.CGST, Part.SGST, Part.IGST);
226
+ });
227
+ }
228
+ return TotalTaxAmt;
229
+ }
230
+
231
+ static GetCustomerTotalBasedOnTaxType(finalTotalsData: any, LaborTaxAmount: number, PartsTaxAmount: number
232
+ , LaborList: any, PartsList: any,
233
+ IsIndependentTax: boolean) {
234
+ // let LaborTotalAfterDisc: any = this.GetLaborTotalAfterDiscount(LaborList);
235
+ let PartsTotalAfterDisc: any = this.GetPartsTotalAfterDiscount(PartsList);
236
+ if (IsIndependentTax) {
237
+ return Add(PartsTotalAfterDisc, LaborTaxAmount, PartsTaxAmount);
238
+ } else {
239
+ return Subtract(PartsTotalAfterDisc, finalTotalsData.Disc);
240
+ }
241
+ }
242
+
243
+ static ItemsTotalAfterDiscount(PartsTotalAfterDisc: number, PartsTaxAmount: number, MainPDisc: number, PDiscInPerc: string) {
244
+ let ItemsTotal: number = Add(PartsTotalAfterDisc, PartsTaxAmount);
245
+ if (!TrUtils.IsZero(MainPDisc)) {
246
+ if (!TrUtils.IsEmpty(PDiscInPerc)) {
247
+ ItemsTotal = Subtract(ItemsTotal, Divide(Multiply(ItemsTotal, Number(PDiscInPerc)), 100));
248
+ } else {
249
+ ItemsTotal = Subtract(ItemsTotal, MainPDisc);
250
+ }
251
+ }
252
+ return ItemsTotal;
253
+ }
254
+
255
+ static GetLaborCGSTTaxTotal(opCodesList: any, IsIndependentTax: boolean) {
256
+ let TotalTaxAmt: any = 0;
257
+ if (IsIndependentTax) {
258
+ opCodesList.forEach((Labor: any) => {
259
+ TotalTaxAmt = Add(TotalTaxAmt, Labor.CGST);
260
+ });
261
+ }
262
+ return TotalTaxAmt;
263
+ }
264
+
265
+ static GetLaborIGSTTaxTotal(opCodesList: any, IsIndependentTax: boolean) {
266
+ let TotalTaxAmt: any = 0;
267
+ if (IsIndependentTax) {
268
+ opCodesList.forEach((Labor: any) => {
269
+ TotalTaxAmt = Add(TotalTaxAmt, Labor.IGST);
270
+ });
271
+ }
272
+ return TotalTaxAmt;
273
+ }
274
+
275
+ static GetLaborSGSTTaxTotal(opCodesList: any, IsIndependentTax: boolean) {
276
+ let TotalTaxAmt: any = 0;
277
+ if (IsIndependentTax) {
278
+ opCodesList.forEach((Labor: any) => {
279
+ TotalTaxAmt = Add(TotalTaxAmt, Labor.SGST);
280
+ });
281
+ }
282
+ return TotalTaxAmt;
283
+ }
284
+
285
+ static GetPartGSTTaxTotal(PartsList: any, IsIndependentTax: boolean) {
286
+ let TotalCGSTAmt: number = 0;
287
+ let TotalSGSTAmt: number = 0;
288
+ let TotalIGSTAmt: number = 0;
289
+ let TotalTaxAmt: number = 0;
290
+ if (IsIndependentTax) {
291
+ PartsList.forEach((Part: any) => {
292
+ TotalCGSTAmt = Add(TotalCGSTAmt, Part.CGST);
293
+ TotalIGSTAmt = Add(TotalIGSTAmt, Part.IGST);
294
+ TotalSGSTAmt = Add(TotalSGSTAmt, Part.SGST);
295
+ TotalTaxAmt = Add(TotalTaxAmt, Part.CGST, Part.SGST, Part.IGST);
296
+ });
297
+ }
298
+ return [TotalCGSTAmt, TotalSGSTAmt, TotalIGSTAmt, TotalTaxAmt];
299
+ }
300
+
301
+ static GetTaxGroupingForPartsByHSN(Parts: any, TaxCodes: any, DecimalsNumber: number) {
302
+ Parts = this.GetCombinedTaxPercentage(Parts, TaxCodes);
303
+ // Parts = this.ResetPartsHSNIfInvalid(Parts);
304
+ let FinalMatchedParts: any[] = this.ComparePartsByHSN(Parts, TaxCodes);
305
+ return this.GetTaxGroupingInfoByHSN(FinalMatchedParts, TaxCodes, DecimalsNumber);
306
+ }
307
+
308
+ static GetCombinedTaxPercentage(Parts: any, TaxCodes: any) {
309
+ Parts.forEach((Part: any) => {
310
+ if (TrUtils.IsNull(Part.HSN)) {
311
+ Part.HSN = '';
312
+ }
313
+ let GSTValues: any[] = this.GetGSTValueBasedOnTaxCode(Part.TCode, TaxCodes);
314
+ Part.CGSTAmt = TrUtils.SetValueToZeroIfNull(GSTValues[0]);
315
+ Part.SGSTAmt = TrUtils.SetValueToZeroIfNull(GSTValues[1]);
316
+ Part.IGSTAmt = TrUtils.SetValueToZeroIfNull(GSTValues[2]);
317
+
318
+ Part.CombinedTaxPercentage = Add(Part.CGSTAmt, Part.SGSTAmt, Part.IGSTAmt);
319
+ });
320
+ return Parts;
321
+ }
322
+
323
+ static ComparePartsByHSN(Parts: any, TaxCodes: any) {
324
+ let FinalMatchedParts: any[] = [];
325
+ Parts.forEach((Part: any) => {
326
+ let MatchedPartsBasedOnHSN = Parts.filter((argPart: any) => {
327
+ let PartFound: boolean = false;
328
+ FinalMatchedParts.forEach((FinalArgParts: any) => {
329
+ let PartIndex: any = FinalArgParts.findIndex((FinalArgPart: any) => {
330
+ return FinalArgPart._id === argPart._id;
331
+ });
332
+ if (PartIndex !== -1) {
333
+ PartFound = true;
334
+ }
335
+ });
336
+
337
+ // let argGSTValues: any[] = this.GetGSTValueBasedOnTaxCode(argPart.TCode, TaxCodes);
338
+ // let argCGST = argGSTValues[0];
339
+ // let argSGST = argGSTValues[1];
340
+ // let argIGST = argGSTValues[2];
341
+
342
+ // let partGSTValues: any[] = this.GetGSTValueBasedOnTaxCode(Part.TCode, TaxCodes);
343
+ // let partCGST = partGSTValues[0];
344
+ // let partSGST = partGSTValues[1];
345
+ // let partIGST = partGSTValues[2];
346
+
347
+ return (argPart.HSN === Part.HSN) && (!PartFound) &&
348
+ (argPart.CGSTAmt === Part.CGSTAmt) && (argPart.IGSTAmt === Part.IGSTAmt) &&
349
+ (argPart.SGSTAmt === Part.SGSTAmt);
350
+ });
351
+ if (MatchedPartsBasedOnHSN.length !== 0) {
352
+ FinalMatchedParts.push(MatchedPartsBasedOnHSN);
353
+ }
354
+ });
355
+ return FinalMatchedParts;
356
+ }
357
+
358
+ static GetTaxGroupingInfoByHSN(FinalMatchedParts: any, TaxCodes: any, DecimalsNumber: any) {
359
+ let HSNTaxInfo: any[] = [];
360
+ FinalMatchedParts.forEach((MatchedPart: any) => {
361
+ let TaxInfo: any = {};
362
+ let TaxOnAmount: any = 0;
363
+ let TaxAmount: any = 0;
364
+
365
+ let CGSTAmt: any = 0;
366
+ let SGSTAmt: any = 0;
367
+ let IGSTAmt: any = 0;
368
+
369
+ let HSN: any = MatchedPart[0].HSN;
370
+ TaxInfo.CombinedTaxPercentage = MatchedPart[0].CombinedTaxPercentage;
371
+ MatchedPart.forEach((argMatchedGSTPart: any) => {
372
+ TaxOnAmount = Add(TaxOnAmount, TrUtils.FixedTo(argMatchedGSTPart.AfterPartDisc, DecimalsNumber));
373
+ TaxAmount = Add(TaxAmount, TrUtils.FixedTo(argMatchedGSTPart.CGST, DecimalsNumber));
374
+ TaxAmount = Add(TaxAmount, TrUtils.FixedTo(argMatchedGSTPart.IGST, DecimalsNumber));
375
+ TaxAmount = Add(TaxAmount, TrUtils.FixedTo(argMatchedGSTPart.SGST, DecimalsNumber));
376
+ CGSTAmt = Add(CGSTAmt, TrUtils.FixedTo(argMatchedGSTPart.CGST, DecimalsNumber));
377
+ SGSTAmt = Add(SGSTAmt, TrUtils.FixedTo(argMatchedGSTPart.SGST, DecimalsNumber));
378
+ IGSTAmt = Add(IGSTAmt, TrUtils.FixedTo(argMatchedGSTPart.IGST, DecimalsNumber));
379
+ });
380
+ TaxInfo.HSN = HSN;
381
+
382
+ TaxInfo.CGSTAmt = CGSTAmt;
383
+ TaxInfo.SGSTAmt = SGSTAmt;
384
+ TaxInfo.IGSTAmt = IGSTAmt;
385
+
386
+ TaxInfo.TotalTaxableAmount = TrUtils.FixPriceValue(TaxOnAmount, DecimalsNumber);
387
+ TaxInfo.TotalTaxAmount = TrUtils.FixPriceValue(TaxAmount, DecimalsNumber);
388
+ TaxInfo.ItemsCount = MatchedPart.length;
389
+ // let GSTValues: any[] = this.GetGSTValueBasedOnTaxCode(MatchedPart[0].TCode, TaxCodes);
390
+ // TaxInfo.CGST = GSTValues[0];
391
+ // TaxInfo.SGST = GSTValues[1];
392
+ // TaxInfo.IGST = GSTValues[2];
393
+ TaxInfo.CGST = MatchedPart[0].CGSTAmt;
394
+ TaxInfo.IGST = MatchedPart[0].IGSTAmt;
395
+ TaxInfo.SGST = MatchedPart[0].SGSTAmt;
396
+ if (TaxOnAmount !== 0) {
397
+ HSNTaxInfo.push(TaxInfo);
398
+ }
399
+ });
400
+ return HSNTaxInfo;
401
+ }
402
+
403
+ static GetGSTValueBasedOnTaxCode(TCode: any, TaxCodes: any) {
404
+ let CGST: number = 0;
405
+ let SGST: number = 0;
406
+ let IGST: number = 0;
407
+ if (TrUtils.IsNull(TCode)) {
408
+ return [CGST, SGST, IGST];
409
+ }
410
+ let TCodeIndex: any = TaxCodes.findIndex((TaxCode: any) => {
411
+ return TaxCode._id === Number(TCode);
412
+ });
413
+ if (TCodeIndex !== -1) {
414
+ if (TaxCodes[TCodeIndex].Type === 'Intra') {
415
+ return [TaxCodes[TCodeIndex].CGST, TaxCodes[TCodeIndex].SGST, 0];
416
+ } else {
417
+ return [0, 0, TaxCodes[TCodeIndex].IGST];
418
+ }
419
+ } else {
420
+ return [CGST, SGST, IGST];
421
+ }
422
+ }
423
+
424
+ }