mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 06:10:31 +00:00
feature : Puschases & Sales / fix : tasks
This commit is contained in:
@@ -4,22 +4,13 @@ import t from 'store/types';
|
||||
export const submitInvoice = ({ form }) => {
|
||||
return (dispatch) =>
|
||||
new Promise((resolve, reject) => {
|
||||
dispatch({
|
||||
type: t.SET_DASHBOARD_REQUEST_LOADING,
|
||||
});
|
||||
ApiService.post('sales/invoices', form)
|
||||
.then((response) => {
|
||||
dispatch({
|
||||
type: t.SET_DASHBOARD_REQUEST_COMPLETED,
|
||||
});
|
||||
resolve(response);
|
||||
})
|
||||
.catch((error) => {
|
||||
const { response } = error;
|
||||
const { data } = response;
|
||||
dispatch({
|
||||
type: t.SET_DASHBOARD_REQUEST_COMPLETED,
|
||||
});
|
||||
|
||||
reject(data?.errors);
|
||||
});
|
||||
@@ -51,18 +42,12 @@ export const editInvoice = (id, form) => {
|
||||
});
|
||||
ApiService.post(`sales/invoices/${id}`, form)
|
||||
.then((response) => {
|
||||
dispatch({
|
||||
type: t.SET_DASHBOARD_REQUEST_COMPLETED,
|
||||
});
|
||||
resolve(response);
|
||||
})
|
||||
.catch((error) => {
|
||||
const { response } = error;
|
||||
const { data } = response;
|
||||
|
||||
dispatch({
|
||||
type: t.SET_DASHBOARD_REQUEST_COMPLETED,
|
||||
});
|
||||
reject(data?.errors);
|
||||
});
|
||||
});
|
||||
@@ -71,7 +56,7 @@ export const editInvoice = (id, form) => {
|
||||
export const fetchInvoicesTable = ({ query } = {}) => {
|
||||
return (dispatch, getState) =>
|
||||
new Promise((resolve, reject) => {
|
||||
const pageQuery = getState().sales_invoices.tableQuery;
|
||||
const pageQuery = getState().salesInvoices.tableQuery;
|
||||
dispatch({
|
||||
type: t.INVOICES_TABLE_LOADING,
|
||||
payload: {
|
||||
@@ -90,6 +75,7 @@ export const fetchInvoicesTable = ({ query } = {}) => {
|
||||
customViewId: response.data.customViewId || -1,
|
||||
},
|
||||
});
|
||||
|
||||
dispatch({
|
||||
type: t.INVOICES_ITEMS_SET,
|
||||
payload: {
|
||||
@@ -138,3 +124,26 @@ export const fetchInvoice = ({ id }) => {
|
||||
});
|
||||
});
|
||||
};
|
||||
export const dueInvoices = ({ id }) => {
|
||||
return (dispatch) =>
|
||||
new Promise((resovle, reject) => {
|
||||
ApiService.get(`sales/invoices/due_invoices`, {
|
||||
params: { customer_id: id },
|
||||
})
|
||||
.then((response) => {
|
||||
dispatch({
|
||||
type: t.DUE_INVOICES_SET,
|
||||
payload: {
|
||||
customer_id: id,
|
||||
due_sales_invoices: response.data.due_sales_invoices,
|
||||
},
|
||||
});
|
||||
resovle(response);
|
||||
})
|
||||
.catch((error) => {
|
||||
const { response } = error;
|
||||
const { data } = response;
|
||||
reject(data?.errors);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user