Merge branch 'development' into 'devops-staging'
fix: deploy See merge request empatnusabangsa/ppob/ppob-backend!87
This commit is contained in:
commit
3f77af8645
|
@ -19,6 +19,17 @@ export class ProductHistoryPriceService {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getAllActivePriceByProduct(productId: string) {
|
||||||
|
const result = await this.productHistoryPriceRepository
|
||||||
|
.createQueryBuilder('product_history_price')
|
||||||
|
.leftJoin('product_history_price.product', 'product')
|
||||||
|
.where({ product: productId })
|
||||||
|
.andWhere('product_history_price.endDate IS NULL')
|
||||||
|
.getMany();
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
async updateEndDate(idProduct: string) {
|
async updateEndDate(idProduct: string) {
|
||||||
try {
|
try {
|
||||||
const dataPrice = await this.productHistoryPriceRepository
|
const dataPrice = await this.productHistoryPriceRepository
|
||||||
|
|
|
@ -520,18 +520,25 @@ export class TransactionService {
|
||||||
if (hitSupplier.harga > product_price.price) {
|
if (hitSupplier.harga > product_price.price) {
|
||||||
product_price.endDate = new Date();
|
product_price.endDate = new Date();
|
||||||
|
|
||||||
|
const listActivePrice =
|
||||||
|
await this.productHistoryPriceService.getAllActivePriceByProduct(
|
||||||
|
product.id,
|
||||||
|
);
|
||||||
|
|
||||||
|
await this.productHistoryPriceService.updateEndDate(product.id);
|
||||||
|
|
||||||
|
listActivePrice.map(async (x) => {
|
||||||
let newProductPrice = new ProductHistoryPrice();
|
let newProductPrice = new ProductHistoryPrice();
|
||||||
|
|
||||||
newProductPrice.id = uuid.v4();
|
newProductPrice.id = uuid.v4();
|
||||||
newProductPrice.type = product_price.type;
|
newProductPrice.type = x.type;
|
||||||
newProductPrice.price = hitSupplier.harga;
|
newProductPrice.price = hitSupplier.harga;
|
||||||
newProductPrice.mark_up_price = product_price.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 = product_price.partner;
|
newProductPrice.partner = x.partner;
|
||||||
|
|
||||||
await this.productHistoryPriceService.updateEndDate(product.id);
|
|
||||||
await this.productHistoryPriceService.create(newProductPrice);
|
await this.productHistoryPriceService.create(newProductPrice);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -1021,9 +1028,6 @@ export class TransactionService {
|
||||||
createdAt: 'DESC',
|
createdAt: 'DESC',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return baseQuery;
|
return baseQuery;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user