@managesome/eposmatic-toolkit 0.2.769 → 0.2.771

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 (57) hide show
  1. package/lib/helpers/utils/receipt-engine.js +10 -2
  2. package/lib/tests/classic-specials-quantity.test.js +7 -4
  3. package/lib/tests/receipt-engine.test.js +79 -0
  4. package/package.json +1 -1
  5. package/lib/constants/MATERIALIZED_REPORTS.d.ts +0 -44
  6. package/lib/constants/MATERIALIZED_REPORTS.js +0 -58
  7. package/lib/constants/WAREHOUSE_INVOICE.d.ts +0 -14
  8. package/lib/constants/WAREHOUSE_INVOICE.js +0 -35
  9. package/lib/helpers/offer/generate-offer.d.ts +0 -11
  10. package/lib/helpers/offer/generate-offer.js +0 -143
  11. package/lib/helpers/offer/index.d.ts +0 -1
  12. package/lib/helpers/offer/index.js +0 -17
  13. package/lib/helpers/order/generate-warehouse-invoice.d.ts +0 -11
  14. package/lib/helpers/order/generate-warehouse-invoice.js +0 -196
  15. package/lib/helpers/store/all-warehouse-invoice-actions.d.ts +0 -13
  16. package/lib/helpers/store/all-warehouse-invoice-actions.js +0 -58
  17. package/lib/helpers/store/common-warehouse-invoice-actions.d.ts +0 -31
  18. package/lib/helpers/store/common-warehouse-invoice-actions.js +0 -545
  19. package/lib/helpers/store/warehouse-invoice-cart-actions.d.ts +0 -24
  20. package/lib/helpers/store/warehouse-invoice-cart-actions.js +0 -486
  21. package/lib/helpers/types/sockets.d.ts +0 -6
  22. package/lib/helpers/types/sockets.js +0 -2
  23. package/lib/helpers/types/warehouse-invoice-cart-actions.d.ts +0 -26
  24. package/lib/helpers/types/warehouse-invoice-cart-actions.js +0 -2
  25. package/lib/helpers/utils/materialized-report-helpers.d.ts +0 -35
  26. package/lib/helpers/utils/materialized-report-helpers.js +0 -73
  27. package/lib/helpers/utils/void-warehouse-invoice-items-helpers.d.ts +0 -3
  28. package/lib/helpers/utils/void-warehouse-invoice-items-helpers.js +0 -38
  29. package/lib/helpers/utils/void-warehouse-invoice-items-report-helpers.d.ts +0 -13
  30. package/lib/helpers/utils/void-warehouse-invoice-items-report-helpers.js +0 -22
  31. package/lib/helpers/utils/warehouse-invoice-order-engine.d.ts +0 -11
  32. package/lib/helpers/utils/warehouse-invoice-order-engine.js +0 -39
  33. package/lib/helpers/utils/warehouse-invoice-x-report-helpers.d.ts +0 -58
  34. package/lib/helpers/utils/warehouse-invoice-x-report-helpers.js +0 -1432
  35. package/lib/schemas/models/inventory_department_transactions.d.ts +0 -86
  36. package/lib/schemas/models/inventory_department_transactions.js +0 -116
  37. package/lib/schemas/models/inventory_department_utilities.d.ts +0 -108
  38. package/lib/schemas/models/inventory_department_utilities.js +0 -88
  39. package/lib/schemas/models/inventory_departments.d.ts +0 -53
  40. package/lib/schemas/models/inventory_departments.js +0 -58
  41. package/lib/schemas/models/inventory_entries.d.ts +0 -152
  42. package/lib/schemas/models/inventory_entries.js +0 -142
  43. package/lib/schemas/models/materialized_reports.d.ts +0 -277
  44. package/lib/schemas/models/materialized_reports.js +0 -60
  45. package/lib/schemas/models/warehouse_invoices.d.ts +0 -2675
  46. package/lib/schemas/models/warehouse_invoices.js +0 -327
  47. package/lib/schemas/models/warehouse_void_invoice_items.d.ts +0 -176
  48. package/lib/schemas/models/warehouse_void_invoice_items.js +0 -176
  49. package/lib/schemas/types/inventory_entries.d.ts +0 -41
  50. package/lib/schemas/types/inventory_entries.js +0 -2
  51. package/lib/schemas/types/materialized_reports.d.ts +0 -82
  52. package/lib/schemas/types/materialized_reports.js +0 -2
  53. package/lib/schemas/types/warehouse_invoices.d.ts +0 -69
  54. package/lib/schemas/types/warehouse_invoices.js +0 -2
  55. package/lib/schemas/types/warehouse_void_invoice_items.d.ts +0 -37
  56. package/lib/schemas/types/warehouse_void_invoice_items.js +0 -2
  57. package/lib/tests/materialized-report-helpers.test.d.ts +0 -1
@@ -1,1432 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getWarehouseInvoiceXReportData = void 0;
7
- exports.getWarehouseInvoiceXReportHtml = getWarehouseInvoiceXReportHtml;
8
- const moment_1 = __importDefault(require("moment"));
9
- const constants_1 = require("../../constants");
10
- const common_1 = require("./common");
11
- const price_conversion_1 = require("./price-conversion");
12
- const getHead = (monochrome) => {
13
- const palette = monochrome
14
- ? {
15
- headingBackground: '#ffffff',
16
- headingText: '#000000',
17
- titleBackground: '#ffffff',
18
- titleText: '#000000',
19
- text: '#000000',
20
- border: '#000000',
21
- borderRight: '#000000',
22
- tableHeaderBackground: '#ffffff',
23
- tableHeaderText: '#000000',
24
- }
25
- : {
26
- headingBackground: '#431665',
27
- headingText: '#ffffff',
28
- titleBackground: '#666666',
29
- titleText: '#ffffff',
30
- text: '#333333',
31
- border: '#ffffff',
32
- borderRight: '#431665',
33
- tableHeaderBackground: '#431665',
34
- tableHeaderText: '#ffffff',
35
- };
36
- const fontLink = monochrome
37
- ? `<link
38
- rel="stylesheet"
39
- href="https://fonts.googleapis.com/css2?family=Roboto+Condensed:wght@300;400;500;700&display=swap"
40
- crossorigin="anonymous"
41
- />`
42
- : `<link
43
- rel="stylesheet"
44
- href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&amp;display=swap"
45
- crossorigin="anonymous"
46
- />`;
47
- return `<head>
48
- <meta charset="UTF-8" />
49
- <link rel="preconnect" href="https://fonts.googleapis.com" />
50
- <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
51
- ${fontLink}
52
- <style>
53
- .cssc-1flmrcm-kjlask {
54
- -webkit-font-smoothing: antialiased;
55
- -webkit-text-size-adjust: 100%;
56
- color: ${palette.text};
57
- line-height: 1.15rem;
58
- font-size: 1rem;
59
- font-family: Roboto, Public Sans, sans-serif;
60
- font-weight: 400;
61
- box-sizing: border-box;
62
- display: flex;
63
- flex-direction: column;
64
- flex: 1;
65
- margin: 0;
66
- margin-top: 8px;
67
- background-color: #ffffff;
68
- }
69
- .cssc-16f6p1q-kjlask {
70
- -webkit-font-smoothing: antialiased;
71
- -webkit-text-size-adjust: 100%;
72
- color: ${palette.text};
73
- line-height: 1.15rem;
74
- font-size: 1rem;
75
- font-family: Roboto, Public Sans, sans-serif;
76
- font-weight: 400;
77
- box-sizing: inherit;
78
- display: flex;
79
- flex-direction: column;
80
- flex: 1;
81
- margin: 0;
82
- border: 1px solid ${palette.borderRight};
83
- }
84
-
85
- .cssc-1qeq10-kjlask {
86
- display: flex;
87
- flex-direction: column;
88
- align-items: center;
89
- justify-content: center;
90
- gap: 4px;
91
- margin-top: 8px;
92
- margin-bottom: 8px;
93
- }
94
-
95
- .cssc-1owvoyj-kjhgs {
96
- -webkit-font-smoothing: antialiased;
97
- -webkit-text-size-adjust: 100%;
98
- color: ${palette.text};
99
- line-height: 1.15rem;
100
- font-size: 1rem;
101
- font-family: Roboto, Public Sans, sans-serif;
102
- font-weight: 400;
103
- box-sizing: border-box;
104
- display: flex;
105
- flex-wrap: wrap;
106
- flex-direction: row;
107
- margin-top: -32px;
108
- width: calc(100% + 16px);
109
- margin-left: -16px;
110
- -webkit-box-pack: center;
111
- justify-content: center;
112
- }
113
-
114
- .cssc-cjhduv-kjhgs {
115
- -webkit-font-smoothing: antialiased;
116
- -webkit-text-size-adjust: 100%;
117
- color: ${palette.text};
118
- line-height: 1.15rem;
119
- font-size: 1rem;
120
- font-family: Roboto, Public Sans, sans-serif;
121
- font-weight: 400;
122
- box-sizing: border-box;
123
- margin: 0;
124
- flex-direction: row;
125
- flex-basis: 100%;
126
- -webkit-box-flex: 0;
127
- flex-grow: 0;
128
- max-width: 100%;
129
- padding-top: 32px;
130
- padding-left: 16px;
131
- }
132
-
133
- .cssc-1qek100-kjlask {
134
- -webkit-font-smoothing: antialiased;
135
- -webkit-text-size-adjust: 100%;
136
- color: ${palette.text};
137
- line-height: 1.15rem;
138
- font-size: 1rem;
139
- font-family: Roboto, Public Sans, sans-serif;
140
- font-weight: 400;
141
- box-sizing: inherit;
142
- display: flex;
143
- flex-direction: column;
144
- background-color: #ffffff;
145
- overflow: hidden;
146
- flex: 1;
147
- scroll-margin-top: 120px;
148
- }
149
-
150
- .cssc-lpyf3a-skks {
151
- -webkit-font-smoothing: antialiased;
152
- -webkit-text-size-adjust: 100%;
153
- position: relative;
154
- box-sizing: border-box;
155
- -webkit-tap-highlight-color: transparent;
156
- outline: 0;
157
- border: 0;
158
- margin: 0;
159
- border-radius: 0;
160
- vertical-align: middle;
161
- -webkit-appearance: none;
162
- text-decoration: none;
163
- text-align: center;
164
- height: 50px;
165
- display: flex;
166
- -webkit-box-align: center;
167
- align-items: center;
168
- -webkit-box-pack: center;
169
- justify-content: center;
170
- padding: 15px;
171
- background-color: ${palette.headingBackground};
172
- color: ${palette.headingText};
173
- border-bottom: 1px solid ${palette.borderRight};
174
- }
175
-
176
- .cssc-1gb95rg-oilkj {
177
- -webkit-font-smoothing: antialiased;
178
- -webkit-text-size-adjust: 100%;
179
- -webkit-tap-highlight-color: transparent;
180
- color: ${palette.headingText};
181
- box-sizing: inherit;
182
- margin: 0;
183
- font-weight: 500;
184
- line-height: 1.9500000000000002rem;
185
- font-size: 1.5rem;
186
- font-family: Roboto, Public Sans, sans-serif;
187
- text-align: center;
188
- flex: 1;
189
- }
190
-
191
- .cssc-rorn0c-lkask {
192
- -webkit-font-smoothing: antialiased;
193
- -webkit-text-size-adjust: 100%;
194
- color: ${palette.text};
195
- line-height: 1.15rem;
196
- font-size: 1rem;
197
- font-family: Roboto, Public Sans, sans-serif;
198
- font-weight: 400;
199
- box-sizing: inherit;
200
- width: 100%;
201
- overflow-x: auto;
202
- }
203
-
204
- .cssc-1m6vi3w-posi {
205
- -webkit-font-smoothing: antialiased;
206
- -webkit-text-size-adjust: 100%;
207
- color: ${palette.text};
208
- line-height: 1.15rem;
209
- font-size: 1rem;
210
- font-family: Roboto, Public Sans, sans-serif;
211
- font-weight: 400;
212
- box-sizing: inherit;
213
- display: table;
214
- width: 100%;
215
- border-collapse: collapse;
216
- border-spacing: 0;
217
- }
218
-
219
- .cssc-15wwp11-qwem {
220
- -webkit-font-smoothing: antialiased;
221
- -webkit-text-size-adjust: 100%;
222
- color: ${palette.text};
223
- line-height: 1.15rem;
224
- font-size: 1rem;
225
- font-family: Roboto, Public Sans, sans-serif;
226
- font-weight: 400;
227
- border-collapse: collapse;
228
- border-spacing: 0;
229
- box-sizing: inherit;
230
- display: table-header-group;
231
- }
232
-
233
- .cssc-ho2sf9-sanbv {
234
- -webkit-font-smoothing: antialiased;
235
- -webkit-text-size-adjust: 100%;
236
- line-height: 1.15rem;
237
- font-size: 1rem;
238
- font-family: Roboto, Public Sans, sans-serif;
239
- font-weight: 400;
240
- border-collapse: collapse;
241
- border-spacing: 0;
242
- box-sizing: inherit;
243
- color: inherit;
244
- display: table-row;
245
- vertical-align: middle;
246
- outline: 0;
247
- }
248
-
249
- .cssc-idkl0b-ssaaw {
250
- -webkit-font-smoothing: antialiased;
251
- -webkit-text-size-adjust: 100%;
252
- border-collapse: collapse;
253
- border-spacing: 0;
254
- box-sizing: inherit;
255
- line-height: 1.5rem;
256
- font-size: 0.875rem;
257
- font-family: Roboto, Public Sans, sans-serif;
258
- font-weight: 500;
259
- display: table-cell;
260
- vertical-align: inherit;
261
- text-align: left;
262
- padding: 6px 16px;
263
- background-color: ${palette.tableHeaderBackground};
264
- color: ${palette.tableHeaderText};
265
- border-right: 1px solid ${palette.border};
266
- }
267
-
268
- .cssc-rq2z2r-oilkj {
269
- -webkit-font-smoothing: antialiased;
270
- -webkit-text-size-adjust: 100%;
271
- border-collapse: collapse;
272
- border-spacing: 0;
273
- text-align: left;
274
- color: ${palette.tableHeaderText};
275
- box-sizing: inherit;
276
- margin: 0;
277
- font-weight: 500;
278
- line-height: 1.15rem;
279
- font-size: 1rem;
280
- font-family: Roboto, Public Sans, sans-serif;
281
- }
282
-
283
- .cssc-1ymm2he-ssaaw {
284
- -webkit-font-smoothing: antialiased;
285
- -webkit-text-size-adjust: 100%;
286
- border-collapse: collapse;
287
- border-spacing: 0;
288
- box-sizing: inherit;
289
- line-height: 1.25rem;
290
- font-size: 0.875rem;
291
- font-family: Roboto, Public Sans, sans-serif;
292
- font-weight: 500;
293
- display: table-cell;
294
- vertical-align: inherit;
295
- text-align: right;
296
- padding: 4px 10px;
297
- flex-direction: row-reverse;
298
- background-color: ${palette.tableHeaderBackground};
299
- color: ${palette.tableHeaderText};
300
- border-right: 1px solid ${palette.border};
301
- }
302
-
303
- .cssc-eyhmry-ssaaw {
304
- -webkit-font-smoothing: antialiased;
305
- -webkit-text-size-adjust: 100%;
306
- border-collapse: collapse;
307
- border-spacing: 0;
308
- box-sizing: inherit;
309
- line-height: 1.25rem;
310
- font-size: 0.875rem;
311
- font-family: Roboto, Public Sans, sans-serif;
312
- font-weight: 500;
313
- display: table-cell;
314
- vertical-align: inherit;
315
- text-align: right;
316
- padding: 4px 10px;
317
- flex-direction: row-reverse;
318
- background-color: ${palette.tableHeaderBackground};
319
- color: ${palette.tableHeaderText};
320
- }
321
-
322
- .cssc-apqrd9-skjas {
323
- -webkit-font-smoothing: antialiased;
324
- -webkit-text-size-adjust: 100%;
325
- color: ${palette.text};
326
- line-height: 1.15rem;
327
- font-size: 1rem;
328
- font-family: Roboto, Public Sans, sans-serif;
329
- font-weight: 400;
330
- border-collapse: collapse;
331
- border-spacing: 0;
332
- box-sizing: inherit;
333
- display: table-row-group;
334
- }
335
-
336
- .cssc-1qrvgoi-sanbv {
337
- -webkit-font-smoothing: antialiased;
338
- -webkit-text-size-adjust: 100%;
339
- line-height: 1.15rem;
340
- font-size: 1rem;
341
- font-family: Roboto, Public Sans, sans-serif;
342
- font-weight: 400;
343
-
344
- border-collapse: collapse;
345
- border-spacing: 0;
346
- box-sizing: inherit;
347
- color: inherit;
348
- display: table-row;
349
- vertical-align: middle;
350
- outline: 0;
351
- background-color: ${palette.titleBackground};
352
- }
353
-
354
- .cssc-gnx8yv-ssaaw {
355
- -webkit-font-smoothing: antialiased;
356
- -webkit-text-size-adjust: 100%;
357
-
358
- border-collapse: collapse;
359
- border-spacing: 0;
360
- box-sizing: inherit;
361
- line-height: 1.1375rem;
362
- font-size: 0.875rem;
363
- font-family: Roboto, Public Sans, sans-serif;
364
- font-weight: 400;
365
- display: table-cell;
366
- vertical-align: inherit;
367
- border-top: 1px solid ${palette.border};
368
- text-align: left;
369
- padding: 6px 16px;
370
- color: ${palette.titleText};
371
- }
372
-
373
- .cssc-1b7x1hq-oilkj {
374
- -webkit-font-smoothing: antialiased;
375
- -webkit-text-size-adjust: 100%;
376
-
377
- border-collapse: collapse;
378
- border-spacing: 0;
379
- box-sizing: inherit;
380
- margin: 0;
381
- font-weight: 500;
382
- line-height: 1.54375rem;
383
- font-size: 1.1875rem;
384
- font-family: Roboto, Public Sans, sans-serif;
385
- text-align: center;
386
- color: ${palette.titleText};
387
- }
388
-
389
- .cssc-kkegnv-sanbv {
390
- -webkit-font-smoothing: antialiased;
391
- -webkit-text-size-adjust: 100%;
392
- line-height: 1.15rem;
393
- font-size: 1rem;
394
- font-family: Roboto, Public Sans, sans-serif;
395
- font-weight: 400;
396
-
397
- border-collapse: collapse;
398
- border-spacing: 0;
399
- box-sizing: inherit;
400
- color: inherit;
401
- display: table-row;
402
- vertical-align: middle;
403
- outline: 0;
404
- }
405
-
406
- .cssc-1d7qqp0-ssaaw {
407
- -webkit-font-smoothing: antialiased;
408
- -webkit-text-size-adjust: 100%;
409
-
410
- border-collapse: collapse;
411
- border-spacing: 0;
412
- box-sizing: inherit;
413
- line-height: 1.1375rem;
414
- font-size: 0.875rem;
415
- font-family: Roboto, Public Sans, sans-serif;
416
- font-weight: 400;
417
- display: table-cell;
418
- vertical-align: inherit;
419
- border-bottom: 1px solid rgba(240, 240, 240, 1);
420
- text-align: left;
421
- padding: 6px 16px;
422
- color: ${palette.text};
423
- border-right: 1px solid ${palette.borderRight};
424
- }
425
-
426
- .cssc-1ebo3of-oilkj {
427
- -webkit-font-smoothing: antialiased;
428
- -webkit-text-size-adjust: 100%;
429
-
430
- border-collapse: collapse;
431
- border-spacing: 0;
432
- text-align: left;
433
- color: ${palette.text};
434
- box-sizing: inherit;
435
- margin: 0;
436
- line-height: 1.1375rem;
437
- font-size: 0.875rem;
438
- font-family: Roboto, Public Sans, sans-serif;
439
- font-weight: 400;
440
- }
441
-
442
- .cssc-up54xb-ssaaw {
443
- -webkit-font-smoothing: antialiased;
444
- -webkit-text-size-adjust: 100%;
445
-
446
- border-collapse: collapse;
447
- border-spacing: 0;
448
- box-sizing: inherit;
449
- line-height: 1.1375rem;
450
- font-size: 0.875rem;
451
- font-family: Roboto, Public Sans, sans-serif;
452
- font-weight: 400;
453
- display: table-cell;
454
- vertical-align: inherit;
455
- border-bottom: 1px solid rgba(240, 240, 240, 1);
456
- text-align: right;
457
- padding: 6px 16px;
458
- color: ${palette.text};
459
- flex-direction: row-reverse;
460
- border-right: 1px solid ${palette.borderRight};
461
- }
462
-
463
- .cssc-v53jtm-ssaaw {
464
- -webkit-font-smoothing: antialiased;
465
- -webkit-text-size-adjust: 100%;
466
-
467
- border-collapse: collapse;
468
- border-spacing: 0;
469
- box-sizing: inherit;
470
- line-height: 1.1375rem;
471
- font-size: 0.875rem;
472
- font-family: Roboto, Public Sans, sans-serif;
473
- font-weight: 400;
474
- display: table-cell;
475
- vertical-align: inherit;
476
- border-bottom: 1px solid rgba(240, 240, 240, 1);
477
- text-align: right;
478
- padding: 6px 16px;
479
- color: ${palette.text};
480
- flex-direction: row-reverse;
481
- }
482
-
483
- .cssc-1ho5x3sk-kjlask {
484
- padding: 10px;
485
- width: 100%;
486
- border-top: 1px solid ${palette.borderRight};
487
- }
488
-
489
- .cssc-1ho5x3p-kjlask {
490
- -webkit-font-smoothing: antialiased;
491
- -webkit-text-size-adjust: 100%;
492
- color: ${palette.text};
493
- line-height: 1.15rem;
494
- font-size: 1rem;
495
- font-family: Roboto, Public Sans, sans-serif;
496
- font-weight: 400;
497
- box-sizing: inherit;
498
- display: flex;
499
- flex-direction: column;
500
- max-width: 400px;
501
- gap: 5px
502
- }
503
-
504
- .cssc-gmwslw-kjlask {
505
- -webkit-font-smoothing: antialiased;
506
- -webkit-text-size-adjust: 100%;
507
- color: ${palette.text};
508
- line-height: 1.15rem;
509
- font-size: 1rem;
510
- font-family: Roboto, Public Sans, sans-serif;
511
- font-weight: 400;
512
- box-sizing: inherit;
513
- display: flex;
514
- flex-direction: row;
515
- -webkit-box-pack: justify;
516
- justify-content: space-between;
517
- margin: 0;
518
- }
519
-
520
- .cssc-1iy4zoj-oilkj {
521
- -webkit-font-smoothing: antialiased;
522
- -webkit-text-size-adjust: 100%;
523
- color: ${palette.text};
524
- box-sizing: inherit;
525
- margin: 0;
526
- line-height: 1.15rem;
527
- font-size: 1rem;
528
- font-family: Roboto, Public Sans, sans-serif;
529
- font-weight: 400;
530
- }
531
-
532
- .cssc-13sv1r4-oilkj {
533
- -webkit-font-smoothing: antialiased;
534
- -webkit-text-size-adjust: 100%;
535
- color: ${palette.text};
536
- box-sizing: inherit;
537
- margin: 0;
538
- line-height: 1.15rem;
539
- font-size: 1rem;
540
- font-family: Roboto, Public Sans, sans-serif;
541
- font-weight: 700;
542
- }
543
-
544
- .cssc-1l6ueuj-sjaksl {
545
- -webkit-font-smoothing: antialiased;
546
- -webkit-text-size-adjust: 100%;
547
- color: ${palette.text};
548
- line-height: 1.15rem;
549
- font-size: 1rem;
550
- font-family: Roboto, Public Sans, sans-serif;
551
- font-weight: 400;
552
- box-sizing: inherit;
553
- flex-shrink: 0;
554
- border-width: 0;
555
- border-style: solid;
556
- border-color: #dcdcdc;
557
- border-bottom-width: thin;
558
- margin: 0;
559
- margin-top: 4px;
560
- }
561
-
562
- .cssc-1pm8g43-kjlask {
563
- -webkit-font-smoothing: antialiased;
564
- -webkit-text-size-adjust: 100%;
565
- color: ${palette.text};
566
- line-height: 1.15rem;
567
- font-size: 1rem;
568
- font-family: Roboto, Public Sans, sans-serif;
569
- font-weight: 400;
570
- box-sizing: inherit;
571
- display: flex;
572
- flex-direction: column;
573
- max-width: 400px;
574
- margin: 0;
575
- gap: 5px;
576
- }
577
-
578
- .cssc-gmwslw-kjlask {
579
- -webkit-font-smoothing: antialiased;
580
- -webkit-text-size-adjust: 100%;
581
- color: ${palette.text};
582
- line-height: 1.15rem;
583
- font-size: 1rem;
584
- font-family: Roboto, Public Sans, sans-serif;
585
- font-weight: 400;
586
- box-sizing: inherit;
587
- display: flex;
588
- flex-direction: row;
589
- -webkit-box-pack: justify;
590
- justify-content: space-between;
591
- margin: 0;
592
- }
593
-
594
- .cssc-1pm8m44-kjlask {
595
- -webkit-font-smoothing: antialiased;
596
- -webkit-text-size-adjust: 100%;
597
- -webkit-user-select: none;
598
- border-collapse: collapse;
599
- border-spacing: 0;
600
- line-height: 1.1375rem;
601
- font-size: 0.875rem;
602
- font-family: Roboto,Public Sans,sans-serif;
603
- font-weight: 400;
604
- text-align: left;
605
- color: ${palette.text};
606
- box-sizing: inherit;
607
- display: flex;
608
- flex-direction: row;
609
- }
610
-
611
- .cssc-1ebo3of-gaplas {
612
- -webkit-font-smoothing: antialiased;
613
- -webkit-text-size-adjust: 100%;
614
- -webkit-user-select: none;
615
- border-collapse: collapse;
616
- border-spacing: 0;
617
- line-height: 1.1375rem;
618
- font-size: 0.875rem;
619
- font-family: Roboto,Public Sans,sans-serif;
620
- font-weight: 400;
621
- text-align: left;
622
- color: ${palette.text};
623
- box-sizing: inherit;
624
- width: 15px;
625
- border-left: 1px solid #DCDCDC;
626
- border-bottom: 1px solid #DCDCDC;
627
- margin: 0;
628
- }
629
-
630
- .cssc-lpyf3z-kjlask {
631
- -webkit-font-smoothing: antialiased;
632
- -webkit-text-size-adjust: 100%;
633
- color: ${palette.text};
634
- line-height: 1.15rem;
635
- font-size: 1rem;
636
- font-family: Roboto,Public Sans,sans-serif;
637
- font-weight: 400;
638
- -webkit-user-select: none;
639
- box-sizing: inherit;
640
- display: flex;
641
- flex-direction: column;
642
- align-items: flex-start;
643
- }
644
-
645
- .cssc-1ebo3gf-oilkj {
646
- -webkit-font-smoothing: antialiased;
647
- -webkit-text-size-adjust: 100%;
648
- -webkit-user-select: none;
649
- box-sizing: inherit;
650
- margin: 0;
651
- line-height: 0.975rem;
652
- font-size: 0.75rem;
653
- font-family: Roboto,Public Sans,sans-serif;
654
- font-weight: 400;
655
- color: ${palette.text};
656
- }
657
-
658
- ${monochrome
659
- ? `
660
- /* Receipt Printer Optimized Styles - Monochrome */
661
-
662
- /* Container Styles */
663
- .cssc-1flmrcm-kjlask {
664
- margin-top: 4px !important;
665
- font-family: "Roboto Condensed", Roboto, sans-serif !important;
666
- }
667
-
668
- .cssc-1qeq10-kjlask {
669
- gap: 2px !important;
670
- margin-top: 4px !important;
671
- margin-bottom: 4px !important;
672
- font-family: "Roboto Condensed", Roboto, sans-serif !important;
673
- }
674
-
675
- .cssc-1owvoyj-kjhgs {
676
- margin-top: 0 !important;
677
- margin-left: 0 !important;
678
- width: 100% !important;
679
- font-family: "Roboto Condensed", Roboto, sans-serif !important;
680
- }
681
-
682
- .cssc-cjhduv-kjhgs {
683
- padding-top: 4px !important;
684
- padding-left: 0 !important;
685
- font-family: "Roboto Condensed", Roboto, sans-serif !important;
686
- }
687
-
688
- /* Header Styles */
689
- .cssc-lpyf3a-skks {
690
- height: 20px !important;
691
- padding: 2px 4px !important;
692
- font-family: "Roboto Condensed", Roboto, sans-serif !important;
693
- }
694
-
695
- .cssc-1gb95rg-oilkj {
696
- font-size: 24px !important;
697
- line-height: 26px !important;
698
- font-family: "Roboto Condensed", Roboto, sans-serif !important;
699
- }
700
-
701
- .cssc-1b7x1hq-oilkj {
702
- font-size: 22px !important;
703
- line-height: 24px !important;
704
- font-family: "Roboto Condensed", Roboto, sans-serif !important;
705
- }
706
-
707
- /* Table Cell Styles */
708
- .cssc-idkl0b-ssaaw,
709
- .cssc-1ymm2he-ssaaw,
710
- .cssc-eyhmry-ssaaw {
711
- padding: 2px 4px !important;
712
- font-size: 17px !important;
713
- line-height: 19px !important;
714
- font-family: "Roboto Condensed", Roboto, sans-serif !important;
715
- }
716
-
717
- .cssc-gnx8yv-ssaaw,
718
- .cssc-1d7qqp0-ssaaw,
719
- .cssc-up54xb-ssaaw,
720
- .cssc-v53jtm-ssaaw {
721
- padding: 2px 4px !important;
722
- font-size: 17px !important;
723
- line-height: 19px !important;
724
- font-family: "Roboto Condensed", Roboto, sans-serif !important;
725
- }
726
-
727
- /* Footer Styles */
728
- .cssc-1ho5x3sk-kjlask {
729
- padding: 4px !important;
730
- font-family: "Roboto Condensed", Roboto, sans-serif !important;
731
- }
732
-
733
- .cssc-1ho5x3p-kjlask {
734
- gap: 2px !important;
735
- font-family: "Roboto Condensed", Roboto, sans-serif !important;
736
- }
737
-
738
- .cssc-1pm8g43-kjlask {
739
- gap: 2px !important;
740
- font-family: "Roboto Condensed", Roboto, sans-serif !important;
741
- }
742
-
743
- .cssc-1l6ueuj-sjaksl {
744
- margin-top: 1px !important;
745
- font-family: "Roboto Condensed", Roboto, sans-serif !important;
746
- }
747
-
748
- .cssc-gmwslw-kjlask {
749
- font-size: 17px !important;
750
- line-height: 19px !important;
751
- font-family: "Roboto Condensed", Roboto, sans-serif !important;
752
- }
753
-
754
- .cssc-1iy4zoj-oilkj,
755
- .cssc-13sv1r4-oilkj {
756
- font-size: 17px !important;
757
- line-height: 19px !important;
758
- font-family: "Roboto Condensed", Roboto, sans-serif !important;
759
- }
760
-
761
- /* Subtitle and Label Styles */
762
- .cssc-rq2z2r-oilkj {
763
- font-size: 18px !important;
764
- line-height: 20px !important;
765
- font-family: "Roboto Condensed", Roboto, sans-serif !important;
766
- }
767
-
768
- .cssc-1ebo3of-oilkj {
769
- font-size: 17px !important;
770
- line-height: 19px !important;
771
- font-family: "Roboto Condensed", Roboto, sans-serif !important;
772
- }
773
-
774
- .cssc-1ebo3gf-oilkj {
775
- font-size: 16px !important;
776
- line-height: 18px !important;
777
- font-family: "Roboto Condensed", Roboto, sans-serif !important;
778
- }
779
-
780
- .cssc-1pm8m44-kjlask {
781
- font-size: 17px !important;
782
- line-height: 19px !important;
783
- font-family: "Roboto Condensed", Roboto, sans-serif !important;
784
- }
785
-
786
- .cssc-1ebo3of-gaplas {
787
- font-size: 17px !important;
788
- line-height: 19px !important;
789
- font-family: "Roboto Condensed", Roboto, sans-serif !important;
790
- }
791
-
792
- .cssc-lpyf3z-kjlask {
793
- font-size: 17px !important;
794
- line-height: 19px !important;
795
- font-family: "Roboto Condensed", Roboto, sans-serif !important;
796
- }
797
-
798
- .cssc-16f6p1q-kjlask {
799
- font-family: "Roboto Condensed", Roboto, sans-serif !important;
800
- }
801
-
802
- .cssc-1qek100-kjlask {
803
- font-family: "Roboto Condensed", Roboto, sans-serif !important;
804
- }
805
-
806
- .cssc-rorn0c-lkask {
807
- font-family: "Roboto Condensed", Roboto, sans-serif !important;
808
- }
809
-
810
- .cssc-1m6vi3w-posi {
811
- font-family: "Roboto Condensed", Roboto, sans-serif !important;
812
- }
813
-
814
- .cssc-15wwp11-qwem {
815
- font-family: "Roboto Condensed", Roboto, sans-serif !important;
816
- }
817
-
818
- .cssc-ho2sf9-sanbv {
819
- font-family: "Roboto Condensed", Roboto, sans-serif !important;
820
- }
821
-
822
- .cssc-apqrd9-skjas {
823
- font-family: "Roboto Condensed", Roboto, sans-serif !important;
824
- }
825
-
826
- .cssc-1qrvgoi-sanbv {
827
- font-family: "Roboto Condensed", Roboto, sans-serif !important;
828
- }
829
-
830
- .cssc-kkegnv-sanbv {
831
- font-family: "Roboto Condensed", Roboto, sans-serif !important;
832
- }
833
- `
834
- : ''}
835
- </style>
836
- <title>Invoice X Report</title>
837
- </head>`;
838
- };
839
- function getBody({ clientWiseData, combinedData, currency_symbol, from, to, warehouseName, monochrome, isFilterApplied, }) {
840
- let mainBodyElements = ``;
841
- const fillMainBody = (staffData, index) => {
842
- let mainBodyFooterElements = `<div class="cssc-gmwslw-kjlask">
843
- <p class="cssc-1iy4zoj-oilkj" style="font-weight: 700">Total Orders</p>
844
- <p class="cssc-13sv1r4-oilkj" style="white-space: nowrap">${staffData.totalOrders}</p>
845
- </div>`;
846
- mainBodyFooterElements += `<hr class="cssc-1l6ueuj-sjaksl" />
847
- <div class="cssc-gmwslw-kjlask">
848
- <h6 class="cssc-1iy4zoj-oilkj" style="font-weight: 700">Item Sales</h6>
849
- <p class="cssc-13sv1r4-oilkj" style="white-space: nowrap">${(0, common_1.localeAmount)(currency_symbol, staffData.itemSales)}</p>
850
- </div>`;
851
- mainBodyFooterElements += `<hr class="cssc-1l6ueuj-sjaksl" />
852
- <div class="cssc-gmwslw-kjlask">
853
- <h6 class="cssc-1iy4zoj-oilkj" style="font-weight: 700">Net Sale</h6>
854
- <p class="cssc-13sv1r4-oilkj" style="white-space: nowrap;${monochrome ? '' : 'color: #008000'}">${(0, common_1.localeAmount)(currency_symbol, staffData.netSale)}</p>
855
- </div>`;
856
- if (staffData.unpaidOrders > 0) {
857
- mainBodyFooterElements += `<hr class="cssc-1l6ueuj-sjaksl" />
858
- <div class="cssc-gmwslw-kjlask">
859
- <h6 class="cssc-1iy4zoj-oilkj" style="font-weight: 700">Amount Collected</h6>
860
- <p class="cssc-13sv1r4-oilkj" style="white-space: nowrap;${monochrome ? '' : 'color: #FF6D00'}">${(0, common_1.localeAmount)(currency_symbol, staffData.amountCollected)}</p>
861
- </div>`;
862
- mainBodyFooterElements += `<hr class="cssc-1l6ueuj-sjaksl" />
863
- <div class="cssc-gmwslw-kjlask">
864
- <h6 class="cssc-1iy4zoj-oilkj" style="font-weight: 700">${staffData.unpaidOrders} Unpaid</h6>
865
- <p class="cssc-13sv1r4-oilkj" style="white-space: nowrap;${monochrome ? '' : 'color: #FF0000'}">${(0, common_1.localeAmount)(currency_symbol, staffData.unpaidAmount)}</p>
866
- </div>`;
867
- }
868
- if (staffData.netWithoutGst > 0 && staffData.netWithoutGst !== staffData.netSale) {
869
- mainBodyFooterElements += `<hr class="cssc-1l6ueuj-sjaksl" />
870
- <div class="cssc-gmwslw-kjlask">
871
- <div class="cssc-lpyf3z-kjlask">
872
- <h6 class="cssc-1iy4zoj-oilkj" style="font-weight: 700">Net Sale (Other)</h6>
873
- <span class="cssc-1ebo3gf-oilkj">${staffData.netWithoutGstSubtitle}</span>
874
- </div>
875
- <p class="cssc-13sv1r4-oilkj" style="white-space: nowrap">${(0, common_1.localeAmount)(currency_symbol, staffData.netWithoutGst)}</p>
876
- </div>`;
877
- }
878
- let mainBodyTableElements = ``;
879
- staffData.channels.forEach((channel) => {
880
- mainBodyTableElements += `<tr class="cssc-1qrvgoi-sanbv">
881
- <td class="cssc-gnx8yv-ssaaw" colspan="3">
882
- <h6 class="cssc-1b7x1hq-oilkj">
883
- ${channel.title}
884
- </h6>
885
- </td>
886
- </tr>`;
887
- channel.subChannels.forEach((subChannel) => {
888
- mainBodyTableElements += `<tr class="cssc-kkegnv-sanbv">
889
- <th class="cssc-1d7qqp0-ssaaw" scope="row">
890
- <p class="cssc-1ebo3of-oilkj"
891
- ${subChannel.bold ? `style="font-weight: bold; text-decoration: underline"` : ''}
892
- >
893
- ${subChannel.title}
894
- </p>
895
- </th>
896
-
897
- <td class="cssc-up54xb-ssaaw" align="right">
898
- <p class="cssc-1iy4zoj-oilkj"
899
- ${subChannel.bold ? `style="font-weight: bold; text-decoration: underline"` : ''}
900
- >${subChannel.count}</p>
901
- </td>
902
-
903
- <td class="cssc-v53jtm-ssaaw" align="right">
904
- <p class="cssc-1iy4zoj-oilkj"
905
- ${subChannel.strikeThrough
906
- ? `style="text-decoration: line-through"`
907
- : subChannel.bold
908
- ? `style="font-weight: bold; text-decoration: underline"`
909
- : ''}
910
- >${(0, common_1.localeAmount)(currency_symbol, subChannel.amount)}</p>
911
- </td>
912
- </tr>`;
913
- });
914
- channel.footerDetails.forEach((row) => {
915
- mainBodyTableElements += `<tr class="cssc-kkegnv-sanbv">
916
- <th class="cssc-1d7qqp0-ssaaw" scope="row">
917
- <div class="cssc-1pm8m44-kjlask" >
918
- <div class="cssc-1ebo3of-gaplas"></div>
919
- <span class="cssc-1ebo3of-oilkj" style="font-weight: normal">
920
- ${row.title}
921
- </span>
922
- </div>
923
- </th>
924
-
925
- <td class="cssc-up54xb-ssaaw" align="right">
926
- <p class="cssc-1iy4zoj-oilkj" style="font-weight: normal">${row.count}</p>
927
- </td>
928
-
929
- <td class="cssc-v53jtm-ssaaw" align="right">
930
- <p class="cssc-1iy4zoj-oilkj" style="font-weight: normal">${(0, common_1.localeAmount)(currency_symbol, row.amount)}</p>
931
- </td>
932
- </tr>`;
933
- });
934
- });
935
- let mainBodyDivider = '';
936
- if (monochrome && index > 0) {
937
- mainBodyDivider = `<hr style="height: 3px; color: #000000; background-color: #000000; border: none;" />`;
938
- }
939
- mainBodyElements += `<div class="cssc-1owvoyj-kjhgs">
940
- <div class="cssc-cjhduv-kjhgs">
941
- ${mainBodyDivider}
942
- <div class="cssc-1qek100-kjlask">
943
- <div class="cssc-lpyf3a-skks">
944
- <h5 class="cssc-1gb95rg-oilkj">${staffData.title}</h5>
945
- </div>
946
-
947
- <div class="cssc-rorn0c-lkask">
948
- <table class="cssc-1m6vi3w-posi">
949
- <thead class="cssc-15wwp11-qwem">
950
- <tr class="cssc-ho2sf9-sanbv">
951
- <th class="cssc-idkl0b-ssaaw" scope="col">
952
- <h6 class="cssc-rq2z2r-oilkj">
953
- Description
954
- </h6>
955
- </th>
956
-
957
- <th class="cssc-1ymm2he-ssaaw" scope="col" align="right">
958
- </th>
959
-
960
- <th class="cssc-eyhmry-ssaaw" scope="col" align="right">
961
- <h6 class="cssc-rq2z2r-oilkj" style="text-align: right">Amount</h6>
962
- </th>
963
- </tr>
964
- </thead>
965
-
966
- <tbody class="cssc-apqrd9-skjas">
967
- ${mainBodyTableElements}
968
- </tbody>
969
- </table>
970
- </div>
971
-
972
- <div class="cssc-1ho5x3sk-kjlask">
973
- <div class="cssc-1ho5x3p-kjlask">
974
- ${mainBodyFooterElements}
975
- </div>
976
- </div>
977
- </div>
978
- </div>
979
- </div>`;
980
- };
981
- clientWiseData.forEach(fillMainBody);
982
- if (combinedData != null && clientWiseData.length > 1) {
983
- fillMainBody(combinedData, clientWiseData.length);
984
- }
985
- return `<div class="cssc-1flmrcm-kjlask">
986
- <div class="cssc-1qeq10-kjlask">
987
- <h5 class="cssc-1gb95rg-oilkj" style="color: #000000">Invoice X Report</h5>
988
- <p class="cssc-1iy4zoj-oilkj">${(0, moment_1.default)(from).format('dddd')} ${(0, moment_1.default)(from).format('MMM DD, YYYY')}</p>
989
- <p class="cssc-1ebo3of-oilkj">${(0, moment_1.default)(from).format('h:mm a, MMM DD')} - ${(0, moment_1.default)(to).format('h:mm a, MMM DD')}</p>
990
- </div>
991
-
992
- <div class="cssc-16f6p1q-kjlask">
993
- ${mainBodyElements}
994
- </div>
995
-
996
- <div class="cssc-1qeq10-kjlask">
997
- <h5 class="cssc-1gb95rg-oilkj" style="color: #000000">${warehouseName ?? ''}</h5>
998
- <p class="cssc-1iy4zoj-oilkj">
999
- Exported on ${(0, moment_1.default)().format('dddd')} ${(0, moment_1.default)().format('MMM DD, YYYY')} at ${(0, moment_1.default)().format('h:mm a')}
1000
- </p>
1001
- ${isFilterApplied
1002
- ? `<p class="cssc-1iy4zoj-oilkj"
1003
- style="text-align: center; font-weight: bold; ${monochrome ? 'color: #000000' : 'color: #FF0000'}"
1004
- >
1005
- Note: This report is filtered. Please ensure to tally the data on your end.
1006
- </p>`
1007
- : ''}
1008
- </div>
1009
- </div>`;
1010
- }
1011
- function getWarehouseInvoiceXReportHtml({ width, monochrome, clientWiseData, combinedData, currency_symbol, from, to, warehouseName, isFilterApplied, }) {
1012
- const style = width ? `style=width: ${width}px; max-width: ${width}px` : '';
1013
- const html = `
1014
- <html lang="en" ${style}>
1015
- ${getHead(monochrome)}
1016
- <body translate="no"
1017
- ${style}
1018
- >
1019
- ${getBody({
1020
- clientWiseData,
1021
- combinedData,
1022
- currency_symbol,
1023
- from,
1024
- to,
1025
- warehouseName,
1026
- monochrome,
1027
- isFilterApplied,
1028
- })}
1029
- </body>
1030
- </html>`;
1031
- return html;
1032
- }
1033
- // ======================>>>><<<<=====================
1034
- const TOTAL_REF = 'TOTAL';
1035
- const CLIENT_ID = 'by_client';
1036
- const getSortedUsableChannels = (channels) => {
1037
- const usableChannels = [];
1038
- for (let i = 0; i < channels.length; i++) {
1039
- const c = channels[i];
1040
- const footerDetailsMap = c.footerDetailsMap;
1041
- const channel = {
1042
- _id: c._id,
1043
- title: c.title,
1044
- ref: c.ref,
1045
- sortIndex: c.sortIndex,
1046
- subChannels: c.subChannels,
1047
- footerDetails: Object.values(footerDetailsMap)
1048
- .map((fd) => ({
1049
- ...fd,
1050
- amount: (0, price_conversion_1.convertIntToDecimal)(fd.amount),
1051
- }))
1052
- .sort((a, b) => a.sortIndex - b.sortIndex),
1053
- };
1054
- const subChannels = channel.subChannels;
1055
- subChannels
1056
- .sort((a, b) => (a.ref > b.ref ? 1 : -1))
1057
- .forEach((sc, index) => {
1058
- sc.sortIndex = index;
1059
- });
1060
- for (let j = 0; j < subChannels.length; j++) {
1061
- const subChannel = subChannels[j];
1062
- if (subChannel.ref === TOTAL_REF) {
1063
- subChannel.sortIndex = 100000;
1064
- subChannel.bold = true;
1065
- }
1066
- else if (channel.ref === constants_1.WAREHOUSE_INVOICE_X_REPORT_TYPE_ENUM.TOTAL_PAYMENT_SALES) {
1067
- const paymentType = subChannel.ref;
1068
- let sortIndex = constants_1.ALL_PAYMENT_TYPE_NAMES.indexOf(paymentType);
1069
- if (sortIndex === -1) {
1070
- sortIndex = 200 + j;
1071
- }
1072
- subChannel.sortIndex = sortIndex;
1073
- }
1074
- else if (channel.ref === constants_1.WAREHOUSE_INVOICE_X_REPORT_TYPE_ENUM.ORDER_STATUS) {
1075
- const status = subChannel.ref;
1076
- let sortIndex = constants_1.ALL_WAREHOUSE_INVOICE_STATUS_NAMES.indexOf(status);
1077
- if (sortIndex === -1) {
1078
- sortIndex = 200 + j;
1079
- }
1080
- if (status === constants_1.WAREHOUSE_INVOICE_STATUS_ENUM.CANCELLED) {
1081
- const totalIndex = channel.subChannels.findIndex((sc) => sc.ref === TOTAL_REF);
1082
- if (totalIndex !== -1) {
1083
- const totalAmount = channel.subChannels[totalIndex].amount;
1084
- channel.subChannels[totalIndex].amount = (0, common_1.parseNum)(totalAmount - subChannel.amount);
1085
- }
1086
- subChannel.strikeThrough = true;
1087
- }
1088
- subChannel.sortIndex = sortIndex;
1089
- }
1090
- else if (channel.ref === constants_1.WAREHOUSE_INVOICE_X_REPORT_TYPE_ENUM.STAFF) {
1091
- // Clients are sorted by ref (client_id)
1092
- subChannel.sortIndex = j;
1093
- }
1094
- }
1095
- usableChannels.push(channel);
1096
- }
1097
- const sortedChannels = usableChannels
1098
- .map((channel) => ({
1099
- ...channel,
1100
- subChannels: channel.subChannels.sort((a, b) => a.sortIndex - b.sortIndex),
1101
- }))
1102
- .sort((a, b) => a.sortIndex - b.sortIndex);
1103
- return sortedChannels;
1104
- };
1105
- const generateClientWiseData = (data, currencySymbol, gstName) => {
1106
- const clientWiseDataMap = {};
1107
- const clientWiseTotalSalesMap = {};
1108
- const clientNamesMap = {};
1109
- data[constants_1.WAREHOUSE_INVOICE_X_REPORT_TYPE_ENUM.TOTAL_SALES].forEach((item) => {
1110
- const clientName = item.client_name ?? 'By Client';
1111
- const clientId = item.client_id ?? CLIENT_ID;
1112
- clientWiseTotalSalesMap[clientId] = item;
1113
- clientNamesMap[clientId] = clientName;
1114
- });
1115
- // ==========>>><<<==========
1116
- data[constants_1.WAREHOUSE_INVOICE_X_REPORT_TYPE_ENUM.STAFF].forEach((item) => {
1117
- const clientId = item.client_id ?? CLIENT_ID;
1118
- const clientName = clientNamesMap[clientId];
1119
- if (clientName != null) {
1120
- const amount = item.grossAmount;
1121
- const obj = {
1122
- _id: clientId,
1123
- ref: item.staff_id,
1124
- title: 'Staff',
1125
- description: item.staff_name,
1126
- type: constants_1.WAREHOUSE_INVOICE_X_REPORT_TYPE_ENUM.STAFF,
1127
- staff_name: clientName,
1128
- count: item.count,
1129
- amount,
1130
- sortIndex: 1,
1131
- };
1132
- if (clientWiseDataMap[clientId] != null) {
1133
- clientWiseDataMap[clientId].push(obj);
1134
- }
1135
- else {
1136
- clientWiseDataMap[clientId] = [obj];
1137
- }
1138
- }
1139
- });
1140
- data[constants_1.WAREHOUSE_INVOICE_X_REPORT_TYPE_ENUM.ORDER_STATUS].forEach((item) => {
1141
- const clientId = item.client_id ?? CLIENT_ID;
1142
- const clientName = clientNamesMap[clientId];
1143
- if (clientName != null) {
1144
- const amount = item.grossAmount;
1145
- const obj = {
1146
- _id: clientId,
1147
- ref: item.status,
1148
- type: constants_1.WAREHOUSE_INVOICE_X_REPORT_TYPE_ENUM.ORDER_STATUS,
1149
- staff_name: clientName,
1150
- title: 'Order Status',
1151
- description: (0, common_1.sentenceCase)(item.status.replace(/_/g, ' ')),
1152
- count: item.count,
1153
- amount,
1154
- sortIndex: 2,
1155
- };
1156
- if (clientWiseDataMap[clientId] != null) {
1157
- clientWiseDataMap[clientId].push(obj);
1158
- }
1159
- else {
1160
- clientWiseDataMap[clientId] = [obj];
1161
- }
1162
- }
1163
- });
1164
- data[constants_1.WAREHOUSE_INVOICE_X_REPORT_TYPE_ENUM.TOTAL_PAYMENT_SALES].forEach((item) => {
1165
- const clientId = item.client_id ?? CLIENT_ID;
1166
- const clientName = clientNamesMap[clientId];
1167
- if (clientName != null) {
1168
- const amount = item.grossAmount;
1169
- const obj = {
1170
- _id: clientId,
1171
- ref: item.payment_type,
1172
- type: constants_1.WAREHOUSE_INVOICE_X_REPORT_TYPE_ENUM.TOTAL_PAYMENT_SALES,
1173
- staff_name: clientName,
1174
- title: 'Payments',
1175
- description: (0, common_1.sentenceCase)(item.payment_type.replace(/_/g, ' ')),
1176
- count: item.count,
1177
- amount,
1178
- sortIndex: 3,
1179
- };
1180
- if (clientWiseDataMap[clientId] != null) {
1181
- clientWiseDataMap[clientId].push(obj);
1182
- }
1183
- else {
1184
- clientWiseDataMap[clientId] = [obj];
1185
- }
1186
- }
1187
- });
1188
- data[constants_1.WAREHOUSE_INVOICE_X_REPORT_TYPE_ENUM.GST].forEach((item) => {
1189
- const clientId = item.client_id ?? CLIENT_ID;
1190
- const clientName = clientNamesMap[clientId];
1191
- if (clientName != null) {
1192
- const gst = (0, price_conversion_1.convertIntToDecimal)(item.gst);
1193
- const amount = item.grossAmount;
1194
- const obj = {
1195
- _id: clientId,
1196
- ref: gst,
1197
- type: constants_1.WAREHOUSE_INVOICE_X_REPORT_TYPE_ENUM.GST,
1198
- staff_name: clientName,
1199
- title: gstName,
1200
- description: `${gst}%`,
1201
- count: item.count,
1202
- amount,
1203
- sortIndex: 4,
1204
- };
1205
- if (clientWiseDataMap[clientId] != null) {
1206
- clientWiseDataMap[clientId].push(obj);
1207
- }
1208
- else {
1209
- clientWiseDataMap[clientId] = [obj];
1210
- }
1211
- }
1212
- });
1213
- const clientWiseDataFooterDetailsMap = {};
1214
- return {
1215
- clientWiseDataMap,
1216
- clientWiseTotalSalesMap,
1217
- clientWiseDataFooterDetailsMap,
1218
- };
1219
- };
1220
- const getUsableData = (data, subtitles) => {
1221
- const defaultCombinedData = {
1222
- _id: 'combined',
1223
- title: 'Combined Report',
1224
- netSale: 0,
1225
- netWithoutGst: 0,
1226
- totalOrders: 0,
1227
- unpaidOrders: 0,
1228
- unpaidAmount: 0,
1229
- amountCollected: 0,
1230
- itemSales: 0,
1231
- channels: [],
1232
- ...subtitles,
1233
- };
1234
- const { clientWiseDataMap, clientWiseTotalSalesMap, clientWiseDataFooterDetailsMap } = data;
1235
- const clientWiseData = [];
1236
- const combinedData = {
1237
- ...defaultCombinedData,
1238
- };
1239
- const combinedChannelsMap = {};
1240
- for (const staffId in clientWiseDataMap) {
1241
- const salesData = clientWiseTotalSalesMap[staffId];
1242
- if (!salesData)
1243
- continue;
1244
- const staffData = clientWiseDataMap[staffId];
1245
- const similarTypes = {};
1246
- for (let i = 0; i < staffData.length; i++) {
1247
- const d = staffData[i];
1248
- if (similarTypes[d.type] != null) {
1249
- similarTypes[d.type].push(d);
1250
- }
1251
- else {
1252
- similarTypes[d.type] = [d];
1253
- }
1254
- }
1255
- const totalOrders = salesData.count;
1256
- const netSale = salesData.grossAmount;
1257
- let totalGst = 0;
1258
- let unpaidOrders = 0;
1259
- let unpaidAmount = 0;
1260
- for (const type in similarTypes) {
1261
- const firstData = similarTypes[type][0];
1262
- if (!firstData)
1263
- continue;
1264
- const combinedData = similarTypes[type].reduce((acc, d) => {
1265
- acc.count += d.count;
1266
- acc.amount += d.amount;
1267
- return acc;
1268
- }, {
1269
- count: 0,
1270
- amount: 0,
1271
- });
1272
- similarTypes[type].push({
1273
- _id: `${firstData._id}-${TOTAL_REF}`,
1274
- ref: TOTAL_REF,
1275
- type: firstData.type,
1276
- staff_name: firstData.staff_name,
1277
- title: firstData.title,
1278
- description: 'Total',
1279
- count: combinedData.count,
1280
- amount: combinedData.amount,
1281
- sortIndex: 100000,
1282
- });
1283
- }
1284
- const topLevelChannels = [];
1285
- for (const type in similarTypes) {
1286
- const clientWiseDataArr = similarTypes[type];
1287
- const firstData = clientWiseDataArr[0];
1288
- const footerDetailsMap = structuredClone(clientWiseDataFooterDetailsMap[staffId]?.[type] ?? {});
1289
- const channel = {
1290
- _id: `${firstData._id}-${firstData.type}`,
1291
- ref: firstData.type,
1292
- title: firstData.title,
1293
- subChannels: [],
1294
- sortIndex: firstData.sortIndex,
1295
- footerDetailsMap,
1296
- };
1297
- const subChannels = [];
1298
- for (let j = 0; j < clientWiseDataArr.length; j++) {
1299
- const d = clientWiseDataArr[j];
1300
- if (d.type === constants_1.WAREHOUSE_INVOICE_X_REPORT_TYPE_ENUM.GST && d.ref !== TOTAL_REF) {
1301
- totalGst += d.amount;
1302
- }
1303
- else if (d.type === constants_1.WAREHOUSE_INVOICE_X_REPORT_TYPE_ENUM.TOTAL_PAYMENT_SALES && d.ref !== TOTAL_REF) {
1304
- if (String(d.description).toUpperCase() === constants_1.PAYMENT_TYPE_ENUM.UNPAID) {
1305
- unpaidOrders += d.count;
1306
- unpaidAmount += d.amount;
1307
- }
1308
- }
1309
- const sChannel = {
1310
- _id: `${d._id}-${d.ref}`,
1311
- ref: d.ref,
1312
- title: typeof d.description === 'string' ? d.description : `${d.description} ${(0, common_1.sentenceCase)(d.type)}`,
1313
- count: d.count,
1314
- amount: d.amount,
1315
- sortIndex: j,
1316
- };
1317
- if (combinedChannelsMap[type] != null) {
1318
- if (combinedChannelsMap[type].subChannels[d.ref] != null) {
1319
- combinedChannelsMap[type].subChannels[d.ref].amount += d.amount;
1320
- combinedChannelsMap[type].subChannels[d.ref].count += d.count;
1321
- }
1322
- else {
1323
- combinedChannelsMap[type].subChannels[d.ref] = {
1324
- ...sChannel,
1325
- sortIndex: j,
1326
- };
1327
- }
1328
- }
1329
- else {
1330
- combinedChannelsMap[type] = {
1331
- _id: `${d._id}-${d.type}`,
1332
- ref: d.type,
1333
- title: d.title,
1334
- sortIndex: d.sortIndex,
1335
- footerDetailsMap: {},
1336
- subChannels: {
1337
- [d.ref]: {
1338
- ...sChannel,
1339
- sortIndex: j,
1340
- },
1341
- },
1342
- };
1343
- }
1344
- if (j === 0) {
1345
- const combinedFooterDetailsMap = structuredClone(combinedChannelsMap[type].footerDetailsMap ?? {});
1346
- for (const key in footerDetailsMap) {
1347
- if (combinedFooterDetailsMap[key] != null) {
1348
- combinedFooterDetailsMap[key].amount += footerDetailsMap[key].amount;
1349
- combinedFooterDetailsMap[key].count += footerDetailsMap[key].count;
1350
- }
1351
- else {
1352
- combinedFooterDetailsMap[key] = footerDetailsMap[key];
1353
- }
1354
- }
1355
- combinedChannelsMap[type].footerDetailsMap = combinedFooterDetailsMap;
1356
- }
1357
- sChannel.amount = (0, price_conversion_1.convertIntToDecimal)(sChannel.amount);
1358
- subChannels.push(sChannel);
1359
- }
1360
- channel.subChannels = subChannels;
1361
- topLevelChannels.push(channel);
1362
- }
1363
- const netWithoutGst = netSale - totalGst;
1364
- const itemSales = salesData.totalItemSales;
1365
- const amountCollected = netSale - unpaidAmount;
1366
- const channelData = {
1367
- ...subtitles,
1368
- _id: staffId,
1369
- title: salesData.client_name,
1370
- netSale: (0, price_conversion_1.convertIntToDecimal)(netSale),
1371
- netWithoutGst: (0, price_conversion_1.convertIntToDecimal)(netWithoutGst),
1372
- itemSales: (0, price_conversion_1.convertIntToDecimal)(itemSales),
1373
- amountCollected: (0, price_conversion_1.convertIntToDecimal)(amountCollected),
1374
- unpaidAmount: (0, price_conversion_1.convertIntToDecimal)(unpaidAmount),
1375
- totalOrders,
1376
- unpaidOrders,
1377
- channels: topLevelChannels,
1378
- };
1379
- combinedData.netSale += channelData.netSale;
1380
- combinedData.netWithoutGst += channelData.netWithoutGst;
1381
- combinedData.totalOrders += channelData.totalOrders;
1382
- combinedData.unpaidOrders += channelData.unpaidOrders;
1383
- combinedData.unpaidAmount += channelData.unpaidAmount;
1384
- combinedData.amountCollected += channelData.amountCollected;
1385
- combinedData.itemSales += channelData.itemSales;
1386
- clientWiseData.push(channelData);
1387
- }
1388
- const usableClientWiseData = clientWiseData
1389
- .map((d) => ({
1390
- ...d,
1391
- channels: getSortedUsableChannels(d.channels),
1392
- }))
1393
- .sort((a, b) => b.netSale - a.netSale);
1394
- const combinedChannels = Object.values(combinedChannelsMap).map((c) => {
1395
- const subChannels = Object.values(c.subChannels).map((sc) => ({
1396
- ...sc,
1397
- amount: (0, price_conversion_1.convertIntToDecimal)(sc.amount),
1398
- }));
1399
- return {
1400
- ...c,
1401
- subChannels,
1402
- };
1403
- });
1404
- const usableCombinedData = {
1405
- ...subtitles,
1406
- _id: combinedData._id,
1407
- title: combinedData.title,
1408
- channels: getSortedUsableChannels(combinedChannels),
1409
- netSale: (0, common_1.parseNum)(combinedData.netSale),
1410
- netWithoutGst: (0, common_1.parseNum)(combinedData.netWithoutGst),
1411
- totalOrders: (0, common_1.parseNum)(combinedData.totalOrders),
1412
- unpaidOrders: (0, common_1.parseNum)(combinedData.unpaidOrders),
1413
- unpaidAmount: (0, common_1.parseNum)(combinedData.unpaidAmount),
1414
- amountCollected: (0, common_1.parseNum)(combinedData.amountCollected),
1415
- itemSales: (0, common_1.parseNum)(combinedData.itemSales),
1416
- };
1417
- return {
1418
- clientWiseData: usableClientWiseData,
1419
- combinedData: usableCombinedData,
1420
- };
1421
- };
1422
- const getWarehouseInvoiceXReportData = (data, currencySymbol, countryAlpha2) => {
1423
- const gstName = (0, common_1.getGSTName)(countryAlpha2);
1424
- const netWithoutGstSubtitle = `excl. ${gstName}`;
1425
- const subtitles = {
1426
- netWithoutGstSubtitle,
1427
- };
1428
- const clientWiseData = generateClientWiseData(data, currencySymbol, gstName);
1429
- const usableData = getUsableData(clientWiseData, subtitles);
1430
- return usableData;
1431
- };
1432
- exports.getWarehouseInvoiceXReportData = getWarehouseInvoiceXReportData;