mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-20 06:40:31 +00:00
Merge pull request #915 from bigcapitalhq/fix-vendor-customer-edit-opening-balance
fix(webapp): vendor/customer edit opening balance
This commit is contained in:
@@ -17,7 +17,7 @@ import {
|
|||||||
FeatureCan,
|
FeatureCan,
|
||||||
InputPrependText,
|
InputPrependText,
|
||||||
} from '@/components';
|
} from '@/components';
|
||||||
import { FMoneyInputGroup, FFormGroup } from '@/components/Forms';
|
import { FMoneyInputGroup, FFormGroup, FDateInput } from '@/components/Forms';
|
||||||
|
|
||||||
import { useCustomerOpeningBalanceContext } from './CustomerOpeningBalanceFormProvider';
|
import { useCustomerOpeningBalanceContext } from './CustomerOpeningBalanceFormProvider';
|
||||||
import { useSetPrimaryBranchToForm } from './utils';
|
import { useSetPrimaryBranchToForm } from './utils';
|
||||||
@@ -59,28 +59,24 @@ function CustomerOpeningBalanceFields({
|
|||||||
</FFormGroup>
|
</FFormGroup>
|
||||||
|
|
||||||
{/*------------ Opening balance at -----------*/}
|
{/*------------ Opening balance at -----------*/}
|
||||||
<FastField name={'opening_balance_at'}>
|
<FFormGroup
|
||||||
{({ form, field: { value } }) => (
|
name={'opening_balance_at'}
|
||||||
<FormGroup
|
label={<T id={'customer_opening_balance.label.opening_balance_at'} />}
|
||||||
label={
|
fill
|
||||||
<T id={'customer_opening_balance.label.opening_balance_at'} />
|
fastField
|
||||||
}
|
|
||||||
className={Classes.FILL}
|
|
||||||
>
|
>
|
||||||
<DateInput
|
<FDateInput
|
||||||
{...momentFormatter('YYYY/MM/DD')}
|
name={'opening_balance_at'}
|
||||||
onChange={handleDateChange((formattedDate) => {
|
formatDate={(date) => date.toLocaleDateString()}
|
||||||
form.setFieldValue('opening_balance_at', formattedDate);
|
parseDate={(str) => new Date(str)}
|
||||||
})}
|
|
||||||
value={tansformDateValue(value)}
|
|
||||||
popoverProps={{ position: Position.BOTTOM, minimal: true }}
|
popoverProps={{ position: Position.BOTTOM, minimal: true }}
|
||||||
inputProps={{
|
inputProps={{
|
||||||
leftIcon: <Icon icon={'date-range'} />,
|
leftIcon: <Icon icon={'date-range'} />,
|
||||||
}}
|
}}
|
||||||
|
fill
|
||||||
|
fastField
|
||||||
/>
|
/>
|
||||||
</FormGroup>
|
</FFormGroup>
|
||||||
)}
|
|
||||||
</FastField>
|
|
||||||
|
|
||||||
<If condition={!isEqual(base_currency, customer.currency_code)}>
|
<If condition={!isEqual(base_currency, customer.currency_code)}>
|
||||||
{/*------------ Opening balance exchange rate -----------*/}
|
{/*------------ Opening balance exchange rate -----------*/}
|
||||||
@@ -99,12 +95,15 @@ function CustomerOpeningBalanceFields({
|
|||||||
<FFormGroup
|
<FFormGroup
|
||||||
label={<T id={'branch'} />}
|
label={<T id={'branch'} />}
|
||||||
name={'opening_balance_branch_id'}
|
name={'opening_balance_branch_id'}
|
||||||
className={classNames('form-group--select-list', Classes.FILL)}
|
fill
|
||||||
|
fastField
|
||||||
>
|
>
|
||||||
<BranchSelect
|
<BranchSelect
|
||||||
name={'opening_balance_branch_id'}
|
name={'opening_balance_branch_id'}
|
||||||
branches={branches}
|
branches={branches}
|
||||||
popoverProps={{ minimal: true }}
|
popoverProps={{ minimal: true }}
|
||||||
|
fastField
|
||||||
|
fill
|
||||||
/>
|
/>
|
||||||
</FFormGroup>
|
</FFormGroup>
|
||||||
</FeatureCan>
|
</FeatureCan>
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ function CustomerOpeningBalanceForm({
|
|||||||
const handleFormSubmit = (values, { setSubmitting, setErrors }) => {
|
const handleFormSubmit = (values, { setSubmitting, setErrors }) => {
|
||||||
const formValues = {
|
const formValues = {
|
||||||
...values,
|
...values,
|
||||||
|
opening_balance_at: moment(values.opening_balance_at).format('YYYY-MM-DD'),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handle request response success.
|
// Handle request response success.
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ function VendorOpeningBalanceForm({
|
|||||||
const handleFormSubmit = (values, { setSubmitting, setErrors }) => {
|
const handleFormSubmit = (values, { setSubmitting, setErrors }) => {
|
||||||
const formValues = {
|
const formValues = {
|
||||||
...values,
|
...values,
|
||||||
|
opening_balance_at: moment(values.opening_balance_at).format('YYYY-MM-DD'),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handle request response success.
|
// Handle request response success.
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import {
|
|||||||
FeatureCan,
|
FeatureCan,
|
||||||
InputPrependText,
|
InputPrependText,
|
||||||
} from '@/components';
|
} from '@/components';
|
||||||
import { FMoneyInputGroup, FFormGroup } from '@/components/Forms';
|
import { FMoneyInputGroup, FFormGroup, FDateInput } from '@/components/Forms';
|
||||||
|
|
||||||
import { useVendorOpeningBalanceContext } from './VendorOpeningBalanceFormProvider';
|
import { useVendorOpeningBalanceContext } from './VendorOpeningBalanceFormProvider';
|
||||||
import { useSetPrimaryBranchToForm } from './utils';
|
import { useSetPrimaryBranchToForm } from './utils';
|
||||||
@@ -59,26 +59,24 @@ function VendorOpeningBalanceFormFields({
|
|||||||
</FFormGroup>
|
</FFormGroup>
|
||||||
|
|
||||||
{/*------------ Opening balance at -----------*/}
|
{/*------------ Opening balance at -----------*/}
|
||||||
<FastField name={'opening_balance_at'}>
|
<FFormGroup
|
||||||
{({ form, field: { value } }) => (
|
name={'opening_balance_at'}
|
||||||
<FormGroup
|
|
||||||
label={<T id={'vendor_opening_balance.label.opening_balance_at'} />}
|
label={<T id={'vendor_opening_balance.label.opening_balance_at'} />}
|
||||||
className={Classes.FILL}
|
fill
|
||||||
|
fastField
|
||||||
>
|
>
|
||||||
<DateInput
|
<FDateInput
|
||||||
{...momentFormatter('YYYY/MM/DD')}
|
name={'opening_balance_at'}
|
||||||
onChange={handleDateChange((formattedDate) => {
|
formatDate={(date) => date.toLocaleDateString()}
|
||||||
form.setFieldValue('opening_balance_at', formattedDate);
|
parseDate={(str) => new Date(str)}
|
||||||
})}
|
|
||||||
value={tansformDateValue(value)}
|
|
||||||
popoverProps={{ position: Position.BOTTOM, minimal: true }}
|
popoverProps={{ position: Position.BOTTOM, minimal: true }}
|
||||||
inputProps={{
|
inputProps={{
|
||||||
leftIcon: <Icon icon={'date-range'} />,
|
leftIcon: <Icon icon={'date-range'} />,
|
||||||
}}
|
}}
|
||||||
|
fill
|
||||||
|
fastField
|
||||||
/>
|
/>
|
||||||
</FormGroup>
|
</FFormGroup>
|
||||||
)}
|
|
||||||
</FastField>
|
|
||||||
|
|
||||||
<If condition={!isEqual(base_currency, vendor.currency_code)}>
|
<If condition={!isEqual(base_currency, vendor.currency_code)}>
|
||||||
{/*------------ Opening balance exchange rate -----------*/}
|
{/*------------ Opening balance exchange rate -----------*/}
|
||||||
@@ -97,7 +95,8 @@ function VendorOpeningBalanceFormFields({
|
|||||||
<FFormGroup
|
<FFormGroup
|
||||||
label={<T id={'branch'} />}
|
label={<T id={'branch'} />}
|
||||||
name={'opening_balance_branch_id'}
|
name={'opening_balance_branch_id'}
|
||||||
className={classNames('form-group--select-list', Classes.FILL)}
|
fill
|
||||||
|
fastField
|
||||||
>
|
>
|
||||||
<BranchSelect
|
<BranchSelect
|
||||||
name={'opening_balance_branch_id'}
|
name={'opening_balance_branch_id'}
|
||||||
|
|||||||
@@ -180,7 +180,7 @@ export function useEditCustomerOpeningBalance(props) {
|
|||||||
|
|
||||||
return useMutation(
|
return useMutation(
|
||||||
([id, values]) =>
|
([id, values]) =>
|
||||||
apiRequest.post(`customers/${id}/opening_balance`, values),
|
apiRequest.put(`customers/${id}/opening-balance`, values),
|
||||||
{
|
{
|
||||||
onSuccess: (res, [id, values]) => {
|
onSuccess: (res, [id, values]) => {
|
||||||
// Invalidate specific customer.
|
// Invalidate specific customer.
|
||||||
|
|||||||
@@ -167,7 +167,7 @@ export function useEditVendorOpeningBalance(props) {
|
|||||||
const apiRequest = useApiRequest();
|
const apiRequest = useApiRequest();
|
||||||
|
|
||||||
return useMutation(
|
return useMutation(
|
||||||
([id, values]) => apiRequest.post(`vendors/${id}/opening_balance`, values),
|
([id, values]) => apiRequest.put(`vendors/${id}/opening-balance`, values),
|
||||||
{
|
{
|
||||||
onSuccess: (res, [id, values]) => {
|
onSuccess: (res, [id, values]) => {
|
||||||
// Invalidate specific vendor.
|
// Invalidate specific vendor.
|
||||||
|
|||||||
Reference in New Issue
Block a user