fix: customer/vendor opening balance .

This commit is contained in:
elforjani13
2022-03-23 00:09:08 +02:00
parent bac6812d36
commit 5a508dd789
4 changed files with 28 additions and 22 deletions

View File

@@ -7,7 +7,7 @@ import {
} from 'hooks/query';
import { useFeatureCan } from 'hooks/state';
import { Features } from 'common';
import { pick } from 'lodash';
import { transfromCustomertoForm } from './utils';
const CustomerOpeningBalanceContext = React.createContext();
@@ -44,15 +44,7 @@ function CustomerOpeningBalanceFormProvider({
// State provider.
const provider = {
branches,
customer: {
...pick(customer, [
'id',
'opening_balance',
'opening_balance_exchange_rate',
'currency_code',
]),
// opening_balance_at: customer.formatted_opening_balance_at,
},
customer: transfromCustomertoForm(customer),
isBranchesSuccess,
isBranchesLoading,

View File

@@ -1,6 +1,6 @@
import React from 'react';
import { useFormikContext } from 'formik';
import { first } from 'lodash';
import { first, pick } from 'lodash';
import { useCustomerOpeningBalanceContext } from './CustomerOpeningBalanceFormProvider';
@@ -18,3 +18,14 @@ export const useSetPrimaryBranchToForm = () => {
}
}, [isBranchesSuccess, setFieldValue, branches]);
};
export function transfromCustomertoForm(values) {
return {
...pick(values, [
'id',
'opening_balance',
'opening_balance_exchange_rate',
'currency_code',
]),
};
}

View File

@@ -7,7 +7,7 @@ import {
} from 'hooks/query';
import { useFeatureCan } from 'hooks/state';
import { Features } from 'common';
import { pick, defaultTo } from 'lodash';
import { transfromVendorToForm } from './utils';
const VendorOpeningBalanceContext = React.createContext();
@@ -43,15 +43,7 @@ function VendorOpeningBalanceFormProvider({
// State provider.
const provider = {
branches,
vendor: {
...pick(vendor, [
'id',
'opening_balance',
'opening_balance_exchange_rate',
'currency_code',
]),
},
vendor: transfromVendorToForm(vendor),
isBranchesSuccess,
isBranchesLoading,
dialogName,

View File

@@ -1,6 +1,6 @@
import React from 'react';
import { useFormikContext } from 'formik';
import { first } from 'lodash';
import { first, pick } from 'lodash';
import { useVendorOpeningBalanceContext } from './VendorOpeningBalanceFormProvider';
@@ -18,3 +18,14 @@ export const useSetPrimaryBranchToForm = () => {
}
}, [isBranchesSuccess, setFieldValue, branches]);
};
export function transfromVendorToForm(values) {
return {
...pick(values, [
'id',
'opening_balance',
'opening_balance_exchange_rate',
'currency_code',
]),
};
}