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,328 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CreditNoteTotalsService = void 0;
4
+ const aggregation_1 = require("../aggregation/aggregation");
5
+ const tr_utils_1 = require("../utils/tr-utils");
6
+ class CreditNoteTotalsService {
7
+ static GetTotalsValue(opCodesList, PartsList, IsIndependentTax, DetailedInfo, Disc, Perc, TaxCodes, WithItems, Settings) {
8
+ // LPerc = TrUtils.SetPercToStringIfNull(LPerc);
9
+ // PPerc = TrUtils.SetPercToStringIfNull(PPerc);
10
+ Perc = tr_utils_1.TrUtils.SetPercToStringIfNull(Perc);
11
+ // LDisc = TrUtils.SetValueToZeroIfNull(LDisc);
12
+ // PDisc = TrUtils.SetValueToZeroIfNull(PDisc);
13
+ Disc = tr_utils_1.TrUtils.SetValueToZeroIfNull(Disc);
14
+ // opCodesList = this.CalculateLaborValues(opCodesList, IsIndependentTax);
15
+ PartsList = this.CalculateLaborPartValues(PartsList, IsIndependentTax);
16
+ let finalTotalsData = this.GetFinalRODataForSave(opCodesList, PartsList, IsIndependentTax, Disc, Perc, DetailedInfo, Settings);
17
+ if (DetailedInfo) {
18
+ finalTotalsData = this.GetDetailedTotalsData(finalTotalsData, IsIndependentTax, opCodesList, PartsList, TaxCodes);
19
+ }
20
+ if (WithItems) {
21
+ // finalTotalsData.Ops = opCodesList;
22
+ finalTotalsData.Items = PartsList;
23
+ }
24
+ return finalTotalsData;
25
+ }
26
+ static CalculateLaborPartValues(PartsList, IsIndependentTax) {
27
+ PartsList = this.ResetLaborPartValues(PartsList, IsIndependentTax);
28
+ return PartsList;
29
+ }
30
+ static ResetLaborPartValues(PartsList, IsIndependentTax) {
31
+ PartsList.forEach((Part) => {
32
+ Part = this.ResetLaborPartValueIfInvalid(Part);
33
+ if (tr_utils_1.TrUtils.IsZero(Part.Qty)) {
34
+ Part.Qty = 1;
35
+ }
36
+ Part.DiscountedPrice = (0, aggregation_1.addition)(Part.Disc, Part.RecDisc);
37
+ Part.AfterPartDisc = Part.NetAmt;
38
+ if (IsIndependentTax) {
39
+ Part.AfterPartTax = (0, aggregation_1.addition)(Part.AfterPartDisc, Part.CGST, Part.SGST, Part.IGST);
40
+ }
41
+ else {
42
+ Part.AfterPartTax = Part.AfterPartDisc;
43
+ }
44
+ });
45
+ return PartsList;
46
+ }
47
+ static ResetLaborPartValueIfInvalid(Part) {
48
+ Part.UnPr = tr_utils_1.TrUtils.SetValueToZeroIfNull(Part.UnPr);
49
+ Part.Disc = tr_utils_1.TrUtils.SetValueToZeroIfNull(Part.Disc);
50
+ Part.RecDisc = tr_utils_1.TrUtils.SetValueToZeroIfNull(Part.RecDisc);
51
+ Part.CGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(Part.CGST);
52
+ Part.SGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(Part.SGST);
53
+ Part.IGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(Part.IGST);
54
+ return Part;
55
+ }
56
+ static GetFinalRODataForSave(LaborList, PartsList, IsIndependentTax, Disc, Perc, DetailedInfo, Settings) {
57
+ let finalTotalsData = {};
58
+ finalTotalsData = this.SetMainDiscountValues(Disc, Perc, finalTotalsData, DetailedInfo);
59
+ finalTotalsData.Settings = Settings;
60
+ finalTotalsData = this.GetFinalCustomerTotalsData(finalTotalsData, [], PartsList, IsIndependentTax, DetailedInfo);
61
+ return finalTotalsData;
62
+ }
63
+ static SetMainDiscountValues(Disc, Perc, finalTotalsData, DetailedInfo) {
64
+ // finalTotalsData.LDisc = LDisc;
65
+ // finalTotalsData.LPerc = LPerc;
66
+ // finalTotalsData.PDisc = PDisc;
67
+ // finalTotalsData.PPerc = PPerc;
68
+ finalTotalsData.Disc = Disc;
69
+ finalTotalsData.Perc = Perc;
70
+ if (DetailedInfo) {
71
+ // finalTotalsData.FixedLDisc = LDisc;
72
+ // finalTotalsData.FixedPDisc = PDisc;
73
+ finalTotalsData.FixedDisc = Disc;
74
+ }
75
+ return finalTotalsData;
76
+ }
77
+ static GetFinalCustomerTotalsData(finalTotalsData, LaborList, PartsList, IsIndependentTax, DetailedInfo) {
78
+ let CustomerAfterDiscTotals = this.GetSubTotalFor([], PartsList);
79
+ // let CustLaborTaxTotal = this.GetLaborTaxTotalFor([], IsIndependentTax);
80
+ let CustPartTaxTotal = this.GetPartsTaxTotalFor(PartsList, IsIndependentTax);
81
+ finalTotalsData.SubTotal = tr_utils_1.TrUtils.FixedTo(CustomerAfterDiscTotals);
82
+ // let CustLaborDiscTotal = this.GetLaborDiscountedTotal(LaborList, IsIndependentTax, finalTotalsData);
83
+ let CustPartsDiscTotal = this.GetPartDiscountedTotal(PartsList, IsIndependentTax, finalTotalsData);
84
+ // let CustLaborTotalAfterDisc = this.GetLaborTotalAfterDiscount(LaborList);
85
+ let CustPartsTotalAfterDisc = this.GetPartsTotalAfterDiscount(PartsList);
86
+ finalTotalsData.STotal = (0, aggregation_1.addition)(CustPartsDiscTotal, CustPartsTotalAfterDisc);
87
+ let CustTotal = this.GetCustomerTotalBasedOnTaxType(finalTotalsData, 0, CustPartTaxTotal, [], PartsList, IsIndependentTax);
88
+ finalTotalsData.Round = (0, aggregation_1.subtraction)(Math.round(CustTotal), CustTotal);
89
+ finalTotalsData.Total = Math.round(CustTotal);
90
+ if (DetailedInfo) {
91
+ finalTotalsData.FixedSubTotal = tr_utils_1.TrUtils.FixedTo(CustomerAfterDiscTotals);
92
+ finalTotalsData.FixedTotal = tr_utils_1.TrUtils.FixedTo(CustTotal);
93
+ }
94
+ return finalTotalsData;
95
+ }
96
+ static GetSubTotalFor(LaborList, PartsList) {
97
+ // let LaborTotalAfterDisc: any = this.GetLaborTotalAfterDiscount(LaborList);
98
+ let PartsTotalAfterDisc = this.GetPartsTotalAfterDiscount(PartsList);
99
+ return PartsTotalAfterDisc;
100
+ }
101
+ static GetPartsTotalAfterDiscount(PartsList) {
102
+ let PartsTotalAfterDisc = 0;
103
+ PartsList.forEach((Part) => {
104
+ PartsTotalAfterDisc = (0, aggregation_1.addition)(PartsTotalAfterDisc, Part.AfterPartDisc);
105
+ });
106
+ return PartsTotalAfterDisc;
107
+ }
108
+ static GetDetailedTotalsData(finalTotalsData, IsIndependentTax, opCodesList, PartsList, TaxCodes) {
109
+ // finalTotalsData.CustLaborDiscTotal = this.GetLaborDiscountedTotal(opCodesList, IsIndependentTax, finalTotalsData);
110
+ finalTotalsData.CustPartsDiscTotal = this.GetPartDiscountedTotal(PartsList, IsIndependentTax, finalTotalsData);
111
+ // finalTotalsData.CustLaborTotalAfterDisc = this.GetLaborTotalAfterDiscount(opCodesList);
112
+ finalTotalsData.CustPartsTotalAfterDisc = this.GetPartsTotalAfterDiscount(PartsList);
113
+ // finalTotalsData.CustLaborTotalBeforeDisc = TrUtils.FixedTo(finalTotalsData.CustLaborTotalAfterDisc
114
+ // + finalTotalsData.CustLaborDiscTotal);
115
+ finalTotalsData.CustPartsTotalBeforeDisc = (0, aggregation_1.addition)(finalTotalsData.CustPartsTotalAfterDisc, finalTotalsData.CustPartsDiscTotal);
116
+ // finalTotalsData.CustLaborITax = this.GetLaborTaxTotalFor(opCodesList, IsIndependentTax);
117
+ // finalTotalsData.CustLaborSGST = this.GetLaborSGSTTaxTotal(opCodesList, IsIndependentTax);
118
+ // finalTotalsData.CustLaborCGST = this.GetLaborCGSTTaxTotal(opCodesList, IsIndependentTax);
119
+ // finalTotalsData.CustLaborIGST = this.GetLaborIGSTTaxTotal(opCodesList, IsIndependentTax);
120
+ let TaxInfo = this.GetPartGSTTaxTotal(PartsList, IsIndependentTax);
121
+ finalTotalsData.CustPartITax = tr_utils_1.TrUtils.SetValueToZeroIfNull(TaxInfo[3]);
122
+ finalTotalsData.CustPartCGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(TaxInfo[0]);
123
+ finalTotalsData.CustPartIGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(TaxInfo[2]);
124
+ finalTotalsData.CustPartSGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(TaxInfo[1]);
125
+ // finalTotalsData.CustLaborAfterTax = addition(finalTotalsData.CustLaborITax, finalTotalsData.CustLaborTotalAfterDisc);
126
+ finalTotalsData.CustPartAfterTax = (0, aggregation_1.addition)(finalTotalsData.CustPartITax, finalTotalsData.CustPartsTotalAfterDisc);
127
+ finalTotalsData.CustTaxGroupData = this.GetTaxGroupingForPartsByHSN(tr_utils_1.TrUtils.Stringify(PartsList), TaxCodes);
128
+ finalTotalsData.CustTotalRoundedBy = tr_utils_1.TrUtils.FixedTo(finalTotalsData.Round);
129
+ finalTotalsData.CustRoundedTotal = tr_utils_1.TrUtils.FixedTo(finalTotalsData.Total);
130
+ for (var key in finalTotalsData) {
131
+ if (key !== 'Total' && key !== 'SubTotal' &&
132
+ key !== 'LDisc' && key !== 'LPerc' && key !== 'PDisc' &&
133
+ key !== 'PPerc' && key !== 'Disc' && key !== 'Perc' && key !== 'Tax'
134
+ && typeof finalTotalsData[key] === 'number') {
135
+ finalTotalsData[key] = tr_utils_1.TrUtils.FixPriceValue(finalTotalsData[key]);
136
+ }
137
+ }
138
+ return finalTotalsData;
139
+ }
140
+ static GetPartDiscountedTotal(PartsList, isTaxable, finalTotalsData) {
141
+ let PartsDiscountedTotal = 0;
142
+ let overallPartDisc = 0;
143
+ if (!isTaxable) {
144
+ overallPartDisc = tr_utils_1.TrUtils.SetValueToZeroIfNull(finalTotalsData.PDisc);
145
+ }
146
+ PartsList.forEach((Part) => {
147
+ PartsDiscountedTotal = (0, aggregation_1.addition)(PartsDiscountedTotal, Part.DiscountedPrice);
148
+ });
149
+ return (0, aggregation_1.addition)(PartsDiscountedTotal, overallPartDisc);
150
+ }
151
+ static GetPartsTaxTotalFor(PartsList, IsIndependentTax) {
152
+ let TotalTaxAmt = 0;
153
+ if (IsIndependentTax) {
154
+ PartsList.forEach((Part) => {
155
+ TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Part.CGST, Part.SGST, Part.IGST);
156
+ });
157
+ }
158
+ return TotalTaxAmt;
159
+ }
160
+ static GetCustomerTotalBasedOnTaxType(finalTotalsData, LaborTaxAmount, PartsTaxAmount, LaborList, PartsList, IsIndependentTax) {
161
+ // let LaborTotalAfterDisc: any = this.GetLaborTotalAfterDiscount(LaborList);
162
+ let PartsTotalAfterDisc = this.GetPartsTotalAfterDiscount(PartsList);
163
+ if (IsIndependentTax) {
164
+ return (0, aggregation_1.addition)(PartsTotalAfterDisc, LaborTaxAmount, PartsTaxAmount);
165
+ }
166
+ else {
167
+ return (0, aggregation_1.subtraction)(PartsTotalAfterDisc, finalTotalsData.Disc);
168
+ }
169
+ }
170
+ static ItemsTotalAfterDiscount(PartsTotalAfterDisc, PartsTaxAmount, MainPDisc, PDiscInPerc) {
171
+ let ItemsTotal = (0, aggregation_1.addition)(PartsTotalAfterDisc, PartsTaxAmount);
172
+ if (!tr_utils_1.TrUtils.IsZero(MainPDisc)) {
173
+ if (!tr_utils_1.TrUtils.IsEmpty(PDiscInPerc)) {
174
+ ItemsTotal = (0, aggregation_1.subtraction)(ItemsTotal, (0, aggregation_1.division)((0, aggregation_1.multiply)(ItemsTotal, Number(PDiscInPerc)), 100));
175
+ }
176
+ else {
177
+ ItemsTotal = (0, aggregation_1.subtraction)(ItemsTotal, MainPDisc);
178
+ }
179
+ }
180
+ return ItemsTotal;
181
+ }
182
+ static GetLaborCGSTTaxTotal(opCodesList, IsIndependentTax) {
183
+ let TotalTaxAmt = 0;
184
+ if (IsIndependentTax) {
185
+ opCodesList.forEach((Labor) => {
186
+ TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Labor.CGST);
187
+ });
188
+ }
189
+ return TotalTaxAmt;
190
+ }
191
+ static GetLaborIGSTTaxTotal(opCodesList, IsIndependentTax) {
192
+ let TotalTaxAmt = 0;
193
+ if (IsIndependentTax) {
194
+ opCodesList.forEach((Labor) => {
195
+ TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Labor.IGST);
196
+ });
197
+ }
198
+ return TotalTaxAmt;
199
+ }
200
+ static GetLaborSGSTTaxTotal(opCodesList, IsIndependentTax) {
201
+ let TotalTaxAmt = 0;
202
+ if (IsIndependentTax) {
203
+ opCodesList.forEach((Labor) => {
204
+ TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Labor.SGST);
205
+ });
206
+ }
207
+ return TotalTaxAmt;
208
+ }
209
+ static GetPartGSTTaxTotal(PartsList, IsIndependentTax) {
210
+ let TotalCGSTAmt = 0;
211
+ let TotalSGSTAmt = 0;
212
+ let TotalIGSTAmt = 0;
213
+ let TotalTaxAmt = 0;
214
+ if (IsIndependentTax) {
215
+ PartsList.forEach((Part) => {
216
+ TotalCGSTAmt = (0, aggregation_1.addition)(TotalCGSTAmt, Part.CGST);
217
+ TotalIGSTAmt = (0, aggregation_1.addition)(TotalIGSTAmt, Part.IGST);
218
+ TotalSGSTAmt = (0, aggregation_1.addition)(TotalSGSTAmt, Part.SGST);
219
+ TotalTaxAmt = (0, aggregation_1.addition)(TotalTaxAmt, Part.CGST, Part.SGST, Part.IGST);
220
+ });
221
+ }
222
+ return [TotalCGSTAmt, TotalSGSTAmt, TotalIGSTAmt, TotalTaxAmt];
223
+ }
224
+ static GetTaxGroupingForPartsByHSN(Parts, TaxCodes) {
225
+ Parts = this.GetCombinedTaxPercentage(Parts, TaxCodes);
226
+ // Parts = this.ResetPartsHSNIfInvalid(Parts);
227
+ let FinalMatchedParts = this.ComparePartsByHSN(Parts, TaxCodes);
228
+ return this.GetTaxGroupingInfoByHSN(FinalMatchedParts, TaxCodes);
229
+ }
230
+ static GetCombinedTaxPercentage(Parts, TaxCodes) {
231
+ Parts.forEach((Part) => {
232
+ if (tr_utils_1.TrUtils.IsNull(Part.HSN)) {
233
+ Part.HSN = '';
234
+ }
235
+ let GSTValues = this.GetGSTValueBasedOnTaxCode(Part.TCode, TaxCodes);
236
+ Part.CGSTAmt = tr_utils_1.TrUtils.SetValueToZeroIfNull(GSTValues[0]);
237
+ Part.SGSTAmt = tr_utils_1.TrUtils.SetValueToZeroIfNull(GSTValues[1]);
238
+ Part.IGSTAmt = tr_utils_1.TrUtils.SetValueToZeroIfNull(GSTValues[2]);
239
+ Part.CombinedTaxPercentage = (0, aggregation_1.addition)(Part.CGSTAmt, Part.SGSTAmt, Part.IGSTAmt);
240
+ });
241
+ return Parts;
242
+ }
243
+ static ComparePartsByHSN(Parts, TaxCodes) {
244
+ let FinalMatchedParts = [];
245
+ Parts.forEach((Part) => {
246
+ let MatchedPartsBasedOnHSN = Parts.filter((argPart) => {
247
+ let PartFound = false;
248
+ FinalMatchedParts.forEach((FinalArgParts) => {
249
+ let PartIndex = FinalArgParts.findIndex((FinalArgPart) => {
250
+ return FinalArgPart._id === argPart._id;
251
+ });
252
+ if (PartIndex !== -1) {
253
+ PartFound = true;
254
+ }
255
+ });
256
+ // let argGSTValues: any[] = this.GetGSTValueBasedOnTaxCode(argPart.TCode, TaxCodes);
257
+ // let argCGST = argGSTValues[0];
258
+ // let argSGST = argGSTValues[1];
259
+ // let argIGST = argGSTValues[2];
260
+ // let partGSTValues: any[] = this.GetGSTValueBasedOnTaxCode(Part.TCode, TaxCodes);
261
+ // let partCGST = partGSTValues[0];
262
+ // let partSGST = partGSTValues[1];
263
+ // let partIGST = partGSTValues[2];
264
+ return (argPart.HSN === Part.HSN) && (!PartFound) &&
265
+ (argPart.CGSTAmt === Part.CGSTAmt) && (argPart.IGSTAmt === Part.IGSTAmt) &&
266
+ (argPart.SGSTAmt === Part.SGSTAmt);
267
+ });
268
+ if (MatchedPartsBasedOnHSN.length !== 0) {
269
+ FinalMatchedParts.push(MatchedPartsBasedOnHSN);
270
+ }
271
+ });
272
+ return FinalMatchedParts;
273
+ }
274
+ static GetTaxGroupingInfoByHSN(FinalMatchedParts, TaxCodes) {
275
+ let HSNTaxInfo = [];
276
+ FinalMatchedParts.forEach((MatchedPart) => {
277
+ let TaxInfo = {};
278
+ let TaxOnAmount = 0;
279
+ let TaxAmount = 0;
280
+ let HSN = MatchedPart[0].HSN;
281
+ TaxInfo.CombinedTaxPercentage = MatchedPart[0].CombinedTaxPercentage;
282
+ MatchedPart.forEach((argMatchedGSTPart) => {
283
+ TaxOnAmount = (0, aggregation_1.addition)(TaxOnAmount, argMatchedGSTPart.AfterPartDisc);
284
+ TaxAmount = (0, aggregation_1.addition)(TaxAmount, argMatchedGSTPart.CGST);
285
+ TaxAmount = (0, aggregation_1.addition)(TaxAmount, argMatchedGSTPart.IGST);
286
+ TaxAmount = (0, aggregation_1.addition)(TaxAmount, argMatchedGSTPart.SGST);
287
+ });
288
+ TaxInfo.HSN = HSN;
289
+ TaxInfo.TotalTaxableAmount = tr_utils_1.TrUtils.FixPriceValue(TaxOnAmount);
290
+ TaxInfo.TotalTaxAmount = tr_utils_1.TrUtils.FixPriceValue(TaxAmount);
291
+ TaxInfo.ItemsCount = MatchedPart.length;
292
+ // let GSTValues: any[] = this.GetGSTValueBasedOnTaxCode(MatchedPart[0].TCode, TaxCodes);
293
+ // TaxInfo.CGST = GSTValues[0];
294
+ // TaxInfo.SGST = GSTValues[1];
295
+ // TaxInfo.IGST = GSTValues[2];
296
+ TaxInfo.CGST = MatchedPart[0].CGSTAmt;
297
+ TaxInfo.IGST = MatchedPart[0].IGSTAmt;
298
+ TaxInfo.SGST = MatchedPart[0].SGSTAmt;
299
+ if (TaxOnAmount !== 0) {
300
+ HSNTaxInfo.push(TaxInfo);
301
+ }
302
+ });
303
+ return HSNTaxInfo;
304
+ }
305
+ static GetGSTValueBasedOnTaxCode(TCode, TaxCodes) {
306
+ let CGST = 0;
307
+ let SGST = 0;
308
+ let IGST = 0;
309
+ if (tr_utils_1.TrUtils.IsNull(TCode)) {
310
+ return [CGST, SGST, IGST];
311
+ }
312
+ let TCodeIndex = TaxCodes.findIndex((TaxCode) => {
313
+ return TaxCode._id === Number(TCode);
314
+ });
315
+ if (TCodeIndex !== -1) {
316
+ if (TaxCodes[TCodeIndex].Type === 'Intra') {
317
+ return [TaxCodes[TCodeIndex].CGST, TaxCodes[TCodeIndex].SGST, 0];
318
+ }
319
+ else {
320
+ return [0, 0, TaxCodes[TCodeIndex].IGST];
321
+ }
322
+ }
323
+ else {
324
+ return [CGST, SGST, IGST];
325
+ }
326
+ }
327
+ }
328
+ exports.CreditNoteTotalsService = CreditNoteTotalsService;
@@ -0,0 +1,118 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CustWiseSalesDetailsService = 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 CustWiseSalesDetailsService {
8
+ static GetCustWiseSalesDetailsPrint(InvoicesData, CName, isPhar, isHC, isSale, searchValue) {
9
+ var dd = {
10
+ info: {
11
+ title: isSale ? 'CustomerWiseSales' : 'VendorWisePurchases',
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: isSale ? 'Customer Wise Sales Details' : 'Vendor Wise Purchases Details', 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, isPhar, isHC, isSale),
24
+ ],
25
+ styles: shared_pdf_service_1.SharedPDFService.GetStyles()
26
+ };
27
+ return dd;
28
+ }
29
+ static GetInvoiceDataTable(InvoicesData, isPhar, isHC, isSale) {
30
+ let Data = [];
31
+ // InvoicesData.forEach((invoice: any) => {
32
+ Data.push(this.GetItemsTable(InvoicesData, isPhar, isHC, isSale));
33
+ // });
34
+ return Data;
35
+ }
36
+ static getTableWidths(isHC) {
37
+ // if (isHC) {
38
+ // return [25, '*', '*', '*', '*'];
39
+ // } else {
40
+ return [20, 50, 50, '*', 40, 40, 40, 45, 37, 40];
41
+ // }
42
+ }
43
+ static GetItemsTable(InvoiceData, isPhar, isHC, isSale) {
44
+ // InvoicesData.forEach((InvoiceData: any) => {
45
+ return {
46
+ style: 'tableExample',
47
+ marginTop: 3,
48
+ marginBottom: 5,
49
+ table: {
50
+ widths: this.getTableWidths(isHC),
51
+ headerRows: 1,
52
+ body: this.BuildTableBodyForLaborAndParts(InvoiceData, isPhar, isHC, isSale)
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, isPhar, isHC, isSale) {
76
+ let body = this.GetHeaderNames(isPhar, isHC, isSale);
77
+ InvoiceData.forEach((invoice, index) => {
78
+ let dataRow = [];
79
+ dataRow.push({ text: index + 1 });
80
+ if (isSale) {
81
+ dataRow.push({ text: invoice.Code });
82
+ }
83
+ else {
84
+ dataRow.push({ text: invoice.BNo });
85
+ }
86
+ dataRow.push({ text: my_date_1.MyDate.ConvertUTCDateToReadable(invoice.CrDate), style: ['headerstyle'], });
87
+ if (isSale) {
88
+ dataRow.push({ text: invoice.CustName });
89
+ }
90
+ else {
91
+ dataRow.push({ text: invoice.VendName });
92
+ }
93
+ dataRow.push({ text: tr_utils_1.TrUtils.FixPriceValue(invoice.SubTotal), alignment: 'right' });
94
+ dataRow.push({ text: tr_utils_1.TrUtils.FixPriceValue(invoice.Disc), alignment: 'right' });
95
+ dataRow.push({ text: tr_utils_1.TrUtils.FixPriceValue(invoice.Tax), alignment: 'right' });
96
+ dataRow.push({ text: tr_utils_1.TrUtils.FixPriceValue(invoice.Adjust), alignment: 'right' });
97
+ dataRow.push({ text: tr_utils_1.TrUtils.FixPriceValue(invoice.Round), alignment: 'right' });
98
+ dataRow.push({ text: tr_utils_1.TrUtils.FixPriceValue(invoice.Total), alignment: 'right' });
99
+ body.push(dataRow);
100
+ });
101
+ return body;
102
+ }
103
+ static GetHeaderNames(isPhar, isHC, isSale) {
104
+ let HeadingNames;
105
+ HeadingNames = [[{ text: 'S.No', style: 'tableheader1', Field: 'SNo', alignment: 'left', line: true },
106
+ { text: 'Transaction #', style: 'tableheader1', Field: 'Code' },
107
+ { text: 'Created Date', style: 'tableheader1', Field: 'CrDate' },
108
+ { text: isSale ? 'Customer Name' : 'Vendor Name', style: 'tableheader1', Field: 'Name' },
109
+ { text: 'SubTotal', style: 'tableheader1', Field: 'SubTotal', alignment: 'right' },
110
+ { text: 'Discount', style: 'tableheader1', Field: 'Disc', alignment: 'right' },
111
+ { text: 'Tax', style: 'tableheader1', Field: 'Tax', alignment: 'right' },
112
+ { text: 'Adjustment', style: 'tableheader1', Field: 'Adjust', alignment: 'right' },
113
+ { text: 'Round off', style: 'tableheader1', Field: 'Round', alignment: 'right' },
114
+ { text: 'Total', style: 'tableheader1', Field: 'Total', alignment: 'right' }]];
115
+ return HeadingNames;
116
+ }
117
+ }
118
+ exports.CustWiseSalesDetailsService = CustWiseSalesDetailsService;
@@ -0,0 +1,111 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SalesByCustomerPDFService = void 0;
4
+ // import { MyDate } from '../utils/my-date';
5
+ const tr_utils_1 = require("../utils/tr-utils");
6
+ const shared_pdf_service_1 = require("./shared-pdf.service");
7
+ class SalesByCustomerPDFService {
8
+ static GetSaleByCustPrint(InvoicesData, CName, isPhar, isHC, IsSales, HeaerName, searchValue) {
9
+ var dd = {
10
+ info: {
11
+ title: 'CustomerWiseSalesSummary',
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: HeaerName, 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, isPhar, isHC, IsSales),
24
+ ],
25
+ styles: shared_pdf_service_1.SharedPDFService.GetStyles()
26
+ };
27
+ return dd;
28
+ }
29
+ static GetInvoiceDataTable(InvoicesData, isPhar, isHC, IsSales) {
30
+ let Data = [];
31
+ // InvoicesData.forEach((invoice: any) => {
32
+ Data.push(this.GetItemsTable(InvoicesData, isPhar, isHC, IsSales));
33
+ // });
34
+ return Data;
35
+ }
36
+ static getTableWidths(isHC) {
37
+ // if (isHC) {
38
+ return [22, '*', 25, 50, 40, 40, 40, 30, 50];
39
+ // } else {
40
+ // return [25, '*', 40, 40, 80];
41
+ // }
42
+ }
43
+ static GetItemsTable(InvoiceData, isPhar, isHC, IsSales) {
44
+ // InvoicesData.forEach((InvoiceData: any) => {
45
+ return {
46
+ style: 'tableExample',
47
+ marginTop: 3,
48
+ marginBottom: 5,
49
+ table: {
50
+ widths: this.getTableWidths(isHC),
51
+ headerRows: 1,
52
+ body: this.BuildTableBodyForLaborAndParts(InvoiceData, isPhar, isHC, IsSales)
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, isPhar, isHC, IsSales) {
76
+ let body = this.GetHeaderNames(isPhar, isHC);
77
+ InvoiceData.forEach((invoice, index) => {
78
+ let dataRow = [];
79
+ dataRow.push({ text: index + 1 });
80
+ if (IsSales) {
81
+ dataRow.push({ text: invoice.CustName, style: ['headerstyle'], });
82
+ }
83
+ else {
84
+ dataRow.push({ text: invoice.VendName, style: ['headerstyle'], });
85
+ }
86
+ dataRow.push({ text: invoice.Count, alignment: 'right' });
87
+ dataRow.push({ text: tr_utils_1.TrUtils.FixPriceValue(invoice.SubTotal), alignment: 'right' });
88
+ dataRow.push({ text: tr_utils_1.TrUtils.FixPriceValue(invoice.Disc), alignment: 'right' });
89
+ dataRow.push({ text: tr_utils_1.TrUtils.FixPriceValue(invoice.Tax), alignment: 'right' });
90
+ dataRow.push({ text: tr_utils_1.TrUtils.FixPriceValue(invoice.Adjust), alignment: 'right' });
91
+ dataRow.push({ text: tr_utils_1.TrUtils.FixPriceValue(invoice.Round), alignment: 'right' });
92
+ dataRow.push({ text: tr_utils_1.TrUtils.FixPriceValue(invoice.Total), alignment: 'right', style: ['headerstyle'], });
93
+ body.push(dataRow);
94
+ });
95
+ return body;
96
+ }
97
+ static GetHeaderNames(isPhar, isHC) {
98
+ let HeadingNames;
99
+ HeadingNames = [[{ text: 'S.No', style: 'tableheader1', Field: 'SNo', alignment: 'left', line: true },
100
+ { text: 'Name', style: 'tableheader1', Field: 'Name' },
101
+ { text: 'Count', style: 'tableheader1', Field: 'Count', alignment: 'right' },
102
+ { text: 'SubTotal', style: 'tableheader1', Field: 'SubTotal', alignment: 'right' },
103
+ { text: 'Discount', style: 'tableheader1', Field: 'Disc', alignment: 'right' },
104
+ { text: 'Tax', style: 'tableheader1', Field: 'Tax', alignment: 'right' },
105
+ { text: 'Adjust', style: 'tableheader1', Field: 'Adjust', alignment: 'right' },
106
+ { text: 'Round', style: 'tableheader1', Field: 'Round', alignment: 'right' },
107
+ { text: 'Total', style: 'tableheader1', Field: 'Total', alignment: 'right' }]];
108
+ return HeadingNames;
109
+ }
110
+ }
111
+ exports.SalesByCustomerPDFService = SalesByCustomerPDFService;