mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-15 12:20: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>
|
||||
|
||||
@@ -1579,7 +1579,7 @@
|
||||
"credit_note_opened.are_sure_to_open_this_credit": "Are you sure you want to open this credit note?",
|
||||
"vendor_credit_opened.alert.success_message": "The vendor credit has been opened successfully",
|
||||
"vendor_credit_opened.are_sure_to_open_this_credit": "Are you sure you want to open this vendor credit?",
|
||||
"reconcile_credit_note.label": "Reconcile credit note with invoices.",
|
||||
"reconcile_credit_note.label": "Reconcile credit note with invoices",
|
||||
"reconcile_credit_note.dialog.total_amount_to_credit": "Total amount to credit",
|
||||
"reconcile_credit_note.dialog.credits_balance": "Credits balance:",
|
||||
"reconcile_credit_note.dialog.remaining_credits": "Remaining credits",
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
.bp3-dialog-body {
|
||||
.footer {
|
||||
display: flex;
|
||||
margin-top: 40px;
|
||||
margin-top: 20px;
|
||||
|
||||
.total_lines {
|
||||
margin-left: auto;
|
||||
@@ -17,7 +17,7 @@
|
||||
.amount,
|
||||
.title {
|
||||
padding: 8px 0px;
|
||||
width: 165px;
|
||||
width: 150px;
|
||||
}
|
||||
.amount {
|
||||
text-align: right;
|
||||
|
||||
Reference in New Issue
Block a user