fixing: get product by supplier and categories

This commit is contained in:
ilham
2021-12-14 22:15:21 +07:00
parent a3ce252e3c
commit 6951d052ff
3 changed files with 42 additions and 14 deletions

View File

@@ -48,7 +48,7 @@ export class SupplierService {
supplierData.id = uuid.v4();
supplierData.name = createSupplierDto.name;
supplierData.code = createSupplierDto.code;
supplierData.status = true;
supplierData.status = false;
await this.connection.transaction(async (manager) => {
const result = await manager.insert(Supplier, supplierData);
@@ -158,4 +158,24 @@ export class SupplierService {
}
}
}
async findByActive() {
try {
return await this.supplierRepository.findOneOrFail({
status: true,
});
} catch (e) {
if (e instanceof EntityNotFoundError) {
throw new HttpException(
{
statusCode: HttpStatus.NOT_FOUND,
error: 'Supplier Data not found',
},
HttpStatus.NOT_FOUND,
);
} else {
throw e;
}
}
}
}