fix(booking) perbaikan column payment type counter

fix/data
Aswin Ashar Abdullah 2024-08-02 17:54:12 +07:00
parent 0bec3c6590
commit 0f05656ca2
11 changed files with 47 additions and 9 deletions

View File

@ -0,0 +1,23 @@
import { MigrationInterface, QueryRunner } from 'typeorm';
export class UpdateTableTransaction1722595038215 implements MigrationInterface {
name = 'UpdateTableTransaction1722595038215';
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`CREATE TYPE "public"."transactions_payment_type_counter_enum" AS ENUM('midtrans', 'bank transfer', 'qris', 'counter', 'cash', 'credit card', 'debit', 'e-money')`,
);
await queryRunner.query(
`ALTER TABLE "transactions" ADD "payment_type_counter" "public"."transactions_payment_type_counter_enum"`,
);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE "transactions" DROP COLUMN "payment_type_counter"`,
);
await queryRunner.query(
`DROP TYPE "public"."transactions_payment_type_counter_enum"`,
);
}
}

View File

@ -32,7 +32,10 @@ export class SeasonPeriodHolidayHandler
const rate = new ItemRateModel(); const rate = new ItemRateModel();
rate.item_id = event.data.id; rate.item_id = event.data.id;
rate.season_period_id = season.id; rate.season_period_id = season.id;
rate.price = Number(event.data.data.total_price) != 0 ? event.data.data.total_price : event.data.data.base_price; rate.price =
Number(event.data.data.total_price) != 0
? event.data.data.total_price
: event.data.data.base_price;
rates.push(rate); rates.push(rate);
} }

View File

@ -36,6 +36,7 @@ export class DetailReconciliationManager extends BaseDetailManager<TransactionEn
`${this.tableName}.reconciliation_mdr`, `${this.tableName}.reconciliation_mdr`,
`${this.tableName}.payment_type`, `${this.tableName}.payment_type`,
`${this.tableName}.payment_type_counter`,
`${this.tableName}.payment_type_method_id`, `${this.tableName}.payment_type_method_id`,
`${this.tableName}.payment_type_method_name`, `${this.tableName}.payment_type_method_name`,
`${this.tableName}.payment_type_method_number`, `${this.tableName}.payment_type_method_number`,

View File

@ -51,6 +51,7 @@ export class IndexReconciliationManager extends BaseIndexManager<TransactionEnti
`${this.tableName}.invoice_code`, `${this.tableName}.invoice_code`,
`${this.tableName}.booking_date`, `${this.tableName}.booking_date`,
`${this.tableName}.payment_type`, `${this.tableName}.payment_type`,
`${this.tableName}.payment_type_counter`,
`${this.tableName}.payment_type_method_id`, `${this.tableName}.payment_type_method_id`,
`${this.tableName}.payment_type_method_name`, `${this.tableName}.payment_type_method_name`,
`${this.tableName}.payment_type_method_number`, `${this.tableName}.payment_type_method_number`,

View File

@ -107,6 +107,13 @@ export class TransactionModel
}) })
payment_type: TransactionPaymentType; payment_type: TransactionPaymentType;
@Column('enum', {
name: 'payment_type_counter',
enum: TransactionPaymentType,
nullable: true,
})
payment_type_counter: TransactionPaymentType;
@Column('varchar', { name: 'payment_code', nullable: true }) @Column('varchar', { name: 'payment_code', nullable: true })
payment_code: string; payment_code: string;

View File

@ -41,6 +41,7 @@ export interface TransactionEntity extends BaseStatusEntity {
// payment data // payment data
payment_type: TransactionPaymentType; payment_type: TransactionPaymentType;
payment_type_counter: TransactionPaymentType;
payment_type_method_id: string; payment_type_method_id: string;
payment_type_method_name: string; payment_type_method_name: string;
payment_type_method_number: string; payment_type_method_number: string;

View File

@ -11,7 +11,7 @@ import { TransactionChangeStatusEvent } from '../../entities/event/transaction-c
@Injectable() @Injectable()
export class ActiveTransactionManager extends BaseUpdateStatusManager<TransactionEntity> { export class ActiveTransactionManager extends BaseUpdateStatusManager<TransactionEntity> {
getResult(): string { getResult(): string {
return `Success active data ${this.result.invoice_code}`; return `Success ${this.dataStatus} data ${this.result.invoice_code}`;
} }
async validateProcess(): Promise<void> { async validateProcess(): Promise<void> {

View File

@ -16,7 +16,7 @@ import { STATUS } from 'src/core/strings/constants/base.constants';
@Injectable() @Injectable()
export class CancelTransactionManager extends BaseUpdateStatusManager<TransactionEntity> { export class CancelTransactionManager extends BaseUpdateStatusManager<TransactionEntity> {
getResult(): string { getResult(): string {
return `Success active data ${this.result.invoice_code}`; return `Success ${this.dataStatus} data ${this.result.invoice_code}`;
} }
async validateProcess(): Promise<void> { async validateProcess(): Promise<void> {

View File

@ -67,6 +67,7 @@ export class DetailTransactionManager extends BaseDetailManager<TransactionEntit
`${this.tableName}.discount_value`, `${this.tableName}.discount_value`,
`${this.tableName}.payment_type`, `${this.tableName}.payment_type`,
`${this.tableName}.payment_type_counter`,
`${this.tableName}.payment_date`, `${this.tableName}.payment_date`,
`${this.tableName}.payment_total_pay`, `${this.tableName}.payment_total_pay`,
`${this.tableName}.payment_type_method_id`, `${this.tableName}.payment_type_method_id`,

View File

@ -98,6 +98,7 @@ export function mappingRevertTransaction(data, type) {
}); });
} else { } else {
Object.assign(data, { Object.assign(data, {
type: type,
creator_id: data.pos_admin?.id, creator_id: data.pos_admin?.id,
creator_name: data.pos_admin?.name, creator_name: data.pos_admin?.name,
invoice_code: data.code, invoice_code: data.code,
@ -107,11 +108,11 @@ export function mappingRevertTransaction(data, type) {
Object.assign(data, { Object.assign(data, {
id: data.booking_id ?? data._id, id: data.booking_id ?? data._id,
creator_counter_no: Number(data.pos_number), creator_counter_no: Number(data.pos_number),
status: STATUS.SETTLED,
settlement_date: new Date(data.created_at), settlement_date: new Date(data.created_at),
payment_date: new Date(data.created_at), payment_date: new Date(data.created_at),
invoice_date: new Date(data.created_at), invoice_date: new Date(data.created_at),
payment_type: payment_type: TransactionPaymentType.COUNTER,
payment_type_counter:
data.payment_type == 'cc' data.payment_type == 'cc'
? TransactionPaymentType.CC ? TransactionPaymentType.CC
: data.payment_type, : data.payment_type,
@ -122,13 +123,12 @@ export function mappingRevertTransaction(data, type) {
discount_percentage: data.discount_code?.discount, discount_percentage: data.discount_code?.discount,
}); });
} else { } else {
// Object.assign(data, { Object.assign(data, {
// payment_type: type: type,
// }) });
} }
Object.assign(data, { Object.assign(data, {
type: type,
payment_total_net_profit: data.payment_total, payment_total_net_profit: data.payment_total,
customer_category_id: data.customer_category?.id ?? null, customer_category_id: data.customer_category?.id ?? null,
customer_category_name: data.customer_category?.name ?? null, customer_category_name: data.customer_category?.name ?? null,

View File

@ -75,6 +75,7 @@ export class IndexTransactionManager extends BaseIndexManager<TransactionEntity>
`${this.tableName}.payment_code`, `${this.tableName}.payment_code`,
`${this.tableName}.payment_card_information`, `${this.tableName}.payment_card_information`,
`${this.tableName}.payment_type`, `${this.tableName}.payment_type`,
`${this.tableName}.payment_type_counter`,
`${this.tableName}.payment_date`, `${this.tableName}.payment_date`,
`${this.tableName}.payment_total_pay`, `${this.tableName}.payment_total_pay`,
`${this.tableName}.payment_type_method_id`, `${this.tableName}.payment_type_method_id`,