mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 14:20:31 +00:00
fix: Expense cannot accept credit card as payment account
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import { Service, Inject } from 'typedi';
|
import { Service, Inject } from 'typedi';
|
||||||
import { sumBy, difference } from 'lodash';
|
import { sumBy, difference } from 'lodash';
|
||||||
import { ServiceError } from '@/exceptions';
|
import { ServiceError } from '@/exceptions';
|
||||||
import { ERRORS } from '../constants';
|
import { ERRORS, SUPPORTED_EXPENSE_PAYMENT_ACCOUNT_TYPES } from '../constants';
|
||||||
import {
|
import {
|
||||||
IAccount,
|
IAccount,
|
||||||
IExpense,
|
IExpense,
|
||||||
@@ -79,7 +79,9 @@ export class CommandExpenseValidator {
|
|||||||
* @throws {ServiceError}
|
* @throws {ServiceError}
|
||||||
*/
|
*/
|
||||||
public validatePaymentAccountType = (paymentAccount: number[]) => {
|
public validatePaymentAccountType = (paymentAccount: number[]) => {
|
||||||
if (!paymentAccount.isParentType(ACCOUNT_PARENT_TYPE.CURRENT_ASSET)) {
|
if (
|
||||||
|
!paymentAccount.isAccountType(SUPPORTED_EXPENSE_PAYMENT_ACCOUNT_TYPES)
|
||||||
|
) {
|
||||||
throw new ServiceError(ERRORS.PAYMENT_ACCOUNT_HAS_INVALID_TYPE);
|
throw new ServiceError(ERRORS.PAYMENT_ACCOUNT_HAS_INVALID_TYPE);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { ACCOUNT_TYPE } from '@/data/AccountTypes';
|
||||||
|
|
||||||
export const DEFAULT_VIEW_COLUMNS = [];
|
export const DEFAULT_VIEW_COLUMNS = [];
|
||||||
export const DEFAULT_VIEWS = [
|
export const DEFAULT_VIEWS = [
|
||||||
{
|
{
|
||||||
@@ -76,3 +78,12 @@ export const ExpensesSampleData = [
|
|||||||
Publish: 'T',
|
Publish: 'T',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
export const SUPPORTED_EXPENSE_PAYMENT_ACCOUNT_TYPES = [
|
||||||
|
ACCOUNT_TYPE.CASH,
|
||||||
|
ACCOUNT_TYPE.BANK,
|
||||||
|
ACCOUNT_TYPE.CREDIT_CARD,
|
||||||
|
ACCOUNT_TYPE.OTHER_CURRENT_ASSET,
|
||||||
|
ACCOUNT_TYPE.NON_CURRENT_ASSET,
|
||||||
|
ACCOUNT_TYPE.FIXED_ASSET,
|
||||||
|
];
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
// @ts-nocheck
|
// @ts-nocheck
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { InputGroup, FormGroup, Position, Classes } from '@blueprintjs/core';
|
import { FormGroup, Position, Classes } from '@blueprintjs/core';
|
||||||
import { DateInput } from '@blueprintjs/datetime';
|
import { DateInput } from '@blueprintjs/datetime';
|
||||||
import { FastField, ErrorMessage } from 'formik';
|
import { FastField, ErrorMessage } from 'formik';
|
||||||
import { CustomersSelect, FormattedMessage as T } from '@/components';
|
import { CustomersSelect, FInputGroup, FormattedMessage as T } from '@/components';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { CLASSES } from '@/constants/classes';
|
import { CLASSES } from '@/constants/classes';
|
||||||
import {
|
import {
|
||||||
@@ -15,15 +15,14 @@ import {
|
|||||||
import { customersFieldShouldUpdate, accountsFieldShouldUpdate } from './utils';
|
import { customersFieldShouldUpdate, accountsFieldShouldUpdate } from './utils';
|
||||||
import {
|
import {
|
||||||
CurrencySelectList,
|
CurrencySelectList,
|
||||||
CustomerSelectField,
|
|
||||||
FFormGroup,
|
FFormGroup,
|
||||||
AccountsSelect,
|
AccountsSelect,
|
||||||
FieldRequiredHint,
|
FieldRequiredHint,
|
||||||
Hint,
|
Hint,
|
||||||
} from '@/components';
|
} from '@/components';
|
||||||
import { ExpensesExchangeRateInputField } from './components';
|
import { ExpensesExchangeRateInputField } from './components';
|
||||||
import { ACCOUNT_PARENT_TYPE } from '@/constants/accountTypes';
|
|
||||||
import { useExpenseFormContext } from './ExpenseFormPageProvider';
|
import { useExpenseFormContext } from './ExpenseFormPageProvider';
|
||||||
|
import { SUPPORTED_EXPENSE_PAYMENT_ACCOUNT_TYPES } from './constants';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Expense form header.
|
* Expense form header.
|
||||||
@@ -68,7 +67,7 @@ export default function ExpenseFormHeader() {
|
|||||||
name={'payment_account_id'}
|
name={'payment_account_id'}
|
||||||
items={accounts}
|
items={accounts}
|
||||||
placeholder={<T id={'select_payment_account'} />}
|
placeholder={<T id={'select_payment_account'} />}
|
||||||
filterByParentTypes={[ACCOUNT_PARENT_TYPE.CURRENT_ASSET]}
|
filterByTypes={SUPPORTED_EXPENSE_PAYMENT_ACCOUNT_TYPES}
|
||||||
allowCreate={true}
|
allowCreate={true}
|
||||||
fastField={true}
|
fastField={true}
|
||||||
shouldUpdate={accountsFieldShouldUpdate}
|
shouldUpdate={accountsFieldShouldUpdate}
|
||||||
@@ -107,19 +106,15 @@ export default function ExpenseFormHeader() {
|
|||||||
formGroupProps={{ label: ' ', inline: true }}
|
formGroupProps={{ label: ' ', inline: true }}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<FastField name={'reference_no'}>
|
{/* ----------- Reference No. ----------- */}
|
||||||
{({ form, field, meta: { error, touched } }) => (
|
<FFormGroup
|
||||||
<FormGroup
|
name={'reference_no'}
|
||||||
label={<T id={'reference_no'} />}
|
label={<T id={'reference_no'} />}
|
||||||
className={classNames('form-group--ref_no', Classes.FILL)}
|
inline={true}
|
||||||
intent={inputIntent({ error, touched })}
|
fastField
|
||||||
helperText={<ErrorMessage name="reference_no" />}
|
>
|
||||||
inline={true}
|
<FInputGroup minimal={true} name={'reference_no'} fastField />
|
||||||
>
|
</FFormGroup>
|
||||||
<InputGroup minimal={true} {...field} />
|
|
||||||
</FormGroup>
|
|
||||||
)}
|
|
||||||
</FastField>
|
|
||||||
|
|
||||||
{/* ----------- Customer ----------- */}
|
{/* ----------- Customer ----------- */}
|
||||||
<ExpenseFormCustomerSelect />
|
<ExpenseFormCustomerSelect />
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
import { ACCOUNT_TYPE } from "@/constants";
|
||||||
|
|
||||||
|
export const SUPPORTED_EXPENSE_PAYMENT_ACCOUNT_TYPES = [
|
||||||
|
ACCOUNT_TYPE.CASH,
|
||||||
|
ACCOUNT_TYPE.BANK,
|
||||||
|
ACCOUNT_TYPE.CREDIT_CARD,
|
||||||
|
ACCOUNT_TYPE.OTHER_CURRENT_ASSET,
|
||||||
|
ACCOUNT_TYPE.NON_CURRENT_ASSET,
|
||||||
|
ACCOUNT_TYPE.FIXED_ASSET,
|
||||||
|
];
|
||||||
Reference in New Issue
Block a user