Merge pull request #754 from bigcapitalhq/adjust-decimal-manual-entry

fix: make manual entries adjust decimal credit/debit amounts
This commit is contained in:
Ahmed Bouhuolia
2024-11-13 18:16:37 +02:00
committed by GitHub

View File

@@ -4,7 +4,7 @@ import * as R from 'ramda';
import moment from 'moment'; import moment from 'moment';
import intl from 'react-intl-universal'; import intl from 'react-intl-universal';
import { Intent } from '@blueprintjs/core'; import { Intent } from '@blueprintjs/core';
import { sumBy, setWith, toSafeInteger, get, first } from 'lodash'; import { sumBy, setWith, get, first, toNumber } from 'lodash';
import { import {
updateTableCell, updateTableCell,
repeatValue, repeatValue,
@@ -91,8 +91,8 @@ export function transformToEditForm(manualJournal) {
* Entries adjustment. * Entries adjustment.
*/ */
function adjustmentEntries(entries) { function adjustmentEntries(entries) {
const credit = sumBy(entries, (e) => toSafeInteger(e.credit)); const credit = sumBy(entries, (e) => toNumber(e.credit));
const debit = sumBy(entries, (e) => toSafeInteger(e.debit)); const debit = sumBy(entries, (e) => toNumber(e.debit));
return { return {
debit: Math.max(credit - debit, 0), debit: Math.max(credit - debit, 0),