mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 21:30:31 +00:00
fix: update financial forms to use new formatted amount utilities and add adjustment fields
This commit is contained in:
@@ -2,33 +2,23 @@
|
||||
import React from 'react';
|
||||
import intl from 'react-intl-universal';
|
||||
import classNames from 'classnames';
|
||||
import { useFormikContext } from 'formik';
|
||||
import { CLASSES } from '@/constants/classes';
|
||||
import VendorCreditNoteFormHeaderFields from './VendorCreditNoteFormHeaderFields';
|
||||
|
||||
import { getEntriesTotal } from '@/containers/Entries/utils';
|
||||
import { PageFormBigNumber } from '@/components';
|
||||
|
||||
import { useVendorCreditTotalFormatted } from './utils';
|
||||
|
||||
/**
|
||||
* Vendor Credit note header.
|
||||
*/
|
||||
function VendorCreditNoteFormHeader() {
|
||||
const { values:{entries ,currency_code} } = useFormikContext();
|
||||
|
||||
// Calculate the total amount.
|
||||
const totalAmount = React.useMemo(
|
||||
() => getEntriesTotal(entries),
|
||||
[entries],
|
||||
);
|
||||
const totalFormatted = useVendorCreditTotalFormatted();
|
||||
|
||||
return (
|
||||
<div className={classNames(CLASSES.PAGE_FORM_HEADER)}>
|
||||
<VendorCreditNoteFormHeaderFields />
|
||||
<PageFormBigNumber
|
||||
label={intl.get('vendor_credits.label.amount_to_credit')}
|
||||
amount={totalAmount}
|
||||
currencyCode={currency_code}
|
||||
amount={totalFormatted}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -206,8 +206,12 @@ export const useVendorCreditSubtotal = () => {
|
||||
*/
|
||||
export const useVendorCreditDiscountAmount = () => {
|
||||
const { values } = useFormikContext();
|
||||
const subtotal = useVendorCreditSubtotal();
|
||||
const discount = toSafeNumber(values.discount);
|
||||
|
||||
return toSafeNumber(values.discount);
|
||||
return values.discount_type === 'percentage'
|
||||
? (subtotal * discount) / 100
|
||||
: discount;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user