mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 21:30:31 +00:00
BIG-125: prevent items entries from send amount computed attribute.
This commit is contained in:
@@ -8,6 +8,7 @@ import {
|
||||
transformToForm,
|
||||
repeatValue,
|
||||
ensureEntriesHasEmptyLine,
|
||||
orderingLinesIndexes
|
||||
} from 'utils';
|
||||
|
||||
const ERROR = {
|
||||
@@ -104,3 +105,25 @@ export const accountsFieldShouldUpdate = (newProps, oldProps) => {
|
||||
defaultFastFieldShouldUpdate(newProps, oldProps)
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Filter expense entries that has no amount or expense account.
|
||||
*/
|
||||
export const filterNonZeroEntries = (categories) => {
|
||||
return categories.filter(
|
||||
(category) => category.amount && category.expense_account_id,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Transformes the form values to request body.
|
||||
*/
|
||||
export const transformFormValuesToRequest = (values) => {
|
||||
const categories = filterNonZeroEntries(values.categories);
|
||||
|
||||
return {
|
||||
...values,
|
||||
categories: R.compose(orderingLinesIndexes)(categories),
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user