journaling

This commit is contained in:
2021-12-08 21:01:31 +07:00
parent 679bb758d8
commit d65af44a52
9 changed files with 220 additions and 9 deletions

View File

@@ -1,4 +1,4 @@
import { Module } from '@nestjs/common';
import { forwardRef, Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { UsersService } from './users.service';
import { UsersController } from './users.controller';
@@ -7,7 +7,7 @@ import { TransactionModule } from 'src/transaction/transaction.module';
import { ConfigurableModule } from 'src/configurable/configurable.module';
@Module({
imports: [TypeOrmModule.forFeature([User]), TransactionModule, ConfigurableModule],
imports: [TypeOrmModule.forFeature([User]), forwardRef(() => TransactionModule), ConfigurableModule],
controllers: [UsersController],
providers: [UsersService],
exports: [UsersService],

View File

@@ -1,4 +1,4 @@
import { HttpException, HttpStatus, Injectable } from '@nestjs/common';
import { forwardRef, HttpException, HttpStatus, Inject, Injectable } from '@nestjs/common';
import { CreateUserDto } from './dto/create-user.dto';
import { UpdateUserDto } from './dto/update-user.dto';
import { EntityNotFoundError, Repository } from 'typeorm';
@@ -7,14 +7,16 @@ import { InjectRepository } from '@nestjs/typeorm';
import { randomStringGenerator } from '@nestjs/common/utils/random-string-generator.util';
import { hashPassword } from '../helper/hash_password';
import { CoaService } from 'src/transaction/coa.service';
import { coaType } from 'src/helper/enum-list';
import { balanceType, coaType } from 'src/helper/enum-list';
import { RoleService } from 'src/configurable/roles.service';
import { InputCoaDto } from 'src/transaction/dto/input-coa.dto';
@Injectable()
export class UsersService {
constructor(
@InjectRepository(User)
private usersRepository: Repository<User>,
@Inject(forwardRef(() => CoaService))
private coaService: CoaService,
private roleService: RoleService
) {}
@@ -32,6 +34,25 @@ export class UsersService {
roles:roles
});
let dataCoaWallet = new InputCoaDto();
dataCoaWallet.userId = result.identifiers[0].id;
dataCoaWallet.balanceType = balanceType.CREDIT;
dataCoaWallet.type = coaType.WALLET;
let dataCoaAR = new InputCoaDto();
dataCoaAR.userId = result.identifiers[0].id;
dataCoaAR.balanceType = balanceType.CREDIT;
dataCoaAR.type = coaType.ACCOUNT_RECEIVABLE;
let dataCoaPayable = new InputCoaDto();
dataCoaPayable.userId = result.identifiers[0].id;
dataCoaPayable.balanceType = balanceType.CREDIT;
dataCoaPayable.type = coaType.ACCOUNT_PAYABLE;
await this.coaService.create(dataCoaWallet);
await this.coaService.create(dataCoaAR);
await this.coaService.create(dataCoaPayable);
return this.usersRepository.findOneOrFail(result.identifiers[0].id);
}