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,295 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.GSTR1ExcelService = void 0;
27
+ const XLSX = __importStar(require("xlsx"));
28
+ const tr_utils_1 = require("../utils/tr-utils");
29
+ class GSTR1ExcelService {
30
+ static GetGSTR1ExcelData(MainData) {
31
+ this.wb = {};
32
+ this.ws = {};
33
+ this.Row = 0;
34
+ this.range = { s: { c: 0, r: 0 }, e: { c: 0, r: 0 } };
35
+ this.MergeArray = [];
36
+ let ws_name = 'GSTR1';
37
+ this.wb.Sheets = {};
38
+ this.wb.Props = {};
39
+ this.wb.SSF = {};
40
+ this.wb.SheetNames = [];
41
+ MainData = this.GetTotals(MainData);
42
+ this.setHeadingInCell();
43
+ this.setInvoiceDetailsInCell(MainData);
44
+ this.ws['!ref'] = XLSX.utils.encode_range(this.range);
45
+ this.ws['!merges'] = this.MergeArray;
46
+ this.wb.SheetNames.push(ws_name);
47
+ this.wb.Sheets[ws_name] = this.ws;
48
+ return this.wb;
49
+ }
50
+ static GetTotals(MainData) {
51
+ MainData.forEach((InvoicesList) => {
52
+ InvoicesList.Invoices.forEach((InvoiceInfo) => {
53
+ // if (InvoiceInfo.Inv.InsTotal != null) {
54
+ // InvoiceInfo.Inv.Amount = InvoiceInfo.Inv.InsTotal;
55
+ // }
56
+ // if (InvoiceInfo.Inv.Total != null) {
57
+ // InvoiceInfo.Inv.Amount = InvoiceInfo.Inv.Total;
58
+ // }
59
+ if (InvoiceInfo.Total != null) {
60
+ InvoiceInfo.Amount = InvoiceInfo.Total;
61
+ }
62
+ });
63
+ });
64
+ return MainData;
65
+ }
66
+ static setHeadingInCell() {
67
+ let MainHeadings = [
68
+ {
69
+ text: 'GSTIN/UIN',
70
+ ColRange: 1,
71
+ bold: true,
72
+ ChildHeadings: []
73
+ },
74
+ {
75
+ text: 'Name',
76
+ ColRange: 1,
77
+ bold: true,
78
+ ChildHeadings: []
79
+ },
80
+ {
81
+ text: 'Invoice Details',
82
+ ColRange: 4,
83
+ bold: true,
84
+ ChildHeadings: [
85
+ { text: 'No', ColRange: 1 },
86
+ { text: 'Date', ColRange: 1 },
87
+ { text: 'Total', ColRange: 1 }
88
+ ]
89
+ },
90
+ {
91
+ text: 'Rate',
92
+ ColRange: 1,
93
+ bold: true,
94
+ ChildHeadings: []
95
+ },
96
+ {
97
+ text: 'Taxable Value',
98
+ ColRange: 1,
99
+ bold: true,
100
+ ChildHeadings: []
101
+ },
102
+ {
103
+ text: 'Amount',
104
+ ColRange: 3,
105
+ bold: true,
106
+ ChildHeadings: [
107
+ { text: 'Central Tax', ColRange: 1 },
108
+ { text: 'State Tax', ColRange: 1 },
109
+ { text: 'IGST Tax', ColRange: 1 },
110
+ ]
111
+ }
112
+ ];
113
+ let MainColStart = 0;
114
+ MainHeadings.forEach((MainHeader) => {
115
+ let ChildColStart = MainColStart;
116
+ this.SetDataInCell(MainHeader.text, MainColStart, this.Row);
117
+ this.MergeArray.push({ s: { r: this.Row, c: MainColStart }, e: { r: this.Row, c: MainColStart + MainHeader.ColRange - 1 } });
118
+ MainColStart += MainHeader.ColRange;
119
+ MainHeader.ChildHeadings.forEach((ChildHeaderInfo) => {
120
+ this.SetDataInCell(ChildHeaderInfo.text, ChildColStart, this.Row + 1);
121
+ this.MergeArray.push({ s: { r: this.Row + 1, c: ChildColStart }, e: { r: this.Row + 1, c: ChildColStart + ChildHeaderInfo.ColRange - 1 } });
122
+ ChildColStart += ChildHeaderInfo.ColRange;
123
+ });
124
+ });
125
+ this.Row += 2;
126
+ }
127
+ static setInvoiceDetailsInCell(MainData) {
128
+ MainData.forEach((InvoiceList) => {
129
+ this.SetInvoiceDataInExcel(InvoiceList);
130
+ });
131
+ }
132
+ static SetInvoiceDataInExcel(InvoiceList) {
133
+ InvoiceList.Invoices.forEach((InvoiceInfo, index) => {
134
+ // let InvoiceInfo = InvoiceInfoData.Inv;
135
+ InvoiceInfo.CrDate = this.ConvertDateToReadableFormat(InvoiceInfo.CrDate);
136
+ let GSTIN;
137
+ let Name;
138
+ if (index === 0) {
139
+ if (InvoiceList._id == 'Unspecified') {
140
+ GSTIN = 'No GST';
141
+ Name = InvoiceInfo.Name;
142
+ }
143
+ else {
144
+ GSTIN = InvoiceList._id;
145
+ Name = InvoiceInfo.Name;
146
+ }
147
+ }
148
+ else {
149
+ if (InvoiceList._id == 'Unspecified') {
150
+ GSTIN = 'No GST';
151
+ Name = InvoiceInfo.Name;
152
+ }
153
+ }
154
+ let InvoiceData = [
155
+ { text: GSTIN, ColRange: 1, IsString: true },
156
+ { text: Name, ColRange: 1, IsString: true },
157
+ { text: InvoiceInfo.Code, ColRange: 1, IsString: true },
158
+ { text: InvoiceInfo.CrDate, ColRange: 1, IsString: true },
159
+ { text: InvoiceInfo.Amount, ColRange: 1, IsString: false }
160
+ ];
161
+ let ColStart = 0;
162
+ InvoiceData.forEach((InvData) => {
163
+ InvData.text = this.ConvertToString(InvData.text, InvData.IsString);
164
+ this.SetDataInCell(InvData.text, ColStart, this.Row);
165
+ this.MergeArray.push({ s: { r: this.Row, c: ColStart }, e: { r: this.Row, c: ColStart + InvData.ColRange - 1 } });
166
+ ColStart += InvData.ColRange;
167
+ });
168
+ let TotalsColStart = ColStart;
169
+ if (!tr_utils_1.TrUtils.IsNull(InvoiceInfo.ItemsArray) && InvoiceInfo.ItemsArray.length !== 0) {
170
+ let PartsHeading = { text: 'Parts', ColRange: 1 };
171
+ this.SetDataInCell(PartsHeading.text, TotalsColStart, this.Row);
172
+ this.MergeArray.push({ s: { r: this.Row, c: TotalsColStart }, e: { r: this.Row, c: TotalsColStart + PartsHeading.ColRange - 1 } });
173
+ InvoiceInfo.ItemsArray.forEach((Part) => {
174
+ let PartData = [
175
+ { text: Part.Rate, ColRange: 1, IsString: false },
176
+ { text: Part.Taxable, ColRange: 1, IsString: false },
177
+ { text: Part.CGST, ColRange: 1, IsString: false },
178
+ { text: Part.SGST, ColRange: 1, IsString: false },
179
+ { text: Part.IGST, ColRange: 1, IsString: false }
180
+ ];
181
+ let PartColStart = TotalsColStart + 1;
182
+ PartData.forEach((PartInfo) => {
183
+ PartInfo.text = this.ConvertToString(PartInfo.text, PartInfo.IsString);
184
+ this.SetDataInCell(PartInfo.text, PartColStart, this.Row);
185
+ this.MergeArray.push({ s: { r: this.Row, c: PartColStart }, e: { r: this.Row, c: PartColStart + PartInfo.ColRange - 1 } });
186
+ PartColStart += PartInfo.ColRange;
187
+ });
188
+ this.Row += 1;
189
+ });
190
+ this.Row += 1;
191
+ }
192
+ if (!tr_utils_1.TrUtils.IsNull(InvoiceInfo.LaborArray) && InvoiceInfo.LaborArray.length !== 0) {
193
+ let LaborHeading = { text: 'Labor', ColRange: 1 };
194
+ this.SetDataInCell(LaborHeading.text, TotalsColStart, this.Row);
195
+ this.MergeArray.push({ s: { r: this.Row, c: TotalsColStart }, e: { r: this.Row, c: TotalsColStart + LaborHeading.ColRange - 1 } });
196
+ InvoiceInfo.LaborArray.forEach((Service) => {
197
+ let ServiceData = [
198
+ { text: Service.Rate, ColRange: 1, IsString: false },
199
+ { text: Service.Taxable, ColRange: 1, IsString: false },
200
+ { text: Service.CGST, ColRange: 1, IsString: false },
201
+ { text: Service.SGST, ColRange: 1, IsString: false },
202
+ { text: Service.IGST, ColRange: 1, IsString: false }
203
+ ];
204
+ let LaborColStart = TotalsColStart + 1;
205
+ ServiceData.forEach((ServiceInfo) => {
206
+ ServiceInfo.text = this.ConvertToString(ServiceInfo.text, ServiceInfo.IsString);
207
+ this.SetDataInCell(ServiceInfo.text, LaborColStart, this.Row);
208
+ this.MergeArray.push({ s: { r: this.Row, c: LaborColStart }, e: { r: this.Row, c: LaborColStart + ServiceInfo.ColRange - 1 } });
209
+ LaborColStart += ServiceInfo.ColRange;
210
+ });
211
+ this.Row += 1;
212
+ });
213
+ this.Row += 1;
214
+ }
215
+ this.Row += 1;
216
+ });
217
+ }
218
+ static ConvertToString(Text, IsString) {
219
+ if (IsString) {
220
+ if (tr_utils_1.TrUtils.IsNull(Text)) {
221
+ Text = '';
222
+ }
223
+ }
224
+ else {
225
+ if (tr_utils_1.TrUtils.IsNull(Text)) {
226
+ Text = 0;
227
+ }
228
+ }
229
+ if (typeof (Text) === 'number') {
230
+ return Number(tr_utils_1.TrUtils.FixedTo(Text));
231
+ }
232
+ else {
233
+ return Text;
234
+ }
235
+ }
236
+ static SetDataInCell(Data, ColRange, RowNum) {
237
+ var cell = { v: Data };
238
+ var cell_ref = XLSX.utils.encode_cell({ c: ColRange, r: RowNum });
239
+ if (this.range.e.c < ColRange) {
240
+ this.range.e.c = ColRange;
241
+ }
242
+ if (this.range.e.r < RowNum) {
243
+ this.range.e.r = RowNum;
244
+ }
245
+ cell = this.getcelltype(cell);
246
+ this.ws[cell_ref] = cell;
247
+ }
248
+ static getcelltype(cell) {
249
+ if (typeof cell.v === 'number')
250
+ cell.t = 'n';
251
+ else if (typeof cell.v === 'boolean')
252
+ cell.t = 'b';
253
+ else
254
+ cell.t = 's';
255
+ return cell;
256
+ }
257
+ static ConvertDateToReadableFormat(DateObject) {
258
+ if (!tr_utils_1.TrUtils.IsEmpty(DateObject)) {
259
+ let date = new Date(DateObject);
260
+ let Month;
261
+ let Day;
262
+ let MonthName = new Array();
263
+ MonthName[0] = 'Jan';
264
+ MonthName[1] = 'Feb';
265
+ MonthName[2] = 'Mar';
266
+ MonthName[3] = 'Apr';
267
+ MonthName[4] = 'May';
268
+ MonthName[5] = 'Jun';
269
+ MonthName[6] = 'Jul';
270
+ MonthName[7] = 'Aug';
271
+ MonthName[8] = 'Sept';
272
+ MonthName[9] = 'Oct';
273
+ MonthName[10] = 'Nov';
274
+ MonthName[11] = 'Dec';
275
+ Month = MonthName[date.getMonth()];
276
+ if (date.getDate() < 10) {
277
+ Day = '0' + date.getDate();
278
+ }
279
+ else {
280
+ Day = date.getDate();
281
+ }
282
+ date = Day + '-' + Month + '-' + date.getFullYear();
283
+ return date;
284
+ }
285
+ else {
286
+ return null;
287
+ }
288
+ }
289
+ }
290
+ exports.GSTR1ExcelService = GSTR1ExcelService;
291
+ GSTR1ExcelService.wb = {};
292
+ GSTR1ExcelService.Row = 0;
293
+ GSTR1ExcelService.MergeArray = [];
294
+ GSTR1ExcelService.range = { s: { c: 0, r: 0 }, e: { c: 0, r: 0 } };
295
+ GSTR1ExcelService.ws = {};
@@ -0,0 +1,295 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.GSTR2ExcelService = void 0;
27
+ const XLSX = __importStar(require("xlsx"));
28
+ const tr_utils_1 = require("../utils/tr-utils");
29
+ class GSTR2ExcelService {
30
+ static GetGSTR1ExcelData(MainData) {
31
+ this.wb = {};
32
+ this.ws = {};
33
+ this.Row = 0;
34
+ this.range = { s: { c: 0, r: 0 }, e: { c: 0, r: 0 } };
35
+ this.MergeArray = [];
36
+ let ws_name = 'GSTR2';
37
+ this.wb.Sheets = {};
38
+ this.wb.Props = {};
39
+ this.wb.SSF = {};
40
+ this.wb.SheetNames = [];
41
+ MainData = this.GetTotals(MainData);
42
+ this.setHeadingInCell();
43
+ this.setInvoiceDetailsInCell(MainData);
44
+ this.ws['!ref'] = XLSX.utils.encode_range(this.range);
45
+ this.ws['!merges'] = this.MergeArray;
46
+ this.wb.SheetNames.push(ws_name);
47
+ this.wb.Sheets[ws_name] = this.ws;
48
+ return this.wb;
49
+ }
50
+ static GetTotals(MainData) {
51
+ MainData.forEach((InvoicesList) => {
52
+ InvoicesList.Bills.forEach((InvoiceInfo) => {
53
+ // if (InvoiceInfo.Inv.InsTotal != null) {
54
+ // InvoiceInfo.Inv.Amount = InvoiceInfo.Inv.InsTotal;
55
+ // }
56
+ // if (InvoiceInfo.Inv.Total != null) {
57
+ // InvoiceInfo.Inv.Amount = InvoiceInfo.Inv.Total;
58
+ // }
59
+ if (InvoiceInfo.Total != null) {
60
+ InvoiceInfo.Amount = InvoiceInfo.Total;
61
+ }
62
+ });
63
+ });
64
+ return MainData;
65
+ }
66
+ static setHeadingInCell() {
67
+ let MainHeadings = [
68
+ {
69
+ text: 'GSTIN/UIN',
70
+ ColRange: 1,
71
+ bold: true,
72
+ ChildHeadings: []
73
+ },
74
+ {
75
+ text: 'Name',
76
+ ColRange: 1,
77
+ bold: true,
78
+ ChildHeadings: []
79
+ },
80
+ {
81
+ text: 'Bill Details',
82
+ ColRange: 4,
83
+ bold: true,
84
+ ChildHeadings: [
85
+ { text: 'No', ColRange: 1 },
86
+ { text: 'Date', ColRange: 1 },
87
+ { text: 'Total', ColRange: 1 }
88
+ ]
89
+ },
90
+ {
91
+ text: 'Rate',
92
+ ColRange: 1,
93
+ bold: true,
94
+ ChildHeadings: []
95
+ },
96
+ {
97
+ text: 'Taxable Value',
98
+ ColRange: 1,
99
+ bold: true,
100
+ ChildHeadings: []
101
+ },
102
+ {
103
+ text: 'Amount',
104
+ ColRange: 3,
105
+ bold: true,
106
+ ChildHeadings: [
107
+ { text: 'Central Tax', ColRange: 1 },
108
+ { text: 'State Tax', ColRange: 1 },
109
+ { text: 'IGST Tax', ColRange: 1 },
110
+ ]
111
+ }
112
+ ];
113
+ let MainColStart = 0;
114
+ MainHeadings.forEach((MainHeader) => {
115
+ let ChildColStart = MainColStart;
116
+ this.SetDataInCell(MainHeader.text, MainColStart, this.Row);
117
+ this.MergeArray.push({ s: { r: this.Row, c: MainColStart }, e: { r: this.Row, c: MainColStart + MainHeader.ColRange - 1 } });
118
+ MainColStart += MainHeader.ColRange;
119
+ MainHeader.ChildHeadings.forEach((ChildHeaderInfo) => {
120
+ this.SetDataInCell(ChildHeaderInfo.text, ChildColStart, this.Row + 1);
121
+ this.MergeArray.push({ s: { r: this.Row + 1, c: ChildColStart }, e: { r: this.Row + 1, c: ChildColStart + ChildHeaderInfo.ColRange - 1 } });
122
+ ChildColStart += ChildHeaderInfo.ColRange;
123
+ });
124
+ });
125
+ this.Row += 2;
126
+ }
127
+ static setInvoiceDetailsInCell(MainData) {
128
+ MainData.forEach((InvoiceList) => {
129
+ this.SetInvoiceDataInExcel(InvoiceList);
130
+ });
131
+ }
132
+ static SetInvoiceDataInExcel(InvoiceList) {
133
+ InvoiceList.Bills.forEach((InvoiceInfo, index) => {
134
+ // let InvoiceInfo = InvoiceInfoData.Inv;
135
+ InvoiceInfo.CrDate = this.ConvertDateToReadableFormat(InvoiceInfo.CrDate);
136
+ let GSTIN;
137
+ let Name;
138
+ if (index === 0) {
139
+ if (InvoiceList._id == 'Unspecified') {
140
+ GSTIN = 'No GST';
141
+ Name = InvoiceInfo.Name;
142
+ }
143
+ else {
144
+ GSTIN = InvoiceList._id;
145
+ Name = InvoiceInfo.Name;
146
+ }
147
+ }
148
+ else {
149
+ if (InvoiceList._id == 'Unspecified') {
150
+ GSTIN = 'No GST';
151
+ Name = InvoiceInfo.Name;
152
+ }
153
+ }
154
+ let InvoiceData = [
155
+ { text: GSTIN, ColRange: 1, IsString: true },
156
+ { text: Name, ColRange: 1, IsString: true },
157
+ { text: InvoiceInfo.BNo, ColRange: 1, IsString: true },
158
+ { text: InvoiceInfo.CrDate, ColRange: 1, IsString: true },
159
+ { text: InvoiceInfo.Amount, ColRange: 1, IsString: false }
160
+ ];
161
+ let ColStart = 0;
162
+ InvoiceData.forEach((InvData) => {
163
+ InvData.text = this.ConvertToString(InvData.text, InvData.IsString);
164
+ this.SetDataInCell(InvData.text, ColStart, this.Row);
165
+ this.MergeArray.push({ s: { r: this.Row, c: ColStart }, e: { r: this.Row, c: ColStart + InvData.ColRange - 1 } });
166
+ ColStart += InvData.ColRange;
167
+ });
168
+ let TotalsColStart = ColStart;
169
+ if (!tr_utils_1.TrUtils.IsNull(InvoiceInfo.ItemsArray) && InvoiceInfo.ItemsArray.length !== 0) {
170
+ let PartsHeading = { text: 'Parts', ColRange: 1 };
171
+ this.SetDataInCell(PartsHeading.text, TotalsColStart, this.Row);
172
+ this.MergeArray.push({ s: { r: this.Row, c: TotalsColStart }, e: { r: this.Row, c: TotalsColStart + PartsHeading.ColRange - 1 } });
173
+ InvoiceInfo.ItemsArray.forEach((Part) => {
174
+ let PartData = [
175
+ { text: Part.Rate, ColRange: 1, IsString: false },
176
+ { text: Part.Taxable, ColRange: 1, IsString: false },
177
+ { text: Part.CGST, ColRange: 1, IsString: false },
178
+ { text: Part.SGST, ColRange: 1, IsString: false },
179
+ { text: Part.IGST, ColRange: 1, IsString: false }
180
+ ];
181
+ let PartColStart = TotalsColStart + 1;
182
+ PartData.forEach((PartInfo) => {
183
+ PartInfo.text = this.ConvertToString(PartInfo.text, PartInfo.IsString);
184
+ this.SetDataInCell(PartInfo.text, PartColStart, this.Row);
185
+ this.MergeArray.push({ s: { r: this.Row, c: PartColStart }, e: { r: this.Row, c: PartColStart + PartInfo.ColRange - 1 } });
186
+ PartColStart += PartInfo.ColRange;
187
+ });
188
+ this.Row += 1;
189
+ });
190
+ this.Row += 1;
191
+ }
192
+ // if (!TrUtils.IsNull(InvoiceInfo.LaborArray) && InvoiceInfo.LaborArray.length !== 0) {
193
+ // let LaborHeading: any = { text: 'Labor', ColRange: 1 };
194
+ // this.SetDataInCell(LaborHeading.text, TotalsColStart, this.Row);
195
+ // this.MergeArray.push({ s: { r: this.Row, c: TotalsColStart }, e: { r: this.Row, c: TotalsColStart + LaborHeading.ColRange - 1 } });
196
+ // InvoiceInfo.LaborArray.forEach((Service: any) => {
197
+ // let ServiceData: any = [
198
+ // { text: Service.Rate, ColRange: 1, IsString: false },
199
+ // { text: Service.Taxable, ColRange: 1, IsString: false },
200
+ // { text: Service.CGST, ColRange: 1, IsString: false },
201
+ // { text: Service.SGST, ColRange: 1, IsString: false },
202
+ // { text: Service.IGST, ColRange: 1, IsString: false }
203
+ // ];
204
+ // let LaborColStart: any = TotalsColStart + 1;
205
+ // ServiceData.forEach((ServiceInfo: any) => {
206
+ // ServiceInfo.text = this.ConvertToString(ServiceInfo.text, ServiceInfo.IsString);
207
+ // this.SetDataInCell(ServiceInfo.text, LaborColStart, this.Row);
208
+ // this.MergeArray.push({ s: { r: this.Row, c: LaborColStart }, e: { r: this.Row, c: LaborColStart + ServiceInfo.ColRange - 1 } });
209
+ // LaborColStart += ServiceInfo.ColRange;
210
+ // });
211
+ // this.Row += 1;
212
+ // });
213
+ // this.Row += 1;
214
+ // }
215
+ this.Row += 1;
216
+ });
217
+ }
218
+ static ConvertToString(Text, IsString) {
219
+ if (IsString) {
220
+ if (tr_utils_1.TrUtils.IsNull(Text)) {
221
+ Text = '';
222
+ }
223
+ }
224
+ else {
225
+ if (tr_utils_1.TrUtils.IsNull(Text)) {
226
+ Text = 0;
227
+ }
228
+ }
229
+ if (typeof (Text) === 'number') {
230
+ return Number(tr_utils_1.TrUtils.FixedTo(Text));
231
+ }
232
+ else {
233
+ return Text;
234
+ }
235
+ }
236
+ static SetDataInCell(Data, ColRange, RowNum) {
237
+ var cell = { v: Data };
238
+ var cell_ref = XLSX.utils.encode_cell({ c: ColRange, r: RowNum });
239
+ if (this.range.e.c < ColRange) {
240
+ this.range.e.c = ColRange;
241
+ }
242
+ if (this.range.e.r < RowNum) {
243
+ this.range.e.r = RowNum;
244
+ }
245
+ cell = this.getcelltype(cell);
246
+ this.ws[cell_ref] = cell;
247
+ }
248
+ static getcelltype(cell) {
249
+ if (typeof cell.v === 'number')
250
+ cell.t = 'n';
251
+ else if (typeof cell.v === 'boolean')
252
+ cell.t = 'b';
253
+ else
254
+ cell.t = 's';
255
+ return cell;
256
+ }
257
+ static ConvertDateToReadableFormat(DateObject) {
258
+ if (!tr_utils_1.TrUtils.IsEmpty(DateObject)) {
259
+ let date = new Date(DateObject);
260
+ let Month;
261
+ let Day;
262
+ let MonthName = new Array();
263
+ MonthName[0] = 'Jan';
264
+ MonthName[1] = 'Feb';
265
+ MonthName[2] = 'Mar';
266
+ MonthName[3] = 'Apr';
267
+ MonthName[4] = 'May';
268
+ MonthName[5] = 'Jun';
269
+ MonthName[6] = 'Jul';
270
+ MonthName[7] = 'Aug';
271
+ MonthName[8] = 'Sept';
272
+ MonthName[9] = 'Oct';
273
+ MonthName[10] = 'Nov';
274
+ MonthName[11] = 'Dec';
275
+ Month = MonthName[date.getMonth()];
276
+ if (date.getDate() < 10) {
277
+ Day = '0' + date.getDate();
278
+ }
279
+ else {
280
+ Day = date.getDate();
281
+ }
282
+ date = Day + '-' + Month + '-' + date.getFullYear();
283
+ return date;
284
+ }
285
+ else {
286
+ return null;
287
+ }
288
+ }
289
+ }
290
+ exports.GSTR2ExcelService = GSTR2ExcelService;
291
+ GSTR2ExcelService.wb = {};
292
+ GSTR2ExcelService.Row = 0;
293
+ GSTR2ExcelService.MergeArray = [];
294
+ GSTR2ExcelService.range = { s: { c: 0, r: 0 }, e: { c: 0, r: 0 } };
295
+ GSTR2ExcelService.ws = {};