mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-20 14:50:32 +00:00
fix: customer/vendor opening balance .
This commit is contained in:
@@ -7,7 +7,7 @@ import {
|
|||||||
} from 'hooks/query';
|
} from 'hooks/query';
|
||||||
import { useFeatureCan } from 'hooks/state';
|
import { useFeatureCan } from 'hooks/state';
|
||||||
import { Features } from 'common';
|
import { Features } from 'common';
|
||||||
import { pick } from 'lodash';
|
import { transfromCustomertoForm } from './utils';
|
||||||
|
|
||||||
const CustomerOpeningBalanceContext = React.createContext();
|
const CustomerOpeningBalanceContext = React.createContext();
|
||||||
|
|
||||||
@@ -44,15 +44,7 @@ function CustomerOpeningBalanceFormProvider({
|
|||||||
// State provider.
|
// State provider.
|
||||||
const provider = {
|
const provider = {
|
||||||
branches,
|
branches,
|
||||||
customer: {
|
customer: transfromCustomertoForm(customer),
|
||||||
...pick(customer, [
|
|
||||||
'id',
|
|
||||||
'opening_balance',
|
|
||||||
'opening_balance_exchange_rate',
|
|
||||||
'currency_code',
|
|
||||||
]),
|
|
||||||
// opening_balance_at: customer.formatted_opening_balance_at,
|
|
||||||
},
|
|
||||||
|
|
||||||
isBranchesSuccess,
|
isBranchesSuccess,
|
||||||
isBranchesLoading,
|
isBranchesLoading,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { useFormikContext } from 'formik';
|
import { useFormikContext } from 'formik';
|
||||||
import { first } from 'lodash';
|
import { first, pick } from 'lodash';
|
||||||
|
|
||||||
import { useCustomerOpeningBalanceContext } from './CustomerOpeningBalanceFormProvider';
|
import { useCustomerOpeningBalanceContext } from './CustomerOpeningBalanceFormProvider';
|
||||||
|
|
||||||
@@ -18,3 +18,14 @@ export const useSetPrimaryBranchToForm = () => {
|
|||||||
}
|
}
|
||||||
}, [isBranchesSuccess, setFieldValue, branches]);
|
}, [isBranchesSuccess, setFieldValue, branches]);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export function transfromCustomertoForm(values) {
|
||||||
|
return {
|
||||||
|
...pick(values, [
|
||||||
|
'id',
|
||||||
|
'opening_balance',
|
||||||
|
'opening_balance_exchange_rate',
|
||||||
|
'currency_code',
|
||||||
|
]),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import {
|
|||||||
} from 'hooks/query';
|
} from 'hooks/query';
|
||||||
import { useFeatureCan } from 'hooks/state';
|
import { useFeatureCan } from 'hooks/state';
|
||||||
import { Features } from 'common';
|
import { Features } from 'common';
|
||||||
import { pick, defaultTo } from 'lodash';
|
import { transfromVendorToForm } from './utils';
|
||||||
|
|
||||||
const VendorOpeningBalanceContext = React.createContext();
|
const VendorOpeningBalanceContext = React.createContext();
|
||||||
|
|
||||||
@@ -43,15 +43,7 @@ function VendorOpeningBalanceFormProvider({
|
|||||||
// State provider.
|
// State provider.
|
||||||
const provider = {
|
const provider = {
|
||||||
branches,
|
branches,
|
||||||
vendor: {
|
vendor: transfromVendorToForm(vendor),
|
||||||
...pick(vendor, [
|
|
||||||
'id',
|
|
||||||
'opening_balance',
|
|
||||||
'opening_balance_exchange_rate',
|
|
||||||
'currency_code',
|
|
||||||
]),
|
|
||||||
},
|
|
||||||
|
|
||||||
isBranchesSuccess,
|
isBranchesSuccess,
|
||||||
isBranchesLoading,
|
isBranchesLoading,
|
||||||
dialogName,
|
dialogName,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { useFormikContext } from 'formik';
|
import { useFormikContext } from 'formik';
|
||||||
import { first } from 'lodash';
|
import { first, pick } from 'lodash';
|
||||||
|
|
||||||
import { useVendorOpeningBalanceContext } from './VendorOpeningBalanceFormProvider';
|
import { useVendorOpeningBalanceContext } from './VendorOpeningBalanceFormProvider';
|
||||||
|
|
||||||
@@ -18,3 +18,14 @@ export const useSetPrimaryBranchToForm = () => {
|
|||||||
}
|
}
|
||||||
}, [isBranchesSuccess, setFieldValue, branches]);
|
}, [isBranchesSuccess, setFieldValue, branches]);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export function transfromVendorToForm(values) {
|
||||||
|
return {
|
||||||
|
...pick(values, [
|
||||||
|
'id',
|
||||||
|
'opening_balance',
|
||||||
|
'opening_balance_exchange_rate',
|
||||||
|
'currency_code',
|
||||||
|
]),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user