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,295 @@
1
+
2
+ import { MyDate } from '../../utils/my-date';
3
+ import { TrUtils } from '../../utils/tr-utils';
4
+ import { InvoiceStatusEnum, PayTypeEnum } from '../../enums/enums';
5
+ import { ROTypeEnum } from '../../enums/code-enums';
6
+ import { DebitNoteTotalsService } from '../../accounting/debit-note/debit-note-totals.service';
7
+ import { PrintSharedService } from '../../shared/shared-print.service';
8
+ import { Add, Divide, Subtract } from '../../shared/math-operations';
9
+
10
+ export class VendorDebitNotePrintService {
11
+
12
+ static GetDebitNotePrintInfo(OriginalInvoiceData: any, OriginalEntityData: any, image: any,
13
+ IncludeGST: boolean, ConsolidateGST: boolean, TaxCodes: any, IsProforma: boolean) {
14
+
15
+ let ForInsurance: boolean = !TrUtils.IsNull(OriginalInvoiceData.BFrom.InsId);
16
+
17
+ let InvoicePrintData: any = {};
18
+
19
+ let argInvoiceData = TrUtils.Stringify(OriginalInvoiceData);
20
+
21
+ if (!IncludeGST) {
22
+ argInvoiceData.Settings.Tax = 'NO';
23
+ }
24
+
25
+ InvoicePrintData.IsProforma = IsProforma;
26
+
27
+ InvoicePrintData.Settings = TrUtils.Stringify(argInvoiceData.Settings);
28
+ InvoicePrintData.SType = TrUtils.Stringify(argInvoiceData.SType);
29
+
30
+
31
+ let SType: any
32
+
33
+ if (!TrUtils.IsNull(OriginalInvoiceData.SType)) {
34
+ SType = OriginalInvoiceData.SType
35
+ }
36
+
37
+ InvoicePrintData = this.GetPrintConditionsBasedOnInput(InvoicePrintData, IncludeGST, ConsolidateGST, ForInsurance,
38
+ SType, argInvoiceData, IsProforma);
39
+
40
+ InvoicePrintData.Entity = PrintSharedService.GetFormattedEntityDataForPrint(OriginalEntityData, "Invoice", OriginalInvoiceData);
41
+
42
+ InvoicePrintData = PrintSharedService.GetEntityHeaderStyles(InvoicePrintData, OriginalEntityData, image);
43
+
44
+ InvoicePrintData = this.GetInvoiceOtherDetailsForPrint(InvoicePrintData, argInvoiceData);
45
+
46
+ let IsTaxable: boolean = (IncludeGST && TrUtils.isTaxable(argInvoiceData.Settings.Tax)) ? true : false;
47
+
48
+ let finalTotalsData: any = DebitNoteTotalsService.GetTotalsValue(argInvoiceData.Items, IsTaxable,
49
+ true, argInvoiceData.Disc, argInvoiceData.Perc, TaxCodes, true, argInvoiceData.Settings, InvoicePrintData.Entity);
50
+
51
+ if (ConsolidateGST) {
52
+ finalTotalsData.CustLaborTotalBeforeDisc = finalTotalsData.CustLaborAfterTax;
53
+ finalTotalsData.CustPartsTotalBeforeDisc = finalTotalsData.CustPartAfterTax;
54
+ }
55
+
56
+ InvoicePrintData = TrUtils.ConcatObjects(InvoicePrintData, finalTotalsData);
57
+
58
+ InvoicePrintData.Items = this.GetItemsPrintInfo(InvoicePrintData.Items, ConsolidateGST, TaxCodes, OriginalEntityData.Entity.Settings?.Acc?.LTot, OriginalEntityData.Entity.DecimalsNumber);
59
+
60
+ argInvoiceData = this.ReverseItemsForInvoicePrint(argInvoiceData);
61
+
62
+ InvoicePrintData.PrintInfo = this.PrepareFormatForInvoicePrint(InvoicePrintData, ROTypeEnum.Invoice, argInvoiceData.Sts);
63
+
64
+ InvoicePrintData = this.GetFormattedProductDataForPrint(argInvoiceData, InvoicePrintData);
65
+
66
+ InvoicePrintData = this.GetBillNameForInvoicePrint(argInvoiceData, InvoicePrintData);
67
+
68
+ // let PaymentData = this.GetPaymentsTotal(argInvoiceData.Payments, InvoicePrintData.Total, argInvoiceData.Sts);
69
+ // if (argInvoiceData.Settings.DiscLvl !== 'REC') {
70
+ // InvoicePrintData.FixedDisc = null;
71
+ // }
72
+ // InvoicePrintData.Due = PaymentData.Due;
73
+ // InvoicePrintData.Paid = PaymentData.Paid;
74
+ // if (!TrUtils.IsNull(PaymentData.Sts)) {
75
+ // InvoicePrintData.Sts = PaymentData.Sts;
76
+ // }
77
+ InvoicePrintData.Consolidate = ConsolidateGST;
78
+ if (!ForInsurance && !ConsolidateGST) {
79
+ // if (PrintSharedService.CheckItemIndexWithDisc(InvoicePrintData) !== -1) {
80
+ InvoicePrintData.ShowDiscountColumn = (InvoicePrintData.Settings.DiscLvl === 'ITM' || InvoicePrintData.Settings.DiscLvl === 'RECITM') ? true : false;
81
+
82
+ // }
83
+ }
84
+ // if (OriginalInvoiceData.Type === '1') {
85
+ // InvoicePrintData.From = 'Sales';
86
+ // }
87
+
88
+ return InvoicePrintData;
89
+ }
90
+
91
+ static GetPrintConditionsBasedOnInput(InvoicePrintData: any, IncludeGST: boolean, ConsolidateGST: boolean,
92
+ ForInsurance: boolean, SType: any, OriginalInvoiceData: any, IsProforma: boolean) {
93
+
94
+ InvoicePrintData.ForInsurance = ForInsurance;
95
+ InvoicePrintData.For = ForInsurance ? PayTypeEnum.Insurance : PayTypeEnum.Customer;
96
+ InvoicePrintData.IncludeGST = IncludeGST;
97
+ InvoicePrintData.ConsolidateGST = ConsolidateGST;
98
+
99
+ InvoicePrintData.ShowAccParts = false;
100
+
101
+ InvoicePrintData.ShowIGST = (TrUtils.IsNull(SType) || (SType === 'Intra')) ? false : true;
102
+
103
+ InvoicePrintData.ShowTaxColumn = (IncludeGST && !ConsolidateGST) ? true : false;
104
+ // InvoicePrintData.ShowDiscountColumn = (!ForInsurance && !ConsolidateGST) ? true : false;
105
+
106
+ InvoicePrintData = this.GetInvoiceTypeHeading(InvoicePrintData, OriginalInvoiceData, IncludeGST, ConsolidateGST, IsProforma);
107
+
108
+ InvoicePrintData.PrDate = TrUtils.IsNull(OriginalInvoiceData.PrDate) ? '' : MyDate.ConvertUTCDateToReadable(OriginalInvoiceData.PrDate);
109
+
110
+ return InvoicePrintData;
111
+ }
112
+
113
+ static GetInvoiceTypeHeading(InvoicePrintData: any, OriginalInvoiceData: any, IncludeGST: boolean,
114
+ ConsolidateGST: boolean, IsProforma: boolean) {
115
+ if (IsProforma) {
116
+ InvoicePrintData.HeaderName = 'pro-forma Invoice';
117
+ } else {
118
+ // if (OriginalInvoiceData.Type === 'Sales') {
119
+ // if (IncludeGST && !ConsolidateGST) {
120
+ // InvoicePrintData.HeaderName = 'Parts Tax Invoice';
121
+ // } else {
122
+ // InvoicePrintData.HeaderName = 'Parts Invoice';
123
+ // }
124
+ // InvoicePrintData.PrintType = 'Parts Order';
125
+ // } else {
126
+ // if (IncludeGST && !ConsolidateGST) {
127
+ // InvoicePrintData.HeaderName = 'Tax Invoice';
128
+ // } else {
129
+ // InvoicePrintData.HeaderName = 'Invoice';
130
+ // }
131
+ // }
132
+ InvoicePrintData.HeaderName = 'Debit Note';
133
+ }
134
+ return InvoicePrintData;
135
+ }
136
+
137
+ static GetInvoiceOtherDetailsForPrint(InvoicePrintData: any, OriginalInvoiceData: any) {
138
+ InvoicePrintData.Type = 'Debit Notes';
139
+ InvoicePrintData._id = OriginalInvoiceData.Code;
140
+ InvoicePrintData.Sts = OriginalInvoiceData.Sts;
141
+ InvoicePrintData.CrDate = MyDate.ConvertUTCDateToReadable(OriginalInvoiceData.CrDate);
142
+ return InvoicePrintData;
143
+ }
144
+
145
+ static GetItemsPrintInfo(Items: any, Consolidate: boolean, TaxCodes: any, LineTotal: string, DecimalsNumber: number) {
146
+ Items.forEach((Item: any) => {
147
+ if (Consolidate) {
148
+ let AfterDiscForEach = Divide(Item.AfterPartDisc, Item.Qty);
149
+ let CTaxAmtPerItem = Divide(Item.CGST, Item.Qty);
150
+ let STaxAmtPerItem = Divide(Item.SGST, Item.Qty);
151
+ let ITaxAmtPerItem = Divide(Item.IGST, Item.Qty);
152
+ Item.UnPr = TrUtils.FixedTo(Add(AfterDiscForEach, CTaxAmtPerItem, STaxAmtPerItem, ITaxAmtPerItem), DecimalsNumber);
153
+ }else{
154
+ Item.UnPr = TrUtils.FixPriceValue(Item.UnPr, DecimalsNumber);
155
+ }
156
+ Item.CGSTAmt = TrUtils.FixPriceValue(Item.CGST, DecimalsNumber);
157
+ Item.SGSTAmt = TrUtils.FixPriceValue(Item.SGST, DecimalsNumber);
158
+ Item.IGSTAmt = TrUtils.FixPriceValue(Item.IGST, DecimalsNumber);
159
+ Item.CGSTPerc = PrintSharedService.GetCGSTValueBasedOnTaxCode(Item.TCode, TaxCodes);
160
+ Item.SGSTPerc = PrintSharedService.GetSGSTValueBasedOnTaxCode(Item.TCode, TaxCodes);
161
+ Item.IGSTPerc = PrintSharedService.GetIGSTValueBasedOnTaxCode(Item.TCode, TaxCodes);
162
+ if (LineTotal === 'AT') {
163
+ Item.LineTotal = TrUtils.FixPriceValue(Item.AfterPartTax, DecimalsNumber);
164
+ } else {
165
+ Item.LineTotal = TrUtils.FixPriceValue(Subtract(Item.UnAmt, Item.Disc), DecimalsNumber);
166
+ }
167
+ if (!TrUtils.IsZero(Item.Qty) && !TrUtils.CheckInvalidSelect(Item.UoM)) {
168
+ Item.QtyAndUoM = Item.Qty + ' ' + Item.UoM;
169
+ }
170
+ });
171
+ return Items;
172
+ }
173
+
174
+ static ReverseItemsForInvoicePrint(argInvoiceData: any) {
175
+ argInvoiceData.Items = argInvoiceData.Items.reverse();
176
+ return argInvoiceData;
177
+ }
178
+
179
+ static PrepareFormatForInvoicePrint(InvoicePrintData: any, ROType: any, InvoiceStatus: any) {
180
+ let PrintInfo: any[] = [];
181
+
182
+ let ROLaborParts: any = {};
183
+
184
+ ROLaborParts.Items = InvoicePrintData.Items;
185
+
186
+ ROLaborParts.Sts = InvoiceStatus;
187
+ ROLaborParts.Type = ROType;
188
+
189
+ PrintInfo.push(ROLaborParts);
190
+ return PrintInfo;
191
+ }
192
+
193
+ static GetFormattedProductDataForPrint(OriginalInvoiceData: any, InvoicePrintData: any) {
194
+ if (!TrUtils.IsNull(OriginalInvoiceData.Prod)) {
195
+ InvoicePrintData.Product = OriginalInvoiceData.Prod;
196
+ if (TrUtils.IsNull(InvoicePrintData.Product.VIN)) {
197
+ InvoicePrintData.Product.VIN = '';
198
+ }
199
+ if (TrUtils.IsNull(InvoicePrintData.Product.RegNo)) {
200
+ InvoicePrintData.Product.RegNo = '';
201
+ }
202
+ if (TrUtils.IsNull(InvoicePrintData.Product.EngNo)) {
203
+ InvoicePrintData.Product.EngNo = '';
204
+ }
205
+ InvoicePrintData.MIn = OriginalInvoiceData.Prod.MIn;
206
+ InvoicePrintData.MOut = OriginalInvoiceData.Prod.MOut;
207
+ }
208
+ return InvoicePrintData;
209
+ }
210
+
211
+ static GetBillNameForInvoicePrint(OriginalInvoiceData: any, InvoicePrintData: any) {
212
+ let Customer: any = {};
213
+ Customer.Name = OriginalInvoiceData.BFrom.Name;
214
+ Customer.Adrs = [];
215
+ Customer.Cons = [];
216
+ // if (!TrUtils.IsNull(OriginalInvoiceData.BFrom.Adrs)) {
217
+ // Customer.Adrs.push(OriginalInvoiceData.BFrom.Adrs.A1);
218
+ // if (!TrUtils.IsEmpty(OriginalInvoiceData.BFrom.Adrs.A2)) {
219
+ // Customer.Adrs.push(OriginalInvoiceData.BFrom.Adrs.A2);
220
+ // }
221
+ // if (!TrUtils.IsEmpty(OriginalInvoiceData.BFrom.Adrs.Ct)) {
222
+ // Customer.Adrs.push(OriginalInvoiceData.BFrom.Adrs.Ct);
223
+ // }
224
+ // }
225
+ // Customer.GSTIN = OriginalInvoiceData.BFrom.GSTIN;
226
+
227
+ // if (!TrUtils.IsEmpty(OriginalInvoiceData.BFrom.Ph)) {
228
+ // Customer.Cons = [
229
+ // {
230
+ // Type: 'M',
231
+ // No: OriginalInvoiceData.BFrom.Ph
232
+ // }
233
+ // ];
234
+ // }
235
+ InvoicePrintData.Customer = Customer;
236
+
237
+ if (!TrUtils.IsNull(OriginalInvoiceData.BFrom.InsId)) {
238
+ InvoicePrintData.Cust = this.GetCustomerDetails(OriginalInvoiceData);
239
+ }
240
+ return InvoicePrintData;
241
+ }
242
+
243
+ static GetCustomerDetails(OriginalInvoiceData: any) {
244
+ let Customer: any = {};
245
+ Customer.Name = this.GetBillToName(OriginalInvoiceData.Cust.Title, OriginalInvoiceData.Cust.Name);
246
+ Customer.Cons = [];
247
+ if (!TrUtils.IsEmpty(OriginalInvoiceData.Cust.Ph)) {
248
+ Customer.Cons = [
249
+ {
250
+ Type: 'M',
251
+ No: OriginalInvoiceData.Cust.Ph
252
+ }
253
+ ];
254
+ }
255
+ Customer.GSTIN = OriginalInvoiceData.Cust.GSTIN;
256
+ Customer.Adrs = [];
257
+ if (!TrUtils.IsNull(OriginalInvoiceData.Cust.Adrs)) {
258
+ Customer.Adrs.push(OriginalInvoiceData.Cust.Adrs.A1);
259
+ if (!TrUtils.IsEmpty(OriginalInvoiceData.Cust.Adrs.A2)) {
260
+ Customer.Adrs.push(OriginalInvoiceData.Cust.Adrs.A2);
261
+ }
262
+ Customer.Adrs.push(OriginalInvoiceData.Cust.Adrs.Ct);
263
+ }
264
+ Customer.ConName = OriginalInvoiceData.Cust.ConName;
265
+ Customer.ConPh = OriginalInvoiceData.Cust.ConPhone;
266
+ return Customer;
267
+ }
268
+
269
+ static GetBillToName(Title: any, Name: string) {
270
+ return TrUtils.IsEmpty(Title) ? Name : Title + ' ' + Name;
271
+ }
272
+
273
+ // static GetPaymentsTotal(InvoicePayments: any, Total: number, InvoiceStatus: string, DecimalsNumber: number) {
274
+ // var i = 0;
275
+ // let Data: any = {};
276
+ // let PaidTotal: any = 0;
277
+ // for (i = 0; i < InvoicePayments.length; i++) {
278
+ // PaidTotal += InvoicePayments[i].Paid;
279
+ // }
280
+ // if (InvoiceStatus === InvoiceStatusEnum.Closed) {
281
+ // Data.Due = 0;
282
+ // } else {
283
+ // Data.Due = TrUtils.FixedTo((Total - PaidTotal), DecimalsNumber);
284
+ // }
285
+ // if (Data.Due < 0) {
286
+ // Data.Due = 0;
287
+ // }
288
+ // if (Data.Due === 0) {
289
+ // Data.Sts = InvoiceStatusEnum.Closed;
290
+ // }
291
+ // Data.Paid = TrUtils.FixedTo(PaidTotal, DecimalsNumber);
292
+ // return Data;
293
+ // }
294
+
295
+ }
@@ -0,0 +1,377 @@
1
+ import { Add, Divide, Multiply, Subtract } from "../../shared/math-operations";
2
+ import { TrUtils } from "../../utils/tr-utils";
3
+
4
+ export class VendorDebitNoteTotalsService {
5
+
6
+ static GetTotalsValue(ItemsList: 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
+ ItemsList = this.CalculateLaborItemValues(ItemsList, IsIndependentTax);
21
+
22
+ let finalTotalsData: any = this.GetFinalRODataForSave(ItemsList, IsIndependentTax, Disc, Perc, DetailedInfo, Settings, EntitySettings.DecimalsNumber);
23
+
24
+ if (DetailedInfo) {
25
+ finalTotalsData = this.GetDetailedTotalsData(finalTotalsData,
26
+ IsIndependentTax, ItemsList, TaxCodes, EntitySettings.DecimalsNumber);
27
+ }
28
+
29
+ if (WithItems) {
30
+ // finalTotalsData.Ops = opCodesList;
31
+ finalTotalsData.Items = ItemsList;
32
+ }
33
+ return finalTotalsData;
34
+ }
35
+
36
+ static CalculateLaborItemValues(ItemsList: any, IsIndependentTax: boolean) {
37
+ ItemsList = this.ResetLaborItemValues(ItemsList, IsIndependentTax);
38
+
39
+ // ItemsList = this.GetLaborItemsDiscountPrice(ItemsList);
40
+
41
+ // ItemsList = this.GetLaborItemsAfterDiscount(ItemsList);
42
+
43
+ // ItemsList = this.GetItemsAfterTax(ItemsList, IsIndependentTax);
44
+
45
+ return ItemsList;
46
+ }
47
+
48
+ static ResetLaborItemValues(ItemsList: any, IsIndependentTax: boolean) {
49
+ ItemsList.forEach((Item: any) => {
50
+ Item = this.ResetLaborItemValueIfInvalid(Item);
51
+ if (TrUtils.IsZero(Item.Qty)) {
52
+ Item.Qty = 1;
53
+ }
54
+ Item.DiscountedPrice = Add(Item.Disc, Item.RecDisc);
55
+ Item.AfterItemDisc = Item.NetAmt;
56
+ if (IsIndependentTax) {
57
+ Item.AfterItemTax = Add(Item.AfterItemDisc, Item.CGST, Item.SGST, Item.IGST);
58
+ } else {
59
+ Item.AfterItemTax = Item.AfterItemDisc;
60
+ }
61
+ });
62
+ return ItemsList;
63
+ }
64
+
65
+ static ResetLaborItemValueIfInvalid(Item: any) {
66
+ Item.UnPr = TrUtils.SetValueToZeroIfNull(Item.UnPr);
67
+ Item.Disc = TrUtils.SetValueToZeroIfNull(Item.Disc);
68
+ Item.RecDisc = TrUtils.SetValueToZeroIfNull(Item.RecDisc);
69
+ Item.CGST = TrUtils.SetValueToZeroIfNull(Item.CGST);
70
+ Item.SGST = TrUtils.SetValueToZeroIfNull(Item.SGST);
71
+ Item.IGST = TrUtils.SetValueToZeroIfNull(Item.IGST);
72
+ return Item;
73
+ }
74
+
75
+ static GetFinalRODataForSave(ItemsList: any, IsIndependentTax: boolean, Disc: any, Perc: string,
76
+ DetailedInfo: boolean, Settings: any, DecimalsNumber: number) {
77
+
78
+ let finalTotalsData: any = {};
79
+
80
+ finalTotalsData = this.SetMainDiscountValues(Disc, Perc, finalTotalsData, DetailedInfo);
81
+
82
+ finalTotalsData.Settings = Settings;
83
+
84
+ finalTotalsData = this.GetFinalCustomerTotalsData(finalTotalsData, ItemsList,
85
+ IsIndependentTax, DetailedInfo, DecimalsNumber);
86
+
87
+ return finalTotalsData;
88
+ }
89
+
90
+ static SetMainDiscountValues(Disc: string, Perc: string, finalTotalsData: any, DetailedInfo: boolean) {
91
+ // finalTotalsData.LDisc = LDisc;
92
+ // finalTotalsData.LPerc = LPerc;
93
+
94
+ // finalTotalsData.PDisc = PDisc;
95
+ // finalTotalsData.PPerc = PPerc;
96
+
97
+ finalTotalsData.Disc = Disc;
98
+ finalTotalsData.Perc = Perc;
99
+
100
+ if (DetailedInfo) {
101
+ // finalTotalsData.FixedLDisc = LDisc;
102
+ // finalTotalsData.FixedPDisc = PDisc;
103
+ finalTotalsData.FixedDisc = Disc;
104
+ }
105
+ return finalTotalsData;
106
+ }
107
+
108
+ static GetFinalCustomerTotalsData(finalTotalsData: any, ItemsList: any, IsIndependentTax: boolean,
109
+ DetailedInfo: boolean, DecimalsNumber: number) {
110
+ let CustomerAfterDiscTotals: number = this.GetSubTotalFor(ItemsList);
111
+
112
+ // let CustLaborTaxTotal = this.GetLaborTaxTotalFor(IsIndependentTax);
113
+
114
+ let CustItemTaxTotal = this.GetItemsTaxTotalFor(ItemsList, IsIndependentTax);
115
+
116
+ finalTotalsData.SubTotal = TrUtils.FixedTo(CustomerAfterDiscTotals, DecimalsNumber);
117
+ // let CustLaborDiscTotal = this.GetLaborDiscountedTotal(LaborList, IsIndependentTax, finalTotalsData);
118
+
119
+ let CustItemsDiscTotal = this.GetItemDiscountedTotal(ItemsList, IsIndependentTax, finalTotalsData);
120
+
121
+ // let CustLaborTotalAfterDisc = this.GetLaborTotalAfterDiscount(LaborList);
122
+ let CustItemsTotalAfterDisc = this.GetItemsTotalAfterDiscount(ItemsList);
123
+
124
+ finalTotalsData.STotal = Add(CustItemsDiscTotal, CustItemsTotalAfterDisc);
125
+
126
+ let CustTotal: any = this.GetCustomerTotalBasedOnTaxType(finalTotalsData, CustItemTaxTotal, ItemsList, IsIndependentTax);
127
+
128
+ finalTotalsData.Round = Subtract(Math.round(CustTotal), CustTotal);
129
+
130
+ finalTotalsData.Total = Math.round(CustTotal);
131
+
132
+ if (DetailedInfo) {
133
+ finalTotalsData.FixedSubTotal = TrUtils.FixedTo(CustomerAfterDiscTotals, DecimalsNumber);
134
+ finalTotalsData.FixedTotal = TrUtils.FixedTo(CustTotal, DecimalsNumber);
135
+ }
136
+
137
+ return finalTotalsData;
138
+ }
139
+
140
+ static GetSubTotalFor(ItemsList: any) {
141
+ // let LaborTotalAfterDisc: any = this.GetLaborTotalAfterDiscount(LaborList);
142
+ let ItemsTotalAfterDisc: any = this.GetItemsTotalAfterDiscount(ItemsList);
143
+ return ItemsTotalAfterDisc;
144
+ }
145
+
146
+ static GetItemsTotalAfterDiscount(ItemsList: any) {
147
+ let ItemsTotalAfterDisc: any = 0;
148
+ ItemsList.forEach((Item: any) => {
149
+ ItemsTotalAfterDisc = Add(ItemsTotalAfterDisc, Item.AfterItemDisc);
150
+ });
151
+ return ItemsTotalAfterDisc;
152
+ }
153
+
154
+ static GetDetailedTotalsData(finalTotalsData: any, IsIndependentTax: boolean, ItemsList: any, TaxCodes: any, DecimalsNumber: number) {
155
+ // finalTotalsData.CustLaborDiscTotal = this.GetLaborDiscountedTotal(opCodesList, IsIndependentTax, finalTotalsData);
156
+
157
+ finalTotalsData.CustItemsDiscTotal = this.GetItemDiscountedTotal(ItemsList, IsIndependentTax, finalTotalsData);
158
+
159
+ // finalTotalsData.CustLaborTotalAfterDisc = this.GetLaborTotalAfterDiscount(opCodesList);
160
+ finalTotalsData.CustItemsTotalAfterDisc = this.GetItemsTotalAfterDiscount(ItemsList);
161
+
162
+ // finalTotalsData.CustLaborTotalBeforeDisc = TrUtils.FixedTo(finalTotalsData.CustLaborTotalAfterDisc
163
+ // + finalTotalsData.CustLaborDiscTotal);
164
+ finalTotalsData.CustItemsTotalBeforeDisc = Add(finalTotalsData.CustItemsTotalAfterDisc
165
+ , finalTotalsData.CustItemsDiscTotal);
166
+
167
+ // finalTotalsData.CustLaborITax = this.GetLaborTaxTotalFor(opCodesList, IsIndependentTax);
168
+ // finalTotalsData.CustLaborSGST = this.GetLaborSGSTTaxTotal(opCodesList, IsIndependentTax);
169
+ // finalTotalsData.CustLaborCGST = this.GetLaborCGSTTaxTotal(opCodesList, IsIndependentTax);
170
+ // finalTotalsData.CustLaborIGST = this.GetLaborIGSTTaxTotal(opCodesList, IsIndependentTax);
171
+ let TaxInfo: any = this.GetItemGSTTaxTotal(ItemsList, IsIndependentTax);
172
+ finalTotalsData.CustItemITax = TrUtils.SetValueToZeroIfNull(TaxInfo[3]);
173
+ finalTotalsData.CustItemCGST = TrUtils.SetValueToZeroIfNull(TaxInfo[0]);
174
+ finalTotalsData.CustItemIGST = TrUtils.SetValueToZeroIfNull(TaxInfo[2]);
175
+ finalTotalsData.CustItemSGST = TrUtils.SetValueToZeroIfNull(TaxInfo[1]);
176
+
177
+ // finalTotalsData.CustItemITax = this.GetItemsTaxTotalFor(ItemsList, IsIndependentTax);
178
+ // finalTotalsData.CustItemCGST = this.GetItemCGSTTaxTotal(ItemsList, IsIndependentTax);
179
+ // finalTotalsData.CustItemIGST = this.GetItemIGSTTaxTotal(ItemsList, IsIndependentTax);
180
+ // finalTotalsData.CustItemSGST = this.GetItemSGSTTaxTotal(ItemsList, IsIndependentTax);
181
+
182
+ // finalTotalsData.CustLaborAfterTax = Add(finalTotalsData.CustLaborITax , finalTotalsData.CustLaborTotalAfterDisc);
183
+ finalTotalsData.CustItemAfterTax = Add(finalTotalsData.CustItemITax, finalTotalsData.CustItemsTotalAfterDisc);
184
+
185
+ finalTotalsData.CustTaxGroupData = this.GetTaxGroupingForItemsByHSN(ItemsList, TaxCodes, DecimalsNumber);
186
+
187
+ finalTotalsData.CustTotalRoundedBy = TrUtils.FixedTo(finalTotalsData.Round, DecimalsNumber);
188
+
189
+ finalTotalsData.CustRoundedTotal = TrUtils.FixedTo(finalTotalsData.Total, DecimalsNumber);
190
+
191
+ for (var key in finalTotalsData) {
192
+ if (key !== 'Total' && key !== 'SubTotal' &&
193
+ key !== 'LDisc' && key !== 'LPerc' && key !== 'PDisc' &&
194
+ key !== 'PPerc' && key !== 'Disc' && key !== 'Perc' && key !== 'Tax'
195
+ && typeof finalTotalsData[key] === 'number') {
196
+ finalTotalsData[key] = TrUtils.FixPriceValue(finalTotalsData[key], DecimalsNumber);
197
+ }
198
+ }
199
+
200
+ return finalTotalsData;
201
+ }
202
+
203
+ static GetItemDiscountedTotal(ItemsList: any, isTaxable: boolean, finalTotalsData: any) {
204
+ let ItemsDiscountedTotal: any = 0;
205
+ let overallItemDisc: number = 0;
206
+ if (!isTaxable) {
207
+ overallItemDisc = TrUtils.SetValueToZeroIfNull(finalTotalsData.PDisc)
208
+ }
209
+ ItemsList.forEach((Item: any) => {
210
+ ItemsDiscountedTotal = Add(ItemsDiscountedTotal, Item.DiscountedPrice);
211
+ });
212
+ return Add(ItemsDiscountedTotal, overallItemDisc);
213
+ }
214
+
215
+ static GetItemsTaxTotalFor(ItemsList: any, IsIndependentTax: boolean) {
216
+ let TotalTaxAmt: any = 0;
217
+ if (IsIndependentTax) {
218
+ ItemsList.forEach((Item: any) => {
219
+ TotalTaxAmt = Add(TotalTaxAmt, Item.CGST, Item.SGST, Item.IGST);
220
+ });
221
+ }
222
+ return TotalTaxAmt;
223
+ }
224
+
225
+ static GetCustomerTotalBasedOnTaxType(finalTotalsData: any, ItemsTaxAmount: number
226
+ , ItemsList: any,
227
+ IsIndependentTax: boolean) {
228
+ // let LaborTotalAfterDisc: any = this.GetLaborTotalAfterDiscount(LaborList);
229
+ let ItemsTotalAfterDisc: any = this.GetItemsTotalAfterDiscount(ItemsList);
230
+ if (IsIndependentTax) {
231
+ return Add(ItemsTotalAfterDisc, ItemsTaxAmount);
232
+ } else {
233
+ return Subtract(ItemsTotalAfterDisc, finalTotalsData.Disc);
234
+ }
235
+ }
236
+
237
+ static ItemsTotalAfterDiscount(ItemsTotalAfterDisc: number, ItemsTaxAmount: number, MainPDisc: number, PDiscInPerc: string) {
238
+ let ItemsTotal: number = Add(ItemsTotalAfterDisc, ItemsTaxAmount);
239
+ if (!TrUtils.IsZero(MainPDisc)) {
240
+ if (!TrUtils.IsEmpty(PDiscInPerc)) {
241
+ ItemsTotal = Subtract(ItemsTotal, Divide(Multiply(ItemsTotal, Number(PDiscInPerc)), 100));
242
+ } else {
243
+ ItemsTotal = Subtract(ItemsTotal, MainPDisc);
244
+ }
245
+ }
246
+ return ItemsTotal;
247
+ }
248
+
249
+ static GetItemGSTTaxTotal(ItemsList: any, IsIndependentTax: boolean) {
250
+ let TotalCGSTAmt: number = 0;
251
+ let TotalSGSTAmt: number = 0;
252
+ let TotalIGSTAmt: number = 0;
253
+ let TotalTaxAmt: number = 0;
254
+ if (IsIndependentTax) {
255
+ ItemsList.forEach((Item: any) => {
256
+ TotalCGSTAmt = Add(TotalCGSTAmt, Item.CGST);
257
+ TotalSGSTAmt = Add(TotalSGSTAmt, Item.SGST);
258
+ TotalIGSTAmt = Add(TotalIGSTAmt, Item.IGST);
259
+ TotalTaxAmt = Add(TotalTaxAmt, Item.CGST, Item.SGST, Item.IGST);
260
+ });
261
+ }
262
+ return [TotalCGSTAmt, TotalSGSTAmt, TotalIGSTAmt, TotalTaxAmt];
263
+ }
264
+
265
+ static GetTaxGroupingForItemsByHSN(Items: any, TaxCodes: any, DecimalsNumber:number) {
266
+ Items = this.GetCombinedTaxPercentage(Items, TaxCodes);
267
+ // Items = this.ResetItemsHSNIfInvalid(Items);
268
+
269
+ let FinalMatchedItems: any[] = this.CompareItemsByHSN(Items, TaxCodes);
270
+
271
+ return this.GetTaxGroupingInfoByHSN(FinalMatchedItems, TaxCodes, DecimalsNumber);
272
+ }
273
+
274
+ static GetCombinedTaxPercentage(Items: any, TaxCodes: any) {
275
+ Items.forEach((Item: any) => {
276
+ if (TrUtils.IsNull(Item.HSN)) {
277
+ Item.HSN = '';
278
+ }
279
+ let TaxInfo = this.GetGSTValueBasedOnTaxCode(Item.TCode, TaxCodes);
280
+ Item.CGSTAmt = TrUtils.SetValueToZeroIfNull(TaxInfo[0]);
281
+ Item.SGSTAmt = TrUtils.SetValueToZeroIfNull(TaxInfo[1]);
282
+ Item.IGSTAmt = TrUtils.SetValueToZeroIfNull(TaxInfo[2]);
283
+
284
+ Item.CombinedTaxPercentage = Add(Item.CGSTAmt, Item.SGSTAmt, Item.IGSTAmt);
285
+ });
286
+ return Items;
287
+ }
288
+
289
+ static CompareItemsByHSN(Items: any, TaxCodes: any) {
290
+ let FinalMatchedItems: any[] = [];
291
+ Items.forEach((Item: any) => {
292
+ let MatchedItemsBasedOnHSN = Items.filter((argItem: any) => {
293
+ let ItemFound: boolean = false;
294
+ FinalMatchedItems.forEach((FinalArgItems: any) => {
295
+ let ItemIndex: any = FinalArgItems.findIndex((FinalArgItem: any) => {
296
+ return FinalArgItem._id === argItem._id;
297
+ });
298
+ if (ItemIndex !== -1) {
299
+ ItemFound = true;
300
+ }
301
+ });
302
+
303
+ // let argGSTValues: any[] = this.GetGSTValueBasedOnTaxCode(argItem.TCode, TaxCodes);
304
+ // let argCGST = argGSTValues[0];
305
+ // let argSGST = argGSTValues[1];
306
+ // let argIGST = argGSTValues[2];
307
+
308
+ // let ItemGSTValues: any[] = this.GetGSTValueBasedOnTaxCode(Item.TCode, TaxCodes);
309
+ // let ItemCGST = ItemGSTValues[0];
310
+ // let ItemSGST = ItemGSTValues[1];
311
+ // let ItemIGST = ItemGSTValues[2];
312
+
313
+ return (argItem.HSN === Item.HSN) && (!ItemFound) &&
314
+ (argItem.CGSTAmt === Item.CGSTAmt) && (argItem.IGSTAmt === Item.IGSTAmt) &&
315
+ (argItem.SGSTAmt === Item.SGSTAmt);
316
+ });
317
+ if (MatchedItemsBasedOnHSN.length !== 0) {
318
+ FinalMatchedItems.push(MatchedItemsBasedOnHSN);
319
+ }
320
+ });
321
+ return FinalMatchedItems;
322
+ }
323
+
324
+ static GetTaxGroupingInfoByHSN(FinalMatchedItems: any, TaxCodes: any, DecimalsNumber: number) {
325
+ let HSNTaxInfo: any[] = [];
326
+ FinalMatchedItems.forEach((MatchedItem: any) => {
327
+ let TaxInfo: any = {};
328
+ let TaxOnAmount: any = 0;
329
+ let TaxAmount: any = 0;
330
+ let HSN: any = MatchedItem[0].HSN;
331
+ TaxInfo.CombinedTaxPercentage = MatchedItem[0].CombinedTaxPercentage;
332
+ MatchedItem.forEach((argMatchedGSTItem: any) => {
333
+ TaxOnAmount = Add(TaxOnAmount, argMatchedGSTItem.AfterItemDisc);
334
+ TaxAmount = Add(TaxAmount, argMatchedGSTItem.CGST);
335
+ TaxAmount = Add(TaxAmount, argMatchedGSTItem.IGST);
336
+ TaxAmount = Add(TaxAmount, argMatchedGSTItem.SGST);
337
+ });
338
+ TaxInfo.HSN = HSN;
339
+ TaxInfo.TotalTaxableAmount = TrUtils.FixPriceValue(TaxOnAmount, DecimalsNumber);
340
+ TaxInfo.TotalTaxAmount = TrUtils.FixPriceValue(TaxAmount, DecimalsNumber);
341
+ TaxInfo.ItemsCount = MatchedItem.length;
342
+ // let GSTValues: any[] = this.GetGSTValueBasedOnTaxCode(MatchedItem[0].TCode, TaxCodes);
343
+ // TaxInfo.CGST = GSTValues[0];
344
+ // TaxInfo.SGST = GSTValues[1];
345
+ // TaxInfo.IGST = GSTValues[2];
346
+ TaxInfo.CGST = MatchedItem[0].CGSTAmt;
347
+ TaxInfo.IGST = MatchedItem[0].IGSTAmt;
348
+ TaxInfo.SGST = MatchedItem[0].SGSTAmt;
349
+ if (TaxOnAmount !== 0) {
350
+ HSNTaxInfo.push(TaxInfo);
351
+ }
352
+ });
353
+ return HSNTaxInfo;
354
+ }
355
+
356
+ static GetGSTValueBasedOnTaxCode(TCode: any, TaxCodes: any) {
357
+ let CGST: number = 0;
358
+ let SGST: number = 0;
359
+ let IGST: number = 0;
360
+ if (TrUtils.IsNull(TCode)) {
361
+ return [CGST, SGST, IGST];
362
+ }
363
+ let TCodeIndex: any = TaxCodes.findIndex((TaxCode: any) => {
364
+ return TaxCode._id === Number(TCode);
365
+ });
366
+ if (TCodeIndex !== -1) {
367
+ if (TaxCodes[TCodeIndex].Type === 'Intra') {
368
+ return [TaxCodes[TCodeIndex].CGST, TaxCodes[TCodeIndex].SGST, 0];
369
+ } else {
370
+ return [0, 0, TaxCodes[TCodeIndex].IGST];
371
+ }
372
+ } else {
373
+ return [CGST, SGST, IGST];
374
+ }
375
+ }
376
+
377
+ }