mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 14:20:31 +00:00
fix: update financial forms to use new formatted amount utilities and add adjustment fields
This commit is contained in:
@@ -1,10 +1,9 @@
|
||||
// @ts-nocheck
|
||||
import React from 'react';
|
||||
import intl from 'react-intl-universal';
|
||||
import { useFormikContext } from 'formik';
|
||||
import { Group, PageFormBigNumber } from '@/components';
|
||||
import InvoiceFormHeaderFields from './InvoiceFormHeaderFields';
|
||||
import { useInvoiceDueAmount } from './utils';
|
||||
import { useInvoiceTotalFormatted } from './utils';
|
||||
|
||||
/**
|
||||
* Invoice form header section.
|
||||
@@ -29,19 +28,11 @@ function InvoiceFormHeader() {
|
||||
* @returns {React.ReactNode}
|
||||
*/
|
||||
function InvoiceFormBigTotal() {
|
||||
const {
|
||||
values: { currency_code },
|
||||
} = useFormikContext();
|
||||
|
||||
// Calculate the total due amount of invoice entries.
|
||||
const totalDueAmount = useInvoiceDueAmount();
|
||||
const totalFormatted = useInvoiceTotalFormatted();
|
||||
|
||||
return (
|
||||
<PageFormBigNumber
|
||||
label={intl.get('due_amount')}
|
||||
amount={totalDueAmount}
|
||||
currencyCode={currency_code}
|
||||
/>
|
||||
<PageFormBigNumber label={intl.get('due_amount')} amount={totalFormatted} />
|
||||
);
|
||||
}
|
||||
export default InvoiceFormHeader;
|
||||
|
||||
@@ -324,7 +324,7 @@ export const useInvoiceSubtotalFormatted = () => {
|
||||
export const useInvoiceDiscountAmount = () => {
|
||||
const { values } = useFormikContext();
|
||||
const subtotal = useInvoiceSubtotal();
|
||||
const discount = parseFloat(values.discount);
|
||||
const discount = toSafeNumber(values.discount);
|
||||
|
||||
return values?.discount_type === 'percentage'
|
||||
? (subtotal * discount) / 100
|
||||
@@ -350,7 +350,7 @@ export const useInvoiceDiscountAmountFormatted = () => {
|
||||
*/
|
||||
export const useInvoiceAdjustmentAmount = () => {
|
||||
const { values } = useFormikContext();
|
||||
const adjustment = parseFloat(values.adjustment);
|
||||
const adjustment = toSafeNumber(values.adjustment);
|
||||
|
||||
return adjustment;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user