mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-20 06:40:31 +00:00
fix: auto-increment transaction field
This commit is contained in:
@@ -26,6 +26,7 @@ import {
|
|||||||
InputPrependButton,
|
InputPrependButton,
|
||||||
CurrencySelectList,
|
CurrencySelectList,
|
||||||
FormattedMessage as T,
|
FormattedMessage as T,
|
||||||
|
FInputGroup,
|
||||||
} from '@/components';
|
} from '@/components';
|
||||||
import { useMakeJournalFormContext } from './MakeJournalProvider';
|
import { useMakeJournalFormContext } from './MakeJournalProvider';
|
||||||
import { JournalExchangeRateInputField } from './components';
|
import { JournalExchangeRateInputField } from './components';
|
||||||
@@ -52,11 +53,9 @@ const MakeJournalTransactionNoField = R.compose(
|
|||||||
}) => {
|
}) => {
|
||||||
const { setFieldValue, values } = useFormikContext();
|
const { setFieldValue, values } = useFormikContext();
|
||||||
|
|
||||||
// Handle journal number change.
|
|
||||||
const handleJournalNumberChange = () => {
|
const handleJournalNumberChange = () => {
|
||||||
openDialog('journal-number-form');
|
openDialog('journal-number-form');
|
||||||
};
|
};
|
||||||
// Handle journal number blur.
|
|
||||||
const handleJournalNoBlur = (event) => {
|
const handleJournalNoBlur = (event) => {
|
||||||
const newValue = event.target.value;
|
const newValue = event.target.value;
|
||||||
|
|
||||||
@@ -86,13 +85,16 @@ const MakeJournalTransactionNoField = R.compose(
|
|||||||
}
|
}
|
||||||
fill={true}
|
fill={true}
|
||||||
inline={true}
|
inline={true}
|
||||||
|
fastField={true}
|
||||||
>
|
>
|
||||||
<ControlGroup fill={true}>
|
<ControlGroup fill={true}>
|
||||||
<InputGroup
|
<FInputGroup
|
||||||
|
name={'journal_number'}
|
||||||
fill={true}
|
fill={true}
|
||||||
value={values.journal_number}
|
value={values.journal_number}
|
||||||
asyncControl={true}
|
asyncControl={true}
|
||||||
onBlur={handleJournalNoBlur}
|
onBlur={handleJournalNoBlur}
|
||||||
|
fastField={true}
|
||||||
/>
|
/>
|
||||||
<InputPrependButton
|
<InputPrependButton
|
||||||
buttonProps={{
|
buttonProps={{
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import {
|
|||||||
ControlGroup,
|
ControlGroup,
|
||||||
} from '@blueprintjs/core';
|
} from '@blueprintjs/core';
|
||||||
import { DateInput } from '@blueprintjs/datetime';
|
import { DateInput } from '@blueprintjs/datetime';
|
||||||
import { FastField, Field, ErrorMessage, useFormikContext } from 'formik';
|
import { FastField, ErrorMessage, useFormikContext } from 'formik';
|
||||||
|
|
||||||
import { CLASSES } from '@/constants/classes';
|
import { CLASSES } from '@/constants/classes';
|
||||||
import {
|
import {
|
||||||
@@ -21,6 +21,7 @@ import {
|
|||||||
FormattedMessage as T,
|
FormattedMessage as T,
|
||||||
CustomerDrawerLink,
|
CustomerDrawerLink,
|
||||||
FFormGroup,
|
FFormGroup,
|
||||||
|
FInputGroup,
|
||||||
} from '@/components';
|
} from '@/components';
|
||||||
import { customerNameFieldShouldUpdate } from './utils';
|
import { customerNameFieldShouldUpdate } from './utils';
|
||||||
|
|
||||||
@@ -85,7 +86,8 @@ const CreditNoteTransactionNoField = R.compose(
|
|||||||
inline={true}
|
inline={true}
|
||||||
>
|
>
|
||||||
<ControlGroup fill={true}>
|
<ControlGroup fill={true}>
|
||||||
<InputGroup
|
<FInputGroup
|
||||||
|
name={'credit_note_number'}
|
||||||
minimal={true}
|
minimal={true}
|
||||||
value={values.credit_note_number}
|
value={values.credit_note_number}
|
||||||
asyncControl={true}
|
asyncControl={true}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
// @ts-nocheck
|
// @ts-nocheck
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import * as R from 'ramda';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import {
|
import {
|
||||||
@@ -10,11 +11,19 @@ import {
|
|||||||
ControlGroup,
|
ControlGroup,
|
||||||
} from '@blueprintjs/core';
|
} from '@blueprintjs/core';
|
||||||
import { DateInput } from '@blueprintjs/datetime';
|
import { DateInput } from '@blueprintjs/datetime';
|
||||||
import * as R from 'ramda';
|
|
||||||
import { FastField, ErrorMessage, useFormikContext } from 'formik';
|
import { FastField, ErrorMessage, useFormikContext } from 'formik';
|
||||||
|
|
||||||
import { FeatureCan, FFormGroup, FormattedMessage as T } from '@/components';
|
import {
|
||||||
|
FeatureCan,
|
||||||
|
FFormGroup,
|
||||||
|
FInputGroup,
|
||||||
|
FormattedMessage as T,
|
||||||
|
CustomerSelectField,
|
||||||
|
FieldRequiredHint,
|
||||||
|
Icon,
|
||||||
|
InputPrependButton,
|
||||||
|
CustomerDrawerLink,
|
||||||
|
} from '@/components';
|
||||||
import {
|
import {
|
||||||
momentFormatter,
|
momentFormatter,
|
||||||
tansformDateValue,
|
tansformDateValue,
|
||||||
@@ -24,24 +33,20 @@ import {
|
|||||||
import { customersFieldShouldUpdate } from './utils';
|
import { customersFieldShouldUpdate } from './utils';
|
||||||
import { CLASSES } from '@/constants/classes';
|
import { CLASSES } from '@/constants/classes';
|
||||||
import { Features } from '@/constants';
|
import { Features } from '@/constants';
|
||||||
import {
|
|
||||||
CustomerSelectField,
|
|
||||||
FieldRequiredHint,
|
|
||||||
Icon,
|
|
||||||
InputPrependButton,
|
|
||||||
CustomerDrawerLink,
|
|
||||||
} from '@/components';
|
|
||||||
|
|
||||||
import withDialogActions from '@/containers/Dialog/withDialogActions';
|
import withDialogActions from '@/containers/Dialog/withDialogActions';
|
||||||
import withSettings from '@/containers/Settings/withSettings';
|
import withSettings from '@/containers/Settings/withSettings';
|
||||||
|
|
||||||
import { ProjectsSelect } from '@/containers/Projects/components';
|
import { ProjectsSelect } from '@/containers/Projects/components';
|
||||||
import {
|
import {
|
||||||
EstimateExchangeRateInputField,
|
EstimateExchangeRateInputField,
|
||||||
EstimateProjectSelectButton,
|
EstimateProjectSelectButton,
|
||||||
} from './components';
|
} from './components';
|
||||||
|
|
||||||
import { useEstimateFormContext } from './EstimateFormProvider';
|
import { useEstimateFormContext } from './EstimateFormProvider';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Estimate number field of estimate form.
|
||||||
|
*/
|
||||||
const EstimateFormEstimateNumberField = R.compose(
|
const EstimateFormEstimateNumberField = R.compose(
|
||||||
withDialogActions,
|
withDialogActions,
|
||||||
withSettings(({ estimatesSettings }) => ({
|
withSettings(({ estimatesSettings }) => ({
|
||||||
@@ -86,11 +91,12 @@ const EstimateFormEstimateNumberField = R.compose(
|
|||||||
inline={true}
|
inline={true}
|
||||||
>
|
>
|
||||||
<ControlGroup fill={true}>
|
<ControlGroup fill={true}>
|
||||||
<InputGroup
|
<FInputGroup
|
||||||
|
name={'estimate_number'}
|
||||||
minimal={true}
|
minimal={true}
|
||||||
value={values.estimate_number}
|
|
||||||
asyncControl={true}
|
asyncControl={true}
|
||||||
onBlur={handleEstimateNoBlur}
|
onBlur={handleEstimateNoBlur}
|
||||||
|
fastField={true}
|
||||||
/>
|
/>
|
||||||
<InputPrependButton
|
<InputPrependButton
|
||||||
buttonProps={{
|
buttonProps={{
|
||||||
@@ -154,13 +160,12 @@ export default function EstimateFormHeader() {
|
|||||||
)}
|
)}
|
||||||
</FastField>
|
</FastField>
|
||||||
|
|
||||||
{/* ----------- Exchange rate ----------- */}
|
{/* ----------- Exchange Rate ----------- */}
|
||||||
<EstimateExchangeRateInputField
|
<EstimateExchangeRateInputField
|
||||||
name={'exchange_rate'}
|
name={'exchange_rate'}
|
||||||
formGroupProps={{ label: ' ', inline: true }}
|
formGroupProps={{ label: ' ', inline: true }}
|
||||||
/>
|
/>
|
||||||
|
{/* ----------- Estimate Date ----------- */}
|
||||||
{/* ----------- Estimate date ----------- */}
|
|
||||||
<FastField name={'estimate_date'}>
|
<FastField name={'estimate_date'}>
|
||||||
{({ form, field: { value }, meta: { error, touched } }) => (
|
{({ form, field: { value }, meta: { error, touched } }) => (
|
||||||
<FormGroup
|
<FormGroup
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import { useCurrentOrganization } from '@/hooks/state';
|
|||||||
import { useEstimateIsForeignCustomer } from './utils';
|
import { useEstimateIsForeignCustomer } from './utils';
|
||||||
import withSettings from '@/containers/Settings/withSettings';
|
import withSettings from '@/containers/Settings/withSettings';
|
||||||
import { transactionNumber } from '@/utils';
|
import { transactionNumber } from '@/utils';
|
||||||
|
import { useUpdateEffect } from '@/hooks';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Estimate exchange rate input field.
|
* Estimate exchange rate input field.
|
||||||
@@ -54,7 +55,7 @@ export const EstimateIncrementSyncSettingsToForm = R.compose(
|
|||||||
)(({ estimateNextNumber, estimateNumberPrefix, estimateAutoIncrement }) => {
|
)(({ estimateNextNumber, estimateNumberPrefix, estimateAutoIncrement }) => {
|
||||||
const { setFieldValue } = useFormikContext();
|
const { setFieldValue } = useFormikContext();
|
||||||
|
|
||||||
useEffect(() => {
|
useUpdateEffect(() => {
|
||||||
if (!estimateAutoIncrement) return null;
|
if (!estimateAutoIncrement) return null;
|
||||||
|
|
||||||
const estimateNo = transactionNumber(
|
const estimateNo = transactionNumber(
|
||||||
@@ -62,7 +63,12 @@ export const EstimateIncrementSyncSettingsToForm = R.compose(
|
|||||||
estimateNextNumber,
|
estimateNextNumber,
|
||||||
);
|
);
|
||||||
setFieldValue('estimate_number', estimateNo);
|
setFieldValue('estimate_number', estimateNo);
|
||||||
}, [setFieldValue, estimateNumberPrefix, estimateNextNumber]);
|
}, [
|
||||||
|
setFieldValue,
|
||||||
|
estimateNumberPrefix,
|
||||||
|
estimateNextNumber,
|
||||||
|
estimateAutoIncrement,
|
||||||
|
]);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
// @ts-nocheck
|
// @ts-nocheck
|
||||||
import React, { useMemo } from 'react';
|
import React, { useMemo } from 'react';
|
||||||
|
import { sumBy, isEmpty, defaultTo } from 'lodash';
|
||||||
import intl from 'react-intl-universal';
|
import intl from 'react-intl-universal';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { Formik, Form } from 'formik';
|
import { Formik, Form } from 'formik';
|
||||||
import { omit, sumBy, pick, isEmpty, defaultTo } from 'lodash';
|
|
||||||
import { Intent } from '@blueprintjs/core';
|
|
||||||
import { useHistory } from 'react-router-dom';
|
import { useHistory } from 'react-router-dom';
|
||||||
|
import { Intent } from '@blueprintjs/core';
|
||||||
|
|
||||||
import '@/style/pages/PaymentReceive/PageForm.scss';
|
import '@/style/pages/PaymentReceive/PageForm.scss';
|
||||||
|
|
||||||
@@ -69,7 +69,6 @@ function PaymentReceiveForm({
|
|||||||
paymentReceiveNumberPrefix,
|
paymentReceiveNumberPrefix,
|
||||||
paymentReceiveNextNumber,
|
paymentReceiveNextNumber,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Form initial values.
|
// Form initial values.
|
||||||
const initialValues = useMemo(
|
const initialValues = useMemo(
|
||||||
() => ({
|
() => ({
|
||||||
@@ -114,7 +113,8 @@ function PaymentReceiveForm({
|
|||||||
const form = transformFormToRequest(values);
|
const form = transformFormToRequest(values);
|
||||||
|
|
||||||
// Handle request response success.
|
// Handle request response success.
|
||||||
const onSaved = (response) => {
|
const onSaved = () => {
|
||||||
|
setSubmitting(false);
|
||||||
AppToaster.show({
|
AppToaster.show({
|
||||||
message: intl.get(
|
message: intl.get(
|
||||||
paymentReceiveId
|
paymentReceiveId
|
||||||
@@ -123,7 +123,6 @@ function PaymentReceiveForm({
|
|||||||
),
|
),
|
||||||
intent: Intent.SUCCESS,
|
intent: Intent.SUCCESS,
|
||||||
});
|
});
|
||||||
setSubmitting(false);
|
|
||||||
|
|
||||||
if (submitPayload.redirect) {
|
if (submitPayload.redirect) {
|
||||||
history.push('/payment-receives');
|
history.push('/payment-receives');
|
||||||
|
|||||||
@@ -109,6 +109,7 @@ const PaymentReceivePaymentNoField = R.compose(
|
|||||||
>
|
>
|
||||||
<ControlGroup fill={true}>
|
<ControlGroup fill={true}>
|
||||||
<InputGroup
|
<InputGroup
|
||||||
|
name={'payment_receive_no'}
|
||||||
minimal={true}
|
minimal={true}
|
||||||
value={values.payment_receive_no}
|
value={values.payment_receive_no}
|
||||||
asyncControl={true}
|
asyncControl={true}
|
||||||
@@ -136,7 +137,7 @@ const PaymentReceivePaymentNoField = R.compose(
|
|||||||
/**
|
/**
|
||||||
* Payment receive header fields.
|
* Payment receive header fields.
|
||||||
*/
|
*/
|
||||||
export default function PaymentReceiveHeaderFields({}) {
|
export default function PaymentReceiveHeaderFields() {
|
||||||
// Payment receive form context.
|
// Payment receive form context.
|
||||||
const { customers, accounts, projects, isNewMode } =
|
const { customers, accounts, projects, isNewMode } =
|
||||||
usePaymentReceiveFormContext();
|
usePaymentReceiveFormContext();
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ import { FastField, ErrorMessage, useFormikContext } from 'formik';
|
|||||||
import * as R from 'ramda';
|
import * as R from 'ramda';
|
||||||
|
|
||||||
import { CLASSES } from '@/constants/classes';
|
import { CLASSES } from '@/constants/classes';
|
||||||
|
import { ACCOUNT_TYPE } from '@/constants/accountTypes';
|
||||||
|
import { Features } from '@/constants';
|
||||||
import {
|
import {
|
||||||
FFormGroup,
|
FFormGroup,
|
||||||
AccountsSelect,
|
AccountsSelect,
|
||||||
@@ -24,8 +26,8 @@ import {
|
|||||||
CustomerDrawerLink,
|
CustomerDrawerLink,
|
||||||
FormattedMessage as T,
|
FormattedMessage as T,
|
||||||
FeatureCan,
|
FeatureCan,
|
||||||
|
FInputGroup,
|
||||||
} from '@/components';
|
} from '@/components';
|
||||||
import { ACCOUNT_TYPE } from '@/constants/accountTypes';
|
|
||||||
import { ProjectsSelect } from '@/containers/Projects/components';
|
import { ProjectsSelect } from '@/containers/Projects/components';
|
||||||
import {
|
import {
|
||||||
momentFormatter,
|
momentFormatter,
|
||||||
@@ -39,10 +41,13 @@ import {
|
|||||||
ReceiptExchangeRateInputField,
|
ReceiptExchangeRateInputField,
|
||||||
ReceiptProjectSelectButton,
|
ReceiptProjectSelectButton,
|
||||||
} from './components';
|
} from './components';
|
||||||
import { Features } from '@/constants';
|
|
||||||
import withSettings from '@/containers/Settings/withSettings';
|
import withSettings from '@/containers/Settings/withSettings';
|
||||||
import withDialogActions from '@/containers/Dialog/withDialogActions';
|
import withDialogActions from '@/containers/Dialog/withDialogActions';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Receipt number field of receipt form.
|
||||||
|
*/
|
||||||
const ReceiptFormReceiptNumberField = R.compose(
|
const ReceiptFormReceiptNumberField = R.compose(
|
||||||
withDialogActions,
|
withDialogActions,
|
||||||
withSettings(({ receiptSettings }) => ({
|
withSettings(({ receiptSettings }) => ({
|
||||||
@@ -58,9 +63,9 @@ const ReceiptFormReceiptNumberField = R.compose(
|
|||||||
}) => {
|
}) => {
|
||||||
const { values, setFieldValue } = useFormikContext();
|
const { values, setFieldValue } = useFormikContext();
|
||||||
|
|
||||||
const handleReceiptNumberChange = useCallback(() => {
|
const handleReceiptNumberChange = () => {
|
||||||
openDialog('receipt-number-form', {});
|
openDialog('receipt-number-form', {});
|
||||||
}, [openDialog]);
|
};
|
||||||
|
|
||||||
const handleReceiptNoBlur = (event) => {
|
const handleReceiptNoBlur = (event) => {
|
||||||
const newValue = event.target.value;
|
const newValue = event.target.value;
|
||||||
@@ -87,7 +92,8 @@ const ReceiptFormReceiptNumberField = R.compose(
|
|||||||
labelInfo={<FieldRequiredHint />}
|
labelInfo={<FieldRequiredHint />}
|
||||||
>
|
>
|
||||||
<ControlGroup fill={true}>
|
<ControlGroup fill={true}>
|
||||||
<InputGroup
|
<FInputGroup
|
||||||
|
name={'receipt_number'}
|
||||||
minimal={true}
|
minimal={true}
|
||||||
value={values.receipt_number}
|
value={values.receipt_number}
|
||||||
asyncControl={true}
|
asyncControl={true}
|
||||||
|
|||||||
Reference in New Issue
Block a user