fix: add coa in supplier

This commit is contained in:
ilham
2021-12-16 15:05:10 +07:00
parent dcad18339b
commit 264b7312ed
5 changed files with 61 additions and 11 deletions

View File

@@ -2,6 +2,7 @@ import { Roles } from 'src/configurable/entities/roles.entity';
import { Entity, Column, PrimaryGeneratedColumn, ManyToOne } from 'typeorm';
import { BaseModel } from '../../config/basemodel.entity';
import { hashPassword } from '../../helper/hash_password';
import { COA } from '../../transaction/entities/coa.entity';
@Entity()
export class Supplier extends BaseModel {
@@ -16,4 +17,6 @@ export class Supplier extends BaseModel {
@Column()
status: boolean;
coa: COA;
}

View File

@@ -14,6 +14,7 @@ import { CreateSupplierDto } from '../dto/create-supplier.dto';
import { CoaService } from '../../transaction/coa.service';
import * as uuid from 'uuid';
import { UpdateSupplierDto } from '../dto/update-supplier.dto';
import { COA } from '../../transaction/entities/coa.entity';
@Injectable()
export class SupplierService {
@@ -129,14 +130,28 @@ export class SupplierService {
return supplierData;
};
findAllSupplier(page) {
return this.supplierRepository.findAndCount({
skip: page * 10,
take: 10,
order: {
version: 'DESC',
},
});
async findAllSupplier(page) {
const baseQuery = this.supplierRepository
.createQueryBuilder('supplier')
.leftJoinAndMapOne(
'supplier.coa',
COA,
'coa',
`coa.supplier = supplier.id`,
)
.select(['supplier', 'coa.amount']);
const data = await baseQuery
.skip(page * 10)
.take(10)
.getMany();
const totalData = await baseQuery.getCount();
return {
data,
count: totalData,
};
}
async findByCode(code: string) {