fix: BIG-206 Reconcilate credit note and vendor credit with invoices should amount to credit be max the invoice remaining amount.

This commit is contained in:
a.bouhuolia
2021-12-30 15:39:22 +02:00
parent 0bd11419bb
commit 0173630e80
6 changed files with 105 additions and 13 deletions

View File

@@ -57,10 +57,12 @@ export default function ReconcileCreditNoteFormFields() {
* @returns {React.JSX}
*/
function ReconcileCreditNoteTotalLines() {
// Reconcile credit note context.
const {
creditNote: { credits_remaining, currency_code },
} = useReconcileCreditNoteContext();
// Formik form context.
const { values } = useFormikContext();
// Calculate the total amount of credit entries.
@@ -68,7 +70,6 @@ function ReconcileCreditNoteTotalLines() {
() => getEntriesTotal(values.entries),
[values.entries],
);
// Calculate the total amount of credit remaining.
const creditsRemaining = subtract(credits_remaining, totalAmount);