- feat: Filter expense and payment accounts on expense form.

- feat: Make journal errors with receivable and payable accounts.
- fix: Handle database big numbers.
- fix: Indexing lines when add a new line on make journal form.
- fix: Abstruct accounts type component.
This commit is contained in:
Ahmed Bouhuolia
2020-07-06 21:22:27 +02:00
parent 3fc390652d
commit 282da55d08
40 changed files with 1031 additions and 747 deletions

View File

@@ -61,36 +61,6 @@ function ExpenseFormHeader({
}
};
// Account item of select accounts field.
const accountItem = (item, { handleClick }) => {
return (
<MenuItem
key={item.id}
text={item.name}
label={item.code}
onClick={handleClick}
/>
);
};
// Filters accounts items.
// @filter accounts predicator resauble
const filterAccountsPredicater = useCallback(
(query, account, _index, exactMatch) => {
const normalizedTitle = account.name.toLowerCase();
const normalizedQuery = query.toLowerCase();
if (exactMatch) {
return normalizedTitle === normalizedQuery;
} else {
return (
`${account.code} ${normalizedTitle}`.indexOf(normalizedQuery) >= 0
);
}
},
[],
);
// Handles change account.
const onChangeAccount = useCallback(
(account) => {
@@ -112,6 +82,12 @@ function ExpenseFormHeader({
[setFieldValue, selectedItems],
);
// Filter payment accounts.
const paymentAccounts = useMemo(
() => accountsList.filter(a => a?.type?.key === 'current_asset'),
[accountsList],
);
return (
<div className={'dashboard__insider--expense-form__header'}>
<Row>
@@ -165,7 +141,7 @@ function ExpenseFormHeader({
}
>
<AccountsSelectList
accounts={accountsList}
accounts={paymentAccounts}
onAccountSelected={onChangeAccount}
defaultSelectText={<T id={'select_payment_account'} />}
selectedAccountId={values.payment_account_id}