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