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