WIP/ Feature : Estimate & Receipt & Bill & Invoice

This commit is contained in:
elforjani3
2020-08-12 21:19:52 +02:00
parent 58c6b5466c
commit c86f0b29bf
66 changed files with 4288 additions and 535 deletions

View File

@@ -29,9 +29,12 @@ export const submitInvoice = ({ form }) => {
export const deleteInvoice = ({ id }) => {
return (dispatch) =>
new Promise((resovle, reject) => {
ApiService.delete(`invoice/${id}`)
ApiService.delete(`sales/invoices/${id}`)
.then((response) => {
dispatch({ type: t.INVOICE_DELETE });
dispatch({
type: t.INVOICE_DELETE,
payload: { id },
});
resovle(response);
})
.catch((error) => {
@@ -46,7 +49,7 @@ export const editInvoice = (id, form) => {
dispatch({
type: t.SET_DASHBOARD_REQUEST_LOADING,
});
ApiService.post(`invoice/${id}`, form)
ApiService.post(`sales/invoices/${id}`, form)
.then((response) => {
dispatch({
type: t.SET_DASHBOARD_REQUEST_COMPLETED,
@@ -64,39 +67,39 @@ export const editInvoice = (id, form) => {
});
});
};
export const fetchInvoicesTable = ({ query = {} }) => {
return (dispatch, getState) =>
new Promise((resolve, rejcet) => {
const pageQuery = getState().invoices.tableQuery;
export const fetchInvoicesTable = ({ query } = {}) => {
return (dispatch, getState) =>
new Promise((resolve, reject) => {
const pageQuery = getState().sales_invoices.tableQuery;
dispatch({
type: t.INVOICES_TABLE_LOADING,
payload: {
loading: true,
},
});
ApiService.get('invoices', {
ApiService.get('sales/invoices', {
params: { ...pageQuery, ...query },
})
.then((response) => {
dispatch({
type: t.INVOICES_PAGE_SET,
payload: {
invoices: response.data.invoices.results,
pagination: response.data.invoices.pagination,
sales_invoices: response.data.sales_invoices.results,
pagination: response.data.sales_invoices.pagination,
customViewId: response.data.customViewId || -1,
},
});
dispatch({
type: t.INVOICES_ITEMS_SET,
payload: {
invoices: response.data.invoices.results,
sales_invoices: response.data.sales_invoices.results,
},
});
dispatch({
type: t.INVOICES_PAGINATION_SET,
payload: {
pagination: response.data.invoices.pagination,
pagination: response.data.sales_invoices.pagination,
customViewId: response.data.customViewId || -1,
},
});
@@ -109,7 +112,7 @@ export const fetchInvoicesTable = ({ query = {} }) => {
resolve(response);
})
.catch((error) => {
rejcet(error);
reject(error);
});
});
};
@@ -117,13 +120,13 @@ export const fetchInvoicesTable = ({ query = {} }) => {
export const fetchInvoice = ({ id }) => {
return (dispatch) =>
new Promise((resovle, reject) => {
ApiService.get(`invoices/${id}`)
ApiService.get(`sales/invoices/${id}`)
.then((response) => {
dispatch({
type: t.INVOICE_SET,
payload: {
id,
invoice: response.data.invoice,
sale_invoice: response.data.sale_invoice,
},
});
resovle(response);