mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 14:20:31 +00:00
fix: Tax rate not saving on creating a new invoice
This commit is contained in:
@@ -70,6 +70,17 @@ export const defaultInvoice = {
|
|||||||
attachments: [],
|
attachments: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Invoice entry request schema.
|
||||||
|
export const defaultReqInvoiceEntry = {
|
||||||
|
index: 0,
|
||||||
|
item_id: '',
|
||||||
|
rate: '',
|
||||||
|
discount: '',
|
||||||
|
quantity: '',
|
||||||
|
description: '',
|
||||||
|
tax_rate_id: '',
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transform invoice to initial values in edit mode.
|
* Transform invoice to initial values in edit mode.
|
||||||
*/
|
*/
|
||||||
@@ -175,13 +186,27 @@ export const ITEMS_FILTER_ROLES_QUERY = JSON.stringify([
|
|||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Transformes bill entries to submit request.
|
||||||
|
*/
|
||||||
|
const transformEntriesToRequest = (entries) => {
|
||||||
|
return R.compose(
|
||||||
|
R.map(R.compose(R.curry(transformToForm)(R.__, defaultReqInvoiceEntry))),
|
||||||
|
filterNonZeroEntries,
|
||||||
|
)(entries);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filters the givne non-zero entries.
|
||||||
|
*/
|
||||||
|
const filterNonZeroEntries = (entries) => {
|
||||||
|
return entries.filter((item) => item.item_id && item.quantity);
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transformes the form values to request body values.
|
* Transformes the form values to request body values.
|
||||||
*/
|
*/
|
||||||
export function transformValueToRequest(values) {
|
export function transformValueToRequest(values) {
|
||||||
const entries = values.entries.filter(
|
|
||||||
(item) => item.item_id && item.quantity,
|
|
||||||
);
|
|
||||||
return {
|
return {
|
||||||
...omit(values, [
|
...omit(values, [
|
||||||
'invoice_no',
|
'invoice_no',
|
||||||
@@ -194,9 +219,7 @@ export function transformValueToRequest(values) {
|
|||||||
invoice_no: values.invoice_no,
|
invoice_no: values.invoice_no,
|
||||||
}),
|
}),
|
||||||
is_inclusive_tax: values.inclusive_exclusive_tax === TaxType.Inclusive,
|
is_inclusive_tax: values.inclusive_exclusive_tax === TaxType.Inclusive,
|
||||||
entries: entries.map((entry) => ({
|
entries: transformEntriesToRequest(values.entries),
|
||||||
...omit(entry, ['amount', 'tax_amount', 'tax_rate']),
|
|
||||||
})),
|
|
||||||
delivered: false,
|
delivered: false,
|
||||||
attachments: transformAttachmentsToRequest(values),
|
attachments: transformAttachmentsToRequest(values),
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user