fix user input
This commit is contained in:
@@ -15,23 +15,19 @@ export class CoaService {
|
||||
) {}
|
||||
|
||||
async create(inputCoaDto: InputCoaDto) {
|
||||
const user = await this.userService.findExist(inputCoaDto.userId)
|
||||
console.log(coaType[inputCoaDto.type])
|
||||
console.log(inputCoaDto.type)
|
||||
const result = await this.coaRepository.insert({
|
||||
user:user.id,
|
||||
name: coaType[inputCoaDto.type] + '-' + user.username,
|
||||
balanceType:inputCoaDto.balanceType,
|
||||
type:inputCoaDto.type,
|
||||
amount:0
|
||||
});
|
||||
const user = inputCoaDto.user
|
||||
let coaData = new COA();
|
||||
coaData.user = user.id;
|
||||
coaData.name = coaType[inputCoaDto.type] + '-' + user.username;
|
||||
coaData.balanceType = inputCoaDto.balanceType;
|
||||
coaData.type = inputCoaDto.type;
|
||||
coaData.amount = 0;
|
||||
|
||||
const result = await inputCoaDto.coaEntityManager.insert(COA,coaData);
|
||||
|
||||
const coaData = await this.coaRepository.findOneOrFail(
|
||||
result.identifiers[0].id,
|
||||
);
|
||||
if(inputCoaDto.type == coaType.ACCOUNT_RECEIVABLE || inputCoaDto.type == coaType.ACCOUNT_PAYABLE){
|
||||
coaData.relatedUser = inputCoaDto.relatedUserId;
|
||||
await this.coaRepository.save(coaData)
|
||||
await inputCoaDto.coaEntityManager.save(coaData)
|
||||
}
|
||||
|
||||
return coaData;
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import { IsNotEmpty, IsUUID } from 'class-validator';
|
||||
import { balanceType, coaType } from 'src/helper/enum-list';
|
||||
import { User } from 'src/users/entities/user.entity';
|
||||
import { EntityManager } from 'typeorm';
|
||||
|
||||
export class InputCoaDto {
|
||||
@IsUUID()
|
||||
userId: string;
|
||||
user: User;
|
||||
|
||||
@IsNotEmpty()
|
||||
type: coaType;
|
||||
@@ -13,4 +15,7 @@ export class InputCoaDto {
|
||||
|
||||
@IsUUID()
|
||||
relatedUserId: string;
|
||||
|
||||
@IsNotEmpty()
|
||||
coaEntityManager: EntityManager;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user