mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 13:50:31 +00:00
fix: create quick payment received and payment made transactions
This commit is contained in:
@@ -3,8 +3,7 @@ import React from 'react';
|
|||||||
import intl from 'react-intl-universal';
|
import intl from 'react-intl-universal';
|
||||||
import { Formik } from 'formik';
|
import { Formik } from 'formik';
|
||||||
import { Intent } from '@blueprintjs/core';
|
import { Intent } from '@blueprintjs/core';
|
||||||
import { pick, omit } from 'lodash';
|
import { omit } from 'lodash';
|
||||||
|
|
||||||
import { AppToaster } from '@/components';
|
import { AppToaster } from '@/components';
|
||||||
import { CreateQuickPaymentMadeFormSchema } from './QuickPaymentMade.schema';
|
import { CreateQuickPaymentMadeFormSchema } from './QuickPaymentMade.schema';
|
||||||
import { useQuickPaymentMadeContext } from './QuickPaymentMadeFormProvider';
|
import { useQuickPaymentMadeContext } from './QuickPaymentMadeFormProvider';
|
||||||
@@ -21,28 +20,25 @@ function QuickPaymentMadeForm({
|
|||||||
// #withDialogActions
|
// #withDialogActions
|
||||||
closeDialog,
|
closeDialog,
|
||||||
}) {
|
}) {
|
||||||
|
|
||||||
const {
|
const {
|
||||||
bill,
|
bill,
|
||||||
dialogName,
|
dialogName,
|
||||||
createPaymentMadeMutate,
|
createPaymentMadeMutate,
|
||||||
} = useQuickPaymentMadeContext();
|
} = useQuickPaymentMadeContext();
|
||||||
|
|
||||||
// Initial form values
|
// Initial form values.
|
||||||
const initialValues = {
|
const initialValues = {
|
||||||
...defaultPaymentMade,
|
...defaultPaymentMade,
|
||||||
...bill,
|
...bill,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handles the form submit.
|
// Handles the form submit.
|
||||||
const handleFormSubmit = (values, { setSubmitting, setFieldError }) => {
|
const handleFormSubmit = (values, { setSubmitting, setFieldError }) => {
|
||||||
const entries = [values]
|
const entries = [
|
||||||
.filter((entry) => entry.id && entry.payment_amount)
|
{
|
||||||
.map((entry) => ({
|
payment_amount: values.amount,
|
||||||
bill_id: entry.id,
|
bill_id: values.id,
|
||||||
...pick(entry, ['payment_amount']),
|
},
|
||||||
}));
|
];
|
||||||
|
|
||||||
const form = {
|
const form = {
|
||||||
...omit(values, ['payment_amount']),
|
...omit(values, ['payment_amount']),
|
||||||
vendor_id: values?.vendor?.id,
|
vendor_id: values?.vendor?.id,
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ function QuickPaymentMadeFormFields({
|
|||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
{/*------------ Amount Received -----------*/}
|
{/*------------ Amount Received -----------*/}
|
||||||
<FastField name={'payment_amount'}>
|
<FastField name={'amount'}>
|
||||||
{({
|
{({
|
||||||
form: { values, setFieldValue },
|
form: { values, setFieldValue },
|
||||||
field: { value },
|
field: { value },
|
||||||
@@ -135,7 +135,7 @@ function QuickPaymentMadeFormFields({
|
|||||||
labelInfo={<FieldRequiredHint />}
|
labelInfo={<FieldRequiredHint />}
|
||||||
className={classNames('form-group--payment_amount', CLASSES.FILL)}
|
className={classNames('form-group--payment_amount', CLASSES.FILL)}
|
||||||
intent={inputIntent({ error, touched })}
|
intent={inputIntent({ error, touched })}
|
||||||
helperText={<ErrorMessage name="payment_amount" />}
|
helperText={<ErrorMessage name="amount" />}
|
||||||
>
|
>
|
||||||
<ControlGroup>
|
<ControlGroup>
|
||||||
<InputPrependText text={values.currency_code} />
|
<InputPrependText text={values.currency_code} />
|
||||||
@@ -144,7 +144,7 @@ function QuickPaymentMadeFormFields({
|
|||||||
value={value}
|
value={value}
|
||||||
minimal={true}
|
minimal={true}
|
||||||
onChange={(amount) => {
|
onChange={(amount) => {
|
||||||
setFieldValue('payment_amount', amount);
|
setFieldValue('amount', amount);
|
||||||
}}
|
}}
|
||||||
intent={inputIntent({ error, touched })}
|
intent={inputIntent({ error, touched })}
|
||||||
inputRef={(ref) => (paymentMadeFieldRef.current = ref)}
|
inputRef={(ref) => (paymentMadeFieldRef.current = ref)}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ export const defaultPaymentMade = {
|
|||||||
payment_date: moment(new Date()).format('YYYY-MM-DD'),
|
payment_date: moment(new Date()).format('YYYY-MM-DD'),
|
||||||
reference: '',
|
reference: '',
|
||||||
payment_number: '',
|
payment_number: '',
|
||||||
|
amount: '',
|
||||||
// statement: '',
|
// statement: '',
|
||||||
exchange_rate: 1,
|
exchange_rate: 1,
|
||||||
branch_id: '',
|
branch_id: '',
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import React from 'react';
|
|||||||
import intl from 'react-intl-universal';
|
import intl from 'react-intl-universal';
|
||||||
import { Formik } from 'formik';
|
import { Formik } from 'formik';
|
||||||
import { Intent } from '@blueprintjs/core';
|
import { Intent } from '@blueprintjs/core';
|
||||||
import { pick, defaultTo, omit } from 'lodash';
|
import { defaultTo, omit } from 'lodash';
|
||||||
|
|
||||||
import { AppToaster } from '@/components';
|
import { AppToaster } from '@/components';
|
||||||
import { useQuickPaymentReceiveContext } from './QuickPaymentReceiveFormProvider';
|
import { useQuickPaymentReceiveContext } from './QuickPaymentReceiveFormProvider';
|
||||||
@@ -26,14 +26,10 @@ function QuickPaymentReceiveForm({
|
|||||||
paymentReceiveAutoIncrement,
|
paymentReceiveAutoIncrement,
|
||||||
paymentReceiveNumberPrefix,
|
paymentReceiveNumberPrefix,
|
||||||
paymentReceiveNextNumber,
|
paymentReceiveNextNumber,
|
||||||
preferredDepositAccount
|
preferredDepositAccount,
|
||||||
}) {
|
}) {
|
||||||
|
const { dialogName, invoice, createPaymentReceiveMutate } =
|
||||||
const {
|
useQuickPaymentReceiveContext();
|
||||||
dialogName,
|
|
||||||
invoice,
|
|
||||||
createPaymentReceiveMutate,
|
|
||||||
} = useQuickPaymentReceiveContext();
|
|
||||||
|
|
||||||
// Payment receive number.
|
// Payment receive number.
|
||||||
const nextPaymentNumber = transactionNumber(
|
const nextPaymentNumber = transactionNumber(
|
||||||
@@ -53,13 +49,12 @@ function QuickPaymentReceiveForm({
|
|||||||
|
|
||||||
// Handles the form submit.
|
// Handles the form submit.
|
||||||
const handleFormSubmit = (values, { setSubmitting, setFieldError }) => {
|
const handleFormSubmit = (values, { setSubmitting, setFieldError }) => {
|
||||||
const entries = [values]
|
const entries = [
|
||||||
.filter((entry) => entry.id && entry.payment_amount)
|
{
|
||||||
.map((entry) => ({
|
invoice_id: values.id,
|
||||||
invoice_id: entry.id,
|
payment_amount: values.amount,
|
||||||
...pick(entry, ['payment_amount']),
|
},
|
||||||
}));
|
];
|
||||||
|
|
||||||
const form = {
|
const form = {
|
||||||
...omit(values, ['payment_receive_no', 'payment_amount']),
|
...omit(values, ['payment_receive_no', 'payment_amount']),
|
||||||
...(!paymentReceiveAutoIncrement && {
|
...(!paymentReceiveAutoIncrement && {
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ function QuickPaymentReceiveFormFields({
|
|||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
{/*------------ Amount Received -----------*/}
|
{/*------------ Amount Received -----------*/}
|
||||||
<FastField name={'payment_amount'}>
|
<FastField name={'amount'}>
|
||||||
{({
|
{({
|
||||||
form: { values, setFieldValue },
|
form: { values, setFieldValue },
|
||||||
field: { value },
|
field: { value },
|
||||||
@@ -139,7 +139,7 @@ function QuickPaymentReceiveFormFields({
|
|||||||
labelInfo={<FieldRequiredHint />}
|
labelInfo={<FieldRequiredHint />}
|
||||||
className={classNames('form-group--payment_amount', CLASSES.FILL)}
|
className={classNames('form-group--payment_amount', CLASSES.FILL)}
|
||||||
intent={inputIntent({ error, touched })}
|
intent={inputIntent({ error, touched })}
|
||||||
helperText={<ErrorMessage name="payment_amount" />}
|
helperText={<ErrorMessage name="amount" />}
|
||||||
>
|
>
|
||||||
<ControlGroup>
|
<ControlGroup>
|
||||||
<InputPrependText text={values.currency_code} />
|
<InputPrependText text={values.currency_code} />
|
||||||
@@ -148,7 +148,7 @@ function QuickPaymentReceiveFormFields({
|
|||||||
value={value}
|
value={value}
|
||||||
minimal={true}
|
minimal={true}
|
||||||
onChange={(amount) => {
|
onChange={(amount) => {
|
||||||
setFieldValue('payment_amount', amount);
|
setFieldValue('amount', amount);
|
||||||
}}
|
}}
|
||||||
intent={inputIntent({ error, touched })}
|
intent={inputIntent({ error, touched })}
|
||||||
inputRef={(ref) => (paymentReceiveFieldRef.current = ref)}
|
inputRef={(ref) => (paymentReceiveFieldRef.current = ref)}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ export const defaultInitialValues = {
|
|||||||
payment_receive_no: '',
|
payment_receive_no: '',
|
||||||
payment_date: moment(new Date()).format('YYYY-MM-DD'),
|
payment_date: moment(new Date()).format('YYYY-MM-DD'),
|
||||||
reference_no: '',
|
reference_no: '',
|
||||||
|
amount: '',
|
||||||
// statement: '',
|
// statement: '',
|
||||||
exchange_rate: 1,
|
exchange_rate: 1,
|
||||||
branch_id: '',
|
branch_id: '',
|
||||||
|
|||||||
Reference in New Issue
Block a user