mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-20 14:50:32 +00:00
feat: payment made form in new and edit mode.
This commit is contained in:
@@ -123,11 +123,19 @@ export const fetchDueBills = ({ vendorId }) => (dispatch) => new Promise((resolv
|
||||
|
||||
ApiService.get(`purchases/bills/due`, { params }).then((response) => {
|
||||
dispatch({
|
||||
type: t.DUE_BILLS_SET,
|
||||
type: t.BILLS_ITEMS_SET,
|
||||
payload: {
|
||||
bills: response.data.bills,
|
||||
}
|
||||
},
|
||||
});
|
||||
if ( vendorId ) {
|
||||
dispatch({
|
||||
type: t.BILLS_PAYABLE_BY_VENDOR_ID,
|
||||
payload: {
|
||||
bills: response.data.bills,
|
||||
}
|
||||
});
|
||||
}
|
||||
resolve(response);
|
||||
}).catch(error => { reject(error) });
|
||||
});
|
||||
@@ -13,7 +13,10 @@ const initialState = {
|
||||
page: 1,
|
||||
},
|
||||
nextBillNumberChanged: false,
|
||||
dueBills: {},
|
||||
payable: {
|
||||
byVendorId: [],
|
||||
byBillPayamentId: [],
|
||||
},
|
||||
};
|
||||
|
||||
const defaultBill = {
|
||||
@@ -105,23 +108,31 @@ const reducer = createReducer(initialState, {
|
||||
state.nextBillNumberChanged = isChanged;
|
||||
},
|
||||
|
||||
[t.DUE_BILLS_SET]: (state, action) => {
|
||||
[t.BILLS_PAYABLE_BY_VENDOR_ID]: (state, action) => {
|
||||
const { bills } = action.payload;
|
||||
|
||||
const _dueBills = { ...state.dueBills };
|
||||
const _bills = { ...state.items };
|
||||
const _data = {};
|
||||
|
||||
bills.forEach((bill) => {
|
||||
_bills[bill.id] = { ...bill };
|
||||
|
||||
if (!_dueBills[bill.vendor_id]) {
|
||||
_dueBills[bill.vendor_id] = []
|
||||
if (!_data[bill.vendor_id]) {
|
||||
_data[bill.vendor_id] = [];
|
||||
}
|
||||
_dueBills[bill.vendor_id].push(bill.id);
|
||||
_data[bill.vendor_id].push(bill.id);
|
||||
});
|
||||
|
||||
state.items = { ..._bills };
|
||||
state.dueBills = { ..._dueBills };
|
||||
state.payable.byVendorId = {
|
||||
...state.payable.byVendorId,
|
||||
..._data,
|
||||
};
|
||||
},
|
||||
|
||||
[t.BILLS_PAYABLE_BY_PAYMENT_ID]: (state, action) => {
|
||||
const { bills, billPaymentId } = action.payload;
|
||||
const _data = [];
|
||||
|
||||
bills.forEach((bill) => {
|
||||
_data.push(bill.id);
|
||||
});
|
||||
state.payable.byBillPayamentId[billPaymentId] = _data;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -19,7 +19,10 @@ const billByIdSelector = (state, props) => state.bills.items[props.billId];
|
||||
* Retrieve vendor due bills ids.
|
||||
* @return {number[]}
|
||||
*/
|
||||
const billsDueVendorSelector = (state, props) => state.bills.dueBills[props.vendorId];
|
||||
const billsPayableVendorSelector = (state, props) => state.bills.payable.byVendorId[props.vendorId];
|
||||
const billsPayableByPaymentMadeSelector = (state, props) => {
|
||||
return state.bills.payable.byBillPayamentId[props.paymentMadeId];
|
||||
}
|
||||
|
||||
const billPaginationSelector = (state, props) => {
|
||||
const viewId = state.bills.currentViewId;
|
||||
@@ -62,16 +65,26 @@ export const getBillPaginationMetaFactory = () =>
|
||||
return billPage?.paginationMeta || {};
|
||||
});
|
||||
|
||||
/**
|
||||
* Retrieve due bills of specific vendor.
|
||||
*/
|
||||
export const getVendorDueBillsFactory = () =>
|
||||
|
||||
export const getVendorPayableBillsFactory = () =>
|
||||
createSelector(
|
||||
billItemsSelector,
|
||||
billsDueVendorSelector,
|
||||
(billsItems, dueBillsIds) => {
|
||||
return Array.isArray(dueBillsIds)
|
||||
? pickItemsFromIds(billsItems, dueBillsIds) || []
|
||||
billsPayableVendorSelector,
|
||||
(billsItems, payableBillsIds) => {
|
||||
return Array.isArray(payableBillsIds)
|
||||
? pickItemsFromIds(billsItems, payableBillsIds) || []
|
||||
: [];
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
export const getPayableBillsByPaymentMadeFactory = () =>
|
||||
createSelector(
|
||||
billItemsSelector,
|
||||
billsPayableByPaymentMadeSelector,
|
||||
(billsItems, payableBillsIds) => {
|
||||
return Array.isArray(payableBillsIds)
|
||||
? pickItemsFromIds(billsItems, payableBillsIds) || []
|
||||
: [];
|
||||
},
|
||||
);
|
||||
@@ -10,5 +10,7 @@ export default {
|
||||
BILLS_PAGE_SET: 'BILLS_PAGE_SET',
|
||||
BILLS_ITEMS_SET: 'BILLS_ITEMS_SET',
|
||||
BILL_NUMBER_CHANGED: 'BILL_NUMBER_CHANGED',
|
||||
DUE_BILLS_SET: 'DUE_BILLS_SET'
|
||||
|
||||
BILLS_PAYABLE_BY_PAYMENT_ID: 'BILLS_PAYABLE_BY_PAYMENT_ID',
|
||||
BILLS_PAYABLE_BY_VENDOR_ID: 'BILLS_PAYABLE_BY_VENDOR_ID',
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user