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

View File

@ -1062,7 +1062,7 @@ export class TransactionService {
'status', 'status',
'userData.name', 'userData.name',
]) ])
.orderBy('transaction.created_at','DESC'); .orderBy('transaction.created_at', 'DESC');
if (startDate && endDate) { if (startDate && endDate) {
baseQuery.andWhere( baseQuery.andWhere(