- fix auto update price and add new repository for product_history_price
This commit is contained in:
parent
d251cadb0d
commit
0b9df3006a
|
@ -1204,6 +1204,12 @@ export class TransactionService {
|
|||
relations: ['product_price'],
|
||||
});
|
||||
|
||||
const dataProductHistoryPrice = await this.productPriceRepository.findOne({
|
||||
where: {
|
||||
id: dataTransaction.product_price.id,
|
||||
},
|
||||
});
|
||||
|
||||
// const dataMsg = callback.msg;
|
||||
// const failedReason = dataMsg.split('.');
|
||||
|
||||
|
@ -1231,7 +1237,7 @@ export class TransactionService {
|
|||
if (callback['message'].includes('METRO')) {
|
||||
if (callback['price'] != dataTransaction.product_price.price) {
|
||||
console.log("mskupdt", "msk")
|
||||
dataTransaction.product_price.price = parseInt(callback['price'])
|
||||
dataProductHistoryPrice.price = parseInt(callback['price'])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1262,6 +1268,7 @@ export class TransactionService {
|
|||
try {
|
||||
await this.connection.transaction(async (manager) => {
|
||||
await manager.save(dataTransaction);
|
||||
await manager.save(dataProductHistoryPrice);
|
||||
|
||||
await this.accountingTransaction({
|
||||
createTransaction: false,
|
||||
|
@ -1315,6 +1322,12 @@ export class TransactionService {
|
|||
relations: ['product_price'],
|
||||
});
|
||||
|
||||
const dataProductHistoryPrice = await this.productPriceRepository.findOne({
|
||||
where: {
|
||||
id: dataTransaction.product_price.id,
|
||||
},
|
||||
});
|
||||
|
||||
dataTransaction.status = statusTransaction.SUCCESS;
|
||||
if(callback['sn']){
|
||||
dataTransaction.seri_number = callback['sn'];
|
||||
|
@ -1329,7 +1342,7 @@ export class TransactionService {
|
|||
if(callback['message']) {
|
||||
if (callback['message'].includes('METRO')) {
|
||||
if (callback['price'] != dataTransaction.product_price.price) {
|
||||
dataTransaction.product_price.price = parseInt(callback['price'])
|
||||
dataProductHistoryPrice.price = parseInt(callback['price'])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1379,6 +1392,7 @@ export class TransactionService {
|
|||
try {
|
||||
await this.connection.transaction(async (manager) => {
|
||||
await manager.save(dataTransaction);
|
||||
await manager.save(dataProductHistoryPrice)
|
||||
|
||||
await this.accountingTransaction({
|
||||
createTransaction: false,
|
||||
|
|
Loading…
Reference in New Issue
Block a user