From 05cc76b4f1184305f8a1a990464bcfcf76f0e6db Mon Sep 17 00:00:00 2001 From: Ahmed Bouhuolia Date: Tue, 7 Apr 2020 17:52:52 +0200 Subject: [PATCH] fix bugs in make journal page. --- .../components/DataTableCells/AccountsListFieldCell.js | 1 + client/src/components/DataTableCells/InputGroupCell.js | 4 ++-- client/src/components/DataTableCells/MoneyFieldCell.js | 7 ++++++- .../Dashboard/Accounting/MakeJournalEntriesFooter.js | 3 +++ .../Dashboard/Accounting/MakeJournalEntriesForm.js | 9 +++++---- 5 files changed, 17 insertions(+), 7 deletions(-) diff --git a/client/src/components/DataTableCells/AccountsListFieldCell.js b/client/src/components/DataTableCells/AccountsListFieldCell.js index 10118bbfa..70b2d1d2e 100644 --- a/client/src/components/DataTableCells/AccountsListFieldCell.js +++ b/client/src/components/DataTableCells/AccountsListFieldCell.js @@ -11,6 +11,7 @@ import { const AccountCellRenderer = ({ column: { id, value }, row: { index, original }, + cell: { value: initialValue }, payload: { accounts, updateData, errors }, }) => { const handleAccountSelected = useCallback((account) => { diff --git a/client/src/components/DataTableCells/InputGroupCell.js b/client/src/components/DataTableCells/InputGroupCell.js index 6e45064f7..86503eabb 100644 --- a/client/src/components/DataTableCells/InputGroupCell.js +++ b/client/src/components/DataTableCells/InputGroupCell.js @@ -4,9 +4,9 @@ import { } from '@blueprintjs/core'; const InputEditableCell = ({ - value: initialValue, row: { index }, - column: { id }, + column: { id, }, + cell: { value: initialValue }, payload, }) => { const [value, setValue] = useState(initialValue) diff --git a/client/src/components/DataTableCells/MoneyFieldCell.js b/client/src/components/DataTableCells/MoneyFieldCell.js index cfe7a182b..627433754 100644 --- a/client/src/components/DataTableCells/MoneyFieldCell.js +++ b/client/src/components/DataTableCells/MoneyFieldCell.js @@ -14,8 +14,13 @@ const MoneyFieldCellRenderer = ({ setValue(value); }, []); + function isNumeric(data) { + return !isNaN(parseFloat(data)) && isFinite(data) && data.constructor !== Array; + } + const onBlur = () => { - payload.updateData(index, id, parseFloat(value)); + const updateValue = isNumeric(value) ? parseFloat(value) : value; + payload.updateData(index, id, updateValue); }; return (