mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 22:30:31 +00:00
feat(Sales & Purchases ): add setfieldvalue exchange rate.
This commit is contained in:
@@ -13,13 +13,12 @@ const Schema = Yup.object().shape({
|
|||||||
.min(1)
|
.min(1)
|
||||||
.max(DATATYPES_LENGTH.STRING)
|
.max(DATATYPES_LENGTH.STRING)
|
||||||
.label(intl.get('journal_type')),
|
.label(intl.get('journal_type')),
|
||||||
date: Yup.date()
|
date: Yup.date().required().label(intl.get('date')),
|
||||||
.required()
|
|
||||||
.label(intl.get('date')),
|
|
||||||
currency_code: Yup.string().max(3),
|
currency_code: Yup.string().max(3),
|
||||||
publish: Yup.boolean(),
|
publish: Yup.boolean(),
|
||||||
reference: Yup.string().nullable().min(1).max(DATATYPES_LENGTH.STRING),
|
reference: Yup.string().nullable().min(1).max(DATATYPES_LENGTH.STRING),
|
||||||
description: Yup.string().min(1).max(DATATYPES_LENGTH.STRING).nullable(),
|
description: Yup.string().min(1).max(DATATYPES_LENGTH.STRING).nullable(),
|
||||||
|
exchange_rate: Yup.number(),
|
||||||
entries: Yup.array().of(
|
entries: Yup.array().of(
|
||||||
Yup.object().shape({
|
Yup.object().shape({
|
||||||
credit: Yup.number().nullable(),
|
credit: Yup.number().nullable(),
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ function MakeJournalEntriesHeader({
|
|||||||
currencies,
|
currencies,
|
||||||
isForeignJournal,
|
isForeignJournal,
|
||||||
baseCurrency,
|
baseCurrency,
|
||||||
|
selectJournalCurrency,
|
||||||
setSelactJournalCurrency,
|
setSelactJournalCurrency,
|
||||||
} = useMakeJournalFormContext();
|
} = useMakeJournalFormContext();
|
||||||
|
|
||||||
@@ -195,39 +196,37 @@ function MakeJournalEntriesHeader({
|
|||||||
|
|
||||||
{/*------------ Currency -----------*/}
|
{/*------------ Currency -----------*/}
|
||||||
{/* <FeatureCan feature={Features.ManualJournal}> */}
|
{/* <FeatureCan feature={Features.ManualJournal}> */}
|
||||||
<FastField
|
<FastField
|
||||||
name={'currency_code'}
|
name={'currency_code'}
|
||||||
currencies={currencies}
|
currencies={currencies}
|
||||||
shouldUpdate={currenciesFieldShouldUpdate}
|
shouldUpdate={currenciesFieldShouldUpdate}
|
||||||
>
|
>
|
||||||
{({ form, field: { value }, meta: { error, touched } }) => (
|
{({ form, field: { value }, meta: { error, touched } }) => (
|
||||||
<FormGroup
|
<FormGroup
|
||||||
label={<T id={'currency'} />}
|
label={<T id={'currency'} />}
|
||||||
className={classNames('form-group--currency', CLASSES.FILL)}
|
className={classNames('form-group--currency', CLASSES.FILL)}
|
||||||
inline={true}
|
inline={true}
|
||||||
>
|
>
|
||||||
<CurrencySelectList
|
<CurrencySelectList
|
||||||
currenciesList={currencies}
|
currenciesList={currencies}
|
||||||
selectedCurrencyCode={value}
|
selectedCurrencyCode={value}
|
||||||
onCurrencySelected={(currencyItem) => {
|
onCurrencySelected={(currencyItem) => {
|
||||||
form.setFieldValue(
|
form.setFieldValue('currency_code', currencyItem.currency_code);
|
||||||
'currency_code',
|
form.setFieldValue('exchange_rate', '');
|
||||||
currencyItem.currency_code,
|
setSelactJournalCurrency(currencyItem);
|
||||||
);
|
}}
|
||||||
setSelactJournalCurrency(currencyItem);
|
defaultSelectText={value}
|
||||||
}}
|
/>
|
||||||
defaultSelectText={value}
|
</FormGroup>
|
||||||
/>
|
)}
|
||||||
</FormGroup>
|
</FastField>
|
||||||
)}
|
|
||||||
</FastField>
|
|
||||||
{/* </FeatureCan> */}
|
{/* </FeatureCan> */}
|
||||||
|
|
||||||
{/* ----------- Exchange rate ----------- */}
|
{/* ----------- Exchange rate ----------- */}
|
||||||
<If condition={isForeignJournal}>
|
<If condition={isForeignJournal}>
|
||||||
<ExchangeRateInputGroup
|
<ExchangeRateInputGroup
|
||||||
fromCurrency={'USD'}
|
fromCurrency={baseCurrency}
|
||||||
toCurrency={'LYD'}
|
toCurrency={selectJournalCurrency?.currency_code}
|
||||||
name={'exchange_rate'}
|
name={'exchange_rate'}
|
||||||
formGroupProps={{ label: ' ', inline: true }}
|
formGroupProps={{ label: ' ', inline: true }}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import {
|
|||||||
repeatValue,
|
repeatValue,
|
||||||
transformToForm,
|
transformToForm,
|
||||||
defaultFastFieldShouldUpdate,
|
defaultFastFieldShouldUpdate,
|
||||||
ensureEntriesHasEmptyLine
|
ensureEntriesHasEmptyLine,
|
||||||
} from 'utils';
|
} from 'utils';
|
||||||
import { AppToaster } from 'components';
|
import { AppToaster } from 'components';
|
||||||
import intl from 'react-intl-universal';
|
import intl from 'react-intl-universal';
|
||||||
@@ -44,6 +44,7 @@ export const defaultManualJournal = {
|
|||||||
reference: '',
|
reference: '',
|
||||||
currency_code: '',
|
currency_code: '',
|
||||||
publish: '',
|
publish: '',
|
||||||
|
exchange_rate: '',
|
||||||
entries: [...repeatValue(defaultEntry, 4)],
|
entries: [...repeatValue(defaultEntry, 4)],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ const BillFormSchema = Yup.object().shape({
|
|||||||
open: Yup.boolean(),
|
open: Yup.boolean(),
|
||||||
branch_id: Yup.string(),
|
branch_id: Yup.string(),
|
||||||
warehouse_id: Yup.string(),
|
warehouse_id: Yup.string(),
|
||||||
|
exchange_rate:Yup.number(),
|
||||||
entries: Yup.array().of(
|
entries: Yup.array().of(
|
||||||
Yup.object().shape({
|
Yup.object().shape({
|
||||||
quantity: Yup.number()
|
quantity: Yup.number()
|
||||||
|
|||||||
@@ -37,7 +37,13 @@ import {
|
|||||||
*/
|
*/
|
||||||
function BillFormHeader() {
|
function BillFormHeader() {
|
||||||
// Bill form context.
|
// Bill form context.
|
||||||
const { vendors, isForeignVendor, setSelectVendor } = useBillFormContext();
|
const {
|
||||||
|
vendors,
|
||||||
|
isForeignVendor,
|
||||||
|
baseCurrency,
|
||||||
|
selectVendor,
|
||||||
|
setSelectVendor,
|
||||||
|
} = useBillFormContext();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classNames(CLASSES.PAGE_FORM_HEADER_FIELDS)}>
|
<div className={classNames(CLASSES.PAGE_FORM_HEADER_FIELDS)}>
|
||||||
@@ -63,6 +69,7 @@ function BillFormHeader() {
|
|||||||
defaultSelectText={<T id={'select_vender_account'} />}
|
defaultSelectText={<T id={'select_vender_account'} />}
|
||||||
onContactSelected={(contact) => {
|
onContactSelected={(contact) => {
|
||||||
form.setFieldValue('vendor_id', contact.id);
|
form.setFieldValue('vendor_id', contact.id);
|
||||||
|
form.setFieldValue('exchange_rate', '');
|
||||||
setSelectVendor(contact);
|
setSelectVendor(contact);
|
||||||
}}
|
}}
|
||||||
popoverFill={true}
|
popoverFill={true}
|
||||||
@@ -77,8 +84,8 @@ function BillFormHeader() {
|
|||||||
{/* ----------- Exchange rate ----------- */}
|
{/* ----------- Exchange rate ----------- */}
|
||||||
<If condition={isForeignVendor}>
|
<If condition={isForeignVendor}>
|
||||||
<ExchangeRateInputGroup
|
<ExchangeRateInputGroup
|
||||||
fromCurrency={'USD'}
|
fromCurrency={baseCurrency}
|
||||||
toCurrency={'LYD'}
|
toCurrency={selectVendor?.currency_code}
|
||||||
name={'exchange_rate'}
|
name={'exchange_rate'}
|
||||||
formGroupProps={{ label: ' ', inline: true }}
|
formGroupProps={{ label: ' ', inline: true }}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ export const defaultBill = {
|
|||||||
open: '',
|
open: '',
|
||||||
branch_id: '',
|
branch_id: '',
|
||||||
warehouse_id: '',
|
warehouse_id: '',
|
||||||
|
exchange_rate: '',
|
||||||
entries: [...repeatValue(defaultBillEntry, MIN_LINES_NUMBER)],
|
entries: [...repeatValue(defaultBillEntry, MIN_LINES_NUMBER)],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ const getSchema = Yup.object().shape({
|
|||||||
open: Yup.boolean(),
|
open: Yup.boolean(),
|
||||||
branch_id: Yup.string(),
|
branch_id: Yup.string(),
|
||||||
warehouse_id: Yup.string(),
|
warehouse_id: Yup.string(),
|
||||||
|
exchange_rate: Yup.number(),
|
||||||
entries: Yup.array().of(
|
entries: Yup.array().of(
|
||||||
Yup.object().shape({
|
Yup.object().shape({
|
||||||
quantity: Yup.number()
|
quantity: Yup.number()
|
||||||
|
|||||||
@@ -51,8 +51,13 @@ function VendorCreditNoteFormHeaderFields({
|
|||||||
vendorcreditNextNumber,
|
vendorcreditNextNumber,
|
||||||
}) {
|
}) {
|
||||||
// Vendor Credit form context.
|
// Vendor Credit form context.
|
||||||
const { vendors, isForeignVendor, setSelectVendor } =
|
const {
|
||||||
useVendorCreditNoteFormContext();
|
vendors,
|
||||||
|
isForeignVendor,
|
||||||
|
baseCurrency,
|
||||||
|
selectVendor,
|
||||||
|
setSelectVendor,
|
||||||
|
} = useVendorCreditNoteFormContext();
|
||||||
|
|
||||||
// Handle vendor credit number changing.
|
// Handle vendor credit number changing.
|
||||||
const handleVendorCreditNumberChange = () => {
|
const handleVendorCreditNumberChange = () => {
|
||||||
@@ -102,6 +107,7 @@ function VendorCreditNoteFormHeaderFields({
|
|||||||
defaultSelectText={<T id={'select_vender_account'} />}
|
defaultSelectText={<T id={'select_vender_account'} />}
|
||||||
onContactSelected={(contact) => {
|
onContactSelected={(contact) => {
|
||||||
form.setFieldValue('vendor_id', contact.id);
|
form.setFieldValue('vendor_id', contact.id);
|
||||||
|
form.setFieldValue('exchange_rate', '');
|
||||||
setSelectVendor(contact);
|
setSelectVendor(contact);
|
||||||
}}
|
}}
|
||||||
popoverFill={true}
|
popoverFill={true}
|
||||||
@@ -116,8 +122,8 @@ function VendorCreditNoteFormHeaderFields({
|
|||||||
{/* ----------- Exchange rate ----------- */}
|
{/* ----------- Exchange rate ----------- */}
|
||||||
<If condition={isForeignVendor}>
|
<If condition={isForeignVendor}>
|
||||||
<ExchangeRateInputGroup
|
<ExchangeRateInputGroup
|
||||||
fromCurrency={'USD'}
|
fromCurrency={baseCurrency}
|
||||||
toCurrency={'LYD'}
|
toCurrency={selectVendor?.currency_code}
|
||||||
name={'exchange_rate'}
|
name={'exchange_rate'}
|
||||||
formGroupProps={{ label: ' ', inline: true }}
|
formGroupProps={{ label: ' ', inline: true }}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ export const defaultVendorsCreditNote = {
|
|||||||
note: '',
|
note: '',
|
||||||
branch_id: '',
|
branch_id: '',
|
||||||
warehouse_id: '',
|
warehouse_id: '',
|
||||||
|
exchange_rate: '',
|
||||||
entries: [...repeatValue(defaultCreditNoteEntry, MIN_LINES_NUMBER)],
|
entries: [...repeatValue(defaultCreditNoteEntry, MIN_LINES_NUMBER)],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -3,12 +3,8 @@ import intl from 'react-intl-universal';
|
|||||||
import { DATATYPES_LENGTH } from 'common/dataTypes';
|
import { DATATYPES_LENGTH } from 'common/dataTypes';
|
||||||
|
|
||||||
const Schema = Yup.object().shape({
|
const Schema = Yup.object().shape({
|
||||||
vendor_id: Yup.string()
|
vendor_id: Yup.string().label(intl.get('vendor_name_')).required(),
|
||||||
.label(intl.get('vendor_name_'))
|
payment_date: Yup.date().required().label(intl.get('payment_date_')),
|
||||||
.required(),
|
|
||||||
payment_date: Yup.date()
|
|
||||||
.required()
|
|
||||||
.label(intl.get('payment_date_')),
|
|
||||||
payment_account_id: Yup.number()
|
payment_account_id: Yup.number()
|
||||||
.required()
|
.required()
|
||||||
.label(intl.get('payment_account_')),
|
.label(intl.get('payment_account_')),
|
||||||
@@ -20,6 +16,7 @@ const Schema = Yup.object().shape({
|
|||||||
reference: Yup.string().min(1).max(DATATYPES_LENGTH.STRING).nullable(),
|
reference: Yup.string().min(1).max(DATATYPES_LENGTH.STRING).nullable(),
|
||||||
description: Yup.string().max(DATATYPES_LENGTH.TEXT),
|
description: Yup.string().max(DATATYPES_LENGTH.TEXT),
|
||||||
branch_id: Yup.string(),
|
branch_id: Yup.string(),
|
||||||
|
exchange_rate: Yup.number(),
|
||||||
entries: Yup.array().of(
|
entries: Yup.array().of(
|
||||||
Yup.object().shape({
|
Yup.object().shape({
|
||||||
id: Yup.number().nullable(),
|
id: Yup.number().nullable(),
|
||||||
|
|||||||
@@ -60,6 +60,8 @@ function PaymentMadeFormHeaderFields({ organization: { base_currency } }) {
|
|||||||
isNewMode,
|
isNewMode,
|
||||||
setPaymentVendorId,
|
setPaymentVendorId,
|
||||||
isForeignVendor,
|
isForeignVendor,
|
||||||
|
baseCurrency,
|
||||||
|
selectVendor,
|
||||||
setSelectVendor,
|
setSelectVendor,
|
||||||
} = usePaymentMadeFormContext();
|
} = usePaymentMadeFormContext();
|
||||||
|
|
||||||
@@ -108,6 +110,7 @@ function PaymentMadeFormHeaderFields({ organization: { base_currency } }) {
|
|||||||
defaultSelectText={<T id={'select_vender_account'} />}
|
defaultSelectText={<T id={'select_vender_account'} />}
|
||||||
onContactSelected={(contact) => {
|
onContactSelected={(contact) => {
|
||||||
form.setFieldValue('vendor_id', contact.id);
|
form.setFieldValue('vendor_id', contact.id);
|
||||||
|
form.setFieldValue('exchange_rate', '');
|
||||||
setPaymentVendorId(contact.id);
|
setPaymentVendorId(contact.id);
|
||||||
setSelectVendor(contact);
|
setSelectVendor(contact);
|
||||||
}}
|
}}
|
||||||
@@ -124,8 +127,8 @@ function PaymentMadeFormHeaderFields({ organization: { base_currency } }) {
|
|||||||
{/* ----------- Exchange rate ----------- */}
|
{/* ----------- Exchange rate ----------- */}
|
||||||
<If condition={isForeignVendor}>
|
<If condition={isForeignVendor}>
|
||||||
<ExchangeRateInputGroup
|
<ExchangeRateInputGroup
|
||||||
fromCurrency={'USD'}
|
fromCurrency={baseCurrency}
|
||||||
toCurrency={'LYD'}
|
toCurrency={selectVendor?.currency_code}
|
||||||
name={'exchange_rate'}
|
name={'exchange_rate'}
|
||||||
formGroupProps={{ label: ' ', inline: true }}
|
formGroupProps={{ label: ' ', inline: true }}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ export const defaultPaymentMade = {
|
|||||||
statement: '',
|
statement: '',
|
||||||
currency_code: '',
|
currency_code: '',
|
||||||
branch_id: '',
|
branch_id: '',
|
||||||
|
exchange_rate: '',
|
||||||
entries: [],
|
entries: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ const getSchema = () =>
|
|||||||
.label(intl.get('note')),
|
.label(intl.get('note')),
|
||||||
branch_id: Yup.string(),
|
branch_id: Yup.string(),
|
||||||
warehouse_id: Yup.string(),
|
warehouse_id: Yup.string(),
|
||||||
|
exchange_rate:Yup.number(),
|
||||||
entries: Yup.array().of(
|
entries: Yup.array().of(
|
||||||
Yup.object().shape({
|
Yup.object().shape({
|
||||||
quantity: Yup.number()
|
quantity: Yup.number()
|
||||||
|
|||||||
@@ -49,8 +49,13 @@ function CreditNoteFormHeaderFields({
|
|||||||
creditNextNumber,
|
creditNextNumber,
|
||||||
}) {
|
}) {
|
||||||
// Credit note form context.
|
// Credit note form context.
|
||||||
const { customers, isForeignCustomer, baseCurrency, setSelectCustomer } =
|
const {
|
||||||
useCreditNoteFormContext();
|
customers,
|
||||||
|
isForeignCustomer,
|
||||||
|
baseCurrency,
|
||||||
|
selectCustomer,
|
||||||
|
setSelectCustomer,
|
||||||
|
} = useCreditNoteFormContext();
|
||||||
|
|
||||||
// Handle credit number changing.
|
// Handle credit number changing.
|
||||||
const handleCreditNumberChange = () => {
|
const handleCreditNumberChange = () => {
|
||||||
@@ -102,6 +107,7 @@ function CreditNoteFormHeaderFields({
|
|||||||
defaultSelectText={<T id={'select_customer_account'} />}
|
defaultSelectText={<T id={'select_customer_account'} />}
|
||||||
onContactSelected={(customer) => {
|
onContactSelected={(customer) => {
|
||||||
form.setFieldValue('customer_id', customer.id);
|
form.setFieldValue('customer_id', customer.id);
|
||||||
|
form.setFieldValue('exchange_rate', '');
|
||||||
setSelectCustomer(customer);
|
setSelectCustomer(customer);
|
||||||
}}
|
}}
|
||||||
popoverFill={true}
|
popoverFill={true}
|
||||||
@@ -116,8 +122,8 @@ function CreditNoteFormHeaderFields({
|
|||||||
{/* ----------- Exchange rate ----------- */}
|
{/* ----------- Exchange rate ----------- */}
|
||||||
<If condition={isForeignCustomer}>
|
<If condition={isForeignCustomer}>
|
||||||
<ExchangeRateInputGroup
|
<ExchangeRateInputGroup
|
||||||
fromCurrency={'USD'}
|
fromCurrency={baseCurrency}
|
||||||
toCurrency={'LYD'}
|
toCurrency={selectCustomer?.currency_code}
|
||||||
name={'exchange_rate'}
|
name={'exchange_rate'}
|
||||||
formGroupProps={{ label: ' ', inline: true }}
|
formGroupProps={{ label: ' ', inline: true }}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ export const defaultCreditNote = {
|
|||||||
terms_conditions: '',
|
terms_conditions: '',
|
||||||
branch_id: '',
|
branch_id: '',
|
||||||
warehouse_id: '',
|
warehouse_id: '',
|
||||||
|
exchange_rate: '',
|
||||||
entries: [...repeatValue(defaultCreditNoteEntry, MIN_LINES_NUMBER)],
|
entries: [...repeatValue(defaultCreditNoteEntry, MIN_LINES_NUMBER)],
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -165,4 +166,4 @@ export const useSetPrimaryWarehouseToForm = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [isWarehousesSuccess, setFieldValue, warehouses]);
|
}, [isWarehousesSuccess, setFieldValue, warehouses]);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ const Schema = Yup.object().shape({
|
|||||||
delivered: Yup.boolean(),
|
delivered: Yup.boolean(),
|
||||||
branch_id: Yup.string(),
|
branch_id: Yup.string(),
|
||||||
warehouse_id: Yup.string(),
|
warehouse_id: Yup.string(),
|
||||||
|
exchange_rate: Yup.number(),
|
||||||
entries: Yup.array().of(
|
entries: Yup.array().of(
|
||||||
Yup.object().shape({
|
Yup.object().shape({
|
||||||
quantity: Yup.number()
|
quantity: Yup.number()
|
||||||
|
|||||||
@@ -47,8 +47,13 @@ function EstimateFormHeader({
|
|||||||
estimateNumberPrefix,
|
estimateNumberPrefix,
|
||||||
estimateNextNumber,
|
estimateNextNumber,
|
||||||
}) {
|
}) {
|
||||||
const { customers, isForeignCustomer, baseCurrency, setSelectCustomer } =
|
const {
|
||||||
useEstimateFormContext();
|
customers,
|
||||||
|
isForeignCustomer,
|
||||||
|
baseCurrency,
|
||||||
|
selectCustomer,
|
||||||
|
setSelectCustomer,
|
||||||
|
} = useEstimateFormContext();
|
||||||
|
|
||||||
const handleEstimateNumberBtnClick = () => {
|
const handleEstimateNumberBtnClick = () => {
|
||||||
openDialog('estimate-number-form', {});
|
openDialog('estimate-number-form', {});
|
||||||
@@ -94,6 +99,7 @@ function EstimateFormHeader({
|
|||||||
defaultSelectText={<T id={'select_customer_account'} />}
|
defaultSelectText={<T id={'select_customer_account'} />}
|
||||||
onContactSelected={(customer) => {
|
onContactSelected={(customer) => {
|
||||||
form.setFieldValue('customer_id', customer.id);
|
form.setFieldValue('customer_id', customer.id);
|
||||||
|
form.setFieldValue('exchange_rate', '');
|
||||||
setSelectCustomer(customer);
|
setSelectCustomer(customer);
|
||||||
}}
|
}}
|
||||||
popoverFill={true}
|
popoverFill={true}
|
||||||
@@ -109,8 +115,8 @@ function EstimateFormHeader({
|
|||||||
{/* ----------- Exchange rate ----------- */}
|
{/* ----------- Exchange rate ----------- */}
|
||||||
<If condition={isForeignCustomer}>
|
<If condition={isForeignCustomer}>
|
||||||
<ExchangeRateInputGroup
|
<ExchangeRateInputGroup
|
||||||
fromCurrency={'USD'}
|
fromCurrency={baseCurrency}
|
||||||
toCurrency={'LYD'}
|
toCurrency={selectCustomer?.currency_code}
|
||||||
name={'exchange_rate'}
|
name={'exchange_rate'}
|
||||||
formGroupProps={{ label: ' ', inline: true }}
|
formGroupProps={{ label: ' ', inline: true }}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ export const defaultEstimate = {
|
|||||||
terms_conditions: '',
|
terms_conditions: '',
|
||||||
branch_id: '',
|
branch_id: '',
|
||||||
warehouse_id: '',
|
warehouse_id: '',
|
||||||
|
exchange_rate: '',
|
||||||
entries: [...repeatValue(defaultEstimateEntry, MIN_LINES_NUMBER)],
|
entries: [...repeatValue(defaultEstimateEntry, MIN_LINES_NUMBER)],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -57,8 +57,13 @@ function InvoiceFormHeaderFields({
|
|||||||
invoiceNextNumber,
|
invoiceNextNumber,
|
||||||
}) {
|
}) {
|
||||||
// Invoice form context.
|
// Invoice form context.
|
||||||
const { customers, isForeignCustomer,selectCustomer ,setSelectCustomer } =
|
const {
|
||||||
useInvoiceFormContext();
|
customers,
|
||||||
|
isForeignCustomer,
|
||||||
|
baseCurrency,
|
||||||
|
selectCustomer,
|
||||||
|
setSelectCustomer,
|
||||||
|
} = useInvoiceFormContext();
|
||||||
|
|
||||||
// Handle invoice number changing.
|
// Handle invoice number changing.
|
||||||
const handleInvoiceNumberChange = () => {
|
const handleInvoiceNumberChange = () => {
|
||||||
@@ -110,6 +115,7 @@ function InvoiceFormHeaderFields({
|
|||||||
defaultSelectText={<T id={'select_customer_account'} />}
|
defaultSelectText={<T id={'select_customer_account'} />}
|
||||||
onContactSelected={(customer) => {
|
onContactSelected={(customer) => {
|
||||||
form.setFieldValue('customer_id', customer.id);
|
form.setFieldValue('customer_id', customer.id);
|
||||||
|
form.setFieldValue('exchange_rate', '');
|
||||||
setSelectCustomer(customer);
|
setSelectCustomer(customer);
|
||||||
}}
|
}}
|
||||||
popoverFill={true}
|
popoverFill={true}
|
||||||
@@ -124,8 +130,8 @@ function InvoiceFormHeaderFields({
|
|||||||
{/* ----------- Exchange rate ----------- */}
|
{/* ----------- Exchange rate ----------- */}
|
||||||
<If condition={isForeignCustomer}>
|
<If condition={isForeignCustomer}>
|
||||||
<ExchangeRateInputGroup
|
<ExchangeRateInputGroup
|
||||||
fromCurrency={'USD'}
|
fromCurrency={baseCurrency}
|
||||||
toCurrency={'LYD'}
|
toCurrency={selectCustomer?.currency_code}
|
||||||
name={'exchange_rate'}
|
name={'exchange_rate'}
|
||||||
formGroupProps={{ label: ' ', inline: true }}
|
formGroupProps={{ label: ' ', inline: true }}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -100,6 +100,7 @@ function InvoiceFormProvider({ invoiceId, baseCurrency, ...props }) {
|
|||||||
invoiceId,
|
invoiceId,
|
||||||
submitPayload,
|
submitPayload,
|
||||||
selectCustomer,
|
selectCustomer,
|
||||||
|
baseCurrency,
|
||||||
branches,
|
branches,
|
||||||
warehouses,
|
warehouses,
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ const Schema = Yup.object().shape({
|
|||||||
reference_no: Yup.string().min(1).max(DATATYPES_LENGTH.STRING).nullable(),
|
reference_no: Yup.string().min(1).max(DATATYPES_LENGTH.STRING).nullable(),
|
||||||
// statement: Yup.string().nullable().max(DATATYPES_LENGTH.TEXT),
|
// statement: Yup.string().nullable().max(DATATYPES_LENGTH.TEXT),
|
||||||
branch_id: Yup.string(),
|
branch_id: Yup.string(),
|
||||||
|
exchange_rate:Yup.number(),
|
||||||
entries: Yup.array().of(
|
entries: Yup.array().of(
|
||||||
Yup.object().shape({
|
Yup.object().shape({
|
||||||
id: Yup.number().nullable(),
|
id: Yup.number().nullable(),
|
||||||
|
|||||||
@@ -73,6 +73,7 @@ function PaymentReceiveHeaderFields({
|
|||||||
isNewMode,
|
isNewMode,
|
||||||
isForeignCustomer,
|
isForeignCustomer,
|
||||||
baseCurrency,
|
baseCurrency,
|
||||||
|
selectCustomer,
|
||||||
setSelectCustomer,
|
setSelectCustomer,
|
||||||
} = usePaymentReceiveFormContext();
|
} = usePaymentReceiveFormContext();
|
||||||
|
|
||||||
@@ -170,8 +171,8 @@ function PaymentReceiveHeaderFields({
|
|||||||
{/* ----------- Exchange rate ----------- */}
|
{/* ----------- Exchange rate ----------- */}
|
||||||
<If condition={isForeignCustomer}>
|
<If condition={isForeignCustomer}>
|
||||||
<ExchangeRateInputGroup
|
<ExchangeRateInputGroup
|
||||||
fromCurrency={'USD'}
|
fromCurrency={baseCurrency}
|
||||||
toCurrency={'LYD'}
|
toCurrency={selectCustomer?.currency_code}
|
||||||
name={'exchange_rate'}
|
name={'exchange_rate'}
|
||||||
formGroupProps={{ label: ' ', inline: true }}
|
formGroupProps={{ label: ' ', inline: true }}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ export const defaultPaymentReceive = {
|
|||||||
full_amount: '',
|
full_amount: '',
|
||||||
currency_code: '',
|
currency_code: '',
|
||||||
branch_id: '',
|
branch_id: '',
|
||||||
|
exchange_rate:'',
|
||||||
entries: [],
|
entries: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ const Schema = Yup.object().shape({
|
|||||||
closed: Yup.boolean(),
|
closed: Yup.boolean(),
|
||||||
branch_id: Yup.string(),
|
branch_id: Yup.string(),
|
||||||
warehouse_id: Yup.string(),
|
warehouse_id: Yup.string(),
|
||||||
|
exchange_rate: Yup.number(),
|
||||||
entries: Yup.array().of(
|
entries: Yup.array().of(
|
||||||
Yup.object().shape({
|
Yup.object().shape({
|
||||||
quantity: Yup.number()
|
quantity: Yup.number()
|
||||||
|
|||||||
@@ -54,8 +54,14 @@ function ReceiptFormHeader({
|
|||||||
receiptNextNumber,
|
receiptNextNumber,
|
||||||
receiptNumberPrefix,
|
receiptNumberPrefix,
|
||||||
}) {
|
}) {
|
||||||
const { accounts, customers, isForeignCustomer, setSelectCustomer } =
|
const {
|
||||||
useReceiptFormContext();
|
accounts,
|
||||||
|
customers,
|
||||||
|
isForeignCustomer,
|
||||||
|
baseCurrency,
|
||||||
|
selectCustomer,
|
||||||
|
setSelectCustomer,
|
||||||
|
} = useReceiptFormContext();
|
||||||
|
|
||||||
const handleReceiptNumberChange = useCallback(() => {
|
const handleReceiptNumberChange = useCallback(() => {
|
||||||
openDialog('receipt-number-form', {});
|
openDialog('receipt-number-form', {});
|
||||||
@@ -101,6 +107,7 @@ function ReceiptFormHeader({
|
|||||||
defaultSelectText={<T id={'select_customer_account'} />}
|
defaultSelectText={<T id={'select_customer_account'} />}
|
||||||
onContactSelected={(customer) => {
|
onContactSelected={(customer) => {
|
||||||
form.setFieldValue('customer_id', customer.id);
|
form.setFieldValue('customer_id', customer.id);
|
||||||
|
form.setFieldValue('exchange_rate', '');
|
||||||
setSelectCustomer(customer);
|
setSelectCustomer(customer);
|
||||||
}}
|
}}
|
||||||
popoverFill={true}
|
popoverFill={true}
|
||||||
@@ -115,8 +122,8 @@ function ReceiptFormHeader({
|
|||||||
{/* ----------- Exchange rate ----------- */}
|
{/* ----------- Exchange rate ----------- */}
|
||||||
<If condition={isForeignCustomer}>
|
<If condition={isForeignCustomer}>
|
||||||
<ExchangeRateInputGroup
|
<ExchangeRateInputGroup
|
||||||
fromCurrency={'USD'}
|
fromCurrency={baseCurrency}
|
||||||
toCurrency={'LYD'}
|
toCurrency={selectCustomer?.currency_code}
|
||||||
name={'exchange_rate'}
|
name={'exchange_rate'}
|
||||||
formGroupProps={{ label: ' ', inline: true }}
|
formGroupProps={{ label: ' ', inline: true }}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ export const defaultReceipt = {
|
|||||||
closed: '',
|
closed: '',
|
||||||
branch_id: '',
|
branch_id: '',
|
||||||
warehouse_id: '',
|
warehouse_id: '',
|
||||||
|
exchange_rate: '',
|
||||||
entries: [...repeatValue(defaultReceiptEntry, MIN_LINES_NUMBER)],
|
entries: [...repeatValue(defaultReceiptEntry, MIN_LINES_NUMBER)],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user