Merge pull request 'development' (#112) from development into production
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/tag Build is passing Details

Reviewed-on: #112
pull/113/head 1.2.2-production.1
irfan 2024-10-19 18:35:05 +00:00
commit fea0420ae4
6 changed files with 44 additions and 7 deletions

View File

@ -34,6 +34,7 @@ export class DetailItemManager extends BaseDetailManager<ItemEntity> {
return [
`${this.tableName}.id`,
`${this.tableName}.image_url`,
`${this.tableName}.video_url`,
`${this.tableName}.created_at`,
`${this.tableName}.status`,
`${this.tableName}.item_type`,

View File

@ -4,9 +4,8 @@ import { EventTopics } from 'src/core/strings/constants/interface.constants';
import { TransactionType } from 'src/modules/transaction/transaction/constants';
import { TransactionModel } from 'src/modules/transaction/transaction/data/models/transaction.model';
import { TransactionEntity } from 'src/modules/transaction/transaction/domain/entities/transaction.entity';
import { Between, IsNull, MoreThan, Not } from 'typeorm';
import { Brackets, DeleteQueryBuilder, IsNull, MoreThan, Not } from 'typeorm';
import * as _ from 'lodash';
import * as moment from 'moment';
import { EMPTY_UUID, STATUS } from 'src/core/strings/constants/base.constants';
import { RecapReconciliationDto } from '../../../infrastructure/dto/recap.dto';
@ -58,11 +57,11 @@ export class RecapReconciliationManager extends BaseCustomManager<TransactionEnt
} = transaction;
const group_by =
creator_counter_no +
'-' +
'|' +
payment_type_counter +
'-' +
'|' +
payment_type_method_id +
'_' +
'|' +
payment_date;
if (!this.recapTransactions[group_by]) {
@ -77,6 +76,38 @@ export class RecapReconciliationManager extends BaseCustomManager<TransactionEnt
async process(): Promise<void> {
const total_recap = Object.keys(this.recapTransactions);
const deleteQuery: DeleteQueryBuilder<TransactionEntity> = this.dataService
.getRepository()
.createQueryBuilder(this.tableName)
.delete();
deleteQuery.where(
`payment_date = :payment_date and is_recap_transaction = true`,
{
payment_date: this.paymentDate,
},
);
deleteQuery.andWhere(
new Brackets((qb) => {
for (const condition of total_recap) {
const [
creator_counter_no,
payment_type_counter,
payment_type_method_id,
] = condition.split('|');
const whereMethodId =
payment_type_method_id == 'null'
? 'IS NULL'
: `= '${payment_type_method_id}'`;
qb.andWhere(
`NOT (creator_counter_no = '${creator_counter_no}' AND payment_type_counter = '${payment_type_counter}' AND payment_type_method_id ${whereMethodId})`,
);
}
}),
);
await deleteQuery.execute();
for (const recap of total_recap) {
const first_transaction = this.recapTransactions[recap][0];

View File

@ -126,6 +126,9 @@ export class PriceCalculator {
let result = null;
try {
if (!formula) {
break;
}
result = math.evaluate(formula.formula_string, values);
calledVariable = [];
} catch (error) {

View File

@ -191,7 +191,7 @@ export function mappingRevertTransaction(data, type) {
const bundlingTotalPrice =
(item.item?.bundling_items?.reduce(
(a, b) => a + Number(b.item_rates ?? b.base_price),
(a, b) => a + Number(b.item_rates || b.base_price),
0,
) ?? 0) * +item.qty;
const totalAndBundlingRatio = total_price / bundlingTotalPrice;
@ -199,7 +199,7 @@ export function mappingRevertTransaction(data, type) {
if (bundling.total_net_price) return bundling;
const basePrice =
(bundling.item_rates ?? bundling.base_price) *
(bundling.item_rates || bundling.base_price) *
+item.qty *
totalAndBundlingRatio;
const discount = discountPercent * basePrice;

View File

@ -35,6 +35,7 @@ export class DetailVipCategoryManager extends BaseDetailManager<VipCategoryEntit
`${this.tableName}.id`,
`${this.tableName}.status`,
`${this.tableName}.name`,
`${this.tableName}.has_vip_pass`,
`${this.tableName}.created_at`,
`${this.tableName}.updated_at`,
`${this.tableName}.creator_name`,

View File

@ -39,6 +39,7 @@ export class IndexVipCategoryManager extends BaseIndexManager<VipCategoryEntity>
`${this.tableName}.id`,
`${this.tableName}.status`,
`${this.tableName}.name`,
`${this.tableName}.has_vip_pass`,
`${this.tableName}.created_at`,
`${this.tableName}.updated_at`,
`${this.tableName}.creator_name`,