fix(webapp): update condition of customer opening balance

This commit is contained in:
Ahmed Bouhuolia
2023-06-11 20:09:51 +02:00
parent 728729094a
commit 6a72594faf
2 changed files with 21 additions and 2 deletions

View File

@@ -141,6 +141,7 @@ function CustomerOpeningBalanceField() {
inline={true}
shouldUpdate={openingBalanceFieldShouldUpdate}
shouldUpdateDeps={{ currencyCode: values.currency_code }}
fastField={true}
>
<ControlGroup>
<InputPrependText text={values.currency_code} />

View File

@@ -18,7 +18,11 @@ import {
ExchangeRateInputGroup,
FDateInput,
} from '@/components';
import { useIsVendorForeignCurrency, useSetPrimaryBranchToForm } from './utils';
import {
openingBalanceFieldShouldUpdate,
useIsVendorForeignCurrency,
useSetPrimaryBranchToForm,
} from './utils';
import { useVendorFormContext } from './VendorFormProvider';
import { useCurrentOrganization } from '@/hooks/state';
@@ -87,6 +91,10 @@ export default function VendorFinanicalPanelTab() {
);
}
/**
* Vendor opening balance field.
* @returns {JSX.Element}
*/
function VendorOpeningBalanceField() {
const { vendorId } = useVendorFormContext();
const { values } = useFormikContext();
@@ -99,6 +107,9 @@ function VendorOpeningBalanceField() {
name={'opening_balance'}
label={<T id={'opening_balance'} />}
inline={true}
shouldUpdate={openingBalanceFieldShouldUpdate}
shouldUpdateDeps={{ currencyCode: values.currency_code }}
FastField={true}
>
<ControlGroup>
<InputPrependText text={values.currency_code} />
@@ -111,6 +122,10 @@ function VendorOpeningBalanceField() {
);
}
/**
* Vendor opening balance at date field.
* @returns {JSX.Element}
*/
function VendorOpeningBalanceAtField() {
const { vendorId } = useVendorFormContext();
@@ -136,6 +151,10 @@ function VendorOpeningBalanceAtField() {
);
}
/**
* Vendor opening balance exchange rate field if the vendor has foreign currency.
* @returns {JSX.Element}
*/
function VendorOpeningBalanceExchangeRateField() {
const { values } = useFormikContext();
const { vendorId } = useVendorFormContext();
@@ -146,7 +165,6 @@ function VendorOpeningBalanceExchangeRateField() {
if (!isForeignVendor || vendorId) {
return null;
}
return (
<FFormGroup
label={' '}