mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 05:40:31 +00:00
refactor: implementing new formatted amount hooks
This commit is contained in:
@@ -5,7 +5,7 @@ import { useFormikContext } from 'formik';
|
||||
import { T, TotalLines, TotalLine, TotalLineTextStyle } from '@/components';
|
||||
import {
|
||||
useVendorCreditAdjustmentAmountFormatted,
|
||||
useVendorCreditDiscountAmount,
|
||||
useVendorCreditDiscountAmountFormatted,
|
||||
useVendorCreditSubtotalFormatted,
|
||||
useVendorCreditTotalFormatted,
|
||||
} from './utils';
|
||||
@@ -19,8 +19,8 @@ export function VendorCreditNoteFormFooterRight() {
|
||||
const totalFormatted = useVendorCreditTotalFormatted();
|
||||
const subtotalFormatted = useVendorCreditSubtotalFormatted();
|
||||
|
||||
const discountAmount = useVendorCreditDiscountAmount();
|
||||
const adjustmentAmount = useVendorCreditAdjustmentAmountFormatted();
|
||||
const discountAmountFormatted = useVendorCreditDiscountAmountFormatted();
|
||||
const adjustmentAmountFormatted = useVendorCreditAdjustmentAmountFormatted();
|
||||
|
||||
return (
|
||||
<VendorCreditNoteTotalLines
|
||||
@@ -33,9 +33,9 @@ export function VendorCreditNoteFormFooterRight() {
|
||||
/>
|
||||
<DiscountTotalLine
|
||||
currencyCode={currency_code}
|
||||
discountAmount={discountAmount}
|
||||
discountAmount={discountAmountFormatted}
|
||||
/>
|
||||
<AdjustmentTotalLine adjustmentAmount={adjustmentAmount} />
|
||||
<AdjustmentTotalLine adjustmentAmount={adjustmentAmountFormatted} />
|
||||
<TotalLine
|
||||
title={<T id={'vendor_credit_form.label.total'} />}
|
||||
value={totalFormatted}
|
||||
|
||||
@@ -185,32 +185,6 @@ export const useSetPrimaryWarehouseToForm = () => {
|
||||
}, [isWarehousesSuccess, setFieldValue, warehouses]);
|
||||
};
|
||||
|
||||
export const useVendorCrditNoteTotals = () => {
|
||||
const {
|
||||
values: { entries, currency_code: currencyCode },
|
||||
} = useFormikContext();
|
||||
|
||||
// Retrieves the invoice entries total.
|
||||
const total = React.useMemo(() => getEntriesTotal(entries), [entries]);
|
||||
|
||||
// Retrieves the formatted total money.
|
||||
const formattedTotal = React.useMemo(
|
||||
() => formattedAmount(total, currencyCode),
|
||||
[total, currencyCode],
|
||||
);
|
||||
// Retrieves the formatted subtotal.
|
||||
const formattedSubtotal = React.useMemo(
|
||||
() => formattedAmount(total, currencyCode, { money: false }),
|
||||
[total, currencyCode],
|
||||
);
|
||||
|
||||
return {
|
||||
total,
|
||||
formattedTotal,
|
||||
formattedSubtotal,
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieves the vendor credit subtotal.
|
||||
* @returns {number}
|
||||
|
||||
Reference in New Issue
Block a user