mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 21:00:31 +00:00
fix: add credited_amount & calculate remaining.
This commit is contained in:
@@ -2,7 +2,8 @@ import React from 'react';
|
||||
import { FastField, useFormikContext } from 'formik';
|
||||
import { Classes } from '@blueprintjs/core';
|
||||
import { T, TotalLines, TotalLine } from 'components';
|
||||
import { sumBy, subtract } from 'lodash';
|
||||
import { subtract } from 'lodash';
|
||||
import { getEntriesTotal } from 'containers/Entries/utils';
|
||||
import ReconcileCreditNoteEntriesTable from './ReconcileCreditNoteEntriesTable';
|
||||
import { useReconcileCreditNoteContext } from './ReconcileCreditNoteFormProvider';
|
||||
import { formattedAmount } from 'utils';
|
||||
@@ -21,11 +22,14 @@ export default function ReconcileCreditNoteFormFields() {
|
||||
|
||||
const { values } = useFormikContext();
|
||||
|
||||
// Calculate the total amount.
|
||||
const totalAmount = React.useMemo(() => {
|
||||
const total = sumBy(values.entries, 'amount');
|
||||
return subtract(credits_remaining, total);
|
||||
}, [values.entries]);
|
||||
// Calculate the total amount of credit entries.
|
||||
const totalAmount = React.useMemo(
|
||||
() => getEntriesTotal(values.entries),
|
||||
[values.entries],
|
||||
);
|
||||
|
||||
// Calculate the total amount of credit remaining.
|
||||
const creditsRemaining = subtract(credits_remaining, totalAmount);
|
||||
|
||||
return (
|
||||
<div className={Classes.DIALOG_BODY}>
|
||||
@@ -64,7 +68,7 @@ export default function ReconcileCreditNoteFormFields() {
|
||||
/>
|
||||
<TotalLine
|
||||
title={<T id={'reconcile_credit_note.dialog.remaining_credits'} />}
|
||||
value={formatted_credits_remaining}
|
||||
value={formattedAmount(creditsRemaining, currency_code)}
|
||||
/>
|
||||
</TotalLines>
|
||||
</div>
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import React from 'react';
|
||||
import { FastField, useFormikContext } from 'formik';
|
||||
import { Classes } from '@blueprintjs/core';
|
||||
import { sumBy, subtract } from 'lodash';
|
||||
import { subtract } from 'lodash';
|
||||
import { getEntriesTotal } from 'containers/Entries/utils';
|
||||
import { T, TotalLines, TotalLine } from 'components';
|
||||
import ReconcileVendorCreditEntriesTable from './ReconcileVendorCreditEntriesTable';
|
||||
import { useReconcileVendorCreditContext } from './ReconcileVendorCreditFormProvider';
|
||||
@@ -18,11 +19,14 @@ export default function ReconcileVendorCreditFormFields() {
|
||||
|
||||
const { values } = useFormikContext();
|
||||
|
||||
// Calculate the total amount.
|
||||
const totalAmount = React.useMemo(() => {
|
||||
const total = sumBy(values.entries, 'amount');
|
||||
return subtract(credits_remaining, total);
|
||||
}, [values.entries]);
|
||||
// Calculate the total amount of credit entries.
|
||||
const totalAmount = React.useMemo(
|
||||
() => getEntriesTotal(values.entries),
|
||||
[values.entries],
|
||||
);
|
||||
|
||||
// Calculate the total amount of credit remaining.
|
||||
const creditsRemaining = subtract(credits_remaining, totalAmount);
|
||||
|
||||
return (
|
||||
<div className={Classes.DIALOG_BODY}>
|
||||
@@ -62,7 +66,7 @@ export default function ReconcileVendorCreditFormFields() {
|
||||
title={
|
||||
<T id={'reconcile_vendor_credit.dialog.remaining_credits'} />
|
||||
}
|
||||
value={formatted_credits_remaining}
|
||||
value={formattedAmount(creditsRemaining, currency_code)}
|
||||
/>
|
||||
</TotalLines>
|
||||
</div>
|
||||
|
||||
@@ -137,7 +137,8 @@ export function StatusAccessor(bill) {
|
||||
animate={false}
|
||||
stripes={false}
|
||||
intent={Intent.PRIMARY}
|
||||
value={calculateStatus(bill.payment_amount, bill.amount)}
|
||||
value={calculateStatus(bill.credited_amount, bill.amount)}
|
||||
// value={calculateStatus(bill.payment_amount, bill.amount)}
|
||||
/>
|
||||
</If>
|
||||
</Choose.When>
|
||||
|
||||
@@ -64,7 +64,7 @@ export const statusAccessor = (row) => {
|
||||
animate={false}
|
||||
stripes={false}
|
||||
intent={Intent.PRIMARY}
|
||||
value={calculateStatus(row.payment_amount, row.balance)}
|
||||
value={calculateStatus(row.credited_amount, row.balance)}
|
||||
/>
|
||||
</If>
|
||||
</Choose.When>
|
||||
|
||||
Reference in New Issue
Block a user