shareneus 1.0.5

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 (125) hide show
  1. package/dist/aggregation/aggregation.js +60 -0
  2. package/dist/enums/cache-enums.js +37 -0
  3. package/dist/enums/code-enums.js +288 -0
  4. package/dist/enums/enums.js +362 -0
  5. package/dist/enums/industry-enums.js +24 -0
  6. package/dist/excel-files/GSTR-RO-excel.service.js +935 -0
  7. package/dist/excel-files/GSTR1-excel.service.js +295 -0
  8. package/dist/excel-files/GSTR2-excel.service.js +295 -0
  9. package/dist/excel-files/analysis-excel.service.js +297 -0
  10. package/dist/excel-files/category-wise-item-excel.service.js +274 -0
  11. package/dist/excel-files/cust-balance-excel.service.js +287 -0
  12. package/dist/excel-files/cust-wise-sales-details.js +320 -0
  13. package/dist/excel-files/cust-wise-sales-summary-excel.service.js +302 -0
  14. package/dist/excel-files/expiring-drugs-excel.service.js +292 -0
  15. package/dist/excel-files/insurance-expire-excel.service.js +301 -0
  16. package/dist/excel-files/invoice-wise-excel.service.js +857 -0
  17. package/dist/excel-files/item-wise-doctor-sale-excel.service.js +258 -0
  18. package/dist/excel-files/item-wise-mout-details.js +292 -0
  19. package/dist/excel-files/item-wise-mout-summary.js +286 -0
  20. package/dist/excel-files/items-wise-sales-excel.service.js +314 -0
  21. package/dist/excel-files/manf-wise-sales-excel.service.js +276 -0
  22. package/dist/excel-files/operator-wise-details.js +265 -0
  23. package/dist/excel-files/operator-wise-summary.js +266 -0
  24. package/dist/excel-files/payment-receive-excel.service.js +225 -0
  25. package/dist/excel-files/payments-made-excel.service.js +302 -0
  26. package/dist/excel-files/repair-orders-excel.service.js +255 -0
  27. package/dist/excel-files/sa-wise-labor-sales-excel.service.js +232 -0
  28. package/dist/excel-files/sa-wise-part-sales-excel.service.js +232 -0
  29. package/dist/excel-files/sale-summary-excel.service.js +326 -0
  30. package/dist/excel-files/sales-by-service-details-excel.service.js +1 -0
  31. package/dist/excel-files/sales-by-service-summary-excel.service.js +422 -0
  32. package/dist/excel-files/scheduled-drug-summary-excel.service.js +367 -0
  33. package/dist/excel-files/scheduled-drugs-excel.service.js +366 -0
  34. package/dist/excel-files/spares-issue-excel.service.js +492 -0
  35. package/dist/excel-files/stock-excel.service.js +283 -0
  36. package/dist/excel-files/tally-sales-import.service.js +765 -0
  37. package/dist/excel-files/ven-balance-excel.service.js +293 -0
  38. package/dist/index.js +237 -0
  39. package/dist/services/analysis-pdf.service.js +105 -0
  40. package/dist/services/appointment-total.service.js +253 -0
  41. package/dist/services/auto-sales-receipt-pdf.service.js +539 -0
  42. package/dist/services/category-wise-item-pdf.service.js +98 -0
  43. package/dist/services/checklist-pdf.js +140 -0
  44. package/dist/services/checklists-pdf.js +124 -0
  45. package/dist/services/cn-print.service.js +211 -0
  46. package/dist/services/consultation-fee-receipt.service.js +378 -0
  47. package/dist/services/consultation-full-pdf.service.js +220 -0
  48. package/dist/services/consultation-pdf.service.js +360 -0
  49. package/dist/services/credit-note-pdf.service.js +578 -0
  50. package/dist/services/credit-note-totals.service.js +328 -0
  51. package/dist/services/cust-wise-sales-details-pdf.service.js +118 -0
  52. package/dist/services/cust-wise-sales-summary-pdf.service.js +111 -0
  53. package/dist/services/customer-balances-pdf.service.js +169 -0
  54. package/dist/services/dc-landscape-pdf.service.js +903 -0
  55. package/dist/services/dc-landscape-without-price-pdf.service.js +853 -0
  56. package/dist/services/dc-without-price-pdf.service.js +489 -0
  57. package/dist/services/debit-note-pdf.service.js +673 -0
  58. package/dist/services/debit-note-print.service.js +234 -0
  59. package/dist/services/debit-note-totals.service.js +293 -0
  60. package/dist/services/delivery-challan-pdf.service.js +434 -0
  61. package/dist/services/delivery-challan-print.service.js +177 -0
  62. package/dist/services/delivery-challan-totals.js +339 -0
  63. package/dist/services/equipment-design-pdf.service.js +144 -0
  64. package/dist/services/est.print-service.js +1053 -0
  65. package/dist/services/expiring-drugs-pdf.service.js +156 -0
  66. package/dist/services/hc-inv-pdf.service.js +837 -0
  67. package/dist/services/insurance-expire-pdf.service.js +99 -0
  68. package/dist/services/inv-pdf.service.js +785 -0
  69. package/dist/services/inv-print.service.js +415 -0
  70. package/dist/services/invoice-landscape-pdf.service.js +909 -0
  71. package/dist/services/invoice-total.service.js +659 -0
  72. package/dist/services/issue-parts-pdf.service.js +763 -0
  73. package/dist/services/item-detais-pdf.js +136 -0
  74. package/dist/services/item-wise-doctor-sale-pdf.service.js +164 -0
  75. package/dist/services/item-wise-mout-details-pdf.js +107 -0
  76. package/dist/services/item-wise-mout-summary-pdf.js +99 -0
  77. package/dist/services/item-wise-sales-pdf.service.js +178 -0
  78. package/dist/services/manf-wise-sales-pdf.service.js +173 -0
  79. package/dist/services/meeting-pdf.js +369 -0
  80. package/dist/services/mout-pdf.service.js +503 -0
  81. package/dist/services/operator-wise-details-pdf.service.js +103 -0
  82. package/dist/services/operator-wise-summary-pdf.js +101 -0
  83. package/dist/services/pack-ship-pdf.service.js +105 -0
  84. package/dist/services/pack-ship-print.service.js +167 -0
  85. package/dist/services/payment-pdf.service.js +373 -0
  86. package/dist/services/payment-report-pdf.service.js +106 -0
  87. package/dist/services/po-totals.service.js +279 -0
  88. package/dist/services/pos-receipt-pdf.js +438 -0
  89. package/dist/services/purchase-order-pdf.service.js +924 -0
  90. package/dist/services/purchase-order-print.service.js +150 -0
  91. package/dist/services/purchase-order-totals.service.js +280 -0
  92. package/dist/services/receipt-print.service.js +50 -0
  93. package/dist/services/reorder-point-pdf.service.js +151 -0
  94. package/dist/services/repair-orders-pdf.service.js +172 -0
  95. package/dist/services/ro-pdf.service.js +1764 -0
  96. package/dist/services/ro-print-service.js +737 -0
  97. package/dist/services/ro-totals.service.js +1241 -0
  98. package/dist/services/sales-by-service-pdf.service.js +116 -0
  99. package/dist/services/sales-pdf.service.js +630 -0
  100. package/dist/services/sales-print.service.js +305 -0
  101. package/dist/services/sales-receipt-pdf.service.js +611 -0
  102. package/dist/services/sales-receipt-print.service.js +425 -0
  103. package/dist/services/sales-totals.service.js +339 -0
  104. package/dist/services/scheduled-drug-pdf.service.js +176 -0
  105. package/dist/services/scheduled-drug-summary-pdf.service.js +188 -0
  106. package/dist/services/separate-wo-print.service.js +351 -0
  107. package/dist/services/shared-inv-pdf.service.js +763 -0
  108. package/dist/services/shared-pdf.service.js +2569 -0
  109. package/dist/services/shared-print.service.js +885 -0
  110. package/dist/services/task-pdf.service.js +220 -0
  111. package/dist/services/task-reports-pdf.service.js +296 -0
  112. package/dist/services/technician-pdf.service.js +238 -0
  113. package/dist/services/technician-print.service.js +87 -0
  114. package/dist/services/transfer-order-pdf.service.js +139 -0
  115. package/dist/services/vendor-balances-pdf.service.js +101 -0
  116. package/dist/services/vendor-credit-note-pdf.service.js +1007 -0
  117. package/dist/services/vendor-credit-note-print.service.js +104 -0
  118. package/dist/services/vendor-credit-note-totals.service.js +327 -0
  119. package/dist/services/vendor-debit-note-pdf.service.js +561 -0
  120. package/dist/services/vendor-debit-note-print.service.js +245 -0
  121. package/dist/services/vendor-debit-note-totals.service.js +305 -0
  122. package/dist/utils/my-date.js +652 -0
  123. package/dist/utils/tr-utils.js +354 -0
  124. package/package.json +24 -0
  125. package/tsconfig.json +109 -0
@@ -0,0 +1,339 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SalesTotalsService = void 0;
4
+ const aggregation_1 = require("../aggregation/aggregation");
5
+ const tr_utils_1 = require("../utils/tr-utils");
6
+ class SalesTotalsService {
7
+ static GetTotalsValue(ItemsList, IsIndependentTax, DetailedInfo, PDisc, PPerc, Disc, Perc, TaxCodes, WithItems, Settings, isRoundable) {
8
+ // LPerc = TrUtils.SetPercToStringIfNull(LPerc);
9
+ PPerc = tr_utils_1.TrUtils.SetPercToStringIfNull(PPerc);
10
+ Perc = tr_utils_1.TrUtils.SetPercToStringIfNull(Perc);
11
+ // LDisc = TrUtils.SetValueToZeroIfNull(LDisc);
12
+ PDisc = tr_utils_1.TrUtils.SetValueToZeroIfNull(PDisc);
13
+ Disc = tr_utils_1.TrUtils.SetValueToZeroIfNull(Disc);
14
+ // opCodesList = this.CalculateLaborValues(opCodesList, IsIndependentTax);
15
+ ItemsList = this.CalculateLaborItemValues(ItemsList, IsIndependentTax);
16
+ let finalTotalsData = this.GetFinalRODataForSave(ItemsList, IsIndependentTax, PDisc, PPerc, Disc, Perc, DetailedInfo, Settings, isRoundable);
17
+ if (DetailedInfo) {
18
+ finalTotalsData = this.GetDetailedTotalsData(finalTotalsData, IsIndependentTax, ItemsList, TaxCodes);
19
+ }
20
+ if (WithItems) {
21
+ finalTotalsData.Items = ItemsList;
22
+ }
23
+ return finalTotalsData;
24
+ }
25
+ static CalculateLaborItemValues(ItemsList, IsIndependentTax) {
26
+ ItemsList = this.ResetLaborItemValues(ItemsList, IsIndependentTax);
27
+ // ItemsList = this.GetLaborItemsDiscountPrice(ItemsList);
28
+ // ItemsList = this.GetLaborItemsAfterDiscount(ItemsList);
29
+ // ItemsList = this.GetItemsAfterTax(ItemsList, IsIndependentTax);
30
+ return ItemsList;
31
+ }
32
+ static ResetLaborItemValues(ItemsList, IsIndependentTax) {
33
+ ItemsList.forEach((Item) => {
34
+ Item = this.ResetLaborItemValueIfInvalid(Item);
35
+ Item.DiscountedPrice = (0, aggregation_1.addition)(Item.Disc, Item.RecDisc);
36
+ Item.AfterItemDisc = tr_utils_1.TrUtils.SetValueToZeroIfNull(Item.NetAmt);
37
+ if (IsIndependentTax) {
38
+ Item.AfterItemTax = (0, aggregation_1.addition)(Item.AfterItemDisc, Item.CGST, Item.SGST, Item.IGST);
39
+ }
40
+ else {
41
+ Item.AfterItemTax = Item.AfterItemDisc;
42
+ }
43
+ });
44
+ return ItemsList;
45
+ }
46
+ static ResetLaborItemValueIfInvalid(Item) {
47
+ Item.UnPr = tr_utils_1.TrUtils.SetValueToZeroIfNull(Item.UnPr);
48
+ Item.Disc = tr_utils_1.TrUtils.SetValueToZeroIfNull(Item.Disc);
49
+ Item.RecDisc = tr_utils_1.TrUtils.SetValueToZeroIfNull(Item.RecDisc);
50
+ Item.CGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(Item.CGST);
51
+ Item.SGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(Item.SGST);
52
+ Item.IGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(Item.IGST);
53
+ return Item;
54
+ }
55
+ static GetFinalRODataForSave(ItemsList, IsIndependentTax, PDisc, PPerc, Disc, Perc, DetailedInfo, Settings, isRoundable) {
56
+ let finalTotalsData = {};
57
+ finalTotalsData = this.SetMainDiscountValues(PPerc, PDisc, Disc, Perc, finalTotalsData, DetailedInfo);
58
+ finalTotalsData.Settings = Settings;
59
+ finalTotalsData = this.GetFinalCustomerTotalsData(finalTotalsData, ItemsList, IsIndependentTax, DetailedInfo, isRoundable);
60
+ return finalTotalsData;
61
+ }
62
+ static SetMainDiscountValues(PPerc, PDisc, Disc, Perc, finalTotalsData, DetailedInfo) {
63
+ finalTotalsData.PDisc = PDisc;
64
+ finalTotalsData.PPerc = PPerc;
65
+ finalTotalsData.Disc = Disc;
66
+ finalTotalsData.Perc = Perc;
67
+ if (DetailedInfo) {
68
+ finalTotalsData.FixedPDisc = PDisc;
69
+ finalTotalsData.FixedDisc = Disc;
70
+ }
71
+ return finalTotalsData;
72
+ }
73
+ static GetFinalCustomerTotalsData(finalTotalsData, ItemsList, IsIndependentTax, DetailedInfo, isRoundable) {
74
+ let CustomerAfterDiscTotals = this.GetSubTotalFor(ItemsList);
75
+ // let CustLaborTaxTotal = this.GetLaborTaxTotalFor(IsIndependentTax);
76
+ let CustItemTaxTotal = this.GetItemsTaxTotalFor(ItemsList, IsIndependentTax);
77
+ let CustItemsDiscTotal = this.GetItemDiscountedTotal(ItemsList);
78
+ finalTotalsData.SubTotal = (0, aggregation_1.addition)(CustomerAfterDiscTotals, CustItemsDiscTotal);
79
+ let CustTotal = this.GetCustomerTotalBasedOnTaxType(CustItemTaxTotal, ItemsList, IsIndependentTax);
80
+ if (isRoundable) {
81
+ finalTotalsData.Round = (0, aggregation_1.subtraction)(Math.round(CustTotal), CustTotal);
82
+ finalTotalsData.Total = Math.round(CustTotal);
83
+ }
84
+ else {
85
+ finalTotalsData.Total = tr_utils_1.TrUtils.FixedTo(CustTotal);
86
+ }
87
+ if (DetailedInfo) {
88
+ finalTotalsData.FixedSubTotal = tr_utils_1.TrUtils.FixedTo(CustomerAfterDiscTotals);
89
+ finalTotalsData.FixedTotal = tr_utils_1.TrUtils.FixedTo(CustTotal);
90
+ }
91
+ return finalTotalsData;
92
+ }
93
+ static GetSubTotalFor(ItemsList) {
94
+ // let LaborTotalAfterDisc: any = this.GetLaborTotalAfterDiscount(LaborList);
95
+ let ItemsTotalAfterDisc = this.GetItemsTotalAfterDiscount(ItemsList);
96
+ return ItemsTotalAfterDisc;
97
+ }
98
+ static GetItemsTotalAfterDiscount(ItemsList) {
99
+ let ItemsTotalAfterDisc = 0;
100
+ ItemsList.forEach((Item) => {
101
+ ItemsTotalAfterDisc = (0, aggregation_1.addition)(ItemsTotalAfterDisc, Item.AfterItemDisc);
102
+ });
103
+ return ItemsTotalAfterDisc;
104
+ }
105
+ static GetDetailedTotalsData(finalTotalsData, IsIndependentTax, ItemsList, TaxCodes) {
106
+ // finalTotalsData.CustLaborDiscTotal = this.GetLaborDiscountedTotal(opCodesList);
107
+ finalTotalsData.CustItemsDiscTotal = this.GetItemDiscountedTotal(ItemsList);
108
+ // finalTotalsData.CustLaborTotalAfterDisc = this.GetLaborTotalAfterDiscount(opCodesList);
109
+ finalTotalsData.CustItemsTotalAfterDisc = this.GetItemsTotalAfterDiscount(ItemsList);
110
+ finalTotalsData.CustLaborTotalBeforeDisc = (0, aggregation_1.addition)(finalTotalsData.CustLaborTotalAfterDisc, finalTotalsData.CustLaborDiscTotal);
111
+ finalTotalsData.CustItemsTotalBeforeDisc = (0, aggregation_1.addition)(finalTotalsData.CustItemsTotalAfterDisc, finalTotalsData.CustItemsDiscTotal);
112
+ // finalTotalsData.CustLaborITax = this.GetLaborTaxTotalFor(opCodesList, IsIndependentTax);
113
+ // finalTotalsData.CustLaborSGST = this.GetLaborSGSTTaxTotal(opCodesList, IsIndependentTax);
114
+ // finalTotalsData.CustLaborCGST = this.GetLaborCGSTTaxTotal(opCodesList, IsIndependentTax);
115
+ // finalTotalsData.CustLaborIGST = this.GetLaborIGSTTaxTotal(opCodesList, IsIndependentTax);
116
+ let TaxInfo = this.GetItemGSTTaxTotal(ItemsList, IsIndependentTax);
117
+ finalTotalsData.CustItemITax = tr_utils_1.TrUtils.SetValueToZeroIfNull(TaxInfo[3]);
118
+ finalTotalsData.CustItemCGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(TaxInfo[0]);
119
+ finalTotalsData.CustItemIGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(TaxInfo[2]);
120
+ finalTotalsData.CustItemSGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(TaxInfo[1]);
121
+ // finalTotalsData.CustLaborAfterTax = TrUtils.FixedTo(finalTotalsData.CustLaborITax + finalTotalsData.CustLaborTotalAfterDisc);
122
+ finalTotalsData.CustItemAfterTax = (0, aggregation_1.addition)(finalTotalsData.CustItemITax, finalTotalsData.CustItemsTotalAfterDisc);
123
+ finalTotalsData.CustTaxGroupData = this.GetTaxGroupingForItemsByHSN(ItemsList, TaxCodes);
124
+ finalTotalsData.CustTotalRoundedBy = tr_utils_1.TrUtils.FixedTo(finalTotalsData.Round);
125
+ finalTotalsData.CustRoundedTotal = tr_utils_1.TrUtils.FixedTo(finalTotalsData.Total);
126
+ for (var key in finalTotalsData) {
127
+ if (key !== 'Total' && key !== 'SubTotal' &&
128
+ key !== 'LDisc' && key !== 'LPerc' && key !== 'PDisc' &&
129
+ key !== 'PPerc' && key !== 'Disc' && key !== 'Perc' && key !== 'Tax'
130
+ && typeof finalTotalsData[key] === 'number') {
131
+ finalTotalsData[key] = tr_utils_1.TrUtils.FixPriceValue(finalTotalsData[key]);
132
+ }
133
+ }
134
+ return finalTotalsData;
135
+ }
136
+ static GetLaborDiscountedTotal(LaborList) {
137
+ let LaborDiscountedTotal = 0;
138
+ LaborList.forEach((Labor) => {
139
+ LaborDiscountedTotal = (0, aggregation_1.addition)(LaborDiscountedTotal, Labor.DiscountedPrice);
140
+ });
141
+ return LaborDiscountedTotal;
142
+ }
143
+ static GetItemDiscountedTotal(ItemsList) {
144
+ let ItemsDiscountedTotal = 0;
145
+ ItemsList.forEach((Item) => {
146
+ ItemsDiscountedTotal = (0, aggregation_1.addition)(ItemsDiscountedTotal, Item.DiscountedPrice);
147
+ });
148
+ return ItemsDiscountedTotal;
149
+ }
150
+ static GetItemsTaxTotalFor(ItemsList, IsIndependentTax) {
151
+ let TotalTaxAmt = 0;
152
+ if (IsIndependentTax) {
153
+ ItemsList.forEach((Item) => {
154
+ TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Item.CGST, Item.SGST, Item.IGST);
155
+ });
156
+ }
157
+ return TotalTaxAmt;
158
+ }
159
+ static GetCustomerTotalBasedOnTaxType(ItemsTaxAmount, ItemsList, IsIndependentTax) {
160
+ // let LaborTotalAfterDisc: any = this.GetLaborTotalAfterDiscount(LaborList);
161
+ let ItemsTotalAfterDisc = this.GetItemsTotalAfterDiscount(ItemsList);
162
+ if (IsIndependentTax) {
163
+ return (0, aggregation_1.addition)(ItemsTotalAfterDisc, ItemsTaxAmount);
164
+ }
165
+ else {
166
+ return ItemsTotalAfterDisc;
167
+ }
168
+ }
169
+ static LaborTotalAfterDiscount(LaborTotalAfterDisc, LaborTaxAmount, MainLDisc, LDiscInPerc) {
170
+ let LaborTotal = (0, aggregation_1.addition)(LaborTotalAfterDisc, LaborTaxAmount);
171
+ if (!tr_utils_1.TrUtils.IsZero(MainLDisc)) {
172
+ if (!tr_utils_1.TrUtils.IsEmpty(LDiscInPerc)) {
173
+ LaborTotal = (0, aggregation_1.subtraction)(LaborTotal, (0, aggregation_1.division)((0, aggregation_1.multiply)(LaborTotal, Number(LDiscInPerc)), 100));
174
+ }
175
+ else {
176
+ LaborTotal = (0, aggregation_1.subtraction)(LaborTotal, MainLDisc);
177
+ }
178
+ }
179
+ return LaborTotal;
180
+ }
181
+ static ItemsTotalAfterDiscount(ItemsTotalAfterDisc, ItemsTaxAmount, MainPDisc, PDiscInPerc) {
182
+ let ItemsTotal = (0, aggregation_1.addition)(ItemsTotalAfterDisc, ItemsTaxAmount);
183
+ if (!tr_utils_1.TrUtils.IsZero(MainPDisc)) {
184
+ if (!tr_utils_1.TrUtils.IsEmpty(PDiscInPerc)) {
185
+ ItemsTotal = (0, aggregation_1.subtraction)(ItemsTotal, (0, aggregation_1.division)((0, aggregation_1.multiply)(ItemsTotal, Number(PDiscInPerc)), 100));
186
+ }
187
+ else {
188
+ ItemsTotal = (0, aggregation_1.subtraction)(ItemsTotal, MainPDisc);
189
+ }
190
+ }
191
+ return ItemsTotal;
192
+ }
193
+ static GetLaborCGSTTaxTotal(opCodesList, IsIndependentTax) {
194
+ let TotalTaxAmt = 0;
195
+ if (IsIndependentTax) {
196
+ opCodesList.forEach((Labor) => {
197
+ TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Labor.CGST);
198
+ });
199
+ }
200
+ return TotalTaxAmt;
201
+ }
202
+ static GetLaborIGSTTaxTotal(opCodesList, IsIndependentTax) {
203
+ let TotalTaxAmt = 0;
204
+ if (IsIndependentTax) {
205
+ opCodesList.forEach((Labor) => {
206
+ TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Labor.IGST);
207
+ });
208
+ }
209
+ return TotalTaxAmt;
210
+ }
211
+ static GetLaborSGSTTaxTotal(opCodesList, IsIndependentTax) {
212
+ let TotalTaxAmt = 0;
213
+ if (IsIndependentTax) {
214
+ opCodesList.forEach((Labor) => {
215
+ TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Labor.SGST);
216
+ });
217
+ }
218
+ return TotalTaxAmt;
219
+ }
220
+ static GetItemGSTTaxTotal(ItemsList, IsIndependentTax) {
221
+ let TotalCGSTAmt = 0;
222
+ let TotalSGSTAmt = 0;
223
+ let TotalIGSTAmt = 0;
224
+ let TotalTaxAmt = 0;
225
+ if (IsIndependentTax) {
226
+ ItemsList.forEach((Item) => {
227
+ TotalCGSTAmt = (0, aggregation_1.addition)(TotalCGSTAmt, Item.CGST);
228
+ TotalSGSTAmt = (0, aggregation_1.addition)(TotalSGSTAmt, Item.SGST);
229
+ TotalIGSTAmt = (0, aggregation_1.addition)(TotalIGSTAmt, Item.IGST);
230
+ TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Item.CGST, Item.SGST, Item.IGST);
231
+ });
232
+ }
233
+ return [TotalCGSTAmt, TotalSGSTAmt, TotalIGSTAmt, TotalTaxAmt];
234
+ }
235
+ static GetTaxGroupingForItemsByHSN(Items, TaxCodes) {
236
+ Items = this.GetCombinedTaxPercentage(Items, TaxCodes);
237
+ // Items = this.ResetItemsHSNIfInvalid(Items);
238
+ let FinalMatchedItems = this.CompareItemsByHSN(Items, TaxCodes);
239
+ return this.GetTaxGroupingInfoByHSN(FinalMatchedItems, TaxCodes);
240
+ }
241
+ static GetCombinedTaxPercentage(Items, TaxCodes) {
242
+ Items.forEach((Item) => {
243
+ if (tr_utils_1.TrUtils.IsNull(Item.HSN)) {
244
+ Item.HSN = '';
245
+ }
246
+ let TaxInfo = this.GetGSTValueBasedOnTaxCode(Item.TCode, TaxCodes);
247
+ Item.CGSTAmt = tr_utils_1.TrUtils.SetValueToZeroIfNull(TaxInfo[0]);
248
+ Item.SGSTAmt = tr_utils_1.TrUtils.SetValueToZeroIfNull(TaxInfo[1]);
249
+ Item.IGSTAmt = tr_utils_1.TrUtils.SetValueToZeroIfNull(TaxInfo[2]);
250
+ Item.CombinedTaxPercentage = (0, aggregation_1.addition)(Item.CGSTAmt, Item.SGSTAmt, Item.IGSTAmt);
251
+ });
252
+ return Items;
253
+ }
254
+ static CompareItemsByHSN(Items, TaxCodes) {
255
+ let FinalMatchedItems = [];
256
+ Items.forEach((Item) => {
257
+ let MatchedItemsBasedOnHSN = Items.filter((argItem) => {
258
+ let ItemFound = false;
259
+ FinalMatchedItems.forEach((FinalArgItems) => {
260
+ let ItemIndex = FinalArgItems.findIndex((FinalArgItem) => {
261
+ return FinalArgItem._id === argItem._id;
262
+ });
263
+ if (ItemIndex !== -1) {
264
+ ItemFound = true;
265
+ }
266
+ });
267
+ // let argGSTValues: any[] = this.GetGSTValueBasedOnTaxCode(argItem.TCode, TaxCodes);
268
+ // let argCGST = argGSTValues[0];
269
+ // let argSGST = argGSTValues[1];
270
+ // let argIGST = argGSTValues[2];
271
+ // let ItemGSTValues: any[] = this.GetGSTValueBasedOnTaxCode(Item.TCode, TaxCodes);
272
+ // let ItemCGST = ItemGSTValues[0];
273
+ // let ItemSGST = ItemGSTValues[1];
274
+ // let ItemIGST = ItemGSTValues[2];
275
+ return (argItem.HSN === Item.HSN) && (!ItemFound) &&
276
+ (argItem.CGSTAmt === Item.CGSTAmt) && (argItem.IGSTAmt === Item.IGSTAmt) &&
277
+ (argItem.SGSTAmt === Item.SGSTAmt);
278
+ });
279
+ if (MatchedItemsBasedOnHSN.length !== 0) {
280
+ FinalMatchedItems.push(MatchedItemsBasedOnHSN);
281
+ }
282
+ });
283
+ return FinalMatchedItems;
284
+ }
285
+ static GetTaxGroupingInfoByHSN(FinalMatchedItems, TaxCodes) {
286
+ let HSNTaxInfo = [];
287
+ FinalMatchedItems.forEach((MatchedItem) => {
288
+ let TaxInfo = {};
289
+ let TaxOnAmount = 0;
290
+ let TaxAmount = 0;
291
+ let HSN = MatchedItem[0].HSN;
292
+ TaxInfo.CombinedTaxPercentage = MatchedItem[0].CombinedTaxPercentage;
293
+ MatchedItem.forEach((argMatchedGSTItem) => {
294
+ TaxOnAmount = (0, aggregation_1.addition)(TaxOnAmount, argMatchedGSTItem.AfterItemDisc);
295
+ TaxAmount = (0, aggregation_1.addition)(TaxAmount, argMatchedGSTItem.CGST);
296
+ TaxAmount = (0, aggregation_1.addition)(TaxAmount, argMatchedGSTItem.IGST);
297
+ TaxAmount = (0, aggregation_1.addition)(TaxAmount, argMatchedGSTItem.SGST);
298
+ });
299
+ TaxInfo.HSN = HSN;
300
+ TaxInfo.TotalTaxableAmount = tr_utils_1.TrUtils.FixPriceValue(TaxOnAmount);
301
+ TaxInfo.TotalTaxAmount = tr_utils_1.TrUtils.FixPriceValue(TaxAmount);
302
+ TaxInfo.ItemsCount = MatchedItem.length;
303
+ // let GSTValues: any[] = this.GetGSTValueBasedOnTaxCode(MatchedItem[0].TCode, TaxCodes);
304
+ // TaxInfo.CGST = GSTValues[0];
305
+ // TaxInfo.SGST = GSTValues[1];
306
+ // TaxInfo.IGST = GSTValues[2];
307
+ TaxInfo.CGST = MatchedItem[0].CGSTAmt;
308
+ TaxInfo.IGST = MatchedItem[0].IGSTAmt;
309
+ TaxInfo.SGST = MatchedItem[0].SGSTAmt;
310
+ if (TaxOnAmount !== 0) {
311
+ HSNTaxInfo.push(TaxInfo);
312
+ }
313
+ });
314
+ return HSNTaxInfo;
315
+ }
316
+ static GetGSTValueBasedOnTaxCode(TCode, TaxCodes) {
317
+ let CGST = 0;
318
+ let SGST = 0;
319
+ let IGST = 0;
320
+ if (tr_utils_1.TrUtils.IsNull(TCode)) {
321
+ return [CGST, SGST, IGST];
322
+ }
323
+ let TCodeIndex = TaxCodes.findIndex((TaxCode) => {
324
+ return TaxCode._id === Number(TCode);
325
+ });
326
+ if (TCodeIndex !== -1) {
327
+ if (TaxCodes[TCodeIndex].Type === 'Intra') {
328
+ return [TaxCodes[TCodeIndex].CGST, TaxCodes[TCodeIndex].SGST, 0];
329
+ }
330
+ else {
331
+ return [0, 0, TaxCodes[TCodeIndex].IGST];
332
+ }
333
+ }
334
+ else {
335
+ return [CGST, SGST, IGST];
336
+ }
337
+ }
338
+ }
339
+ exports.SalesTotalsService = SalesTotalsService;
@@ -0,0 +1,176 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ScheduledDrugPDFService = void 0;
4
+ const my_date_1 = require("../utils/my-date");
5
+ const tr_utils_1 = require("../utils/tr-utils");
6
+ const shared_pdf_service_1 = require("./shared-pdf.service");
7
+ class ScheduledDrugPDFService {
8
+ static GetScheduledDrugPrint(InvoicesData, CName, searchValue) {
9
+ var dd = {
10
+ info: {
11
+ title: 'ScheduledDrugs',
12
+ },
13
+ header: function (currentPage, pageCount) {
14
+ return { text: currentPage.toString() + ' of ' + pageCount, alignment: 'right', marginRight: 7, fontSize: 8, marginTop: 2 };
15
+ },
16
+ pageMargins: [10, 15, 10, 15],
17
+ content: [
18
+ { text: '' + CName + '', style: ['header'] },
19
+ { text: 'Schedule Wise Drug Sales', alignment: 'center', fontSize: 15, bold: true },
20
+ // { text: 'As of ' + MyDate.ConvertUTCDateToReadable(MyDate.GetDateTimeNowInUTC()), alignment: 'center', fontSize: 10 },
21
+ // SharedPDFService.HeaderAfterLine(),
22
+ shared_pdf_service_1.SharedPDFService.GetSearchValueDetails(searchValue),
23
+ this.GetInvoiceDataTable(InvoicesData),
24
+ ],
25
+ styles: shared_pdf_service_1.SharedPDFService.GetStyles()
26
+ };
27
+ return dd;
28
+ }
29
+ static GetInvoiceDataTable(InvoicesData) {
30
+ let Data = [];
31
+ // InvoicesData.forEach((invoice: any) => {
32
+ Data.push(this.GetItemsTable(InvoicesData));
33
+ // });
34
+ return Data;
35
+ }
36
+ static getTableWidths() {
37
+ // if (isHC) {
38
+ // return [25, '*', '*', '*', '*'];
39
+ // } else {
40
+ return [22, 50, 50, '*', '*', '*', 40, 40, 25, 40, 40];
41
+ // }
42
+ }
43
+ static GetItemsTable(InvoiceData) {
44
+ // InvoicesData.forEach((InvoiceData: any) => {
45
+ return {
46
+ style: 'tableExample',
47
+ marginTop: 3,
48
+ marginBottom: 5,
49
+ table: {
50
+ widths: this.getTableWidths(),
51
+ headerRows: 1,
52
+ body: this.BuildTableBodyForLaborAndParts(InvoiceData)
53
+ // body:[['fsdfsdf','asfafdas','asdasdas','asdasdasd','asddass']]
54
+ },
55
+ layout: {
56
+ hLineWidth: function (i, node) {
57
+ return (i === 0 || i === 1 || i === node.table.body.length) ? 1 : 0.5;
58
+ },
59
+ vLineWidth: function (i, node) {
60
+ return (i === 0 || i === node.table.widths.length) ? 1 : 0.5;
61
+ },
62
+ // hLineStyle: function (i, node) {
63
+ // return (i === 0 || i === 1) ? { dash: { length: 5, space: 5 } } : null;
64
+ // },
65
+ hLineColor: function (i, node) {
66
+ return (i === 0 || i === 1 || i === node.table.body.length) ? 'gray' : 'lightgrey';
67
+ },
68
+ vLineColor: function (i, node) {
69
+ return 'gray';
70
+ },
71
+ }
72
+ };
73
+ // });
74
+ }
75
+ static BuildTableBodyForLaborAndParts(InvoiceData) {
76
+ let body = this.GetHeaderNames();
77
+ // let Row: any = [{ text: InvoiceData.Name, alignment: 'left', colSpan: isHC ? 5 : 8, bold: true, fontSize: 12 }, {}, {}, {}, {}];
78
+ // if (!isHC) {
79
+ // Row.push({});
80
+ // Row.push({});
81
+ // Row.push({});
82
+ // }
83
+ // body.unshift(Row);
84
+ // InvoicesData.forEach((InvoiceData: any) => {
85
+ InvoiceData.forEach((invoice, index) => {
86
+ let dataRow = [];
87
+ // if (isHC) {
88
+ // dataRow.push({ text: index + 1 });
89
+ // dataRow.push({ text: invoice.Code });
90
+ // if (!isHC) {
91
+ // dataRow.push({ text: invoice.Prod?.RegNo });
92
+ // dataRow.push({ text: TrUtils.IsNull(invoice.Prod) ? '' : invoice.Prod?.Model + ' ' + invoice.Prod?.Var });
93
+ // }
94
+ // // dataRow.push({ text: invoice.BFrom.Name, alignment: 'left', style: ['headerstyle'], });
95
+ // dataRow.push({ text: MyDate.ConvertUTCDateToReadable(invoice.CrDate), alignment: 'center', style: ['headerstyle'], });
96
+ // dataRow.push({ text: TrUtils.FixPriceValue(invoice.Total), alignment: 'right', style: ['headerstyle'], });
97
+ // dataRow.push({ text: TrUtils.FixPriceValue(invoice.Due), alignment: 'right', style: ['headerstyle'], });
98
+ // body.push(dataRow);
99
+ // if (InvoiceData.Invoices.length === (index + 1)) {
100
+ // let Row: any = [{ text: 'Total Due ', alignment: 'right', colSpan: isHC ? 4 : 6, bold: true, fontSize: 9 }, {}, {}, {}, { text: TrUtils.FixPriceValue(InvoiceData.Balance), fontSize: 9, alignment: 'right', bold: true }];
101
+ // if (!isHC) {
102
+ // Row.splice(2, 0, {}, {});
103
+ // // Row.push({});
104
+ // }
105
+ // body.push(Row);
106
+ // }
107
+ // } else {
108
+ dataRow.push({ text: index + 1 });
109
+ dataRow.push({ text: invoice.Code });
110
+ dataRow.push({ text: my_date_1.MyDate.ConvertUTCDateToReadable(invoice.CrDate), style: ['headerstyle'], });
111
+ dataRow.push({ text: invoice.CustName });
112
+ dataRow.push({ text: invoice.Name });
113
+ dataRow.push({ text: invoice.ItemName });
114
+ let batchdata;
115
+ // invoice?.Items?.Batches?.forEach((batch: any) => {
116
+ if (!tr_utils_1.TrUtils.IsNull(invoice.Batch)) {
117
+ batchdata = invoice.Batch.BN;
118
+ }
119
+ // else {
120
+ // batchdata = batch.BN;
121
+ // }
122
+ // // }
123
+ // });
124
+ let batchExdate;
125
+ // invoice.Items?.Batches?.forEach((batch: any) => {
126
+ if (!tr_utils_1.TrUtils.IsNull(invoice.Batch)) {
127
+ batchExdate = batchExdate + ',' + my_date_1.MyDate.ConvertUTCDateToReadableExDate(invoice.Batch.ExDt);
128
+ }
129
+ // else {
130
+ // batchExdate = MyDate.ConvertUTCDateToReadableExDate(batch.ExDt);
131
+ // }
132
+ // });
133
+ // if(!isHC){
134
+ dataRow.push({ text: batchdata });
135
+ dataRow.push({ text: batchExdate });
136
+ dataRow.push({ text: tr_utils_1.TrUtils.FixPriceValue(invoice.Qty), alignment: 'right' });
137
+ dataRow.push({ text: tr_utils_1.TrUtils.FixPriceValue(invoice.NetAmt), alignment: 'right' });
138
+ dataRow.push({ text: tr_utils_1.TrUtils.FixPriceValue(invoice.Tax), alignment: 'right' });
139
+ // dataRow.push({ text: TrUtils.FixPriceValue(invoice.Total), alignment: 'right' });
140
+ // dataRow.push({ text: TrUtils.IsNull(invoice.Prod) ? '' : invoice.Prod?.Model + ' ' + invoice.Prod?.Var });
141
+ // }
142
+ // dataRow.push({ text: invoice.BFrom.Name, alignment: 'left', style: ['headerstyle'], });
143
+ // dataRow.push({ text: TrUtils.FixPriceValue(invoice.UnAmt + invoice.Tax), alignment: 'right', style: ['headerstyle'], });
144
+ // dataRow.push({ text: TrUtils.FixPriceValue(invoice.Due), alignment: 'right', style: ['headerstyle'], });
145
+ body.push(dataRow);
146
+ // if (InvoiceData.Invoices.length === (index + 1)) {
147
+ // let Row: any = [{ text: 'Total Due ', alignment: 'right', colSpan: isHC?4:6, bold: true, fontSize: 9 }, {}, {}, {}, { text: TrUtils.FixPriceValue(InvoiceData.Balance), fontSize: 9, alignment: 'right', bold: true }];
148
+ // if(!isHC){
149
+ // Row.splice(2, 0,{},{});
150
+ // // Row.push({});
151
+ // }
152
+ // body.push(Row);
153
+ // }
154
+ // }
155
+ });
156
+ // });
157
+ return body;
158
+ }
159
+ static GetHeaderNames() {
160
+ let HeadingNames;
161
+ HeadingNames = [[{ text: 'S.No', style: 'tableheader1', Field: 'SNo', alignment: 'left', line: true },
162
+ { text: 'Transaction #', style: 'tableheader1', Field: 'Code' },
163
+ { text: 'Created Date', style: 'tableheader1', Field: 'CrDate' },
164
+ { text: 'Customer Name', style: 'tableheader1', Field: 'CustName' },
165
+ { text: 'Doctor Name', style: 'tableheader1', Field: 'Name', },
166
+ { text: 'Item Name', style: 'tableheader1', Field: 'Desc' },
167
+ { text: 'Batch No', style: 'tableheader1', Field: 'Batch' },
168
+ { text: 'Expiry', style: 'tableheader1', Field: 'Expiry' },
169
+ { text: 'Qty', style: 'tableheader1', Field: 'Round', alignment: 'right' },
170
+ { text: 'Amount', style: 'tableheader1', Field: 'Total', alignment: 'right' },
171
+ { text: 'Tax', style: 'tableheader1', Field: 'Total', alignment: 'right' }]
172
+ ];
173
+ return HeadingNames;
174
+ }
175
+ }
176
+ exports.ScheduledDrugPDFService = ScheduledDrugPDFService;