add: transaction distribution and order

This commit is contained in:
ilham
2021-12-07 23:07:29 +07:00
parent 37352567f1
commit 426c2ccec8
7 changed files with 99 additions and 24 deletions

View File

@@ -2,6 +2,7 @@ import { HttpException, HttpStatus, Injectable } from '@nestjs/common';
import { EntityNotFoundError, Repository } from 'typeorm';
import { InjectRepository } from '@nestjs/typeorm';
import { COA } from './entities/coa.entity';
import { coaType } from '../helper/enum-list';
export class CoaService {
constructor(
@@ -9,9 +10,9 @@ export class CoaService {
private coaRepository: Repository<COA>,
) {}
async findByUser(id: string) {
async findByUser(id: string, type: coaType) {
try {
return await this.coaRepository.findOneOrFail({ user: id });
return await this.coaRepository.findOneOrFail({ user: id, type: type });
} catch (e) {
if (e instanceof EntityNotFoundError) {
throw new HttpException(