@appcorp/stellar-solutions-invoice-module 0.1.57 → 0.1.60

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 (34) hide show
  1. package/base-modules/invoice/actions.d.ts +6 -6
  2. package/base-modules/invoice/context.js +21 -4
  3. package/base-modules/invoice/pricing-form-section.js +51 -28
  4. package/base-modules/invoice/types.d.ts +1 -0
  5. package/base-modules/payment/actions.d.ts +196 -0
  6. package/base-modules/payment/actions.js +49 -0
  7. package/base-modules/payment/constants.d.ts +101 -0
  8. package/base-modules/payment/constants.js +165 -0
  9. package/base-modules/payment/context.d.ts +56 -0
  10. package/base-modules/payment/context.js +421 -0
  11. package/base-modules/payment/drawer.d.ts +6 -0
  12. package/base-modules/payment/drawer.js +39 -0
  13. package/base-modules/payment/form.d.ts +18 -0
  14. package/base-modules/payment/form.js +90 -0
  15. package/base-modules/payment/index.d.ts +0 -0
  16. package/base-modules/payment/index.js +13 -0
  17. package/base-modules/payment/payment.d.ts +8 -0
  18. package/base-modules/payment/payment.js +39 -0
  19. package/base-modules/payment/reducer.d.ts +29 -0
  20. package/base-modules/payment/reducer.js +211 -0
  21. package/base-modules/payment/types.d.ts +82 -0
  22. package/base-modules/payment/types.js +19 -0
  23. package/base-modules/payment/validate.d.ts +20 -0
  24. package/base-modules/payment/validate.js +23 -0
  25. package/base-modules/quote/actions.d.ts +1 -1
  26. package/base-modules/quote/constants.js +1 -1
  27. package/base-modules/quote/context.js +27 -2
  28. package/base-modules/quote/pricing-form-section.js +51 -28
  29. package/base-modules/quote/types.d.ts +1 -0
  30. package/i18n/navigation.d.ts +342 -0
  31. package/i18n/navigation.js +9 -0
  32. package/i18n/routing.d.ts +18 -0
  33. package/i18n/routing.js +9 -0
  34. package/package.json +5 -5
@@ -1,8 +1,8 @@
1
- import { ProductTypeBE } from '@appcorp/stellar-solutions-product-module/base-modules/product/types';
2
- import { DISCOUNT_UNIT, INVOICE_DRAWER, InvoiceState, QuoteInvoiceTypeBE, Product, Service, INVOICE_MODAL } from './types';
3
- import { TaxTypeBE } from '@appcorp/stellar-solutions-modules/global-modules/preferences/types';
4
- import { CompanyTypeBE } from '@appcorp/stellar-solutions-company-module/base-modules/company/types';
5
- import { CustomerTypeBE } from '@appcorp/stellar-solutions-company-module/base-modules/customer/types';
1
+ import { ProductTypeBE } from "@appcorp/stellar-solutions-product-module/base-modules/product/types";
2
+ import { DISCOUNT_UNIT, INVOICE_DRAWER, InvoiceState, QuoteInvoiceTypeBE, Product, Service, INVOICE_MODAL } from "./types";
3
+ import { TaxTypeBE } from "@appcorp/stellar-solutions-modules/global-modules/preferences/types";
4
+ import { CompanyTypeBE } from "@appcorp/stellar-solutions-company-module/base-modules/company/types";
5
+ import { CustomerTypeBE } from "@appcorp/stellar-solutions-company-module/base-modules/customer/types";
6
6
  export declare enum INVOICE_ACTION_TYPES {
7
7
  ADD_ITEM_PRODUCT = "ADD_ITEM_PRODUCT",
8
8
  ADD_ITEM_SERVICE = "ADD_ITEM_SERVICE",
@@ -40,7 +40,7 @@ export declare enum INVOICE_ACTION_TYPES {
40
40
  export type InvoiceUpdateFieldAction = {
41
41
  type: INVOICE_ACTION_TYPES.SET_INPUT_FIELD;
42
42
  payload: {
43
- key: keyof QuoteInvoiceTypeBE | 'servicesList' | 'productsList';
43
+ key: keyof QuoteInvoiceTypeBE | "servicesList" | "productsList" | "taxQuery" | "productQuery" | "companyQuery";
44
44
  value: string | string[] | boolean | number | number[] | Service[] | Product[];
45
45
  };
46
46
  };
@@ -145,6 +145,7 @@ var calculate_subtotal_1 = require("./calculate-subtotal");
145
145
  var calculate_total_1 = require("./calculate-total");
146
146
  var context_1 = require("@appcorp/stellar-solutions-modules/global-modules/tax/context");
147
147
  var context_2 = require("@appcorp/stellar-solutions-modules/global-modules/preferences/context");
148
+ var navigation_1 = require("../../i18n/navigation");
148
149
  // ============================================================================
149
150
  // MAIN HOOK
150
151
  // ============================================================================
@@ -158,6 +159,7 @@ var useInvoiceState = function () {
158
159
  var theme = (0, next_themes_1.useTheme)().theme;
159
160
  var taxes = (0, context_1.useTaxStateContext)().taxes;
160
161
  var currencies = (0, context_2.usePreferenceStateContext)().currencies;
162
+ var router = (0, navigation_1.useRouter)();
161
163
  // ---------------------------------------------------------------------------
162
164
  // Toast Helpers
163
165
  // ---------------------------------------------------------------------------
@@ -582,6 +584,10 @@ var useInvoiceState = function () {
582
584
  });
583
585
  // eslint-disable-next-line react-hooks/exhaustive-deps
584
586
  }, []);
587
+ var handleRecordPayment = (0, react_1.useCallback)(function (id) {
588
+ (0, util_functions_1.setStorageValue)("paymentInvoiceId", id);
589
+ router.push("/invoice");
590
+ }, [router]);
585
591
  var handleDelete = (0, react_1.useCallback)(function (id) {
586
592
  deleteFetchNow === null || deleteFetchNow === void 0 ? void 0 : deleteFetchNow(undefined, {
587
593
  body: JSON.stringify({ id: id }),
@@ -593,7 +599,6 @@ var useInvoiceState = function () {
593
599
  // ---------------------------------------------------------------------------
594
600
  var handleSubmit = (0, react_1.useCallback)(function () {
595
601
  if (!state.servicesList[0].name && !state.productsList[0].id) {
596
- console.log("inside", state.servicesList, state.productsList);
597
602
  dispatch({
598
603
  type: actions_1.INVOICE_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON,
599
604
  payload: { disableSaveButton: true },
@@ -745,6 +750,12 @@ var useInvoiceState = function () {
745
750
  payload: { searchQuery: "" },
746
751
  });
747
752
  };
753
+ var handleTaxSearch = function (searchQuery) {
754
+ dispatch({
755
+ type: actions_1.INVOICE_ACTION_TYPES.SET_INPUT_FIELD,
756
+ payload: { key: "taxQuery", value: searchQuery },
757
+ });
758
+ };
748
759
  var closeDrawer = function () {
749
760
  dispatch({
750
761
  type: actions_1.INVOICE_ACTION_TYPES.SET_DRAWER,
@@ -796,16 +807,22 @@ var useInvoiceState = function () {
796
807
  label: "Edit",
797
808
  order: 1,
798
809
  },
810
+ {
811
+ enabled: true,
812
+ handleAction: function (id) { return handleRecordPayment(id); },
813
+ label: "Record payment",
814
+ order: 2,
815
+ },
799
816
  {
800
817
  enabled: true,
801
818
  handleAction: function (id) { return handleDelete(id); },
802
819
  label: "Delete",
803
- order: 2,
820
+ order: 3,
804
821
  },
805
822
  ];
806
- return __assign(__assign({}, state), { byIdError: byIdError, byIdLoading: byIdLoading, clearSearch: clearSearch, closeDrawer: closeDrawer, deleteError: deleteError, deleteLoading: deleteLoading, dispatch: dispatch, handleAddItemProduct: handleAddItemProduct, handleAddItemService: handleAddItemService, handleChange: handleChange, handleDeleteProductRow: handleDeleteProductRow, handleDeleteServiceRow: handleDeleteServiceRow, handleItemChangeProducts: handleItemChangeProducts, handleItemChangeServices: handleItemChangeServices, handleNextClick: handleNextClick, handlePageLimit: handlePageLimit, handlePreviousClick: handlePreviousClick, handleSubmit: handleSubmit, headerActions: headerActions, listError: listError, listFetchNow: listFetchNow, listLoading: listLoading, rowActions: rowActions, searchOnChange: searchOnChange, updateError: updateError, updateLoading: updateLoading });
823
+ return __assign(__assign({}, state), { byIdError: byIdError, byIdLoading: byIdLoading, clearSearch: clearSearch, closeDrawer: closeDrawer, deleteError: deleteError, deleteLoading: deleteLoading, dispatch: dispatch, handleAddItemProduct: handleAddItemProduct, handleAddItemService: handleAddItemService, handleChange: handleChange, handleDeleteProductRow: handleDeleteProductRow, handleDeleteServiceRow: handleDeleteServiceRow, handleItemChangeProducts: handleItemChangeProducts, handleItemChangeServices: handleItemChangeServices, handleNextClick: handleNextClick, handlePageLimit: handlePageLimit, handlePreviousClick: handlePreviousClick, handleSubmit: handleSubmit, headerActions: headerActions, listError: listError, listFetchNow: listFetchNow, listLoading: listLoading, rowActions: rowActions, searchOnChange: searchOnChange, handleTaxSearch: handleTaxSearch, updateError: updateError, updateLoading: updateLoading });
807
824
  };
808
- exports.InvoiceStateContext = (0, react_1.createContext)(__assign(__assign({}, reducer_1.initialInvoiceState), { byIdError: undefined, byIdLoading: false, clearSearch: function () { return void 0; }, closeDrawer: function () { return void 0; }, deleteError: undefined, deleteLoading: false, dispatch: function () { return void 0; }, handleAddItemProduct: function () { return void 0; }, handleAddItemService: function () { return void 0; }, handleChange: function () { return void 0; }, handleDeleteProductRow: function () { return void 0; }, handleDeleteServiceRow: function () { return void 0; }, handleItemChangeProducts: function () { return void 0; }, handleItemChangeServices: function () { return void 0; }, handleNextClick: function () { return void 0; }, handlePageLimit: function () { return void 0; }, handlePreviousClick: function () { return void 0; }, handleSubmit: function () { return void 0; }, headerActions: [], listError: undefined, listFetchNow: function () { return void 0; }, listLoading: false, rowActions: [], searchOnChange: function () { return void 0; }, updateError: undefined, updateLoading: false }));
825
+ exports.InvoiceStateContext = (0, react_1.createContext)(__assign(__assign({}, reducer_1.initialInvoiceState), { byIdError: undefined, byIdLoading: false, clearSearch: function () { return void 0; }, closeDrawer: function () { return void 0; }, deleteError: undefined, deleteLoading: false, dispatch: function () { return void 0; }, handleAddItemProduct: function () { return void 0; }, handleAddItemService: function () { return void 0; }, handleChange: function () { return void 0; }, handleDeleteProductRow: function () { return void 0; }, handleDeleteServiceRow: function () { return void 0; }, handleItemChangeProducts: function () { return void 0; }, handleItemChangeServices: function () { return void 0; }, handleNextClick: function () { return void 0; }, handlePageLimit: function () { return void 0; }, handlePreviousClick: function () { return void 0; }, handleSubmit: function () { return void 0; }, headerActions: [], listError: undefined, listFetchNow: function () { return void 0; }, listLoading: false, rowActions: [], searchOnChange: function () { return void 0; }, handleTaxSearch: function () { return void 0; }, updateError: undefined, updateLoading: false }));
809
826
  var InvoiceStateContextProvider = function (_a) {
810
827
  var children = _a.children;
811
828
  var state = useInvoiceState();
@@ -5,41 +5,58 @@
5
5
  * Totals calculation section for invoice pricing including tax and discount.
6
6
  * Uses Shadcn UI components with RTL support and i18n.
7
7
  */
8
- var __importDefault = (this && this.__importDefault) || function (mod) {
9
- return (mod && mod.__esModule) ? mod : { "default": mod };
10
- };
8
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
+ if (k2 === undefined) k2 = k;
10
+ var desc = Object.getOwnPropertyDescriptor(m, k);
11
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
12
+ desc = { enumerable: true, get: function() { return m[k]; } };
13
+ }
14
+ Object.defineProperty(o, k2, desc);
15
+ }) : (function(o, m, k, k2) {
16
+ if (k2 === undefined) k2 = k;
17
+ o[k2] = m[k];
18
+ }));
19
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
20
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
21
+ }) : function(o, v) {
22
+ o["default"] = v;
23
+ });
24
+ var __importStar = (this && this.__importStar) || (function () {
25
+ var ownKeys = function(o) {
26
+ ownKeys = Object.getOwnPropertyNames || function (o) {
27
+ var ar = [];
28
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
29
+ return ar;
30
+ };
31
+ return ownKeys(o);
32
+ };
33
+ return function (mod) {
34
+ if (mod && mod.__esModule) return mod;
35
+ var result = {};
36
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
37
+ __setModuleDefault(result, mod);
38
+ return result;
39
+ };
40
+ })();
11
41
  Object.defineProperty(exports, "__esModule", { value: true });
12
42
  exports.PricingSection = void 0;
13
- var react_1 = __importDefault(require("react"));
43
+ var react_1 = __importStar(require("react"));
14
44
  var next_intl_1 = require("next-intl");
15
45
  var combobox_1 = require("@appcorp/shadcn/components/combobox");
16
46
  var input_1 = require("@appcorp/shadcn/components/input");
17
47
  var label_1 = require("@appcorp/shadcn/components/label");
18
48
  var button_1 = require("@appcorp/shadcn/components/button");
19
- var context_1 = require("./context");
49
+ var context_1 = require("@appcorp/stellar-solutions-modules/global-modules/tax/context");
50
+ var context_2 = require("./context");
20
51
  var types_1 = require("./types");
21
52
  var PricingSection = function () {
22
53
  var t = (0, next_intl_1.useTranslations)("invoicePage");
23
- var _a = (0, context_1.useInvoiceStateContext)(), afterDiscount = _a.afterDiscount, discount = _a.discount, discountUnit = _a.discountUnit, errors = _a.errors, handleChange = _a.handleChange, subTotal = _a.subTotal, tax = _a.tax, taxes = _a.taxes, total = _a.total;
24
- var handleTaxChange = function (selectedTaxId) {
25
- var selectedTax = taxes === null || taxes === void 0 ? void 0 : taxes.find(function (t) { return t.id === selectedTaxId; });
26
- if (selectedTax) {
27
- handleChange("taxRate", selectedTax.taxRate);
28
- }
29
- };
30
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
31
- var handleTaxSearch = function (_searchQuery) {
32
- // Tax search functionality placeholder
33
- };
34
- var handleDiscountUnitChange = function (unit) {
35
- handleChange("discountUnit", unit);
36
- };
37
- // Map taxes to have consistent structure for CompanyCombobox
38
- var taxOptions = (taxes || []).map(function (tax) { return ({
39
- id: tax.id,
40
- name: "".concat(tax.taxName, " (").concat(tax.taxRate, "%)"),
41
- }); });
42
- var currentTax = taxes === null || taxes === void 0 ? void 0 : taxes.find(function (t) { return String(t.taxRate) === String(tax); });
54
+ var _a = (0, context_1.useTaxStateContext)(), taxesFromTaxContext = _a.taxes, taxesLoading = _a.listLoading;
55
+ var _b = (0, context_2.useInvoiceStateContext)(), afterDiscount = _b.afterDiscount, discount = _b.discount, discountUnit = _b.discountUnit, errors = _b.errors, handleChange = _b.handleChange, handleTaxSearch = _b.handleTaxSearch, subTotal = _b.subTotal, tax = _b.tax, taxRate = _b.taxRate, total = _b.total;
56
+ // Find the current tax based on taxRate value
57
+ var currentTax = (0, react_1.useMemo)(function () {
58
+ return taxesFromTaxContext === null || taxesFromTaxContext === void 0 ? void 0 : taxesFromTaxContext.find(function (t) { return String(t.taxRate) === String(taxRate); });
59
+ }, [taxesFromTaxContext, taxRate]);
43
60
  return (react_1.default.createElement("div", { className: "flex flex-col gap-6" },
44
61
  react_1.default.createElement("h3", { className: "text-lg font-semibold border-b pb-2" }, t("pricingSectionTitle")),
45
62
  react_1.default.createElement("div", { className: "grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6" },
@@ -53,12 +70,12 @@ var PricingSection = function () {
53
70
  react_1.default.createElement("p", { className: "text-sm text-muted-foreground" }, t("discountUnitDescription")),
54
71
  react_1.default.createElement("div", { className: "flex gap-2" },
55
72
  react_1.default.createElement(button_1.Button, { onClick: function () {
56
- return handleDiscountUnitChange(types_1.DISCOUNT_UNIT.FIXED_VALUE);
73
+ return handleChange("discountUnit", types_1.DISCOUNT_UNIT.FIXED_VALUE);
57
74
  }, size: "sm", type: "button", variant: discountUnit === types_1.DISCOUNT_UNIT.FIXED_VALUE
58
75
  ? "default"
59
76
  : "outline" }, t("discountUnitFixedValue")),
60
77
  react_1.default.createElement(button_1.Button, { onClick: function () {
61
- return handleDiscountUnitChange(types_1.DISCOUNT_UNIT.PERCENTAGE_VALUE);
78
+ return handleChange("discountUnit", types_1.DISCOUNT_UNIT.PERCENTAGE_VALUE);
62
79
  }, size: "sm", type: "button", variant: discountUnit === types_1.DISCOUNT_UNIT.PERCENTAGE_VALUE
63
80
  ? "default"
64
81
  : "outline" }, t("discountUnitPercentageValue")))),
@@ -67,7 +84,13 @@ var PricingSection = function () {
67
84
  react_1.default.createElement("div", { className: "space-y-2" },
68
85
  react_1.default.createElement(input_1.Input, { id: "afterDiscount", label: t("formLabelAfterDiscount"), onChange: function (e) { return handleChange("afterDiscount", e.target.value); }, placeholder: "0.00", readOnly: true, type: "text", value: afterDiscount || "0" })),
69
86
  react_1.default.createElement("div", { className: "space-y-2" },
70
- react_1.default.createElement(combobox_1.CompanyCombobox, { companies: taxOptions, id: "taxRate", label: t("formLabelTax"), onSearchChange: handleTaxSearch, onValueChange: handleTaxChange, placeholder: t("formPlaceholderTax"), value: (currentTax === null || currentTax === void 0 ? void 0 : currentTax.id) || "" })),
87
+ react_1.default.createElement(combobox_1.Combobox, { id: "taxRate", label: t("formLabelTax"), value: (currentTax === null || currentTax === void 0 ? void 0 : currentTax.taxRate) || "", onValueChange: function (v) { return handleChange("taxRate", v); }, onSearchChange: handleTaxSearch, loading: taxesLoading, options: (taxesFromTaxContext || [])
88
+ .slice()
89
+ .sort(function (a, b) { return a.taxName.localeCompare(b.taxName); })
90
+ .map(function (tax) { return ({
91
+ label: "".concat(tax.taxName, " (").concat(tax.taxRate, "%)"),
92
+ value: tax.taxRate.toString(),
93
+ }); }), placeholder: t("formPlaceholderTax"), searchPlaceholder: "Search taxes...", info: t("formInfoTax"), error: errors.taxRate, required: true })),
71
94
  react_1.default.createElement("div", { className: "space-y-2" },
72
95
  react_1.default.createElement(input_1.Input, { id: "afterTax", label: t("formLabelAfterTax"), placeholder: "0.00", readOnly: true, type: "text", value: isNaN(Number(tax)) ? "0" : tax || "0" })),
73
96
  react_1.default.createElement("div", { className: "space-y-2" },
@@ -33,6 +33,7 @@ export interface InvoiceContextType {
33
33
  handlePageLimit: (node: string, value: object) => void;
34
34
  handlePreviousClick: () => void;
35
35
  handleSubmit: () => void;
36
+ handleTaxSearch: (searchQuery: string) => void;
36
37
  headerActions: HeaderAction[];
37
38
  listError?: Error;
38
39
  listFetchNow: () => void;
@@ -0,0 +1,196 @@
1
+ /**
2
+ * Payment Actions
3
+ *
4
+ * This module defines all action types and interfaces for the Payment state management.
5
+ * Actions are organized by functionality and follow consistent naming patterns.
6
+ *
7
+ * Organization:
8
+ * - Action Types Enum (grouped by functionality)
9
+ * - Reset Actions (form/error reset)
10
+ * - Form Data Actions (input fields, form state)
11
+ * - UI State Actions (drawers, modals, buttons)
12
+ * - List Management Actions (payments, pagination)
13
+ * - Search Actions (queries, filters)
14
+ * - Union Type Export
15
+ *
16
+ * Naming Convention: Payment{Operation}{Target}Action
17
+ * Examples: PaymentSetInputFieldAction, PaymentResetFormAction
18
+ */
19
+ import { PAYMENT_DRAWER, PAYMENT_MODAL, PaymentModeTypeBE, PaymentTypeBE } from "./types";
20
+ import { QuoteInvoiceTypeBE } from "../invoice/types";
21
+ export declare enum PAYMENT_ACTION_TYPES {
22
+ RESET_ERRORS = "RESET_ERRORS",
23
+ RESET_FORM = "RESET_FORM",
24
+ SET_ERRORS = "SET_ERRORS",
25
+ SET_FORM = "SET_FORM",
26
+ SET_INPUT_FIELD = "SET_INPUT_FIELD",
27
+ SET_DISABLE_SAVE_BUTTON = "SET_DISABLE_SAVE_BUTTON",
28
+ SET_DRAWER = "SET_DRAWER",
29
+ SET_MODAL = "SET_MODAL",
30
+ SET_COUNT = "SET_COUNT",
31
+ SET_CURRENT_PAGE = "SET_CURRENT_PAGE",
32
+ SET_PAGE_LIMIT = "SET_PAGE_LIMIT",
33
+ SET_PAYMENT_MODES = "SET_PAYMENT_MODES",
34
+ SET_PAYMENTS = "SET_PAYMENTS",
35
+ SET_QUOTE_INVOICES = "SET_QUOTE_INVOICES",
36
+ SET_PAYMENT_MODE_QUERY = "SET_PAYMENT_MODE_QUERY",
37
+ SET_QUOTE_INVOICE_QUERY = "SET_QUOTE_INVOICE_QUERY",
38
+ SET_SEARCH_QUERY = "SET_SEARCH_QUERY"
39
+ }
40
+ /**
41
+ * Reset form validation errors
42
+ */
43
+ export type PaymentResetErrorsAction = {
44
+ type: PAYMENT_ACTION_TYPES.RESET_ERRORS;
45
+ };
46
+ /**
47
+ * Reset entire form to initial state
48
+ */
49
+ export type PaymentResetFormAction = {
50
+ type: PAYMENT_ACTION_TYPES.RESET_FORM;
51
+ };
52
+ /**
53
+ * Set form validation errors
54
+ */
55
+ export type PaymentSetErrorsAction = {
56
+ type: PAYMENT_ACTION_TYPES.SET_ERRORS;
57
+ payload: {
58
+ errors: {
59
+ [key: string]: string;
60
+ };
61
+ };
62
+ };
63
+ /**
64
+ * Set entire form data (used when editing existing payment)
65
+ */
66
+ export type PaymentSetFormAction = {
67
+ type: PAYMENT_ACTION_TYPES.SET_FORM;
68
+ payload: {
69
+ form: PaymentTypeBE;
70
+ };
71
+ };
72
+ /**
73
+ * Update individual form field dynamically
74
+ */
75
+ export type PaymentSetInputFieldAction = {
76
+ type: PAYMENT_ACTION_TYPES.SET_INPUT_FIELD;
77
+ payload: {
78
+ key: string;
79
+ value: string | string[] | boolean | number | number[];
80
+ };
81
+ };
82
+ /**
83
+ * Disable or enable the save button
84
+ */
85
+ export type PaymentSetDisableSaveButtonAction = {
86
+ type: PAYMENT_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON;
87
+ payload: {
88
+ disableSaveButton: boolean;
89
+ };
90
+ };
91
+ /**
92
+ * Set the current drawer state
93
+ */
94
+ export type PaymentSetDrawerAction = {
95
+ type: PAYMENT_ACTION_TYPES.SET_DRAWER;
96
+ payload: {
97
+ drawer: PAYMENT_DRAWER | null;
98
+ };
99
+ };
100
+ /**
101
+ * Set the current modal state
102
+ */
103
+ export type PaymentSetModalAction = {
104
+ type: PAYMENT_ACTION_TYPES.SET_MODAL;
105
+ payload: {
106
+ modal: PAYMENT_MODAL | null;
107
+ };
108
+ };
109
+ /**
110
+ * Set the total count of payments
111
+ */
112
+ export type PaymentSetCountAction = {
113
+ type: PAYMENT_ACTION_TYPES.SET_COUNT;
114
+ payload: {
115
+ count: number;
116
+ };
117
+ };
118
+ /**
119
+ * Set the current page for pagination
120
+ */
121
+ export type PaymentSetCurrentPageAction = {
122
+ type: PAYMENT_ACTION_TYPES.SET_CURRENT_PAGE;
123
+ payload: {
124
+ currentPage: number;
125
+ };
126
+ };
127
+ /**
128
+ * Set the page limit for pagination
129
+ */
130
+ export type PaymentSetPageLimitAction = {
131
+ type: PAYMENT_ACTION_TYPES.SET_PAGE_LIMIT;
132
+ payload: {
133
+ pageLimit: number;
134
+ };
135
+ };
136
+ /**
137
+ * Set the list of payment modes
138
+ */
139
+ export type PaymentSetPaymentModesAction = {
140
+ type: PAYMENT_ACTION_TYPES.SET_PAYMENT_MODES;
141
+ payload: {
142
+ paymentModes: PaymentModeTypeBE[];
143
+ };
144
+ };
145
+ /**
146
+ * Set the list of payments
147
+ */
148
+ export type PaymentSetPaymentsAction = {
149
+ type: PAYMENT_ACTION_TYPES.SET_PAYMENTS;
150
+ payload: {
151
+ payments: PaymentTypeBE[];
152
+ };
153
+ };
154
+ /**
155
+ * Set the list of quote invoices
156
+ */
157
+ export type PaymentSetQuoteInvoicesAction = {
158
+ type: PAYMENT_ACTION_TYPES.SET_QUOTE_INVOICES;
159
+ payload: {
160
+ quoteInvoices: QuoteInvoiceTypeBE[];
161
+ };
162
+ };
163
+ /**
164
+ * Set the search query for payment modes
165
+ */
166
+ export type PaymentSetPaymentModeQueryAction = {
167
+ type: PAYMENT_ACTION_TYPES.SET_PAYMENT_MODE_QUERY;
168
+ payload: {
169
+ paymentModeQuery: string;
170
+ };
171
+ };
172
+ /**
173
+ * Set the search query for quote invoices
174
+ */
175
+ export type PaymentSetQuoteInvoiceQueryAction = {
176
+ type: PAYMENT_ACTION_TYPES.SET_QUOTE_INVOICE_QUERY;
177
+ payload: {
178
+ quoteInvoiceQuery: string;
179
+ };
180
+ };
181
+ /**
182
+ * Set the search query for payments
183
+ */
184
+ export type PaymentSetSearchQueryAction = {
185
+ type: PAYMENT_ACTION_TYPES.SET_SEARCH_QUERY;
186
+ payload: {
187
+ searchQuery: string;
188
+ };
189
+ };
190
+ /**
191
+ * All Payment Actions
192
+ *
193
+ * A union of all action types for the Payment module, representing all possible actions
194
+ * that can be dispatched to modify the Payment state.
195
+ */
196
+ export type PaymentActions = PaymentResetErrorsAction | PaymentResetFormAction | PaymentSetCountAction | PaymentSetCurrentPageAction | PaymentSetDisableSaveButtonAction | PaymentSetDrawerAction | PaymentSetErrorsAction | PaymentSetFormAction | PaymentSetInputFieldAction | PaymentSetModalAction | PaymentSetPageLimitAction | PaymentSetPaymentModeQueryAction | PaymentSetPaymentModesAction | PaymentSetPaymentsAction | PaymentSetQuoteInvoiceQueryAction | PaymentSetQuoteInvoicesAction | PaymentSetSearchQueryAction;
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ /**
3
+ * Payment Actions
4
+ *
5
+ * This module defines all action types and interfaces for the Payment state management.
6
+ * Actions are organized by functionality and follow consistent naming patterns.
7
+ *
8
+ * Organization:
9
+ * - Action Types Enum (grouped by functionality)
10
+ * - Reset Actions (form/error reset)
11
+ * - Form Data Actions (input fields, form state)
12
+ * - UI State Actions (drawers, modals, buttons)
13
+ * - List Management Actions (payments, pagination)
14
+ * - Search Actions (queries, filters)
15
+ * - Union Type Export
16
+ *
17
+ * Naming Convention: Payment{Operation}{Target}Action
18
+ * Examples: PaymentSetInputFieldAction, PaymentResetFormAction
19
+ */
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.PAYMENT_ACTION_TYPES = void 0;
22
+ // ============================================================================
23
+ // ACTION TYPES ENUM
24
+ // ============================================================================
25
+ var PAYMENT_ACTION_TYPES;
26
+ (function (PAYMENT_ACTION_TYPES) {
27
+ // Reset Actions
28
+ PAYMENT_ACTION_TYPES["RESET_ERRORS"] = "RESET_ERRORS";
29
+ PAYMENT_ACTION_TYPES["RESET_FORM"] = "RESET_FORM";
30
+ // Form Data Actions
31
+ PAYMENT_ACTION_TYPES["SET_ERRORS"] = "SET_ERRORS";
32
+ PAYMENT_ACTION_TYPES["SET_FORM"] = "SET_FORM";
33
+ PAYMENT_ACTION_TYPES["SET_INPUT_FIELD"] = "SET_INPUT_FIELD";
34
+ // UI State Actions
35
+ PAYMENT_ACTION_TYPES["SET_DISABLE_SAVE_BUTTON"] = "SET_DISABLE_SAVE_BUTTON";
36
+ PAYMENT_ACTION_TYPES["SET_DRAWER"] = "SET_DRAWER";
37
+ PAYMENT_ACTION_TYPES["SET_MODAL"] = "SET_MODAL";
38
+ // List Management Actions
39
+ PAYMENT_ACTION_TYPES["SET_COUNT"] = "SET_COUNT";
40
+ PAYMENT_ACTION_TYPES["SET_CURRENT_PAGE"] = "SET_CURRENT_PAGE";
41
+ PAYMENT_ACTION_TYPES["SET_PAGE_LIMIT"] = "SET_PAGE_LIMIT";
42
+ PAYMENT_ACTION_TYPES["SET_PAYMENT_MODES"] = "SET_PAYMENT_MODES";
43
+ PAYMENT_ACTION_TYPES["SET_PAYMENTS"] = "SET_PAYMENTS";
44
+ PAYMENT_ACTION_TYPES["SET_QUOTE_INVOICES"] = "SET_QUOTE_INVOICES";
45
+ // Search Actions
46
+ PAYMENT_ACTION_TYPES["SET_PAYMENT_MODE_QUERY"] = "SET_PAYMENT_MODE_QUERY";
47
+ PAYMENT_ACTION_TYPES["SET_QUOTE_INVOICE_QUERY"] = "SET_QUOTE_INVOICE_QUERY";
48
+ PAYMENT_ACTION_TYPES["SET_SEARCH_QUERY"] = "SET_SEARCH_QUERY";
49
+ })(PAYMENT_ACTION_TYPES || (exports.PAYMENT_ACTION_TYPES = PAYMENT_ACTION_TYPES = {}));
@@ -0,0 +1,101 @@
1
+ /**
2
+ * Payment Module Constants
3
+ *
4
+ * Organization:
5
+ * - Page Configuration
6
+ * - Default Values
7
+ * - Validation Error Keys
8
+ * - API Routes
9
+ * - Table Configuration
10
+ * - Form Configuration
11
+ * - Network Messages
12
+ * - Validation Messages
13
+ * - UI Messages
14
+ */
15
+ import { COMPONENT_TYPE } from "@appcorp/shadcn/components/enhanced-table";
16
+ /**
17
+ * Default page limit for pagination
18
+ */
19
+ export declare const pageLimit: number;
20
+ /**
21
+ * Validation error keys for i18n translation
22
+ */
23
+ export declare const VALIDATION_KEYS: {
24
+ amount: string;
25
+ attachment: string;
26
+ balance: string;
27
+ currency: string;
28
+ date: string;
29
+ description: string;
30
+ paymentMode: string;
31
+ paymentType: string;
32
+ quoteInvoice: string;
33
+ ref: string;
34
+ };
35
+ /**
36
+ * API routes for payment-related operations
37
+ */
38
+ export declare const PAYMENT_API_ROUTES: {
39
+ readonly PAYMENT: "/api/payment";
40
+ readonly PAYMENT_BY_ID: "/api/payment/payment-by-id";
41
+ readonly PAYMENT_MODES: "/api/payment-modes";
42
+ readonly PAYMENTS: "/api/payments";
43
+ readonly QUOTE_INVOICES: "/api/quotes-invoices";
44
+ };
45
+ /**
46
+ * Table body column configuration for payment listing
47
+ */
48
+ export declare const tableBodyCols: ({
49
+ componentType: COMPONENT_TYPE;
50
+ key: string;
51
+ textFormatter?: undefined;
52
+ } | {
53
+ componentType: COMPONENT_TYPE;
54
+ key: string[];
55
+ textFormatter?: undefined;
56
+ } | {
57
+ componentType: COMPONENT_TYPE;
58
+ key: string;
59
+ textFormatter: (text: unknown) => string;
60
+ })[];
61
+ /**
62
+ * Information tooltips for form fields
63
+ */
64
+ export declare const formInfo: {
65
+ amount: string;
66
+ attachment: string;
67
+ balance: string;
68
+ currency: string;
69
+ date: string;
70
+ description: string;
71
+ paymentMode: string;
72
+ paymentType: string;
73
+ quoteInvoice: string;
74
+ ref: string;
75
+ };
76
+ export declare const validationError: {
77
+ readonly amount: "validationAmountRequired";
78
+ readonly currency: "validationCurrencyRequired";
79
+ readonly date: "validationDateRequired";
80
+ readonly paymentModeId: "validationPaymentModeRequired";
81
+ readonly paymentType: "validationPaymentTypeRequired";
82
+ readonly quoteInvoiceId: "validationQuoteInvoiceRequired";
83
+ readonly attachmentInvalid: "validationAttachmentInvalid";
84
+ readonly balanceInvalid: "validationBalanceInvalid";
85
+ readonly descriptionInvalid: "validationDescriptionInvalid";
86
+ readonly refInvalid: "validationRefInvalid";
87
+ readonly general: "validationFormGeneralError";
88
+ readonly requiredField: "validationFormGeneralError";
89
+ };
90
+ export declare const uiMessages: {
91
+ readonly cancel: "drawerButtonCancel";
92
+ readonly delete: "actionsButtonDelete";
93
+ readonly edit: "actionsButtonEdit";
94
+ readonly save: "drawerButtonSave";
95
+ readonly clearFilters: "drawerButtonClearFilter";
96
+ readonly filterByPaymentMode: "drawerFilterLabelPaymentMode";
97
+ readonly searchPlaceholder: "tableSearchPlaceholder";
98
+ readonly addPayment: "actionsButtonAddItem";
99
+ readonly loadingPayments: "tableDescription";
100
+ readonly noPaymentsFound: "tableDescription";
101
+ };