feat: deliver status in invoice.

This commit is contained in:
elforjani3
2020-12-16 11:55:39 +02:00
parent 6388d4d48e
commit 57d05102a9
5 changed files with 84 additions and 26 deletions

View File

@@ -121,31 +121,35 @@ export const fetchInvoice = ({ id }) => {
});
};
export const fetchDueInvoices = ({ customerId }) => (dispatch) => new Promise((resovle, reject) => {
export const fetchDueInvoices = ({ customerId }) => (dispatch) =>
new Promise((resovle, reject) => {
ApiService.get(`sales/invoices/payable`, {
params: { customer_id: customerId },
})
.then((response) => {
dispatch({
type: t.INVOICES_ITEMS_SET,
payload: {
sales_invoices: response.data.sales_invoices,
},
});
if (customerId) {
.then((response) => {
dispatch({
type: t.INVOICES_RECEIVABLE_BY_CUSTOMER_ID,
type: t.INVOICES_ITEMS_SET,
payload: {
customerId,
saleInvoices: response.data.sales_invoices,
sales_invoices: response.data.sales_invoices,
},
});
}
resovle(response);
})
.catch((error) => {
const { response } = error;
const { data } = response;
reject(data?.errors);
});
if (customerId) {
dispatch({
type: t.INVOICES_RECEIVABLE_BY_CUSTOMER_ID,
payload: {
customerId,
saleInvoices: response.data.sales_invoices,
},
});
}
resovle(response);
})
.catch((error) => {
const { response } = error;
const { data } = response;
reject(data?.errors);
});
});
export const deliverInvoice = ({ id }) => {
return (dispatch) => ApiService.post(`sales/invoices/${id}/deliver`);
};