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,425 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SaleReceiptPrintService = void 0;
4
+ const shared_print_service_1 = require("./shared-print.service");
5
+ const invoice_total_service_1 = require("./invoice-total.service");
6
+ const tr_utils_1 = require("../utils/tr-utils");
7
+ const code_enums_1 = require("../enums/code-enums");
8
+ const enums_1 = require("../enums/enums");
9
+ const my_date_1 = require("../utils/my-date");
10
+ const aggregation_1 = require("../aggregation/aggregation");
11
+ class SaleReceiptPrintService {
12
+ static GetSaleReceiptPrintInfo(OriginalInvoiceData, OriginalEntityData, image, IncludeGST, ConsolidateGST, TaxCodes, IsProforma, OBN) {
13
+ var _a, _b, _c, _d;
14
+ let ForInsurance = !tr_utils_1.TrUtils.IsNull(OriginalInvoiceData.BillTo) && !tr_utils_1.TrUtils.IsNull(OriginalInvoiceData.BillTo.InsId);
15
+ let InvoicePrintData = {};
16
+ let argInvoiceData = tr_utils_1.TrUtils.Stringify(OriginalInvoiceData);
17
+ if (!IncludeGST) {
18
+ if (argInvoiceData.Settings.Tax === 'TI') {
19
+ argInvoiceData.Settings.Tax = 'NO';
20
+ }
21
+ }
22
+ InvoicePrintData.IsProforma = IsProforma;
23
+ InvoicePrintData.Settings = tr_utils_1.TrUtils.Stringify(argInvoiceData.Settings);
24
+ let SType;
25
+ if (!tr_utils_1.TrUtils.IsNull(argInvoiceData.Settings) && !tr_utils_1.TrUtils.IsNull(argInvoiceData.Settings.PoS)) {
26
+ SType = argInvoiceData.Settings.PoS.SType;
27
+ }
28
+ InvoicePrintData = this.GetPrintConditionsBasedOnInput(InvoicePrintData, IncludeGST, ConsolidateGST, ForInsurance, SType, argInvoiceData, IsProforma);
29
+ InvoicePrintData.Entity = shared_print_service_1.PrintSharedService.GetFormattedEntityDataForPrint(OriginalEntityData, "Invoice", OriginalInvoiceData);
30
+ InvoicePrintData = shared_print_service_1.PrintSharedService.GetEntityHeaderStyles(InvoicePrintData, OriginalEntityData, image);
31
+ InvoicePrintData = this.GetInvoiceOtherDetailsForPrint(InvoicePrintData, argInvoiceData);
32
+ let IsTaxable = (IncludeGST && tr_utils_1.TrUtils.isTaxable(argInvoiceData.Settings.Tax)) ? true : false;
33
+ if (tr_utils_1.TrUtils.IsNull(argInvoiceData.Ops)) {
34
+ argInvoiceData.Ops = [];
35
+ }
36
+ let finalTotalsData = invoice_total_service_1.InvoiceTotalsService.GetTotalsValue(argInvoiceData.Ops, argInvoiceData.Items, IsTaxable, true, argInvoiceData.LDisc, argInvoiceData.LPerc, argInvoiceData.PDisc, argInvoiceData.PPerc, argInvoiceData.Disc, argInvoiceData.Perc, TaxCodes, true, argInvoiceData.Settings, argInvoiceData.Adjust, InvoicePrintData.Entity.Round);
37
+ if (ConsolidateGST) {
38
+ finalTotalsData.CustLaborTotalBeforeDisc = finalTotalsData.CustLaborAfterTax;
39
+ finalTotalsData.CustPartsTotalBeforeDisc = finalTotalsData.CustPartAfterTax;
40
+ }
41
+ InvoicePrintData = tr_utils_1.TrUtils.ConcatObjects(InvoicePrintData, finalTotalsData);
42
+ InvoicePrintData.Ops = this.GetLaborPrintInfo(InvoicePrintData.Ops, ConsolidateGST, TaxCodes, (_b = (_a = OriginalEntityData.Entity.Settings) === null || _a === void 0 ? void 0 : _a.Acc) === null || _b === void 0 ? void 0 : _b.LTot);
43
+ InvoicePrintData.Items = this.GetItemsPrintInfo(InvoicePrintData.Items, ConsolidateGST, TaxCodes, OBN, (_d = (_c = OriginalEntityData.Entity.Settings) === null || _c === void 0 ? void 0 : _c.Acc) === null || _d === void 0 ? void 0 : _d.LTot);
44
+ // InvoicePrintData.Items = InvoicePrintData.Items.filter((item: any) => {
45
+ // return !item.Ret;
46
+ // })
47
+ argInvoiceData = this.ReverseItemsForInvoicePrint(argInvoiceData);
48
+ InvoicePrintData.PrintInfo = this.PrepareFormatForInvoicePrint(InvoicePrintData, code_enums_1.ROTypeEnum.Invoice, argInvoiceData.Sts);
49
+ InvoicePrintData = this.GetFormattedProductDataForPrint(argInvoiceData, InvoicePrintData);
50
+ InvoicePrintData = this.GetBillNameForInvoicePrint(argInvoiceData, InvoicePrintData);
51
+ let PaymentData = this.GetPaymentsTotal(argInvoiceData.Payments, InvoicePrintData.Total, argInvoiceData.Sts);
52
+ // if (argInvoiceData.Settings.DiscLvl !== 'REC') {
53
+ // InvoicePrintData.FixedDisc = null;
54
+ // }
55
+ InvoicePrintData.Due = tr_utils_1.TrUtils.FixPriceValue(argInvoiceData.Due);
56
+ InvoicePrintData.Paid = argInvoiceData.Receipt ? argInvoiceData.Total : PaymentData.Paid;
57
+ if (!tr_utils_1.TrUtils.IsNull(PaymentData.Sts)) {
58
+ InvoicePrintData.Sts = PaymentData.Sts;
59
+ }
60
+ InvoicePrintData.Consolidate = ConsolidateGST;
61
+ InvoicePrintData.ShowDiscountColumn = false;
62
+ if (!ForInsurance && !ConsolidateGST) {
63
+ if (shared_print_service_1.PrintSharedService.CheckItemIndexWithDisc(InvoicePrintData) !== -1) {
64
+ InvoicePrintData.ShowDiscountColumn = (InvoicePrintData.Settings.DiscLvl === 'ITM' || InvoicePrintData.Settings.DiscLvl === 'RECITM') ? true : false;
65
+ }
66
+ }
67
+ if (OriginalInvoiceData.Type === '1') {
68
+ InvoicePrintData.From = 'Sales';
69
+ }
70
+ // console.log('InvoicePrintData', InvoicePrintData);
71
+ return InvoicePrintData;
72
+ }
73
+ static GetPrintConditionsBasedOnInput(InvoicePrintData, IncludeGST, ConsolidateGST, ForInsurance, SType, OriginalInvoiceData, IsProforma) {
74
+ InvoicePrintData.ForInsurance = ForInsurance;
75
+ InvoicePrintData.For = ForInsurance ? enums_1.PayTypeEnum.Insurance : enums_1.PayTypeEnum.Customer;
76
+ InvoicePrintData.IncludeGST = IncludeGST;
77
+ InvoicePrintData.ConsolidateGST = ConsolidateGST;
78
+ InvoicePrintData.ShowAccParts = false;
79
+ InvoicePrintData.ShowIGST = (tr_utils_1.TrUtils.IsNull(SType) || (SType === 'Intra')) ? false : true;
80
+ InvoicePrintData.ShowTaxColumn = (IncludeGST && !ConsolidateGST) ? true : false;
81
+ // InvoicePrintData.ShowDiscountColumn = (!ForInsurance && !ConsolidateGST) ? true : false;
82
+ InvoicePrintData = this.GetInvoiceTypeHeading(InvoicePrintData, OriginalInvoiceData, IncludeGST, ConsolidateGST, IsProforma);
83
+ InvoicePrintData.PrDate = tr_utils_1.TrUtils.IsNull(OriginalInvoiceData.PrDate) ? '' : my_date_1.MyDate.ConvertUTCDateToReadable(OriginalInvoiceData.PrDate);
84
+ return InvoicePrintData;
85
+ }
86
+ static GetInvoiceTypeHeading(InvoicePrintData, OriginalInvoiceData, IncludeGST, ConsolidateGST, IsProforma) {
87
+ if (IsProforma) {
88
+ InvoicePrintData.HeaderName = 'pro-forma Invoice';
89
+ }
90
+ else {
91
+ if (OriginalInvoiceData.Type === 'Sales') {
92
+ // if (IncludeGST && !ConsolidateGST) {
93
+ // InvoicePrintData.HeaderName = 'Parts Tax Invoice';
94
+ // } else {
95
+ // InvoicePrintData.HeaderName = 'Parts Invoice';
96
+ // }
97
+ InvoicePrintData.PrintType = 'Parts Order';
98
+ if (InvoicePrintData.Settings.Tax === 'BS') {
99
+ InvoicePrintData.HeaderName = 'Bill of Supply';
100
+ }
101
+ else {
102
+ if (InvoicePrintData.Settings.Tax === 'TI') {
103
+ InvoicePrintData.HeaderName = 'Parts Tax Invoice';
104
+ }
105
+ else {
106
+ InvoicePrintData.HeaderName = 'Parts Invoice';
107
+ }
108
+ }
109
+ }
110
+ else {
111
+ // if (IncludeGST && !ConsolidateGST) {
112
+ // InvoicePrintData.HeaderName = 'Tax Invoice';
113
+ // } else {
114
+ // InvoicePrintData.HeaderName = 'Invoice';
115
+ // }
116
+ if (InvoicePrintData.Settings.Tax === 'BS') {
117
+ InvoicePrintData.HeaderName = 'Bill of Supply';
118
+ }
119
+ else {
120
+ if (InvoicePrintData.Settings.Tax === 'TI') {
121
+ if (OriginalInvoiceData.Receipt) {
122
+ InvoicePrintData.HeaderName = 'Tax Sales Receipt';
123
+ }
124
+ else {
125
+ InvoicePrintData.HeaderName = 'Tax Invoice';
126
+ }
127
+ }
128
+ else {
129
+ if (OriginalInvoiceData.Receipt) {
130
+ InvoicePrintData.HeaderName = 'Sales Receipt';
131
+ }
132
+ else {
133
+ InvoicePrintData.HeaderName = 'Invoice';
134
+ }
135
+ }
136
+ }
137
+ }
138
+ }
139
+ return InvoicePrintData;
140
+ }
141
+ static GetInvoiceOtherDetailsForPrint(InvoicePrintData, OriginalInvoiceData) {
142
+ InvoicePrintData.Type = 'Invoice';
143
+ InvoicePrintData._id = OriginalInvoiceData.Code;
144
+ InvoicePrintData.Sts = OriginalInvoiceData.Sts;
145
+ InvoicePrintData.Name = OriginalInvoiceData.Name;
146
+ InvoicePrintData.CrDate = my_date_1.MyDate.ConvertUTCDateTimeToReadable(OriginalInvoiceData.CrDate);
147
+ return InvoicePrintData;
148
+ }
149
+ static GetLaborPrintInfo(LaborList, Consolidate, TaxCodes, LineTotal) {
150
+ LaborList.forEach((Labor) => {
151
+ Labor.HSN = Labor.SAC;
152
+ if (Consolidate) {
153
+ Labor.UnPr = tr_utils_1.TrUtils.FixedTo(Labor.AfterLaborTax);
154
+ }
155
+ else {
156
+ Labor.UnPr = tr_utils_1.TrUtils.FixPriceValue(Labor.Pr);
157
+ }
158
+ Labor.CGSTAmt = tr_utils_1.TrUtils.FixPriceValue(Labor.CGST);
159
+ Labor.SGSTAmt = tr_utils_1.TrUtils.FixPriceValue(Labor.SGST);
160
+ Labor.IGSTAmt = tr_utils_1.TrUtils.FixPriceValue(Labor.IGST);
161
+ Labor.CGSTPerc = shared_print_service_1.PrintSharedService.GetCGSTValueBasedOnTaxCode(Labor.TCode, TaxCodes);
162
+ Labor.SGSTPerc = shared_print_service_1.PrintSharedService.GetSGSTValueBasedOnTaxCode(Labor.TCode, TaxCodes);
163
+ Labor.IGSTPerc = shared_print_service_1.PrintSharedService.GetIGSTValueBasedOnTaxCode(Labor.TCode, TaxCodes);
164
+ if (LineTotal === 'AT') {
165
+ Labor.LineTotal = tr_utils_1.TrUtils.FixPriceValue(Labor.AfterLaborTax);
166
+ }
167
+ else {
168
+ Labor.LineTotal = tr_utils_1.TrUtils.FixPriceValue((0, aggregation_1.subtraction)(Labor.Amt, Labor.Disc));
169
+ }
170
+ });
171
+ return LaborList;
172
+ }
173
+ static GetItemsPrintInfo(Items, Consolidate, TaxCodes, OBN, LineTotal) {
174
+ Items.forEach((Item) => {
175
+ var _a;
176
+ if (Consolidate) {
177
+ let AfterDiscForEach = Item.AfterPartDisc / Item.Qty;
178
+ let CTaxAmtPerItem = Item.CGST / Item.Qty;
179
+ let STaxAmtPerItem = Item.SGST / Item.Qty;
180
+ let ITaxAmtPerItem = Item.IGST / Item.Qty;
181
+ Item.UnPr = tr_utils_1.TrUtils.FixedTo(AfterDiscForEach + CTaxAmtPerItem + STaxAmtPerItem + ITaxAmtPerItem);
182
+ }
183
+ else {
184
+ Item.UnPr = tr_utils_1.TrUtils.FixPriceValue(Item.UnPr);
185
+ }
186
+ Item.ExDt = this.GetExpiryDate(Item);
187
+ Item.Batch = this.GetBatchesData(Item, OBN);
188
+ Item.CGSTAmt = tr_utils_1.TrUtils.FixedTo(Item.CGST);
189
+ if (tr_utils_1.TrUtils.IsNull(Item.ConUt)) {
190
+ Item.ConUt = 1;
191
+ }
192
+ if (!tr_utils_1.TrUtils.IsNull(Item.Make)) {
193
+ Item.Make = (_a = Item.Make) === null || _a === void 0 ? void 0 : _a.slice(0, 4).toUpperCase();
194
+ }
195
+ Item.Qty = tr_utils_1.TrUtils.FixedTo(Item.Qty * Item.ConUt);
196
+ Item.SGSTAmt = tr_utils_1.TrUtils.FixedTo(Item.SGST);
197
+ Item.IGSTAmt = tr_utils_1.TrUtils.FixedTo(Item.IGST);
198
+ Item.CGSTPerc = shared_print_service_1.PrintSharedService.GetCGSTValueBasedOnTaxCode(Item.TCode, TaxCodes);
199
+ Item.SGSTPerc = shared_print_service_1.PrintSharedService.GetSGSTValueBasedOnTaxCode(Item.TCode, TaxCodes);
200
+ Item.TaxName = this.getTaxName(Item.TCode, TaxCodes);
201
+ Item.IGSTPerc = shared_print_service_1.PrintSharedService.GetIGSTValueBasedOnTaxCode(Item.TCode, TaxCodes);
202
+ if (LineTotal === 'AT') {
203
+ Item.LineTotal = tr_utils_1.TrUtils.FixPriceValue(Item.AfterPartTax);
204
+ }
205
+ else {
206
+ Item.LineTotal = tr_utils_1.TrUtils.FixPriceValue((0, aggregation_1.subtraction)(Item.UnAmt, Item.Disc));
207
+ }
208
+ if (!tr_utils_1.TrUtils.IsZero(Item.Qty) && !tr_utils_1.TrUtils.CheckInvalidSelect(Item.UoM)) {
209
+ Item.QtyAndUoM = Item.Qty + ' ' + Item.UoM;
210
+ }
211
+ });
212
+ return Items;
213
+ }
214
+ static getTaxName(TCode, TaxCodes) {
215
+ let Index = TaxCodes.findIndex((TaxCode) => {
216
+ return Number(TCode) === TaxCode._id;
217
+ });
218
+ return (Index !== -1) ? TaxCodes[Index].Name : '';
219
+ }
220
+ static GetBatchesData(Item, OBN) {
221
+ if (!tr_utils_1.TrUtils.IsNull(Item.Batches)) {
222
+ let batchdata;
223
+ Item.Batches.forEach((batch) => {
224
+ if (OBN) {
225
+ let BN = tr_utils_1.TrUtils.IsNull(batch.MBN) ? batch.BN : batch.MBN;
226
+ if (!tr_utils_1.TrUtils.IsNull(batchdata)) {
227
+ batchdata = batchdata + ',' + BN;
228
+ }
229
+ else {
230
+ batchdata = BN;
231
+ }
232
+ }
233
+ else {
234
+ if (!tr_utils_1.TrUtils.IsNull(batchdata)) {
235
+ batchdata = batchdata + ',' + batch.BN;
236
+ }
237
+ else {
238
+ batchdata = batch.BN;
239
+ }
240
+ }
241
+ });
242
+ return batchdata;
243
+ }
244
+ else if (!tr_utils_1.TrUtils.IsNull(Item.Batch)) {
245
+ if (OBN) {
246
+ let BN = tr_utils_1.TrUtils.IsNull(Item.Batch.MBN) ? Item.Batch.BN : Item.Batch.MBN;
247
+ return BN;
248
+ }
249
+ else {
250
+ return Item.Batch.BN;
251
+ }
252
+ }
253
+ else {
254
+ return '';
255
+ }
256
+ }
257
+ static GetExpiryDate(Item) {
258
+ if (!tr_utils_1.TrUtils.IsNull(Item.Batches)) {
259
+ let batchdata;
260
+ Item.Batches.forEach((batch) => {
261
+ if (!tr_utils_1.TrUtils.IsNull(batchdata)) {
262
+ batchdata = batchdata + ',' + my_date_1.MyDate.ConvertUTCDateToReadableExDate(batch.ExDt);
263
+ }
264
+ else {
265
+ batchdata = my_date_1.MyDate.ConvertUTCDateToReadableExDate(batch.ExDt);
266
+ }
267
+ });
268
+ return batchdata;
269
+ }
270
+ else if (!tr_utils_1.TrUtils.IsNull(Item.Batch)) {
271
+ return my_date_1.MyDate.ConvertUTCDateToReadableExDate(Item.Batch.ExDt);
272
+ }
273
+ else {
274
+ return '';
275
+ }
276
+ }
277
+ static ReverseItemsForInvoicePrint(argInvoiceData) {
278
+ // argInvoiceData.Ops = argInvoiceData.Ops.reverse();
279
+ // argInvoiceData.Items = argInvoiceData.Items.reverse();
280
+ return argInvoiceData;
281
+ }
282
+ static PrepareFormatForInvoicePrint(InvoicePrintData, ROType, InvoiceStatus) {
283
+ let PrintInfo = [];
284
+ let ROLaborParts = {};
285
+ ROLaborParts.Ops = InvoicePrintData.Ops;
286
+ ROLaborParts.Items = InvoicePrintData.Items;
287
+ ROLaborParts.Sts = InvoiceStatus;
288
+ ROLaborParts.Type = ROType;
289
+ PrintInfo.push(ROLaborParts);
290
+ return PrintInfo;
291
+ }
292
+ static GetFormattedProductDataForPrint(OriginalInvoiceData, InvoicePrintData) {
293
+ if (!tr_utils_1.TrUtils.IsNull(OriginalInvoiceData.Prod)) {
294
+ InvoicePrintData.Product = OriginalInvoiceData.Prod;
295
+ if (tr_utils_1.TrUtils.IsNull(InvoicePrintData.Product.VIN)) {
296
+ InvoicePrintData.Product.VIN = '';
297
+ }
298
+ if (tr_utils_1.TrUtils.IsNull(InvoicePrintData.Product.RegNo)) {
299
+ InvoicePrintData.Product.RegNo = '';
300
+ }
301
+ if (tr_utils_1.TrUtils.IsNull(InvoicePrintData.Product.EngNo)) {
302
+ InvoicePrintData.Product.EngNo = '';
303
+ }
304
+ InvoicePrintData.MIn = OriginalInvoiceData.Prod.MIn;
305
+ InvoicePrintData.MOut = OriginalInvoiceData.Prod.MOut;
306
+ }
307
+ return InvoicePrintData;
308
+ }
309
+ static GetBillNameForInvoicePrint(OriginalInvoiceData, InvoicePrintData) {
310
+ let Customer = {};
311
+ if (!tr_utils_1.TrUtils.IsNull(OriginalInvoiceData.BillTo)) {
312
+ Customer.Name = OriginalInvoiceData.BillTo.Name;
313
+ Customer.Doctor = tr_utils_1.TrUtils.IsNull(OriginalInvoiceData.Name) ? '' : OriginalInvoiceData.Name;
314
+ Customer.Adrs = [];
315
+ Customer.Cons = [];
316
+ if (!tr_utils_1.TrUtils.IsNull(OriginalInvoiceData.BillTo.Adrs)) {
317
+ Customer.Adrs.push(OriginalInvoiceData.BillTo.Adrs.A1);
318
+ if (!tr_utils_1.TrUtils.IsEmpty(OriginalInvoiceData.BillTo.Adrs.A2)) {
319
+ Customer.Adrs.push(OriginalInvoiceData.BillTo.Adrs.A2);
320
+ }
321
+ if (!tr_utils_1.TrUtils.IsEmpty(OriginalInvoiceData.BillTo.Adrs.Ct)) {
322
+ Customer.Adrs.push(OriginalInvoiceData.BillTo.Adrs.Ct);
323
+ }
324
+ }
325
+ Customer.GSTIN = OriginalInvoiceData.BillTo.GSTIN;
326
+ if (!tr_utils_1.TrUtils.IsEmpty(OriginalInvoiceData.BillTo.Ph)) {
327
+ Customer.Cons = [
328
+ {
329
+ Type: 'M',
330
+ No: OriginalInvoiceData.BillTo.Ph
331
+ }
332
+ ];
333
+ }
334
+ InvoicePrintData.Customer = Customer;
335
+ }
336
+ else if (!tr_utils_1.TrUtils.IsNull(OriginalInvoiceData.BillTo)) {
337
+ Customer.Name = OriginalInvoiceData.BillTo.Name;
338
+ Customer.Adrs = [];
339
+ Customer.Cons = [];
340
+ InvoicePrintData.Customer = Customer;
341
+ }
342
+ else {
343
+ InvoicePrintData.Customer = {};
344
+ }
345
+ if (!tr_utils_1.TrUtils.IsNull(OriginalInvoiceData.ShipTo)) {
346
+ let location = {};
347
+ location.Adrs = shared_print_service_1.PrintSharedService.GetAddress(OriginalInvoiceData.ShipTo.Adrs);
348
+ let Name;
349
+ if (tr_utils_1.TrUtils.IsNull(OriginalInvoiceData.ShipTo.Name)) {
350
+ Name = OriginalInvoiceData.ShipTo.ConName;
351
+ }
352
+ else {
353
+ Name = OriginalInvoiceData.ShipTo.Name;
354
+ }
355
+ if (tr_utils_1.TrUtils.IsNull(Name)) {
356
+ Name = '';
357
+ }
358
+ location.Name = Name;
359
+ if (!tr_utils_1.TrUtils.IsNull(OriginalInvoiceData.ShipTo.ConPh)) {
360
+ location.Cons = [
361
+ {
362
+ Type: 'M',
363
+ No: OriginalInvoiceData.ShipTo.ConPh
364
+ }
365
+ ];
366
+ }
367
+ InvoicePrintData.Location = location;
368
+ }
369
+ return InvoicePrintData;
370
+ }
371
+ static GetCustomerDetails(OriginalInvoiceData) {
372
+ let Customer = {};
373
+ Customer.Name = this.GetBillToName(OriginalInvoiceData.BillTo.Title, OriginalInvoiceData.BillTo.Name);
374
+ Customer.Cons = [];
375
+ if (!tr_utils_1.TrUtils.IsEmpty(OriginalInvoiceData.BillTo.Ph)) {
376
+ Customer.Cons = [
377
+ {
378
+ Type: 'M',
379
+ No: OriginalInvoiceData.BillTo.Ph
380
+ }
381
+ ];
382
+ }
383
+ Customer.GSTIN = OriginalInvoiceData.BillTo.GSTIN;
384
+ Customer.Adrs = [];
385
+ if (!tr_utils_1.TrUtils.IsNull(OriginalInvoiceData.BillTo.Adrs)) {
386
+ Customer.Adrs.push(OriginalInvoiceData.BillTo.Adrs.A1);
387
+ if (!tr_utils_1.TrUtils.IsEmpty(OriginalInvoiceData.BillTo.Adrs.A2)) {
388
+ Customer.Adrs.push(OriginalInvoiceData.BillTo.Adrs.A2);
389
+ }
390
+ Customer.Adrs.push(OriginalInvoiceData.BillTo.Adrs.Ct);
391
+ }
392
+ Customer.ConName = OriginalInvoiceData.BillTo.ConName;
393
+ Customer.ConPh = OriginalInvoiceData.BillTo.ConPhone;
394
+ return Customer;
395
+ }
396
+ static GetBillToName(Title, Name) {
397
+ return tr_utils_1.TrUtils.IsEmpty(Title) ? Name : Title + ' ' + Name;
398
+ }
399
+ static GetPaymentsTotal(InvoicePayments, Total, InvoiceStatus) {
400
+ if (tr_utils_1.TrUtils.IsNull(InvoicePayments)) {
401
+ InvoicePayments = [];
402
+ }
403
+ var i = 0;
404
+ let Data = {};
405
+ let PaidTotal = 0;
406
+ for (i = 0; i < InvoicePayments.length; i++) {
407
+ PaidTotal += InvoicePayments[i].Paid;
408
+ }
409
+ if (InvoiceStatus === enums_1.InvoiceStatusEnum.Closed) {
410
+ Data.Due = 0;
411
+ }
412
+ else {
413
+ Data.Due = tr_utils_1.TrUtils.FixedTo(Total - PaidTotal);
414
+ }
415
+ if (Data.Due < 0) {
416
+ Data.Due = 0;
417
+ }
418
+ if (Data.Due === 0) {
419
+ Data.Sts = enums_1.InvoiceStatusEnum.Closed;
420
+ }
421
+ Data.Paid = tr_utils_1.TrUtils.FixedTo(PaidTotal);
422
+ return Data;
423
+ }
424
+ }
425
+ exports.SaleReceiptPrintService = SaleReceiptPrintService;