mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-21 15:20:34 +00:00
feat: payment made form in new and edit mode.
This commit is contained in:
@@ -106,7 +106,20 @@ export const fetchPaymentMade = ({ id }) => {
|
||||
type: t.PAYMENT_MADE_SET,
|
||||
payload: {
|
||||
id,
|
||||
bill_payment: response.data.bill_payment,
|
||||
paymentMade: response.data.bill_payment,
|
||||
},
|
||||
});
|
||||
dispatch({
|
||||
type: t.BILLS_PAYABLE_BY_PAYMENT_ID,
|
||||
payload: {
|
||||
billPaymentId: id,
|
||||
bills: response.data.bill_payment.payable_bills,
|
||||
},
|
||||
});
|
||||
dispatch({
|
||||
type: t.BILLS_ITEMS_SET,
|
||||
payload: {
|
||||
bills: response.data.bill_payment.payable_bills,
|
||||
},
|
||||
});
|
||||
resovle(response);
|
||||
@@ -118,3 +131,17 @@ export const fetchPaymentMade = ({ id }) => {
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
export const fetchPaymentMadeBills = ({ paymentMadeId }) => (dispatch) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
ApiService.get(`purchases/bill_payments/${paymentMadeId}/bills`).then((response) => {
|
||||
dispatch({
|
||||
type: t.BILLS_ITEMS_SET,
|
||||
payload: {
|
||||
bills: response.data.bills,
|
||||
},
|
||||
});
|
||||
resolve(response);
|
||||
}).catch((error) => { reject(error) });
|
||||
});
|
||||
}
|
||||
@@ -39,6 +39,17 @@ const reducer = createReducer(initialState, {
|
||||
};
|
||||
},
|
||||
|
||||
[t.PAYMENT_MADE_SET]: (state, action) => {
|
||||
const { id, paymentMade } = action.payload;
|
||||
const _oldPaymentMade = (state.items[id] || {});
|
||||
|
||||
state.items[id] = {
|
||||
...defaultPaymentMade,
|
||||
..._oldPaymentMade,
|
||||
...paymentMade,
|
||||
};
|
||||
},
|
||||
|
||||
[t.PAYMENT_MADE_DELETE]: (state, action) => {
|
||||
const { id } = action.payload;
|
||||
|
||||
|
||||
@@ -23,6 +23,9 @@ const paymentMadesIds = (state, props) => {
|
||||
return state.paymentMades.items[props.paymentMadeId];
|
||||
};
|
||||
|
||||
const paymentMadeEntries = (state, props) => props.paymentMadeEntries;
|
||||
const billsItemsSelector = (state, props) => state.bills.items;
|
||||
|
||||
export const getPaymentMadeCurrentPageFactory = () =>
|
||||
createSelector(
|
||||
paymentMadesPageSelector,
|
||||
@@ -54,3 +57,15 @@ export const getPaymentMadeByIdFactory = () =>
|
||||
createSelector(paymentMadesIds, (payment_Made) => {
|
||||
return payment_Made;
|
||||
});
|
||||
|
||||
export const getPaymentMadeEntriesDataFactory = () =>
|
||||
createSelector(
|
||||
billsItemsSelector,
|
||||
paymentMadeEntries,
|
||||
(billsItems, paymentEntries) => {
|
||||
return Array.isArray(paymentEntries) ?
|
||||
paymentEntries.map((entry) => ({
|
||||
...entry, ...(billsItems[entry.bill_id] || {}),
|
||||
})) : [];
|
||||
}
|
||||
)
|
||||
Reference in New Issue
Block a user