Feat: add validation error if id partner is null
This commit is contained in:
parent
a1f689e82b
commit
3ff8193949
|
@ -55,6 +55,7 @@ export class ProductService {
|
|||
const supplierData = await this.supplierService.findByCode(supplierCode);
|
||||
|
||||
const data = await parsingFile(uploadFile);
|
||||
|
||||
data.shift();
|
||||
await mapSeries(data, async (it) => {
|
||||
let dataHistoryPrice;
|
||||
|
@ -71,6 +72,7 @@ export class ProductService {
|
|||
code: it[0],
|
||||
supplier: supplierData,
|
||||
});
|
||||
|
||||
if (productData) {
|
||||
//TODO : Handle Update Product
|
||||
productData.name = it[1];
|
||||
|
@ -111,9 +113,11 @@ export class ProductService {
|
|||
});
|
||||
} else {
|
||||
let partnerData;
|
||||
|
||||
if (it[6] != '-' && it[6] != '') {
|
||||
partnerData = await this.partnerService.findOne(it[6]);
|
||||
}
|
||||
|
||||
const savedProduct = await this.productRepository.insert({
|
||||
name: it[1],
|
||||
code: it[0],
|
||||
|
@ -294,6 +298,16 @@ export class ProductService {
|
|||
const user = await this.usersService.findOneByUsername(username);
|
||||
const supplier = await this.supplierService.findByActive();
|
||||
|
||||
if (user.partner === null) {
|
||||
throw new HttpException(
|
||||
{
|
||||
statusCode: HttpStatus.NOT_FOUND,
|
||||
error: 'Partner id not found',
|
||||
},
|
||||
HttpStatus.NOT_FOUND,
|
||||
);
|
||||
}
|
||||
|
||||
const baseQuery = this.productRepository
|
||||
.createQueryBuilder('product')
|
||||
.leftJoin('product.sub_categories', 'sub_categories')
|
||||
|
|
Loading…
Reference in New Issue
Block a user