Merge branch 'master' of https://gitlab.com/empatnusabangsa/ppob/ppob-backend into devops-production
This commit is contained in:
		| @@ -63,6 +63,7 @@ export class ProductService { | ||||
|     await mapSeries(data, async (it) => { | ||||
|       let dataHistoryPrice; | ||||
|       let partnerData; | ||||
|       let productStatusPartner; | ||||
|  | ||||
|       const subCategories = | ||||
|           await this.productSubCategoriesService.findOneForCSVParser(it[2]); | ||||
| @@ -76,15 +77,26 @@ export class ProductService { | ||||
|         supplier: supplierData, | ||||
|       }); | ||||
|  | ||||
|       const productStatus = await this.productHistoryStatus.findOne({ | ||||
|         product: productData, | ||||
|         partner: null, | ||||
|       }); | ||||
|  | ||||
|       if (productData) { | ||||
|         //TODO : Handle Update Product | ||||
|         productData.name = it[1]; | ||||
|         productData.status = it[5] == 'active' ? 'ACTIVE' : 'NOT ACTIVE'; | ||||
|  | ||||
|         await this.productRepository.save(productData); | ||||
|  | ||||
|         //TODO : Handle History Price | ||||
|         if (it[6] != '-' && it[6] != '') { | ||||
|           partnerData = await this.partnerService.findOne(it[6]); | ||||
|           productStatusPartner = await this.productHistoryStatus.findOne({ | ||||
|             product: productData, | ||||
|             partner: partnerData.id, | ||||
|           }); | ||||
|  | ||||
|           dataHistoryPrice = await this.productHistoryPrice.findOne({ | ||||
|             where: { | ||||
|               product: productData.id, | ||||
| @@ -93,6 +105,8 @@ export class ProductService { | ||||
|             }, | ||||
|           }); | ||||
|         } else { | ||||
|           productStatus.status = it[5] == 'active' ? 'ACTIVE' : 'NOT ACTIVE'; | ||||
|           await this.productHistoryStatus.save(productStatus); | ||||
|           dataHistoryPrice = await this.productHistoryPrice.findOne({ | ||||
|             product: productData, | ||||
|             partner: IsNull(), | ||||
| @@ -106,12 +120,11 @@ export class ProductService { | ||||
|           }); | ||||
|         } | ||||
|  | ||||
|         await this.productHistoryStatus.insert({ | ||||
|           product: productData, | ||||
|           partner: it[6] != '-' ? partnerData : null, | ||||
|           status: it[5] == 'active' ? 'ACTIVE' : 'NOT ACTIVE', | ||||
|  | ||||
|         }); | ||||
|         if (productStatusPartner) { | ||||
|           await this.productHistoryStatus.update(productStatusPartner.id, { | ||||
|             status: it[5] == 'active' ? 'ACTIVE' : 'NOT ACTIVE', | ||||
|           }); | ||||
|         } | ||||
|  | ||||
|         await this.productHistoryPrice.insert({ | ||||
|           product: productData, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user