@appcorp/stellar-solutions-invoice-module 0.1.1

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 (76) hide show
  1. package/README.md +36 -0
  2. package/base-modules/invoice/actions.d.ts +134 -0
  3. package/base-modules/invoice/actions.js +29 -0
  4. package/base-modules/invoice/add-service-product-section.d.ts +2 -0
  5. package/base-modules/invoice/add-service-product-section.js +21 -0
  6. package/base-modules/invoice/calculate-subtotal.d.ts +2 -0
  7. package/base-modules/invoice/calculate-subtotal.js +20 -0
  8. package/base-modules/invoice/constants.d.ts +42 -0
  9. package/base-modules/invoice/constants.js +450 -0
  10. package/base-modules/invoice/context.d.ts +10 -0
  11. package/base-modules/invoice/context.js +661 -0
  12. package/base-modules/invoice/drawer.d.ts +8 -0
  13. package/base-modules/invoice/drawer.js +19 -0
  14. package/base-modules/invoice/form.d.ts +8 -0
  15. package/base-modules/invoice/form.js +67 -0
  16. package/base-modules/invoice/invoice.d.ts +10 -0
  17. package/base-modules/invoice/invoice.js +90 -0
  18. package/base-modules/invoice/pricing-form-elements.d.ts +3 -0
  19. package/base-modules/invoice/pricing-form-elements.js +41 -0
  20. package/base-modules/invoice/pricing-form-section.d.ts +2 -0
  21. package/base-modules/invoice/pricing-form-section.js +20 -0
  22. package/base-modules/invoice/products-form-elements.d.ts +4 -0
  23. package/base-modules/invoice/products-form-elements.js +41 -0
  24. package/base-modules/invoice/products-form-section.d.ts +2 -0
  25. package/base-modules/invoice/products-form-section.js +17 -0
  26. package/base-modules/invoice/reducer.d.ts +4 -0
  27. package/base-modules/invoice/reducer.js +138 -0
  28. package/base-modules/invoice/services-form-elements.d.ts +4 -0
  29. package/base-modules/invoice/services-form-elements.js +41 -0
  30. package/base-modules/invoice/services-form-section.d.ts +2 -0
  31. package/base-modules/invoice/services-form-section.js +17 -0
  32. package/base-modules/invoice/types.d.ts +163 -0
  33. package/base-modules/invoice/types.js +40 -0
  34. package/base-modules/invoice/validate.d.ts +36 -0
  35. package/base-modules/invoice/validate.js +17 -0
  36. package/base-modules/product/actions.d.ts +113 -0
  37. package/base-modules/product/actions.js +22 -0
  38. package/base-modules/product/constants.d.ts +33 -0
  39. package/base-modules/product/constants.js +204 -0
  40. package/base-modules/product/context.d.ts +10 -0
  41. package/base-modules/product/context.js +557 -0
  42. package/base-modules/product/drawer.d.ts +8 -0
  43. package/base-modules/product/drawer.js +19 -0
  44. package/base-modules/product/form-elements.d.ts +2 -0
  45. package/base-modules/product/form-elements.js +41 -0
  46. package/base-modules/product/form.d.ts +8 -0
  47. package/base-modules/product/form.js +107 -0
  48. package/base-modules/product/product.d.ts +10 -0
  49. package/base-modules/product/product.js +80 -0
  50. package/base-modules/product/reducer.d.ts +4 -0
  51. package/base-modules/product/reducer.js +88 -0
  52. package/base-modules/product/types.d.ts +87 -0
  53. package/base-modules/product/types.js +28 -0
  54. package/base-modules/product/validate.d.ts +36 -0
  55. package/base-modules/product/validate.js +17 -0
  56. package/base-modules/product-category/actions.d.ts +90 -0
  57. package/base-modules/product-category/actions.js +19 -0
  58. package/base-modules/product-category/constants.d.ts +28 -0
  59. package/base-modules/product-category/constants.js +74 -0
  60. package/base-modules/product-category/context.d.ts +10 -0
  61. package/base-modules/product-category/context.js +390 -0
  62. package/base-modules/product-category/drawer.d.ts +8 -0
  63. package/base-modules/product-category/drawer.js +19 -0
  64. package/base-modules/product-category/form-elements.d.ts +2 -0
  65. package/base-modules/product-category/form-elements.js +41 -0
  66. package/base-modules/product-category/form.d.ts +8 -0
  67. package/base-modules/product-category/form.js +81 -0
  68. package/base-modules/product-category/product-category.d.ts +10 -0
  69. package/base-modules/product-category/product-category.js +53 -0
  70. package/base-modules/product-category/reducer.d.ts +4 -0
  71. package/base-modules/product-category/reducer.js +73 -0
  72. package/base-modules/product-category/types.d.ts +59 -0
  73. package/base-modules/product-category/types.js +11 -0
  74. package/base-modules/product-category/validate.d.ts +12 -0
  75. package/base-modules/product-category/validate.js +11 -0
  76. package/package.json +60 -0
@@ -0,0 +1,450 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ var _a, _b, _c, _d;
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.messages = exports.tableBodyCols = exports.INVOICE_API_ROUTES = exports.staticProductSection = exports.staticServiceSection = exports.staticPricingSection = exports.staticCompanySection = exports.toastErrors = exports.changeActionsMap = exports.handleSplitId = exports.pageLimit = void 0;
8
+ var react_1 = __importDefault(require("react"));
9
+ var util_functions_1 = require("@react-pakistan/util-functions");
10
+ var form_schema_1 = require("@appcorp/app-corp-vista/utils/form-schema");
11
+ var vista_button_type_1 = require("@appcorp/app-corp-vista/type/vista-button-type");
12
+ var solid_1 = require("@heroicons/react/24/solid");
13
+ var vista_table_type_1 = require("@appcorp/app-corp-vista/type/vista-table-type");
14
+ exports.pageLimit = Number(process.env.NEXT_PUBLIC_PAGE_LIMIT);
15
+ var handleSplitId = function (value) {
16
+ return value === null || value === void 0 ? void 0 : value.split(util_functions_1.VALUE_DELIMITER.COLON);
17
+ };
18
+ exports.handleSplitId = handleSplitId;
19
+ exports.changeActionsMap = {
20
+ companyId: function (val) { return (0, exports.handleSplitId)(val)[1]; },
21
+ };
22
+ exports.toastErrors = {
23
+ fetchInvoiceError: 'Error Fetching Invoice',
24
+ submitFormError: 'Error Submitting Form',
25
+ networkError: 'Network Error Occurred',
26
+ genericError: 'Something Went Wrong',
27
+ validationError: 'Validation Failed',
28
+ formSubmittedSuccess: 'Form Submitted Successfully',
29
+ };
30
+ exports.staticCompanySection = (_a = {},
31
+ _a[form_schema_1.VISTA_FORM_ELEMENTS.TEXT_INPUT_V1] = [
32
+ {
33
+ disabled: true,
34
+ enabled: true,
35
+ error: '',
36
+ handleOnChange: function () { return void 0; },
37
+ id: 'ref',
38
+ label: '',
39
+ order: 6,
40
+ placeholder: '',
41
+ required: true,
42
+ type: 'text',
43
+ value: '',
44
+ },
45
+ {
46
+ enabled: true,
47
+ error: '',
48
+ handleOnChange: function () { return void 0; },
49
+ id: 'date',
50
+ label: '',
51
+ order: 2,
52
+ placeholder: '',
53
+ required: false,
54
+ type: 'date',
55
+ value: '',
56
+ },
57
+ {
58
+ enabled: true,
59
+ error: '',
60
+ handleOnChange: function () { return void 0; },
61
+ id: 'expiryDate',
62
+ label: '',
63
+ order: 3,
64
+ placeholder: '',
65
+ required: false,
66
+ type: 'date',
67
+ value: '',
68
+ },
69
+ {
70
+ enabled: true,
71
+ error: '',
72
+ handleOnChange: function () { return void 0; },
73
+ id: 'note',
74
+ label: '',
75
+ order: 5,
76
+ placeholder: 'This is invoice for...',
77
+ required: false,
78
+ type: 'text',
79
+ value: '',
80
+ },
81
+ ],
82
+ _a[form_schema_1.VISTA_FORM_ELEMENTS.SELECT_V1] = [
83
+ {
84
+ enabled: true,
85
+ handleOnChange: function () { return void 0; },
86
+ label: 'Company',
87
+ listItems: [],
88
+ nodeSelectKey: 'companyId',
89
+ order: 1,
90
+ required: false,
91
+ selectKey1: 'name',
92
+ selectKey2: '',
93
+ selectedItem: { name: '' },
94
+ },
95
+ {
96
+ enabled: true,
97
+ handleOnChange: function () { return void 0; },
98
+ label: 'Currency',
99
+ listItems: [],
100
+ nodeSelectKey: 'currency',
101
+ order: 4,
102
+ required: false,
103
+ selectKey1: 'label',
104
+ selectKey2: '',
105
+ selectedItem: { label: '' },
106
+ },
107
+ // {
108
+ // enabled: false,
109
+ // handleOnChange: () => void 0,
110
+ // label: 'Invoice Status',
111
+ // listItems: [],
112
+ // nodeSelectedKey: 'invoiceStatus',
113
+ // order: 3,
114
+ // required: false,
115
+ // selectKey1: 'label',
116
+ // selectKey2: '',
117
+ // selectedItem: { label: 'Unpaid' },
118
+ // },
119
+ ],
120
+ _a);
121
+ exports.staticPricingSection = (_b = {},
122
+ _b[form_schema_1.VISTA_FORM_ELEMENTS.TEXT_INPUT_V1] = [
123
+ {
124
+ disabled: true,
125
+ enabled: true,
126
+ error: '',
127
+ handleOnChange: function () { return void 0; },
128
+ id: 'subTotal',
129
+ label: '',
130
+ order: 1,
131
+ placeholder: '0.00',
132
+ required: false,
133
+ type: 'text',
134
+ value: '',
135
+ },
136
+ {
137
+ enabled: true,
138
+ error: '',
139
+ handleOnChange: function () { return void 0; },
140
+ id: 'discount',
141
+ label: '',
142
+ order: 3,
143
+ placeholder: '0.00',
144
+ required: false,
145
+ type: 'number',
146
+ value: '',
147
+ },
148
+ {
149
+ disabled: true,
150
+ enabled: true,
151
+ error: '',
152
+ handleOnChange: function () { return void 0; },
153
+ id: 'totaldiscount',
154
+ label: '',
155
+ order: 4,
156
+ placeholder: '',
157
+ required: false,
158
+ type: 'text',
159
+ value: '',
160
+ },
161
+ {
162
+ disabled: true,
163
+ enabled: true,
164
+ error: '',
165
+ handleOnChange: function () { return void 0; },
166
+ id: 'totaltax',
167
+ label: '',
168
+ order: 6,
169
+ placeholder: '',
170
+ required: false,
171
+ type: 'text',
172
+ value: '',
173
+ },
174
+ {
175
+ disabled: true,
176
+ enabled: true,
177
+ error: '',
178
+ handleOnChange: function () { return void 0; },
179
+ id: 'total',
180
+ label: '',
181
+ order: 7,
182
+ placeholder: 'Total',
183
+ required: false,
184
+ type: 'text',
185
+ value: '',
186
+ },
187
+ ],
188
+ _b[form_schema_1.VISTA_FORM_ELEMENTS.COMBOBOX_V1] = [
189
+ {
190
+ enabled: true,
191
+ handleInputOnChange: function () { return void 0; },
192
+ handleOnBlur: function () { return void 0; },
193
+ handleOnChange: function () { return void 0; },
194
+ label: 'Tax',
195
+ listItems: [],
196
+ nodeQueryKey: '',
197
+ nodeSelectKey: 'taxValue',
198
+ order: 5,
199
+ query: '',
200
+ required: false,
201
+ selectKey1: 'taxName',
202
+ selectedItem: { taxName: '' },
203
+ },
204
+ ],
205
+ _b[form_schema_1.VISTA_FORM_ELEMENTS.RADIO_V1] = [
206
+ {
207
+ description: 'Discount can either be applied as a fixed value or percentage value, select below to confirm.',
208
+ enabled: true,
209
+ handleOnChange: function () { return void 0; },
210
+ order: 2,
211
+ selectedValue: '',
212
+ title: 'Pick discount unit',
213
+ list: [
214
+ {
215
+ enabled: true,
216
+ id: 'item-1',
217
+ label: 'Fixed Value',
218
+ order: 1,
219
+ value: 'fixed-value',
220
+ },
221
+ {
222
+ enabled: true,
223
+ id: 'item-2',
224
+ label: 'Percentage Value',
225
+ order: 2,
226
+ value: 'percentage-value',
227
+ },
228
+ ],
229
+ },
230
+ ],
231
+ _b);
232
+ exports.staticServiceSection = (_c = {},
233
+ _c[form_schema_1.VISTA_FORM_ELEMENTS.TEXT_INPUT_V1] = [
234
+ {
235
+ className: '',
236
+ disabled: false,
237
+ enabled: true,
238
+ error: '',
239
+ handleOnChange: function () { return void 0; },
240
+ id: 'name',
241
+ label: 'Item',
242
+ order: 1,
243
+ placeholder: 'Service Name',
244
+ required: false,
245
+ type: 'text',
246
+ value: '',
247
+ },
248
+ {
249
+ className: '',
250
+ disabled: false,
251
+ enabled: true,
252
+ error: '',
253
+ handleOnChange: function () { return void 0; },
254
+ id: 'description',
255
+ label: 'Description',
256
+ order: 2,
257
+ placeholder: 'Service Description',
258
+ required: false,
259
+ type: 'text',
260
+ value: '',
261
+ },
262
+ {
263
+ className: '',
264
+ disabled: false,
265
+ enabled: true,
266
+ error: '',
267
+ handleOnChange: function () { return void 0; },
268
+ id: 'quantity',
269
+ label: 'Quantity',
270
+ order: 3,
271
+ placeholder: '1',
272
+ required: false,
273
+ type: 'number',
274
+ value: '',
275
+ },
276
+ {
277
+ className: '',
278
+ disabled: false,
279
+ enabled: true,
280
+ error: '',
281
+ handleOnChange: function () { return void 0; },
282
+ id: 'price',
283
+ label: 'Price',
284
+ order: 4,
285
+ placeholder: '0.00',
286
+ required: false,
287
+ type: 'number',
288
+ value: '',
289
+ },
290
+ {
291
+ className: '',
292
+ disabled: true,
293
+ enabled: true,
294
+ error: '',
295
+ handleOnChange: function () { return void 0; },
296
+ id: 'rowTotal',
297
+ label: 'Row Total',
298
+ order: 5,
299
+ placeholder: '0.00',
300
+ required: false,
301
+ type: 'text',
302
+ value: '',
303
+ },
304
+ ],
305
+ _c[form_schema_1.VISTA_FORM_ELEMENTS.BUTTON_V1] = [
306
+ {
307
+ className: 'flex justify-center items-end',
308
+ enabled: true,
309
+ handleOnClick: function () { return void 0; },
310
+ icon: react_1.default.createElement(solid_1.TrashIcon, { className: "size-6" }),
311
+ order: 6,
312
+ variant: vista_button_type_1.VISTA_BUTTON_VARIANT.ICON,
313
+ },
314
+ ],
315
+ _c);
316
+ exports.staticProductSection = (_d = {},
317
+ _d[form_schema_1.VISTA_FORM_ELEMENTS.SELECT_V1] = [
318
+ {
319
+ className: 'col-span-2',
320
+ enabled: true,
321
+ handleOnChange: function () { return void 0; },
322
+ label: 'Product',
323
+ listItems: [],
324
+ nodeSelectKey: 'productId',
325
+ order: 1,
326
+ required: false,
327
+ selectKey1: 'name',
328
+ selectKey2: '',
329
+ selectedItem: { name: '' },
330
+ },
331
+ ],
332
+ _d[form_schema_1.VISTA_FORM_ELEMENTS.TEXT_INPUT_V1] = [
333
+ {
334
+ className: '',
335
+ disabled: false,
336
+ enabled: true,
337
+ error: '',
338
+ handleOnChange: function () { return void 0; },
339
+ id: 'quantity',
340
+ label: 'Quantity',
341
+ order: 2,
342
+ placeholder: '1',
343
+ required: false,
344
+ type: 'number',
345
+ value: '',
346
+ },
347
+ {
348
+ className: '',
349
+ disabled: false,
350
+ enabled: true,
351
+ error: '',
352
+ handleOnChange: function () { return void 0; },
353
+ id: 'price',
354
+ label: 'Price',
355
+ order: 3,
356
+ placeholder: '0.00',
357
+ required: false,
358
+ type: 'number',
359
+ value: '',
360
+ },
361
+ {
362
+ className: '',
363
+ disabled: true,
364
+ enabled: true,
365
+ error: '',
366
+ handleOnChange: function () { return void 0; },
367
+ id: 'rowTotal',
368
+ label: 'Row Total',
369
+ order: 4,
370
+ placeholder: '0.00',
371
+ required: false,
372
+ type: 'text',
373
+ value: '',
374
+ },
375
+ ],
376
+ _d[form_schema_1.VISTA_FORM_ELEMENTS.BUTTON_V1] = [
377
+ {
378
+ className: 'flex justify-center items-end',
379
+ enabled: true,
380
+ handleOnClick: function () { return void 0; },
381
+ icon: react_1.default.createElement(solid_1.TrashIcon, { className: "size-6" }),
382
+ order: 5,
383
+ variant: vista_button_type_1.VISTA_BUTTON_VARIANT.ICON,
384
+ },
385
+ ],
386
+ _d);
387
+ exports.INVOICE_API_ROUTES = {
388
+ INVOICES: '/api/invoices',
389
+ INVOICE: '/api/invoice',
390
+ INVOICE_BY_ID: '/api/invoice/invoice-by-id',
391
+ };
392
+ exports.tableBodyCols = [
393
+ {
394
+ componentType: vista_table_type_1.VISTA_TABLE_CELL_TYPE.ID,
395
+ key: 'id',
396
+ },
397
+ {
398
+ componentType: vista_table_type_1.VISTA_TABLE_CELL_TYPE.OBJECT,
399
+ key: ['company', 'name'],
400
+ },
401
+ {
402
+ componentType: vista_table_type_1.VISTA_TABLE_CELL_TYPE.TEXT,
403
+ key: 'currency',
404
+ },
405
+ {
406
+ componentType: vista_table_type_1.VISTA_TABLE_CELL_TYPE.TEXT,
407
+ key: 'status',
408
+ },
409
+ {
410
+ componentType: vista_table_type_1.VISTA_TABLE_CELL_TYPE.MULTIPLE_TEXT_LINES,
411
+ key: ['issueDate', 'expiryDate'],
412
+ },
413
+ {
414
+ componentType: vista_table_type_1.VISTA_TABLE_CELL_TYPE.TEXT,
415
+ key: 'ref',
416
+ },
417
+ {
418
+ componentType: vista_table_type_1.VISTA_TABLE_CELL_TYPE.TEXT,
419
+ key: 'subTotal',
420
+ },
421
+ {
422
+ componentType: vista_table_type_1.VISTA_TABLE_CELL_TYPE.TEXT,
423
+ key: 'taxValue',
424
+ },
425
+ {
426
+ componentType: vista_table_type_1.VISTA_TABLE_CELL_TYPE.TEXT,
427
+ key: 'discountPrice',
428
+ },
429
+ {
430
+ componentType: vista_table_type_1.VISTA_TABLE_CELL_TYPE.TEXT,
431
+ key: 'totalPrice',
432
+ },
433
+ {
434
+ componentType: vista_table_type_1.VISTA_TABLE_CELL_TYPE.TEXT,
435
+ key: 'category',
436
+ },
437
+ {
438
+ componentType: vista_table_type_1.VISTA_TABLE_CELL_TYPE.ACTIONS,
439
+ },
440
+ ];
441
+ exports.messages = {
442
+ buyPrice: 'Buy Price should be more than 1 unit',
443
+ currency: 'Please select a currency unit for this product',
444
+ error: 'Error occurred, please try again',
445
+ name: 'Product category name is required',
446
+ productCategoryId: 'Product Category Id is required',
447
+ quantity: 'Quantity should be more than 1 unit',
448
+ salePrice: 'Sale Price should be more than 1 unit',
449
+ success: 'Operation successful!',
450
+ };
@@ -0,0 +1,10 @@
1
+ import React, { FC, ReactNode } from 'react';
2
+ import { InvoiceContextType, InvoiceState } from './types';
3
+ type State = InvoiceContextType & InvoiceState;
4
+ interface StateProviderProps {
5
+ children: ReactNode;
6
+ }
7
+ export declare const InvoiceStateContext: React.Context<State>;
8
+ export declare const InvoiceStateContextProvider: FC<StateProviderProps>;
9
+ export declare const useInvoiceStateContext: () => State;
10
+ export {};