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

This commit is contained in:
elforjani13
2022-02-21 15:25:32 +02:00
parent 914e1de79f
commit 7c9ad8438c
22 changed files with 306 additions and 47 deletions

View File

@@ -1,4 +1,6 @@
import React, { createContext, useContext } from 'react';
import { isEmpty, pick, isEqual, isUndefined } from 'lodash';
import { DashboardInsider } from 'components';
import {
useSettingsPaymentReceives,
@@ -16,10 +18,16 @@ const PaymentReceiveFormContext = createContext();
/**
* Payment receive form provider.
*/
function PaymentReceiveFormProvider({ paymentReceiveId, ...props }) {
function PaymentReceiveFormProvider({
paymentReceiveId,
baseCurrency,
...props
}) {
// Form state.
const [submitPayload, setSubmitPayload] = React.useState({});
const [selectCustomer, setSelectCustomer] = React.useState(null);
// Fetches payment recevie details.
const {
data: {
@@ -59,6 +67,11 @@ function PaymentReceiveFormProvider({ paymentReceiveId, ...props }) {
const { mutateAsync: editPaymentReceiveMutate } = useEditPaymentReceive();
const { mutateAsync: createPaymentReceiveMutate } = useCreatePaymentReceive();
// Determines whether the foreign customer.
const isForeignCustomer =
!isEqual(selectCustomer?.currency_code, baseCurrency) &&
!isUndefined(selectCustomer?.currency_code);
// Provider payload.
const provider = {
paymentReceiveId,
@@ -67,6 +80,7 @@ function PaymentReceiveFormProvider({ paymentReceiveId, ...props }) {
accounts,
customers,
branches,
baseCurrency,
isPaymentLoading,
isAccountsLoading,
@@ -74,10 +88,13 @@ function PaymentReceiveFormProvider({ paymentReceiveId, ...props }) {
isCustomersLoading,
isFeatureLoading,
isBranchesSuccess,
isForeignCustomer,
isNewMode,
submitPayload,
setSubmitPayload,
selectCustomer,
setSelectCustomer,
editPaymentReceiveMutate,
createPaymentReceiveMutate,