- 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;
if (hitSupplier.harga != product_price.price) {
console.log("priceupdate1supplier", hitSupplier.harga)
console.log("priceupdate1normal", product_price.price)
product_price.endDate = new Date();
costInventory = hitSupplier.harga;
const listActivePrice =
await this.productHistoryPriceService.getAllActivePriceByProduct(
product.id,
);
if (hitSupplier.harga != undefined) {
if (hitSupplier.harga != product_price.price) {
console.log("priceupdate1supplier", hitSupplier.harga)
console.log("priceupdate1normal", product_price.price)
product_price.endDate = new Date();
costInventory = hitSupplier.harga;
const listActivePrice =
await this.productHistoryPriceService.getAllActivePriceByProduct(
product.id,
);
await this.productHistoryPriceService.updateEndDate(product.id);
await this.productHistoryPriceService.updateEndDate(product.id);
listActivePrice.map(async (x) => {
const newProductPrice = new ProductHistoryPrice();
listActivePrice.map(async (x) => {
const newProductPrice = new ProductHistoryPrice();
newProductPrice.id = uuid.v4();
newProductPrice.type = x.type;
newProductPrice.price = hitSupplier.harga;
newProductPrice.mark_up_price = x.mark_up_price;
newProductPrice.startDate = new Date();
newProductPrice.product = product;
newProductPrice.partner = x.partner;
await this.productHistoryPriceService.create(newProductPrice);
product_price = newProductPrice;
});
}
newProductPrice.id = uuid.v4();
newProductPrice.type = x.type;
newProductPrice.price = hitSupplier.harga;
newProductPrice.mark_up_price = x.mark_up_price;
newProductPrice.startDate = new Date();
newProductPrice.product = product;
newProductPrice.partner = x.partner;
await this.productHistoryPriceService.create(newProductPrice);
product_price = newProductPrice;
});
}
}
try {
//TRANSACTION DATA
await this.connection.transaction(async (manager) => {