feat(Sales & Purchases ): add setfieldvalue exchange rate.

This commit is contained in:
elforjani13
2022-02-23 12:22:27 +02:00
parent cf7d032aae
commit e6a7c7bc58
26 changed files with 118 additions and 66 deletions

View File

@@ -18,6 +18,7 @@ const getSchema = Yup.object().shape({
open: Yup.boolean(),
branch_id: Yup.string(),
warehouse_id: Yup.string(),
exchange_rate: Yup.number(),
entries: Yup.array().of(
Yup.object().shape({
quantity: Yup.number()

View File

@@ -51,8 +51,13 @@ function VendorCreditNoteFormHeaderFields({
vendorcreditNextNumber,
}) {
// Vendor Credit form context.
const { vendors, isForeignVendor, setSelectVendor } =
useVendorCreditNoteFormContext();
const {
vendors,
isForeignVendor,
baseCurrency,
selectVendor,
setSelectVendor,
} = useVendorCreditNoteFormContext();
// Handle vendor credit number changing.
const handleVendorCreditNumberChange = () => {
@@ -102,6 +107,7 @@ function VendorCreditNoteFormHeaderFields({
defaultSelectText={<T id={'select_vender_account'} />}
onContactSelected={(contact) => {
form.setFieldValue('vendor_id', contact.id);
form.setFieldValue('exchange_rate', '');
setSelectVendor(contact);
}}
popoverFill={true}
@@ -116,8 +122,8 @@ function VendorCreditNoteFormHeaderFields({
{/* ----------- Exchange rate ----------- */}
<If condition={isForeignVendor}>
<ExchangeRateInputGroup
fromCurrency={'USD'}
toCurrency={'LYD'}
fromCurrency={baseCurrency}
toCurrency={selectVendor?.currency_code}
name={'exchange_rate'}
formGroupProps={{ label: ' ', inline: true }}
/>

View File

@@ -41,6 +41,7 @@ export const defaultVendorsCreditNote = {
note: '',
branch_id: '',
warehouse_id: '',
exchange_rate: '',
entries: [...repeatValue(defaultCreditNoteEntry, MIN_LINES_NUMBER)],
};