mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 22:00:31 +00:00
refactoring: WIP payment receive and made form.
This commit is contained in:
@@ -119,3 +119,26 @@ export function useOpenBill(props) {
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the due bills of the given vendor id.
|
||||
* @param {number} vendorId -
|
||||
*/
|
||||
export function useDueBills(vendorId, props) {
|
||||
const states = useQuery(
|
||||
['BILLS_DUE', vendorId],
|
||||
() =>
|
||||
ApiService.get(`purchases/bills/due`, {
|
||||
params: { vendor_id: vendorId },
|
||||
}),
|
||||
{
|
||||
select: (res) => res.data.bills,
|
||||
...props,
|
||||
},
|
||||
);
|
||||
|
||||
return {
|
||||
...states,
|
||||
data: defaultTo(states.data, []),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -77,8 +77,8 @@ export function useInvoices(query, props) {
|
||||
total: 0,
|
||||
},
|
||||
filterMeta: {},
|
||||
})
|
||||
}
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -87,27 +87,25 @@ export function useInvoices(query, props) {
|
||||
export function useDeliverInvoice(props) {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation(
|
||||
(id) => ApiService.post(`sales/invoices/${id}/deliver`),
|
||||
{
|
||||
onSuccess: (res, id) => {
|
||||
queryClient.invalidateQueries('SALE_INVOICES');
|
||||
queryClient.invalidateQueries(['SALE_INVOICE', id]);
|
||||
},
|
||||
...props,
|
||||
return useMutation((id) => ApiService.post(`sales/invoices/${id}/deliver`), {
|
||||
onSuccess: (res, id) => {
|
||||
queryClient.invalidateQueries('SALE_INVOICES');
|
||||
queryClient.invalidateQueries(['SALE_INVOICE', id]);
|
||||
},
|
||||
);
|
||||
...props,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the sale invoice details.
|
||||
*/
|
||||
export function useInvoice(id, props) {
|
||||
const states = useQuery(['SALE_INVOICE', id], () =>
|
||||
ApiService.get(`sales/invoices/${id}`),
|
||||
{
|
||||
const states = useQuery(
|
||||
['SALE_INVOICE', id],
|
||||
() => ApiService.get(`sales/invoices/${id}`),
|
||||
{
|
||||
select: (res) => res.data.sale_invoice,
|
||||
...props
|
||||
...props,
|
||||
},
|
||||
);
|
||||
|
||||
@@ -116,3 +114,26 @@ export function useInvoice(id, props) {
|
||||
data: defaultTo(states.data, {}),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve due invoices of the given customer id.
|
||||
* @param {number} customerId - Customer id.
|
||||
*/
|
||||
export function useDueInvoices(customerId, props) {
|
||||
const states = useQuery(
|
||||
['SALE_INVOICE_DUE', customerId],
|
||||
() =>
|
||||
ApiService.get(`sales/invoices/payable`, {
|
||||
params: { customer_id: customerId },
|
||||
}),
|
||||
{
|
||||
select: (res) => res.data.sales_invoices,
|
||||
...props,
|
||||
},
|
||||
);
|
||||
|
||||
return {
|
||||
...states,
|
||||
data: defaultTo(states.data, []),
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user