add server to monorepo.

This commit is contained in:
a.bouhuolia
2023-02-03 11:57:50 +02:00
parent 28e309981b
commit 80b97b5fdc
1303 changed files with 137049 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
import { Service, Inject } from 'typedi';
import { ServiceError } from '@/exceptions';
import HasTenancyService from '@/services/Tenancy/TenancyService';
import { ERRORS } from './constants';
@Service()
export default class CashflowDeleteAccount {
@Inject()
tenancy: HasTenancyService;
/**
* Validate the account has no associated cashflow transactions.
* @param {number} tenantId
* @param {number} accountId
*/
public validateAccountHasNoCashflowEntries = async (
tenantId: number,
accountId: number
) => {
const { CashflowTransactionLine } = this.tenancy.models(tenantId);
const associatedLines = await CashflowTransactionLine.query()
.where('creditAccountId', accountId)
.orWhere('cashflowAccountId', accountId);
if (associatedLines.length > 0) {
throw new ServiceError(ERRORS.ACCOUNT_HAS_ASSOCIATED_TRANSACTIONS)
}
};
}