Merge branch 'master' of https://gitlab.com/empatnusabangsa/ppob/ppob-backend into devops-production

This commit is contained in:
Fadli 2022-09-06 21:37:47 +07:00
commit fd2cd506f5
2 changed files with 115 additions and 104 deletions

View File

@ -123,6 +123,7 @@ export class ProductService {
status: it[5] == 'active' ? 'ACTIVE' : 'NOT ACTIVE',
});
}
dataHistoryPrice = await this.productHistoryPrice.findOne({
product: productData,
partner: IsNull(),
@ -227,7 +228,7 @@ export class ProductService {
'product.currentStatus',
'product.statusHistory',
'history_status',
'history_status.deleted_at is NULL'
'history_status.deleted_at is NULL',
)
.select(['product.id'])
.addSelect([
@ -330,7 +331,7 @@ export class ProductService {
.addSelect(['product.name', 'product.code', 'sub_categories.name'])
.addSelect('(current_price.price + current_price.mark_up_price) as price')
.orderBy('price', 'ASC')
.distinct()
.distinct();
if (subCategories != 'null' && subCategories) {
baseQuery.andWhere('product.sub_categories_id = :id', {
@ -397,13 +398,17 @@ export class ProductService {
'product.currentStatus',
'product.statusHistory',
'history_status',
'history_status.deleted_at is NULL'
)
.where(`history_status.partner_id = :id_partner and history_status.status = 'ACTIVE'`,
'history_status.partner_id = :id_partner and history_status.deleted_at is NULL',
{
id_partner: user.partner.id,
},
)
// .where(`history_status.partner_id = :id_partner`, {
// partner: user.partner.id,
// })
.where(`history_status.status = 'ACTIVE'`, {
status: 'ACTIVE',
})
.select(['product.id'])
.addSelect([
'product.name',
@ -416,7 +421,7 @@ export class ProductService {
'current_price.price as price',
])
.addSelect('history_status.status', 'status')
.distinct()
.distinct();
// .addSelect(
// '(current_price.price + current_price.mark_up_price) as price',
// );
@ -431,14 +436,15 @@ export class ProductService {
// });
// }
if (subCategories && filterSubCategories.length > 0) {
baseQuery.where('product.sub_categories_id IN (:...subCategoryId)', {
baseQuery
.where('product.sub_categories_id IN (:...subCategoryId)', {
subCategoryId: filterSubCategories,
}).andWhere(`history_status.status = 'ACTIVE'`)
})
.andWhere(`history_status.status = 'ACTIVE'`);
}
const newData = []
const newData = [];
const data = await baseQuery
.offset(page * pageSize)
@ -446,23 +452,24 @@ export class ProductService {
.getRawMany();
data.map((dataa) => {
let actualPrice = 0
let actualPrice = 0;
if (dataa.product_type === 'prepaid') {
actualPrice = Number(dataa['price']) + Number(dataa['markup_price'])
actualPrice = Number(dataa['price']) + Number(dataa['markup_price']);
}
if (dataa.product_type === 'postpaid') {
actualPrice = Number(dataa['admin_price'])- (Number(dataa['partner_fee']) + Number(dataa['markup_price']))
actualPrice =
Number(dataa['admin_price']) -
(Number(dataa['partner_fee']) + Number(dataa['markup_price']));
}
dataa.price = actualPrice
dataa.price = actualPrice;
newData.push({
...dataa
})
})
...dataa,
});
});
const totalData = await baseQuery.getCount();
@ -495,14 +502,19 @@ export class ProductService {
}
}
async findOneActive(code: string, type: string, roles: string, supplierId: string) {
if (roles == "Retail") {
async findOneActive(
code: string,
type: string,
roles: string,
supplierId: string,
) {
if (roles == 'Retail') {
try {
return await this.productRepository.findOneOrFail({
relations: ['supplier'],
where: {
code: code,
supplier: supplierId
supplier: supplierId,
},
});
} catch (e) {
@ -519,8 +531,6 @@ export class ProductService {
}
}
} else {
try {
return await this.productRepository.findOneOrFail({
relations: ['supplier'],
@ -541,7 +551,6 @@ export class ProductService {
throw e;
}
}
}
}
@ -598,6 +607,7 @@ export class ProductService {
await this.productHistoryStatus.update(dataStatus.id, {
status: updateProductDto.status,
});
const result = await this.productRepository.update(id, {
name: updateProductDto.name,
code: updateProductDto.code,

View File

@ -1111,23 +1111,23 @@ export class TransactionService {
supplier_trx_id
);
if (transactionData.status == statusTransaction.FAILED) {
throw new HttpException(
{
statusCode: HttpStatus.BAD_REQUEST,
error: 'failed to update, the transaction already failed',
},
HttpStatus.BAD_REQUEST,
);
} else if (transactionData.status == statusTransaction.SUCCESS) {
throw new HttpException(
{
statusCode: HttpStatus.BAD_REQUEST,
error: 'failed to update, the transaction already success',
},
HttpStatus.BAD_REQUEST,
);
} else {
// if (transactionData.status == statusTransaction.FAILED) {
// throw new HttpException(
// {
// statusCode: HttpStatus.BAD_REQUEST,
// error: 'failed to update, the transaction already failed',
// },
// HttpStatus.BAD_REQUEST,
// );
// } else if (transactionData.status == statusTransaction.SUCCESS) {
// throw new HttpException(
// {
// statusCode: HttpStatus.BAD_REQUEST,
// error: 'failed to update, the transaction already success',
// },
// HttpStatus.BAD_REQUEST,
// );
// } else {
const updateTransaction = await this.callbackOrderFailed(
supplier_trx_id,
callback,
@ -1142,7 +1142,7 @@ export class TransactionService {
HttpStatus.BAD_REQUEST,
);
}
// }
}
@ -1337,7 +1337,7 @@ export class TransactionService {
});
dataTransaction.status = statusTransaction.SUCCESS;
if(callback['sn']){
if (callback['sn']) {
dataTransaction.seri_number = callback['sn'];
console.log("msksn1", dataTransaction.seri_number)
} else {
@ -1352,7 +1352,7 @@ export class TransactionService {
}
dataTransaction.callback_json = callback;
if(callback['message']) {
if (callback['message']) {
if (callback['message'].includes('METRO')) {
if (callback['price'] != dataTransaction.product_price.price) {
dataProductHistoryPrice.price = parseInt(callback['price'])
@ -1420,7 +1420,7 @@ export class TransactionService {
} catch (e) {
throw e;
}
if (userData.partner != null) {
if (userData.partner) {
const message = `Transaksi ${product.code} dengan tujuan ${dataTransaction.destination} telah berhasil.`;
this.callbackToPartner(
@ -1435,6 +1435,7 @@ export class TransactionService {
);
}
}
}
async resendOrderToPartner(supplier_trx_id: string, status: boolean){
const dataTransaction = await this.transactionRepository.findOne({