- fix auto update price elang

This commit is contained in:
Fadli 2022-08-21 01:51:46 +07:00
parent 1ae7966861
commit 4cc5794ea5

View File

@ -591,34 +591,35 @@ export class TransactionService {
let costInventory = product_price.price; let costInventory = product_price.price;
if (hitSupplier.harga != product_price.price) { if (hitSupplier.harga != undefined) {
console.log("priceupdate1supplier", hitSupplier.harga) if (hitSupplier.harga != product_price.price) {
console.log("priceupdate1normal", product_price.price) console.log("priceupdate1supplier", hitSupplier.harga)
product_price.endDate = new Date(); console.log("priceupdate1normal", product_price.price)
costInventory = hitSupplier.harga; product_price.endDate = new Date();
const listActivePrice = costInventory = hitSupplier.harga;
await this.productHistoryPriceService.getAllActivePriceByProduct( const listActivePrice =
product.id, await this.productHistoryPriceService.getAllActivePriceByProduct(
); product.id,
);
await this.productHistoryPriceService.updateEndDate(product.id); await this.productHistoryPriceService.updateEndDate(product.id);
listActivePrice.map(async (x) => { listActivePrice.map(async (x) => {
const newProductPrice = new ProductHistoryPrice(); const newProductPrice = new ProductHistoryPrice();
newProductPrice.id = uuid.v4(); newProductPrice.id = uuid.v4();
newProductPrice.type = x.type; newProductPrice.type = x.type;
newProductPrice.price = hitSupplier.harga; newProductPrice.price = hitSupplier.harga;
newProductPrice.mark_up_price = x.mark_up_price; newProductPrice.mark_up_price = x.mark_up_price;
newProductPrice.startDate = new Date(); newProductPrice.startDate = new Date();
newProductPrice.product = product; newProductPrice.product = product;
newProductPrice.partner = x.partner; newProductPrice.partner = x.partner;
await this.productHistoryPriceService.create(newProductPrice); await this.productHistoryPriceService.create(newProductPrice);
product_price = newProductPrice;
});
}
product_price = newProductPrice;
});
}
}
try { try {
//TRANSACTION DATA //TRANSACTION DATA
await this.connection.transaction(async (manager) => { await this.connection.transaction(async (manager) => {