fix: add coa in supplier
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user