@appcorp/stellar-solutions-invoice-module 0.1.57 → 0.1.59
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.
- package/base-modules/invoice/context.js +13 -2
- package/base-modules/payment/actions.d.ts +196 -0
- package/base-modules/payment/actions.js +49 -0
- package/base-modules/payment/constants.d.ts +101 -0
- package/base-modules/payment/constants.js +165 -0
- package/base-modules/payment/context.d.ts +56 -0
- package/base-modules/payment/context.js +421 -0
- package/base-modules/payment/drawer.d.ts +6 -0
- package/base-modules/payment/drawer.js +39 -0
- package/base-modules/payment/form.d.ts +18 -0
- package/base-modules/payment/form.js +90 -0
- package/base-modules/payment/index.d.ts +0 -0
- package/base-modules/payment/index.js +13 -0
- package/base-modules/payment/payment.d.ts +8 -0
- package/base-modules/payment/payment.js +39 -0
- package/base-modules/payment/reducer.d.ts +29 -0
- package/base-modules/payment/reducer.js +211 -0
- package/base-modules/payment/types.d.ts +82 -0
- package/base-modules/payment/types.js +19 -0
- package/base-modules/payment/validate.d.ts +20 -0
- package/base-modules/payment/validate.js +23 -0
- package/i18n/navigation.d.ts +342 -0
- package/i18n/navigation.js +9 -0
- package/i18n/routing.d.ts +18 -0
- package/i18n/routing.js +9 -0
- package/package.json +5 -5
|
@@ -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 },
|
|
@@ -796,11 +801,17 @@ var useInvoiceState = function () {
|
|
|
796
801
|
label: "Edit",
|
|
797
802
|
order: 1,
|
|
798
803
|
},
|
|
804
|
+
{
|
|
805
|
+
enabled: true,
|
|
806
|
+
handleAction: function (id) { return handleRecordPayment(id); },
|
|
807
|
+
label: "Record payment",
|
|
808
|
+
order: 2,
|
|
809
|
+
},
|
|
799
810
|
{
|
|
800
811
|
enabled: true,
|
|
801
812
|
handleAction: function (id) { return handleDelete(id); },
|
|
802
813
|
label: "Delete",
|
|
803
|
-
order:
|
|
814
|
+
order: 3,
|
|
804
815
|
},
|
|
805
816
|
];
|
|
806
817
|
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 });
|
|
@@ -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
|
+
};
|
|
@@ -0,0 +1,165 @@
|
|
|
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
|
+
"use client";
|
|
16
|
+
"use strict";
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.uiMessages = exports.validationError = exports.formInfo = exports.tableBodyCols = exports.PAYMENT_API_ROUTES = exports.VALIDATION_KEYS = exports.pageLimit = void 0;
|
|
19
|
+
var enhanced_table_1 = require("@appcorp/shadcn/components/enhanced-table");
|
|
20
|
+
var util_functions_1 = require("@react-pakistan/util-functions");
|
|
21
|
+
// ============================================================================
|
|
22
|
+
// PAGE CONFIGURATION
|
|
23
|
+
// ============================================================================
|
|
24
|
+
/**
|
|
25
|
+
* Default page limit for pagination
|
|
26
|
+
*/
|
|
27
|
+
exports.pageLimit = Number(process.env.NEXT_PUBLIC_PAGE_LIMIT);
|
|
28
|
+
// ============================================================================
|
|
29
|
+
// VALIDATION ERROR KEYS
|
|
30
|
+
// ============================================================================
|
|
31
|
+
/**
|
|
32
|
+
* Validation error keys for i18n translation
|
|
33
|
+
*/
|
|
34
|
+
exports.VALIDATION_KEYS = {
|
|
35
|
+
amount: "validationAmountRequired",
|
|
36
|
+
attachment: "validationAttachmentInvalid",
|
|
37
|
+
balance: "validationBalanceInvalid",
|
|
38
|
+
currency: "validationCurrencyRequired",
|
|
39
|
+
date: "validationDateRequired",
|
|
40
|
+
description: "validationDescriptionInvalid",
|
|
41
|
+
paymentMode: "validationPaymentModeRequired",
|
|
42
|
+
paymentType: "validationPaymentTypeRequired",
|
|
43
|
+
quoteInvoice: "validationQuoteInvoiceRequired",
|
|
44
|
+
ref: "validationRefInvalid",
|
|
45
|
+
};
|
|
46
|
+
// ============================================================================
|
|
47
|
+
// API ROUTES
|
|
48
|
+
// ============================================================================
|
|
49
|
+
/**
|
|
50
|
+
* API routes for payment-related operations
|
|
51
|
+
*/
|
|
52
|
+
exports.PAYMENT_API_ROUTES = {
|
|
53
|
+
PAYMENT: "/api/payment",
|
|
54
|
+
PAYMENT_BY_ID: "/api/payment/payment-by-id",
|
|
55
|
+
PAYMENT_MODES: "/api/payment-modes",
|
|
56
|
+
PAYMENTS: "/api/payments",
|
|
57
|
+
QUOTE_INVOICES: "/api/quotes-invoices",
|
|
58
|
+
};
|
|
59
|
+
// ============================================================================
|
|
60
|
+
// TABLE CONFIGURATION
|
|
61
|
+
// ============================================================================
|
|
62
|
+
/**
|
|
63
|
+
* Table body column configuration for payment listing
|
|
64
|
+
*/
|
|
65
|
+
exports.tableBodyCols = [
|
|
66
|
+
{
|
|
67
|
+
componentType: enhanced_table_1.COMPONENT_TYPE.ID,
|
|
68
|
+
key: "id",
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
componentType: enhanced_table_1.COMPONENT_TYPE.OBJECT,
|
|
72
|
+
key: ["quoteInvoice:ref"],
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
componentType: enhanced_table_1.COMPONENT_TYPE.TEXT,
|
|
76
|
+
key: "date",
|
|
77
|
+
textFormatter: function (text) {
|
|
78
|
+
return (0, util_functions_1.formatDate)(text, util_functions_1.DATE_FORMATS.LOCALE_DATE);
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
componentType: enhanced_table_1.COMPONENT_TYPE.TEXT,
|
|
83
|
+
key: "amount",
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
componentType: enhanced_table_1.COMPONENT_TYPE.TEXT,
|
|
87
|
+
key: "balance",
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
componentType: enhanced_table_1.COMPONENT_TYPE.TEXT,
|
|
91
|
+
key: "currency",
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
componentType: enhanced_table_1.COMPONENT_TYPE.TEXT,
|
|
95
|
+
key: "paymentType",
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
componentType: enhanced_table_1.COMPONENT_TYPE.OBJECT,
|
|
99
|
+
key: ["paymentMode:label"],
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
componentType: enhanced_table_1.COMPONENT_TYPE.TEXT,
|
|
103
|
+
key: "ref",
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
componentType: enhanced_table_1.COMPONENT_TYPE.ACTIONS,
|
|
107
|
+
key: "action",
|
|
108
|
+
},
|
|
109
|
+
];
|
|
110
|
+
// ============================================================================
|
|
111
|
+
// FORM CONFIGURATION
|
|
112
|
+
// ============================================================================
|
|
113
|
+
/**
|
|
114
|
+
* Information tooltips for form fields
|
|
115
|
+
*/
|
|
116
|
+
exports.formInfo = {
|
|
117
|
+
amount: "Enter the payment amount",
|
|
118
|
+
attachment: "Upload payment receipt or proof",
|
|
119
|
+
balance: "Remaining balance after this payment",
|
|
120
|
+
currency: "Select the currency for the payment",
|
|
121
|
+
date: "Date when payment was made",
|
|
122
|
+
description: "Additional notes about this payment",
|
|
123
|
+
paymentMode: "Select the payment method used",
|
|
124
|
+
paymentType: "Choose full or partial payment",
|
|
125
|
+
quoteInvoice: "Select the invoice this payment is for",
|
|
126
|
+
ref: "Payment reference number",
|
|
127
|
+
};
|
|
128
|
+
// ============================================================================
|
|
129
|
+
// VALIDATION MESSAGES
|
|
130
|
+
// ============================================================================
|
|
131
|
+
exports.validationError = {
|
|
132
|
+
// Required Fields
|
|
133
|
+
amount: "validationAmountRequired",
|
|
134
|
+
currency: "validationCurrencyRequired",
|
|
135
|
+
date: "validationDateRequired",
|
|
136
|
+
paymentModeId: "validationPaymentModeRequired",
|
|
137
|
+
paymentType: "validationPaymentTypeRequired",
|
|
138
|
+
quoteInvoiceId: "validationQuoteInvoiceRequired",
|
|
139
|
+
// Format Validation
|
|
140
|
+
attachmentInvalid: "validationAttachmentInvalid",
|
|
141
|
+
balanceInvalid: "validationBalanceInvalid",
|
|
142
|
+
descriptionInvalid: "validationDescriptionInvalid",
|
|
143
|
+
refInvalid: "validationRefInvalid",
|
|
144
|
+
// General
|
|
145
|
+
general: "validationFormGeneralError",
|
|
146
|
+
requiredField: "validationFormGeneralError",
|
|
147
|
+
};
|
|
148
|
+
// ============================================================================
|
|
149
|
+
// UI MESSAGES
|
|
150
|
+
// ============================================================================
|
|
151
|
+
exports.uiMessages = {
|
|
152
|
+
// Form Actions
|
|
153
|
+
cancel: "drawerButtonCancel",
|
|
154
|
+
delete: "actionsButtonDelete",
|
|
155
|
+
edit: "actionsButtonEdit",
|
|
156
|
+
save: "drawerButtonSave",
|
|
157
|
+
// Search & Filters
|
|
158
|
+
clearFilters: "drawerButtonClearFilter",
|
|
159
|
+
filterByPaymentMode: "drawerFilterLabelPaymentMode",
|
|
160
|
+
searchPlaceholder: "tableSearchPlaceholder",
|
|
161
|
+
// Table Actions
|
|
162
|
+
addPayment: "actionsButtonAddItem",
|
|
163
|
+
loadingPayments: "tableDescription",
|
|
164
|
+
noPaymentsFound: "tableDescription",
|
|
165
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Payment State Context
|
|
3
|
+
*
|
|
4
|
+
* This module provides comprehensive state management for the Payment feature including:
|
|
5
|
+
* - CRUD operations (create, read, update, delete)
|
|
6
|
+
* - Form validation and error handling
|
|
7
|
+
* - Search and filtering functionality
|
|
8
|
+
* - Pagination controls
|
|
9
|
+
* - Payment mode and quote invoice integration
|
|
10
|
+
* - Currency management with default selection
|
|
11
|
+
* - Internationalization support
|
|
12
|
+
* - Theme-aware toast notifications
|
|
13
|
+
*
|
|
14
|
+
* Organization:
|
|
15
|
+
* - Types & Interfaces
|
|
16
|
+
* - Main Hook (usePaymentState)
|
|
17
|
+
* - State & Core Hooks
|
|
18
|
+
* - Debounced Values
|
|
19
|
+
* - API Parameters (memoized)
|
|
20
|
+
* - API Callbacks (with error handling)
|
|
21
|
+
* - Module Entity Hook
|
|
22
|
+
* - Effects (list refresh, currency defaults)
|
|
23
|
+
* - Drawer & Modal Handlers
|
|
24
|
+
* - CRUD Operation Handlers
|
|
25
|
+
* - Form Handlers
|
|
26
|
+
* - Pagination Handlers
|
|
27
|
+
* - Search Handlers
|
|
28
|
+
* - Table Actions (memoized)
|
|
29
|
+
* - Return State
|
|
30
|
+
* - Context Setup
|
|
31
|
+
* - Provider Component
|
|
32
|
+
* - Custom Hook
|
|
33
|
+
*/
|
|
34
|
+
import React, { FC, ReactNode } from "react";
|
|
35
|
+
import { PaymentContextType, PaymentState } from "./types";
|
|
36
|
+
type State = PaymentContextType & PaymentState & {
|
|
37
|
+
headerActions: Array<{
|
|
38
|
+
enabled: boolean;
|
|
39
|
+
handleOnClick: () => void;
|
|
40
|
+
label: string;
|
|
41
|
+
order: number;
|
|
42
|
+
}>;
|
|
43
|
+
rowActions: Array<{
|
|
44
|
+
enabled: boolean;
|
|
45
|
+
handleAction: (id: string) => void;
|
|
46
|
+
label: string;
|
|
47
|
+
order: number;
|
|
48
|
+
}>;
|
|
49
|
+
};
|
|
50
|
+
interface StateProviderProps {
|
|
51
|
+
children: ReactNode;
|
|
52
|
+
}
|
|
53
|
+
export declare const PaymentStateContext: React.Context<State>;
|
|
54
|
+
export declare const PaymentStateContextProvider: FC<StateProviderProps>;
|
|
55
|
+
export declare const usePaymentStateContext: () => State;
|
|
56
|
+
export {};
|