fix: fix product upload

This commit is contained in:
ilham 2022-01-06 23:13:38 +07:00
parent ad71d81b4e
commit f5b510d75b
2 changed files with 15 additions and 22 deletions

View File

@ -84,28 +84,22 @@ export class ProductService {
where: {
product: productData.id,
partner: partnerData.id,
endDate: IsNull(),
},
});
} else {
dataHistoryPrice = await this.productHistoryPrice.findOne({
product: productData,
partner: IsNull(),
endDate: IsNull(),
});
}
if (!dataHistoryPrice) {
await this.productHistoryPrice.insert({
product: productData,
mark_up_price: it[4],
price: it[3],
type: productType.NORMAL,
startDate: new Date(),
partner: it[6] != '-' ? partnerData : null,
if (dataHistoryPrice) {
await this.productHistoryPrice.update(dataHistoryPrice.id, {
endDate: new Date(),
});
} else {
dataHistoryPrice.endDate = new Date();
await this.productHistoryPrice.save(dataHistoryPrice);
}
await this.productHistoryPrice.insert({
product: productData,
@ -115,7 +109,6 @@ export class ProductService {
startDate: new Date(),
partner: it[6] != '-' ? partnerData : null,
});
}
} else {
let partnerData;
if (it[6] != '-' && it[6] != '') {