@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
package/README.md ADDED
@@ -0,0 +1,36 @@
1
+ This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app).
2
+
3
+ ## Getting Started
4
+
5
+ First, run the development server:
6
+
7
+ ```bash
8
+ npm run dev
9
+ # or
10
+ yarn dev
11
+ # or
12
+ pnpm dev
13
+ # or
14
+ bun dev
15
+ ```
16
+
17
+ Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
18
+
19
+ You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.
20
+
21
+ This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.
22
+
23
+ ## Learn More
24
+
25
+ To learn more about Next.js, take a look at the following resources:
26
+
27
+ - [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
28
+ - [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
29
+
30
+ You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!
31
+
32
+ ## Deploy on Vercel
33
+
34
+ The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
35
+
36
+ Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.
@@ -0,0 +1,134 @@
1
+ import { INVOICE_DRAWER, InvoiceState, InvoiceTypeBE, Product, Service } from './types';
2
+ export declare enum INVOICE_ACTION_TYPES {
3
+ SET_INPUT_FIELD = "SET_INPUT_FIELD",
4
+ SET_CUSTOMER_DATA = "SET_CUSTOMER_DATA",
5
+ CLEAR_ERRORS = "CLEAR_ERRORS",
6
+ RESET_FORM = "RESET_FORM",
7
+ SET_ERRORS = "SET_ERRORS",
8
+ SET_CURRENT_PAGE = "SET_CURRENT_PAGE",
9
+ SET_BUTTON_DISABLE = "SET_BUTTON_DISABLE",
10
+ SET_FORM_LOADING = "SET_FORM_LOADING",
11
+ SET_PAGE_LIMIT = "SET_PAGE_LIMIT",
12
+ SET_SEARCH_QUERY = "SET_SEARCH_QUERY",
13
+ SET_INVOICES = "SET_INVOICES",
14
+ SET_INVOICE_FORM = "SET_INVOICE_FORM",
15
+ SET_SKELTON_LOADING = "SET_SKELTON_LOADING",
16
+ ADD_ITEM_PRODUCT = "ADD_ITEM_PRODUCT",
17
+ ADD_ITEM_SERVICE = "ADD_ITEM_SERVICE",
18
+ DELETE_ITEM_PRODUCT = "DELETE_ITEM_PRODUCT",
19
+ DELETE_ITEM_SERVICE = "DELETE_ITEM_SERVICE",
20
+ SET_DISCOUNT_UNIT = "SET_DISCOUNT_UNIT",
21
+ SET_IS_INVOICE_API_SUCCESS = "SET_IS_INVOICE_API_SUCCESS",
22
+ SET_DRAWER = "SET_DRAWER",
23
+ SET_COUNT = "SET_COUNT",
24
+ SET_FORM = "SET_FORM",
25
+ SET_DISABLE_SAVE_BUTTON = "SET_DISABLE_SAVE_BUTTON"
26
+ }
27
+ export type InvoiceUpdateFieldAction = {
28
+ type: INVOICE_ACTION_TYPES.SET_INPUT_FIELD;
29
+ payload: {
30
+ key: keyof InvoiceTypeBE;
31
+ value: string | string[] | boolean | number | number[] | Service[] | Product[];
32
+ };
33
+ };
34
+ export type InvoiceClearErrorAction = {
35
+ type: INVOICE_ACTION_TYPES.CLEAR_ERRORS;
36
+ };
37
+ export type InvoiceResetFormAction = {
38
+ type: INVOICE_ACTION_TYPES.RESET_FORM;
39
+ };
40
+ export type InvoiceSetErrorsAction = {
41
+ type: INVOICE_ACTION_TYPES.SET_ERRORS;
42
+ payload: {
43
+ [key: string]: string;
44
+ };
45
+ };
46
+ export type InvoiceSetCurrentPageAction = {
47
+ type: INVOICE_ACTION_TYPES.SET_CURRENT_PAGE;
48
+ payload: {
49
+ currentPage: number;
50
+ };
51
+ };
52
+ export type InvoiceSetButtonDisableAction = {
53
+ type: INVOICE_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON;
54
+ payload: {
55
+ disableSaveButton: boolean;
56
+ };
57
+ };
58
+ export type InvoiceSetFormLoadingAction = {
59
+ type: INVOICE_ACTION_TYPES.SET_FORM_LOADING;
60
+ payload: boolean;
61
+ };
62
+ export type InvoiceSetMaxPageLimitAction = {
63
+ type: INVOICE_ACTION_TYPES.SET_PAGE_LIMIT;
64
+ payload: {
65
+ pageLimit: number;
66
+ };
67
+ };
68
+ export type InvoiceSetSearchQueryAction = {
69
+ type: INVOICE_ACTION_TYPES.SET_SEARCH_QUERY;
70
+ payload: {
71
+ searchQuery: string;
72
+ };
73
+ };
74
+ export type InvoiceSetInvoicesAction = {
75
+ type: INVOICE_ACTION_TYPES.SET_INVOICES;
76
+ payload: {
77
+ invoices: InvoiceTypeBE[];
78
+ };
79
+ };
80
+ export type InvoiceSetCountAction = {
81
+ type: INVOICE_ACTION_TYPES.SET_COUNT;
82
+ payload: {
83
+ count: number;
84
+ };
85
+ };
86
+ export type InvoiceSetInvoiceFormAction = {
87
+ type: INVOICE_ACTION_TYPES.SET_INVOICE_FORM;
88
+ payload: InvoiceTypeBE;
89
+ };
90
+ export type InvoiceToggleLoadingAction = {
91
+ type: INVOICE_ACTION_TYPES.SET_SKELTON_LOADING;
92
+ payload: boolean;
93
+ };
94
+ export type InvoiceAddItemServiceAction = {
95
+ type: INVOICE_ACTION_TYPES.ADD_ITEM_SERVICE;
96
+ payload: Service;
97
+ };
98
+ export type InvoiceAddItemProductAction = {
99
+ type: INVOICE_ACTION_TYPES.ADD_ITEM_PRODUCT;
100
+ payload: Product[];
101
+ };
102
+ export type InvoiceDeleteItemProductAction = {
103
+ type: INVOICE_ACTION_TYPES.DELETE_ITEM_PRODUCT;
104
+ payload: number;
105
+ };
106
+ export type InvoiceDeleteItemServiceAction = {
107
+ type: INVOICE_ACTION_TYPES.DELETE_ITEM_SERVICE;
108
+ payload: number;
109
+ };
110
+ export type InvoiceSetDiscountUnitAction = {
111
+ type: INVOICE_ACTION_TYPES.SET_DISCOUNT_UNIT;
112
+ payload: string;
113
+ };
114
+ export type InvoiceSetCustomerDataAction = {
115
+ type: INVOICE_ACTION_TYPES.SET_CUSTOMER_DATA;
116
+ payload: InvoiceState;
117
+ };
118
+ export type InvoiceSetIsInvoiceApiSuccessAction = {
119
+ type: INVOICE_ACTION_TYPES.SET_IS_INVOICE_API_SUCCESS;
120
+ payload: boolean;
121
+ };
122
+ export type InvoiceSetDrawerAction = {
123
+ type: INVOICE_ACTION_TYPES.SET_DRAWER;
124
+ payload: {
125
+ drawer: INVOICE_DRAWER | null;
126
+ };
127
+ };
128
+ export type InvoiceSetFormAction = {
129
+ type: INVOICE_ACTION_TYPES.SET_FORM;
130
+ payload: {
131
+ form: InvoiceTypeBE;
132
+ };
133
+ };
134
+ export type InvoiceActions = InvoiceAddItemProductAction | InvoiceAddItemServiceAction | InvoiceClearErrorAction | InvoiceDeleteItemProductAction | InvoiceDeleteItemServiceAction | InvoiceResetFormAction | InvoiceSetButtonDisableAction | InvoiceSetCurrentPageAction | InvoiceSetCustomerDataAction | InvoiceSetDiscountUnitAction | InvoiceSetErrorsAction | InvoiceSetFormLoadingAction | InvoiceSetInvoicesAction | InvoiceSetInvoiceFormAction | InvoiceSetIsInvoiceApiSuccessAction | InvoiceSetMaxPageLimitAction | InvoiceSetSearchQueryAction | InvoiceUpdateFieldAction | InvoiceToggleLoadingAction | InvoiceSetDrawerAction | InvoiceSetCountAction | InvoiceSetFormAction;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.INVOICE_ACTION_TYPES = void 0;
4
+ var INVOICE_ACTION_TYPES;
5
+ (function (INVOICE_ACTION_TYPES) {
6
+ INVOICE_ACTION_TYPES["SET_INPUT_FIELD"] = "SET_INPUT_FIELD";
7
+ INVOICE_ACTION_TYPES["SET_CUSTOMER_DATA"] = "SET_CUSTOMER_DATA";
8
+ INVOICE_ACTION_TYPES["CLEAR_ERRORS"] = "CLEAR_ERRORS";
9
+ INVOICE_ACTION_TYPES["RESET_FORM"] = "RESET_FORM";
10
+ INVOICE_ACTION_TYPES["SET_ERRORS"] = "SET_ERRORS";
11
+ INVOICE_ACTION_TYPES["SET_CURRENT_PAGE"] = "SET_CURRENT_PAGE";
12
+ INVOICE_ACTION_TYPES["SET_BUTTON_DISABLE"] = "SET_BUTTON_DISABLE";
13
+ INVOICE_ACTION_TYPES["SET_FORM_LOADING"] = "SET_FORM_LOADING";
14
+ INVOICE_ACTION_TYPES["SET_PAGE_LIMIT"] = "SET_PAGE_LIMIT";
15
+ INVOICE_ACTION_TYPES["SET_SEARCH_QUERY"] = "SET_SEARCH_QUERY";
16
+ INVOICE_ACTION_TYPES["SET_INVOICES"] = "SET_INVOICES";
17
+ INVOICE_ACTION_TYPES["SET_INVOICE_FORM"] = "SET_INVOICE_FORM";
18
+ INVOICE_ACTION_TYPES["SET_SKELTON_LOADING"] = "SET_SKELTON_LOADING";
19
+ INVOICE_ACTION_TYPES["ADD_ITEM_PRODUCT"] = "ADD_ITEM_PRODUCT";
20
+ INVOICE_ACTION_TYPES["ADD_ITEM_SERVICE"] = "ADD_ITEM_SERVICE";
21
+ INVOICE_ACTION_TYPES["DELETE_ITEM_PRODUCT"] = "DELETE_ITEM_PRODUCT";
22
+ INVOICE_ACTION_TYPES["DELETE_ITEM_SERVICE"] = "DELETE_ITEM_SERVICE";
23
+ INVOICE_ACTION_TYPES["SET_DISCOUNT_UNIT"] = "SET_DISCOUNT_UNIT";
24
+ INVOICE_ACTION_TYPES["SET_IS_INVOICE_API_SUCCESS"] = "SET_IS_INVOICE_API_SUCCESS";
25
+ INVOICE_ACTION_TYPES["SET_DRAWER"] = "SET_DRAWER";
26
+ INVOICE_ACTION_TYPES["SET_COUNT"] = "SET_COUNT";
27
+ INVOICE_ACTION_TYPES["SET_FORM"] = "SET_FORM";
28
+ INVOICE_ACTION_TYPES["SET_DISABLE_SAVE_BUTTON"] = "SET_DISABLE_SAVE_BUTTON";
29
+ })(INVOICE_ACTION_TYPES || (exports.INVOICE_ACTION_TYPES = INVOICE_ACTION_TYPES = {}));
@@ -0,0 +1,2 @@
1
+ import React from "react";
2
+ export declare const AddServiceProductSection: () => React.JSX.Element;
@@ -0,0 +1,21 @@
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.AddServiceProductSection = void 0;
7
+ var react_1 = __importDefault(require("react"));
8
+ // import { useInvoiceStateContext } from './context';
9
+ var AddServiceProductSection = function () {
10
+ // const { handleAddItemService, handleAddItemProduct } = useInvoiceStateContext();
11
+ return (react_1.default.createElement("div", { className: "rounded-md border border-dashed border-gray-900 py-[15px] dark:border-white" },
12
+ react_1.default.createElement("div", { className: "flex items-center justify-center gap-2" },
13
+ react_1.default.createElement("div", { className: "flex gap-2" },
14
+ react_1.default.createElement("p", null, "Add a")),
15
+ react_1.default.createElement("button", { type: "button", className: "flex w-fit items-center gap-[10px]" },
16
+ react_1.default.createElement("p", { className: "cursor-pointer hover:underline" }, "Service")),
17
+ react_1.default.createElement("div", { className: "" }, "or"),
18
+ react_1.default.createElement("button", { type: "button", className: "flex w-fit items-center gap-[10px]" },
19
+ react_1.default.createElement("p", { className: "cursor-pointer hover:underline" }, "Product")))));
20
+ };
21
+ exports.AddServiceProductSection = AddServiceProductSection;
@@ -0,0 +1,2 @@
1
+ import { Product, Service } from './types';
2
+ export declare const calculateSubtotal: (services?: Service[], products?: Product[]) => string;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.calculateSubtotal = void 0;
4
+ var calculateSubtotal = function (services, products) {
5
+ var subtotal = 0;
6
+ if (services) {
7
+ var servicesSubtotal = services.reduce(function (acc, item) {
8
+ return acc + parseFloat(item.rowTotal || '0');
9
+ }, 0);
10
+ subtotal += servicesSubtotal;
11
+ }
12
+ if (products) {
13
+ var productsSubtotal = products.reduce(function (acc, item) {
14
+ return acc + parseFloat(item.rowTotal || '0');
15
+ }, 0);
16
+ subtotal += productsSubtotal;
17
+ }
18
+ return subtotal.toFixed(2);
19
+ };
20
+ exports.calculateSubtotal = calculateSubtotal;
@@ -0,0 +1,42 @@
1
+ import { VistaFormElements } from '@appcorp/app-corp-vista/type/vista-form-elements';
2
+ import { VISTA_TABLE_CELL_TYPE } from '@appcorp/app-corp-vista/type/vista-table-type';
3
+ export declare const pageLimit: number;
4
+ export declare const handleSplitId: (value: string) => string[];
5
+ export declare const changeActionsMap: Record<string, (val: string | number | number[]) => string | number | number[]>;
6
+ export declare const toastErrors: {
7
+ fetchInvoiceError: string;
8
+ submitFormError: string;
9
+ networkError: string;
10
+ genericError: string;
11
+ validationError: string;
12
+ formSubmittedSuccess: string;
13
+ };
14
+ export declare const staticCompanySection: VistaFormElements;
15
+ export declare const staticPricingSection: VistaFormElements;
16
+ export declare const staticServiceSection: VistaFormElements;
17
+ export declare const staticProductSection: VistaFormElements;
18
+ export declare const INVOICE_API_ROUTES: {
19
+ INVOICES: string;
20
+ INVOICE: string;
21
+ INVOICE_BY_ID: string;
22
+ };
23
+ export declare const tableBodyCols: ({
24
+ componentType: VISTA_TABLE_CELL_TYPE;
25
+ key: string;
26
+ } | {
27
+ componentType: VISTA_TABLE_CELL_TYPE;
28
+ key: string[];
29
+ } | {
30
+ componentType: VISTA_TABLE_CELL_TYPE;
31
+ key?: undefined;
32
+ })[];
33
+ export declare const messages: {
34
+ buyPrice: string;
35
+ currency: string;
36
+ error: string;
37
+ name: string;
38
+ productCategoryId: string;
39
+ quantity: string;
40
+ salePrice: string;
41
+ success: string;
42
+ };