mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-14 20:00:33 +00:00
Compare commits
6 Commits
v0.17.2
...
fix-paymen
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
031ccc4a0b | ||
|
|
858f347fd4 | ||
|
|
4d73b59cf3 | ||
|
|
bc67f0cca8 | ||
|
|
ef2d1ff141 | ||
|
|
dc4cdb2a8f |
@@ -104,10 +104,10 @@ export default class UncategorizedCashflowTransaction extends mixin(
|
||||
*/
|
||||
private async updateUncategorizedTransactionCount(
|
||||
queryContext: QueryContext,
|
||||
increment: boolean
|
||||
increment: boolean,
|
||||
amount: number = 1
|
||||
) {
|
||||
const operation = increment ? 'increment' : 'decrement';
|
||||
const amount = increment ? 1 : -1;
|
||||
|
||||
await Account.query(queryContext.transaction)
|
||||
.findById(this.accountId)
|
||||
|
||||
@@ -12,7 +12,6 @@ import { Knex } from 'knex';
|
||||
import { transformCategorizeTransToCashflow } from './utils';
|
||||
import { CommandCashflowValidator } from './CommandCasflowValidator';
|
||||
import NewCashflowTransactionService from './NewCashflowTransactionService';
|
||||
import { TransferAuthorizationGuaranteeDecision } from 'plaid';
|
||||
|
||||
@Service()
|
||||
export class CategorizeCashflowTransaction {
|
||||
|
||||
@@ -68,7 +68,11 @@ export const CASHFLOW_TRANSACTION_TYPE_META = {
|
||||
[`${CASHFLOW_TRANSACTION_TYPE.OTHER_EXPENSE}`]: {
|
||||
type: 'OtherExpense',
|
||||
direction: CASHFLOW_DIRECTION.OUT,
|
||||
creditType: [ACCOUNT_TYPE.EXPENSE, ACCOUNT_TYPE.OTHER_EXPENSE],
|
||||
creditType: [
|
||||
ACCOUNT_TYPE.EXPENSE,
|
||||
ACCOUNT_TYPE.OTHER_EXPENSE,
|
||||
ACCOUNT_TYPE.COST_OF_GOODS_SOLD,
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { upperFirst, camelCase, omit } from 'lodash';
|
||||
import { upperFirst, camelCase } from 'lodash';
|
||||
import {
|
||||
CASHFLOW_TRANSACTION_TYPE,
|
||||
CASHFLOW_TRANSACTION_TYPE_META,
|
||||
@@ -6,7 +6,6 @@ import {
|
||||
} from './constants';
|
||||
import {
|
||||
ICashflowNewCommandDTO,
|
||||
ICashflowTransaction,
|
||||
ICategorizeCashflowTransactioDTO,
|
||||
IUncategorizedCashflowTransaction,
|
||||
} from '@/interfaces';
|
||||
@@ -42,8 +41,8 @@ export const getCashflowAccountTransactionsTypes = () => {
|
||||
/**
|
||||
* Tranasformes the given uncategorized transaction and categorized DTO
|
||||
* to cashflow create DTO.
|
||||
* @param {IUncategorizedCashflowTransaction} uncategorizeModel
|
||||
* @param {ICategorizeCashflowTransactioDTO} categorizeDTO
|
||||
* @param {IUncategorizedCashflowTransaction} uncategorizeModel
|
||||
* @param {ICategorizeCashflowTransactioDTO} categorizeDTO
|
||||
* @returns {ICashflowNewCommandDTO}
|
||||
*/
|
||||
export const transformCategorizeTransToCashflow = (
|
||||
@@ -62,6 +61,7 @@ export const transformCategorizeTransToCashflow = (
|
||||
transactionNumber: categorizeDTO.transactionNumber,
|
||||
transactionType: categorizeDTO.transactionType,
|
||||
uncategorizedTransactionId: uncategorizeModel.id,
|
||||
branchId: categorizeDTO?.branchId,
|
||||
publish: true,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -108,17 +108,28 @@ export default class ResourceService {
|
||||
const $hasFields = (field) =>
|
||||
'undefined' !== typeof field.fields ? field : undefined;
|
||||
|
||||
const $hasColumns = (column) =>
|
||||
const $ColumnHasColumns = (column) =>
|
||||
'undefined' !== typeof column.columns ? column : undefined;
|
||||
|
||||
const $hasColumns = (columns) =>
|
||||
'undefined' !== typeof columns ? columns : undefined;
|
||||
|
||||
const naviagations = [
|
||||
['fields', qim.$each, 'name'],
|
||||
['fields', qim.$each, $enumerationType, 'options', qim.$each, 'label'],
|
||||
['fields2', qim.$each, 'name'],
|
||||
['fields2', qim.$each, $enumerationType, 'options', qim.$each, 'label'],
|
||||
['fields2', qim.$each, $hasFields, 'fields', qim.$each, 'name'],
|
||||
['columns', qim.$each, 'name'],
|
||||
['columns', qim.$each, $hasColumns, 'columns', qim.$each, 'name'],
|
||||
['columns', $hasColumns, qim.$each, 'name'],
|
||||
[
|
||||
'columns',
|
||||
$hasColumns,
|
||||
qim.$each,
|
||||
$ColumnHasColumns,
|
||||
'columns',
|
||||
qim.$each,
|
||||
'name',
|
||||
],
|
||||
];
|
||||
return this.i18nService.i18nApply(naviagations, meta, tenantId);
|
||||
}
|
||||
|
||||
@@ -146,6 +146,7 @@ export class EditPaymentReceive {
|
||||
paymentReceiveId,
|
||||
paymentReceive,
|
||||
oldPaymentReceive,
|
||||
paymentReceiveDTO,
|
||||
authorizedUser,
|
||||
trx,
|
||||
} as IPaymentReceiveEditedPayload);
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
// @ts-nocheck
|
||||
import { FSuggest } from '../Forms';
|
||||
|
||||
interface BranchSuggestFieldProps {
|
||||
items: any[];
|
||||
}
|
||||
|
||||
export function BranchSuggestField({ ...props }: BranchSuggestFieldProps) {
|
||||
return (
|
||||
<FSuggest
|
||||
valueAccessor={'id'}
|
||||
labelAccessor={'code'}
|
||||
textAccessor={'name'}
|
||||
inputProps={{ placeholder: 'Select a branch' }}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
// @ts-nocheck
|
||||
import React from 'react';
|
||||
import React, { useMemo } from 'react';
|
||||
import { first } from 'lodash';
|
||||
import { DrawerHeaderContent, DrawerLoading } from '@/components';
|
||||
import { DRAWERS } from '@/constants/drawers';
|
||||
import {
|
||||
@@ -34,6 +35,12 @@ function CategorizeTransactionBoot({ uncategorizedTransactionId, ...props }) {
|
||||
isLoading: isUncategorizedTransactionLoading,
|
||||
} = useUncategorizedTransaction(uncategorizedTransactionId);
|
||||
|
||||
// Retrieves the primary branch.
|
||||
const primaryBranch = useMemo(
|
||||
() => branches?.find((b) => b.primary) || first(branches),
|
||||
[branches],
|
||||
);
|
||||
|
||||
const provider = {
|
||||
uncategorizedTransactionId,
|
||||
uncategorizedTransaction,
|
||||
@@ -42,6 +49,7 @@ function CategorizeTransactionBoot({ uncategorizedTransactionId, ...props }) {
|
||||
accounts,
|
||||
isBranchesLoading,
|
||||
isAccountsLoading,
|
||||
primaryBranch,
|
||||
};
|
||||
const isLoading =
|
||||
isBranchesLoading || isUncategorizedTransactionLoading || isAccountsLoading;
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
// @ts-nocheck
|
||||
import { FFormGroup, FeatureCan } from '@/components';
|
||||
import { useCategorizeTransactionBoot } from './CategorizeTransactionBoot';
|
||||
import { Features } from '@/constants';
|
||||
import { BranchSuggestField } from '@/components/Branches/BranchSuggestField_';
|
||||
|
||||
export function CategorizeTransactionBranchField() {
|
||||
const { branches } = useCategorizeTransactionBoot();
|
||||
|
||||
return (
|
||||
<FFormGroup name={'branchId'} label={'Branch'} fastField inline>
|
||||
<FeatureCan feature={Features.Branches}>
|
||||
<BranchSuggestField
|
||||
name={'branchId'}
|
||||
items={branches}
|
||||
popoverProps={{ minimal: true }}
|
||||
fill
|
||||
/>
|
||||
</FeatureCan>
|
||||
</FFormGroup>
|
||||
);
|
||||
}
|
||||
@@ -24,8 +24,11 @@ function CategorizeTransactionFormRoot({
|
||||
// #withDrawerActions
|
||||
closeDrawer,
|
||||
}) {
|
||||
const { uncategorizedTransactionId, uncategorizedTransaction } =
|
||||
useCategorizeTransactionBoot();
|
||||
const {
|
||||
uncategorizedTransactionId,
|
||||
uncategorizedTransaction,
|
||||
primaryBranch,
|
||||
} = useCategorizeTransactionBoot();
|
||||
const { mutateAsync: categorizeTransaction } = useCategorizeTransaction();
|
||||
|
||||
// Callbacks handles form submit.
|
||||
@@ -37,18 +40,28 @@ function CategorizeTransactionFormRoot({
|
||||
.then(() => {
|
||||
setSubmitting(false);
|
||||
closeDrawer(DRAWERS.CATEGORIZE_TRANSACTION);
|
||||
|
||||
|
||||
AppToaster.show({
|
||||
message: 'The uncategorized transaction has been categorized.',
|
||||
intent: Intent.SUCCESS,
|
||||
});
|
||||
})
|
||||
.catch(() => {
|
||||
.catch((err) => {
|
||||
setSubmitting(false);
|
||||
AppToaster.show({
|
||||
message: 'Something went wrong!',
|
||||
intent: Intent.DANGER,
|
||||
});
|
||||
if (
|
||||
err.response.data?.errors?.some(
|
||||
(e) => e.type === 'BRANCH_ID_REQUIRED',
|
||||
)
|
||||
) {
|
||||
setErrors({
|
||||
branchId: 'The branch is required.',
|
||||
});
|
||||
} else {
|
||||
AppToaster.show({
|
||||
message: 'Something went wrong!',
|
||||
intent: Intent.DANGER,
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
// Form initial values in create and edit mode.
|
||||
@@ -60,6 +73,9 @@ function CategorizeTransactionFormRoot({
|
||||
* as well.
|
||||
*/
|
||||
...transformToCategorizeForm(uncategorizedTransaction),
|
||||
|
||||
/** Assign the primary branch id as default value. */
|
||||
branchId: primaryBranch?.id || null,
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
FTextArea,
|
||||
} from '@/components';
|
||||
import { useCategorizeTransactionBoot } from '../CategorizeTransactionBoot';
|
||||
import { CategorizeTransactionBranchField } from '../CategorizeTransactionBranchField';
|
||||
|
||||
export default function CategorizeTransactionOtherIncome() {
|
||||
const { accounts } = useCategorizeTransactionBoot();
|
||||
@@ -68,6 +69,8 @@ export default function CategorizeTransactionOtherIncome() {
|
||||
fill={true}
|
||||
/>
|
||||
</FFormGroup>
|
||||
|
||||
<CategorizeTransactionBranchField />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
FTextArea,
|
||||
} from '@/components';
|
||||
import { useCategorizeTransactionBoot } from '../CategorizeTransactionBoot';
|
||||
import { CategorizeTransactionBranchField } from '../CategorizeTransactionBranchField';
|
||||
|
||||
export default function CategorizeTransactionOwnerContribution() {
|
||||
const { accounts } = useCategorizeTransactionBoot();
|
||||
@@ -63,6 +64,8 @@ export default function CategorizeTransactionOwnerContribution() {
|
||||
<FFormGroup name={'description'} label={'Description'} fastField inline>
|
||||
<FTextArea name={'description'} growVertically large fill />
|
||||
</FFormGroup>
|
||||
|
||||
<CategorizeTransactionBranchField />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
FTextArea,
|
||||
} from '@/components';
|
||||
import { useCategorizeTransactionBoot } from '../CategorizeTransactionBoot';
|
||||
import { CategorizeTransactionBranchField } from '../CategorizeTransactionBranchField';
|
||||
|
||||
export default function CategorizeTransactionTransferFrom() {
|
||||
const { accounts } = useCategorizeTransactionBoot();
|
||||
@@ -47,7 +48,7 @@ export default function CategorizeTransactionTransferFrom() {
|
||||
inline
|
||||
>
|
||||
<AccountsSelect
|
||||
name={'to_account_id'}
|
||||
name={'creditAccountId'}
|
||||
items={accounts}
|
||||
filterByRootTypes={['asset']}
|
||||
fastField
|
||||
@@ -68,6 +69,8 @@ export default function CategorizeTransactionTransferFrom() {
|
||||
fill={true}
|
||||
/>
|
||||
</FFormGroup>
|
||||
|
||||
<CategorizeTransactionBranchField />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
FTextArea,
|
||||
} from '@/components';
|
||||
import { useCategorizeTransactionBoot } from '../CategorizeTransactionBoot';
|
||||
import { CategorizeTransactionBranchField } from '../CategorizeTransactionBranchField';
|
||||
|
||||
export default function CategorizeTransactionOtherExpense() {
|
||||
const { accounts } = useCategorizeTransactionBoot();
|
||||
@@ -68,6 +69,8 @@ export default function CategorizeTransactionOtherExpense() {
|
||||
fill={true}
|
||||
/>
|
||||
</FFormGroup>
|
||||
|
||||
<CategorizeTransactionBranchField />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
FTextArea,
|
||||
} from '@/components';
|
||||
import { useCategorizeTransactionBoot } from '../CategorizeTransactionBoot';
|
||||
import { CategorizeTransactionBranchField } from '../CategorizeTransactionBranchField';
|
||||
|
||||
export default function CategorizeTransactionOwnerDrawings() {
|
||||
const { accounts } = useCategorizeTransactionBoot();
|
||||
@@ -68,6 +69,8 @@ export default function CategorizeTransactionOwnerDrawings() {
|
||||
fill={true}
|
||||
/>
|
||||
</FFormGroup>
|
||||
|
||||
<CategorizeTransactionBranchField />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
FTextArea,
|
||||
} from '@/components';
|
||||
import { useCategorizeTransactionBoot } from '../CategorizeTransactionBoot';
|
||||
import { CategorizeTransactionBranchField } from '../CategorizeTransactionBranchField';
|
||||
|
||||
export default function CategorizeTransactionToAccount() {
|
||||
const { accounts } = useCategorizeTransactionBoot();
|
||||
@@ -49,7 +50,7 @@ export default function CategorizeTransactionToAccount() {
|
||||
<AccountsSelect
|
||||
name={'creditAccountId'}
|
||||
items={accounts}
|
||||
filterByRootTypes={['assset']}
|
||||
filterByRootTypes={['asset']}
|
||||
fastField
|
||||
fill
|
||||
allowCreate
|
||||
@@ -68,6 +69,8 @@ export default function CategorizeTransactionToAccount() {
|
||||
fill={true}
|
||||
/>
|
||||
</FFormGroup>
|
||||
|
||||
<CategorizeTransactionBranchField />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ export const defaultInitialValues = {
|
||||
transactionType: '',
|
||||
referenceNo: '',
|
||||
description: '',
|
||||
branchId: '',
|
||||
};
|
||||
|
||||
export const transformToCategorizeForm = (uncategorizedTransaction) => {
|
||||
|
||||
Reference in New Issue
Block a user