refactoring: WIP payment receive and made form.

This commit is contained in:
a.bouhuolia
2021-02-16 17:31:18 +02:00
parent a75177b9d1
commit d60429f5e0
17 changed files with 441 additions and 657 deletions

View File

@@ -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, []),
};
}

View File

@@ -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, []),
};
}