mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 21:30:31 +00:00
WIP / Feature Fix _bills
This commit is contained in:
136
client/src/store/Bills/bills.actions.js
Normal file
136
client/src/store/Bills/bills.actions.js
Normal file
@@ -0,0 +1,136 @@
|
||||
import ApiService from 'services/ApiService';
|
||||
import t from 'store/types';
|
||||
|
||||
export const fetchBillsTable = ({ query = {} }) => {
|
||||
return (dispatch, getState) =>
|
||||
new Promise((resolve, rejcet) => {
|
||||
const pageQuery = getState().bill.tableQuery;
|
||||
|
||||
dispatch({
|
||||
type: t.BILLS_TABLE_LOADING,
|
||||
payload: {
|
||||
loading: true,
|
||||
},
|
||||
});
|
||||
ApiService.get('bills', {
|
||||
params: { ...pageQuery, ...query },
|
||||
})
|
||||
.then((response) => {
|
||||
dispatch({
|
||||
type: t.BILLS_PAGE_SET,
|
||||
payload: {
|
||||
bills: response.data.bills.results,
|
||||
pagination: response.data.bills.pagination,
|
||||
customViewId: response.data.customViewId || -1,
|
||||
},
|
||||
});
|
||||
dispatch({
|
||||
type: t.BILLS_ITEMS_SET,
|
||||
payload: {
|
||||
bills: response.data.bills.results,
|
||||
},
|
||||
});
|
||||
dispatch({
|
||||
type: t.BILLS_PAGINATION_SET,
|
||||
payload: {
|
||||
pagination: response.data.bills.pagination,
|
||||
customViewId: response.data.customViewId || -1,
|
||||
},
|
||||
});
|
||||
dispatch({
|
||||
type: t.BILLS_TABLE_LOADING,
|
||||
payload: {
|
||||
loading: false,
|
||||
},
|
||||
});
|
||||
resolve(response);
|
||||
})
|
||||
.catch((error) => {
|
||||
rejcet(error);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
export const deleteBill = ({ id }) => {
|
||||
return (dispatch) =>
|
||||
new Promise((resovle, reject) => {
|
||||
ApiService.delete(`bills/${id}`)
|
||||
.then((response) => {
|
||||
dispatch({ type: t.BILL_DELETE });
|
||||
resovle(response);
|
||||
})
|
||||
.catch((error) => {
|
||||
reject(error.response.data.errors || []);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
export const submitBill = ({ form }) => {
|
||||
return (dispatch) =>
|
||||
new Promise((resolve, reject) => {
|
||||
dispatch({
|
||||
type: t.SET_DASHBOARD_REQUEST_LOADING,
|
||||
});
|
||||
ApiService.post('bills', 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);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
export const fetchBill = ({ id }) => {
|
||||
return (dispatch) =>
|
||||
new Promise((resovle, reject) => {
|
||||
ApiService.get(`bills/${id}`)
|
||||
.then((response) => {
|
||||
dispatch({
|
||||
type: t.BILL_SET,
|
||||
payload: {
|
||||
id,
|
||||
bill: response.data.bill,
|
||||
},
|
||||
});
|
||||
resovle(response);
|
||||
})
|
||||
.catch((error) => {
|
||||
const { response } = error;
|
||||
const { data } = response;
|
||||
reject(data?.errors);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
export const editBill = (id, form) => {
|
||||
return (dispatch) =>
|
||||
new Promise((resolve, rejcet) => {
|
||||
dispatch({
|
||||
type: t.SET_DASHBOARD_REQUEST_LOADING,
|
||||
});
|
||||
ApiService.post(`bills/${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,
|
||||
});
|
||||
rejcet(data?.errors);
|
||||
});
|
||||
});
|
||||
};
|
||||
0
client/src/store/Bills/bills.reducer.js
Normal file
0
client/src/store/Bills/bills.reducer.js
Normal file
6
client/src/store/Bills/bills.selectors.js
Normal file
6
client/src/store/Bills/bills.selectors.js
Normal file
@@ -0,0 +1,6 @@
|
||||
import { createSelector } from '@reduxjs/toolkit';
|
||||
|
||||
const billByIdSelector = (state, props) => state.bills.items[props.billId];
|
||||
|
||||
export const getBillById = () =>
|
||||
createSelector(billByIdSelector, (_bill) => _bill);
|
||||
12
client/src/store/Bills/bills.type.js
Normal file
12
client/src/store/Bills/bills.type.js
Normal file
@@ -0,0 +1,12 @@
|
||||
export default {
|
||||
BILL_DELETE: 'BILL_DELETE',
|
||||
BILLS_BULK_DELETE: 'BILLS_BULK_DELETE',
|
||||
BILLS_LIST_SET: 'BILLS_LIST_SET',
|
||||
BILL_SET: 'BILL_SET',
|
||||
BILLS_SET_CURRENT_VIEW: 'BILLS_SET_CURRENT_VIEW',
|
||||
BILLS_TABLE_QUERIES_ADD: 'BILLS_TABLE_QUERIES_ADD',
|
||||
BILLS_TABLE_LOADING: 'BILLS_TABLE_LOADING',
|
||||
BILLS_PAGINATION_SET: 'BILLS_PAGINATION_SET',
|
||||
BILLS_PAGE_SET: 'BILLS_PAGE_SET',
|
||||
BILLS_ITEMS_SET: 'BILLS_ITEMS_SET',
|
||||
};
|
||||
136
client/src/store/PaymentReceive/paymentReceive.actions.js
Normal file
136
client/src/store/PaymentReceive/paymentReceive.actions.js
Normal file
@@ -0,0 +1,136 @@
|
||||
import ApiService from 'services/ApiService';
|
||||
import t from 'store/types';
|
||||
|
||||
export const submitPaymentReceive = ({ form }) => {
|
||||
return (dispatch) =>
|
||||
new Promise((resolve, reject) => {
|
||||
dispatch({
|
||||
type: t.SET_DASHBOARD_REQUEST_LOADING,
|
||||
});
|
||||
ApiService.post('sales/payment_receives', 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);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
export const editPaymentReceive = (id, form) => {
|
||||
return (dispatch) =>
|
||||
new Promise((resolve, rejcet) => {
|
||||
dispatch({
|
||||
type: t.SET_DASHBOARD_REQUEST_LOADING,
|
||||
});
|
||||
ApiService.post(`sales/payment_receives/${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,
|
||||
});
|
||||
rejcet(data?.errors);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
export const deletePaymentReceive = ({ id }) => {
|
||||
return (dispatch) =>
|
||||
new Promise((resovle, reject) => {
|
||||
ApiService.delete(`payment_receives/${id}`)
|
||||
.then((response) => {
|
||||
dispatch({ type: t.PAYMENT_RECEIVE_DELETE });
|
||||
resovle(response);
|
||||
})
|
||||
.catch((error) => {
|
||||
reject(error.response.data.errors || []);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
export const fetchPaymentReceive = ({ id }) => {
|
||||
return (dispatch) =>
|
||||
new Promise((resovle, reject) => {
|
||||
ApiService.get(`payment_receives/${id}`)
|
||||
.then((response) => {
|
||||
dispatch({
|
||||
type: t.PAYMENT_RECEIVE_SET,
|
||||
payload: {
|
||||
id,
|
||||
payment_receive: response.data.payment_receive,
|
||||
},
|
||||
});
|
||||
resovle(response);
|
||||
})
|
||||
.catch((error) => {
|
||||
const { response } = error;
|
||||
const { data } = response;
|
||||
reject(data?.errors);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
export const fetchPaymentReceivesTable = ({ query = {} }) => {
|
||||
return (dispatch, getState) =>
|
||||
new Promise((resolve, rejcet) => {
|
||||
const pageQuery = getState().payment_receive.tableQuery;
|
||||
|
||||
dispatch({
|
||||
type: t.PAYMENT_RECEIVES_TABLE_LOADING,
|
||||
payload: {
|
||||
loading: true,
|
||||
},
|
||||
});
|
||||
ApiService.get('payment_receives', {
|
||||
params: { ...pageQuery, ...query },
|
||||
})
|
||||
.then((response) => {
|
||||
dispatch({
|
||||
type: t.RECEIPTS_PAGE_SET,
|
||||
payload: {
|
||||
payment_receives: response.data.payment_receives.results,
|
||||
pagination: response.data.payment_receives.pagination,
|
||||
customViewId: response.data.customViewId || -1,
|
||||
},
|
||||
});
|
||||
dispatch({
|
||||
type: t.PAYMENT_RECEIVES_ITEMS_SET,
|
||||
payload: {
|
||||
payment_receives: response.data.payment_receives.results,
|
||||
},
|
||||
});
|
||||
dispatch({
|
||||
type: t.PAYMENT_RECEIVES_PAGINATION_SET,
|
||||
payload: {
|
||||
pagination: response.data.payment_receives.pagination,
|
||||
customViewId: response.data.customViewId || -1,
|
||||
},
|
||||
});
|
||||
dispatch({
|
||||
type: t.PAYMENT_RECEIVES_TABLE_LOADING,
|
||||
payload: {
|
||||
loading: false,
|
||||
},
|
||||
});
|
||||
resolve(response);
|
||||
})
|
||||
.catch((error) => {
|
||||
rejcet(error);
|
||||
});
|
||||
});
|
||||
};
|
||||
11
client/src/store/PaymentReceive/paymentReceive.type.js
Normal file
11
client/src/store/PaymentReceive/paymentReceive.type.js
Normal file
@@ -0,0 +1,11 @@
|
||||
export default {
|
||||
PAYMENT_RECEIVE_LIST_SET: 'PAYMENT_RECEIVE_LIST_SET',
|
||||
PAYMENT_RECEIVE_SET: 'PAYMENT_RECEIVE_SET',
|
||||
PAYMENT_RECEIVE_DELETE: 'PAYMENT_RECEIVE_DELETE',
|
||||
PAYMENT_RECEIVE_SET_CURRENT_VIEW: 'PAYMENT_RECEIVE_SET_CURRENT_VIEW',
|
||||
PAYMENT_RECEIVE_TABLE_QUERIES_ADD: 'PAYMENT_RECEIVE_TABLE_QUERIES_ADD',
|
||||
PAYMENT_RECEIVES_TABLE_LOADING: 'PAYMENT_RECEIVES_TABLE_LOADING',
|
||||
PAYMENT_RECEIVES_PAGE_SET: 'PAYMENT_RECEIVES_PAGE_SET',
|
||||
PAYMENT_RECEIVES_ITEMS_SET: 'PAYMENT_RECEIVES_ITEMS_SET',
|
||||
PAYMENT_RECEIVES_PAGINATION_SET: 'PAYMENT_RECEIVES_PAGINATION_SET',
|
||||
};
|
||||
@@ -20,6 +20,8 @@ import customer from './customers/customers.type';
|
||||
import estimates from './Estimate/estimates.types';
|
||||
import invoices from './Invoice/invoices.types';
|
||||
import receipts from './receipt/receipt.type';
|
||||
import bills from './Bills/bills.type';
|
||||
import paymentReceives from './PaymentReceive/paymentReceive.type';
|
||||
|
||||
export default {
|
||||
...authentication,
|
||||
@@ -43,5 +45,7 @@ export default {
|
||||
...customer,
|
||||
...estimates,
|
||||
...invoices,
|
||||
...receipts
|
||||
...receipts,
|
||||
...bills,
|
||||
...paymentReceives,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user