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 supplierData = await this.supplierService.findByCode(supplierCode);
|
||||||
|
|
||||||
const data = await parsingFile(uploadFile);
|
const data = await parsingFile(uploadFile);
|
||||||
|
|
||||||
data.shift();
|
data.shift();
|
||||||
await mapSeries(data, async (it) => {
|
await mapSeries(data, async (it) => {
|
||||||
let dataHistoryPrice;
|
let dataHistoryPrice;
|
||||||
|
@ -71,6 +72,7 @@ export class ProductService {
|
||||||
code: it[0],
|
code: it[0],
|
||||||
supplier: supplierData,
|
supplier: supplierData,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (productData) {
|
if (productData) {
|
||||||
//TODO : Handle Update Product
|
//TODO : Handle Update Product
|
||||||
productData.name = it[1];
|
productData.name = it[1];
|
||||||
|
@ -111,9 +113,11 @@ export class ProductService {
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
let partnerData;
|
let partnerData;
|
||||||
|
|
||||||
if (it[6] != '-' && it[6] != '') {
|
if (it[6] != '-' && it[6] != '') {
|
||||||
partnerData = await this.partnerService.findOne(it[6]);
|
partnerData = await this.partnerService.findOne(it[6]);
|
||||||
}
|
}
|
||||||
|
|
||||||
const savedProduct = await this.productRepository.insert({
|
const savedProduct = await this.productRepository.insert({
|
||||||
name: it[1],
|
name: it[1],
|
||||||
code: it[0],
|
code: it[0],
|
||||||
|
@ -294,6 +298,16 @@ export class ProductService {
|
||||||
const user = await this.usersService.findOneByUsername(username);
|
const user = await this.usersService.findOneByUsername(username);
|
||||||
const supplier = await this.supplierService.findByActive();
|
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
|
const baseQuery = this.productRepository
|
||||||
.createQueryBuilder('product')
|
.createQueryBuilder('product')
|
||||||
.leftJoin('product.sub_categories', 'sub_categories')
|
.leftJoin('product.sub_categories', 'sub_categories')
|
||||||
|
|
Loading…
Reference in New Issue
Block a user