Compare commits
17 Commits
f30a23d3c4
...
f4387767a8
Author | SHA1 | Date |
---|---|---|
|
f4387767a8 | |
|
8b82f9b7db | |
|
ee232447b6 | |
|
a2a9c16619 | |
|
6227555671 | |
|
fa286820fc | |
|
e966de6158 | |
|
50e8951b71 | |
|
cefeef8854 | |
|
dcf0a55dfc | |
|
3678353f34 | |
|
bd13f50bc0 | |
|
f4939ffe89 | |
|
4fe385bca1 | |
|
88cc9f4bc3 | |
|
dc595dfb07 | |
|
211a1e8a3c |
|
@ -71,6 +71,7 @@ import { BannerModel } from './modules/web-information/banner/data/models/banner
|
|||
import { MailModule } from './modules/configuration/mail/mail.module';
|
||||
import { PosLogModel } from './modules/configuration/log/data/models/pos-log.model';
|
||||
import { ExportModule } from './modules/configuration/export/export.module';
|
||||
import { TransactionDemographyModel } from './modules/transaction/transaction/data/models/transaction-demography.model';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
|
@ -109,6 +110,7 @@ import { ExportModule } from './modules/configuration/export/export.module';
|
|||
TransactionModel,
|
||||
TransactionItemModel,
|
||||
TransactionTaxModel,
|
||||
TransactionDemographyModel,
|
||||
UserModel,
|
||||
VipCategoryModel,
|
||||
VipCodeModel,
|
||||
|
|
|
@ -21,6 +21,7 @@ export enum TABLE_NAME {
|
|||
TRANSACTION = 'transactions',
|
||||
TRANSACTION_ITEM = 'transaction_items',
|
||||
TRANSACTION_TAX = 'transaction_taxes',
|
||||
TRANSACTION_DEMOGRAPHY = 'transaction_demographies',
|
||||
USER = 'users',
|
||||
USER_PRIVILEGE = 'user_privileges',
|
||||
USER_PRIVILEGE_CONFIGURATION = 'user_privilege_configurations',
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
export class AddItemProfit1723706764654 implements MigrationInterface {
|
||||
name = 'AddItemProfit1723706764654';
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE "items" ADD "share_profit" numeric`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE "items" DROP COLUMN "share_profit"`);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,85 @@
|
|||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
export class AddItemProfit1723706764654 implements MigrationInterface {
|
||||
name = 'AddOtherType1723706764655';
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "items" ADD "breakdown_bundling" boolean NOT NULL DEFAULT false`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TYPE "public"."item_categories_item_type_enum" RENAME TO "item_categories_item_type_enum_old"`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`CREATE TYPE "public"."item_categories_item_type_enum" AS ENUM('tiket masuk', 'wahana', 'bundling', 'free gift', 'other')`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "item_categories" ALTER COLUMN "item_type" DROP DEFAULT`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "item_categories" ALTER COLUMN "item_type" TYPE "public"."item_categories_item_type_enum" USING "item_type"::"text"::"public"."item_categories_item_type_enum"`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "item_categories" ALTER COLUMN "item_type" SET DEFAULT 'tiket masuk'`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`DROP TYPE "public"."item_categories_item_type_enum_old"`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TYPE "public"."items_item_type_enum" RENAME TO "items_item_type_enum_old"`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`CREATE TYPE "public"."items_item_type_enum" AS ENUM('tiket masuk', 'wahana', 'bundling', 'free gift', 'other')`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "items" ALTER COLUMN "item_type" DROP DEFAULT`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "items" ALTER COLUMN "item_type" TYPE "public"."items_item_type_enum" USING "item_type"::"text"::"public"."items_item_type_enum"`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "items" ALTER COLUMN "item_type" SET DEFAULT 'tiket masuk'`,
|
||||
);
|
||||
await queryRunner.query(`DROP TYPE "public"."items_item_type_enum_old"`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`CREATE TYPE "public"."items_item_type_enum_old" AS ENUM('bundling', 'free gift', 'tiket masuk', 'wahana')`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "items" ALTER COLUMN "item_type" DROP DEFAULT`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "items" ALTER COLUMN "item_type" TYPE "public"."items_item_type_enum_old" USING "item_type"::"text"::"public"."items_item_type_enum_old"`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "items" ALTER COLUMN "item_type" SET DEFAULT 'tiket masuk'`,
|
||||
);
|
||||
await queryRunner.query(`DROP TYPE "public"."items_item_type_enum"`);
|
||||
await queryRunner.query(
|
||||
`ALTER TYPE "public"."items_item_type_enum_old" RENAME TO "items_item_type_enum"`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`CREATE TYPE "public"."item_categories_item_type_enum_old" AS ENUM('bundling', 'free gift', 'tiket masuk', 'wahana')`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "item_categories" ALTER COLUMN "item_type" DROP DEFAULT`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "item_categories" ALTER COLUMN "item_type" TYPE "public"."item_categories_item_type_enum_old" USING "item_type"::"text"::"public"."item_categories_item_type_enum_old"`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "item_categories" ALTER COLUMN "item_type" SET DEFAULT 'tiket masuk'`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`DROP TYPE "public"."item_categories_item_type_enum"`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TYPE "public"."item_categories_item_type_enum_old" RENAME TO "item_categories_item_type_enum"`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "items" DROP COLUMN "breakdown_bundling"`,
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
export class AddDemographyTransaction1723713873756
|
||||
implements MigrationInterface
|
||||
{
|
||||
name = 'AddDemographyTransaction1723713873756';
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`CREATE TABLE "transaction_demographies" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "man" integer NOT NULL DEFAULT '0', "woman" integer NOT NULL DEFAULT '0', "teen" integer NOT NULL DEFAULT '0', "child" integer NOT NULL DEFAULT '0', "local" integer NOT NULL DEFAULT '0', "foreign" integer NOT NULL DEFAULT '0', "transaction_id" uuid, CONSTRAINT "PK_84083b782ebc2c6cb2a2dab8e2d" PRIMARY KEY ("id"))`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "transaction_demographies" ADD CONSTRAINT "FK_a2b705884bca06c148e3b35ab04" FOREIGN KEY ("transaction_id") REFERENCES "transactions"("id") ON DELETE CASCADE ON UPDATE CASCADE`,
|
||||
);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "transaction_demographies" DROP CONSTRAINT "FK_a2b705884bca06c148e3b35ab04"`,
|
||||
);
|
||||
await queryRunner.query(`DROP TABLE "transaction_demographies"`);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
export class FixDemographyNationality1723716561482
|
||||
implements MigrationInterface
|
||||
{
|
||||
name = 'FixDemographyNationality1723716561482';
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "transaction_demographies" DROP COLUMN "local"`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "transaction_demographies" DROP COLUMN "foreign"`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`CREATE TYPE "public"."transaction_demographies_nationality_enum" AS ENUM('local', 'foreign')`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "transaction_demographies" ADD "nationality" "public"."transaction_demographies_nationality_enum" NOT NULL DEFAULT 'local'`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "transaction_demographies" DROP CONSTRAINT "FK_a2b705884bca06c148e3b35ab04"`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "transaction_demographies" ADD CONSTRAINT "UQ_a2b705884bca06c148e3b35ab04" UNIQUE ("transaction_id")`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "transaction_demographies" ADD CONSTRAINT "FK_a2b705884bca06c148e3b35ab04" FOREIGN KEY ("transaction_id") REFERENCES "transactions"("id") ON DELETE CASCADE ON UPDATE CASCADE`,
|
||||
);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "transaction_demographies" DROP CONSTRAINT "FK_a2b705884bca06c148e3b35ab04"`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "transaction_demographies" DROP CONSTRAINT "UQ_a2b705884bca06c148e3b35ab04"`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "transaction_demographies" ADD CONSTRAINT "FK_a2b705884bca06c148e3b35ab04" FOREIGN KEY ("transaction_id") REFERENCES "transactions"("id") ON DELETE CASCADE ON UPDATE CASCADE`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "transaction_demographies" DROP COLUMN "nationality"`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`DROP TYPE "public"."transaction_demographies_nationality_enum"`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "transaction_demographies" ADD "foreign" integer NOT NULL DEFAULT '0'`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "transaction_demographies" ADD "local" integer NOT NULL DEFAULT '0'`,
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
export class AddEstimationToItem1723801180604 implements MigrationInterface {
|
||||
name = 'AddEstimationToItem1723801180604';
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "items" ADD "play_estimation" integer`,
|
||||
);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "items" DROP COLUMN "play_estimation"`,
|
||||
);
|
||||
}
|
||||
}
|
|
@ -50,6 +50,7 @@ import {
|
|||
} from './domain/managers/season-type.handler';
|
||||
import { SeasonPeriodDataService } from 'src/modules/season-related/season-period/data/services/season-period-data.service';
|
||||
import { SeasonPeriodModel } from 'src/modules/season-related/season-period/data/models/season-period.model';
|
||||
import { TransactionDemographyModel } from 'src/modules/transaction/transaction/data/models/transaction-demography.model';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
|
@ -63,6 +64,7 @@ import { SeasonPeriodModel } from 'src/modules/season-related/season-period/data
|
|||
TransactionModel,
|
||||
TransactionTaxModel,
|
||||
TransactionItemModel,
|
||||
TransactionDemographyModel,
|
||||
],
|
||||
CONNECTION_NAME.DEFAULT,
|
||||
),
|
||||
|
|
|
@ -3,4 +3,5 @@ export enum ItemType {
|
|||
WAHANA = 'wahana',
|
||||
BUNDLING = 'bundling',
|
||||
FREE_GIFT = 'free gift',
|
||||
OTHER = 'other',
|
||||
}
|
||||
|
|
|
@ -91,6 +91,8 @@ export class IndexItemRateManager extends BaseIndexManager<ItemEntity> {
|
|||
`${this.tableName}.created_at`,
|
||||
`${this.tableName}.name`,
|
||||
`${this.tableName}.base_price`,
|
||||
`${this.tableName}.breakdown_bundling`,
|
||||
`${this.tableName}.share_profit`,
|
||||
|
||||
'tenant.id',
|
||||
'tenant.name',
|
||||
|
|
|
@ -41,18 +41,27 @@ export class ItemModel
|
|||
@Column('decimal', { name: 'sales_margin', nullable: true })
|
||||
sales_margin: number;
|
||||
|
||||
@Column('decimal', { name: 'share_profit', nullable: true })
|
||||
share_profit: number;
|
||||
|
||||
@Column('bigint', { name: 'total_price', nullable: true })
|
||||
total_price: number;
|
||||
|
||||
@Column('bigint', { name: 'base_price', nullable: true })
|
||||
base_price: number;
|
||||
|
||||
@Column('int', { name: 'play_estimation', nullable: true })
|
||||
play_estimation: number;
|
||||
|
||||
@Column('boolean', { name: 'use_queue', default: false })
|
||||
use_queue: boolean;
|
||||
|
||||
@Column('boolean', { name: 'show_to_booking', default: false })
|
||||
show_to_booking: boolean;
|
||||
|
||||
@Column('boolean', { name: 'breakdown_bundling', default: false })
|
||||
breakdown_bundling: boolean;
|
||||
|
||||
@Column('enum', {
|
||||
name: 'limit_type',
|
||||
enum: LimitType,
|
||||
|
|
|
@ -42,10 +42,13 @@ export class DetailItemManager extends BaseDetailManager<ItemEntity> {
|
|||
`${this.tableName}.limit_value`,
|
||||
`${this.tableName}.hpp`,
|
||||
`${this.tableName}.sales_margin`,
|
||||
`${this.tableName}.share_profit`,
|
||||
`${this.tableName}.total_price`,
|
||||
`${this.tableName}.base_price`,
|
||||
`${this.tableName}.use_queue`,
|
||||
`${this.tableName}.show_to_booking`,
|
||||
`${this.tableName}.breakdown_bundling`,
|
||||
`${this.tableName}.play_estimation`,
|
||||
|
||||
`item_category.id`,
|
||||
`item_category.name`,
|
||||
|
|
|
@ -19,14 +19,25 @@ export class IndexItemRatesManager extends BaseIndexManager<ItemRateEntity> {
|
|||
}
|
||||
|
||||
async afterProcess(): Promise<void> {
|
||||
this.result.data?.map((item) => {
|
||||
this.result.data?.map((rates) => {
|
||||
const item = rates['item'];
|
||||
const item_price =
|
||||
Number(item['item']?.total_price ?? 0) == 0
|
||||
? item['item']?.total_price
|
||||
: item['item']?.base_price;
|
||||
Number(item?.total_price ?? 0) == 0
|
||||
? item?.total_price
|
||||
: item?.base_price;
|
||||
|
||||
const bundlings = item?.bundling_items ?? [];
|
||||
const bundling_items = bundlings.map((bundling) => {
|
||||
const rate = bundling.item_rates?.[0]?.price ?? 0;
|
||||
return {
|
||||
...bundling,
|
||||
item_rates: rate,
|
||||
};
|
||||
});
|
||||
|
||||
Object.assign(item, {
|
||||
price: item.price ?? item_price,
|
||||
bundling_items,
|
||||
});
|
||||
});
|
||||
return;
|
||||
|
@ -38,7 +49,13 @@ export class IndexItemRatesManager extends BaseIndexManager<ItemRateEntity> {
|
|||
joinRelations: [],
|
||||
|
||||
// relation join and select (relasi yang ingin ditampilkan),
|
||||
selectRelations: ['season_period', 'season_period.season_type', 'item'],
|
||||
selectRelations: [
|
||||
'season_period',
|
||||
'season_period.season_type',
|
||||
'item',
|
||||
'item.bundling_items',
|
||||
'bundling_items.item_rates',
|
||||
],
|
||||
|
||||
// relation yang hanya ingin dihitung (akan return number)
|
||||
countRelations: [],
|
||||
|
@ -54,6 +71,13 @@ export class IndexItemRatesManager extends BaseIndexManager<ItemRateEntity> {
|
|||
'item.id',
|
||||
'item.total_price',
|
||||
'item.base_price',
|
||||
'item.breakdown_bundling',
|
||||
'bundling_items.base_price',
|
||||
'bundling_items.hpp',
|
||||
'bundling_items.id',
|
||||
'bundling_items.name',
|
||||
|
||||
'item_rates.price',
|
||||
|
||||
`season_period.id`,
|
||||
`season_period.priority`,
|
||||
|
|
|
@ -45,6 +45,9 @@ export class IndexItemManager extends BaseIndexManager<ItemEntity> {
|
|||
`${this.tableName}.limit_type`,
|
||||
`${this.tableName}.limit_value`,
|
||||
`${this.tableName}.base_price`,
|
||||
`${this.tableName}.share_profit`,
|
||||
`${this.tableName}.breakdown_bundling`,
|
||||
`${this.tableName}.play_estimation`,
|
||||
|
||||
`item_category.id`,
|
||||
`item_category.name`,
|
||||
|
|
|
@ -49,6 +49,8 @@ export class IndexSeasonPeriodeItemManager extends BaseIndexManager<ItemRateEnti
|
|||
`item.limit_type`,
|
||||
`item.limit_value`,
|
||||
`item.base_price`,
|
||||
`item.breakdown_bundling`,
|
||||
`item.share_profit`,
|
||||
|
||||
`item_category.id`,
|
||||
`item_category.name`,
|
||||
|
|
|
@ -29,3 +29,8 @@ export const TransactionModels = [
|
|||
TransactionItemModel,
|
||||
TransactionTaxModel,
|
||||
];
|
||||
|
||||
export enum DemographyNationality {
|
||||
LOCAL = 'local',
|
||||
FOREIGN = 'foreign',
|
||||
}
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';
|
||||
import { Column, Entity, JoinColumn, OneToOne } from 'typeorm';
|
||||
import { BaseCoreModel } from 'src/core/modules/data/model/base-core.model';
|
||||
import { TransactionModel } from './transaction.model';
|
||||
import { TransactionDemographyEntity } from '../../domain/entities/transaction-graphy.entity';
|
||||
import { DemographyNationality } from '../../constants';
|
||||
|
||||
@Entity(TABLE_NAME.TRANSACTION_DEMOGRAPHY)
|
||||
export class TransactionDemographyModel
|
||||
extends BaseCoreModel<TransactionDemographyEntity>
|
||||
implements TransactionDemographyEntity
|
||||
{
|
||||
@Column('int', { default: 0 })
|
||||
man: number;
|
||||
|
||||
@Column('int', { default: 0 })
|
||||
woman: number;
|
||||
|
||||
@Column('int', { default: 0 })
|
||||
teen: number;
|
||||
|
||||
@Column('int', { default: 0 })
|
||||
child: number;
|
||||
|
||||
@Column('enum', {
|
||||
name: 'nationality',
|
||||
enum: DemographyNationality,
|
||||
default: DemographyNationality.LOCAL,
|
||||
})
|
||||
nationality: DemographyNationality;
|
||||
|
||||
@Column('varchar', { name: 'transaction_id', nullable: true })
|
||||
transaction_id: string;
|
||||
|
||||
@OneToOne(() => TransactionModel, (model) => model.demographies, {
|
||||
onDelete: 'CASCADE',
|
||||
onUpdate: 'CASCADE',
|
||||
})
|
||||
@JoinColumn({ name: 'transaction_id' })
|
||||
transaction: TransactionModel;
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';
|
||||
import { TransactionEntity } from '../../domain/entities/transaction.entity';
|
||||
import { Column, Entity, OneToMany } from 'typeorm';
|
||||
import { Column, Entity, OneToMany, OneToOne } from 'typeorm';
|
||||
import { BaseStatusModel } from 'src/core/modules/data/model/base-status.model';
|
||||
import {
|
||||
TransactionType,
|
||||
|
@ -12,6 +12,7 @@ import { TransactionItemModel } from './transaction-item.model';
|
|||
import { TransactionTaxModel } from './transaction-tax.model';
|
||||
import { STATUS } from 'src/core/strings/constants/base.constants';
|
||||
import { RefundModel } from 'src/modules/transaction/refund/data/models/refund.model';
|
||||
import { TransactionDemographyModel } from './transaction-demography.model';
|
||||
|
||||
@Entity(TABLE_NAME.TRANSACTION)
|
||||
export class TransactionModel
|
||||
|
@ -242,6 +243,13 @@ export class TransactionModel
|
|||
})
|
||||
taxes: TransactionTaxModel[];
|
||||
|
||||
@OneToOne(() => TransactionDemographyModel, (model) => model.transaction, {
|
||||
cascade: true,
|
||||
onDelete: 'CASCADE',
|
||||
onUpdate: 'CASCADE',
|
||||
})
|
||||
demographies: TransactionDemographyModel;
|
||||
|
||||
// relations to refund
|
||||
@OneToMany(() => RefundModel, (model) => model.transaction, {
|
||||
cascade: true,
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
import { BaseCoreEntity } from 'src/core/modules/domain/entities/base-core.entity';
|
||||
import { DemographyNationality } from '../../constants';
|
||||
|
||||
export interface TransactionDemographyEntity extends BaseCoreEntity {
|
||||
man: number;
|
||||
woman: number;
|
||||
teen: number;
|
||||
child: number;
|
||||
nationality: DemographyNationality;
|
||||
}
|
|
@ -92,14 +92,16 @@ export function mappingTransaction(data, refundId?: string) {
|
|||
}
|
||||
|
||||
export function mappingRevertTransaction(data, type) {
|
||||
const { status } = data;
|
||||
const isCancel = status == STATUS.CANCEL;
|
||||
if (type == TransactionType.COUNTER) {
|
||||
if (data.booking_id) {
|
||||
Object.assign(data, {
|
||||
editor_id: data.pos_admin?.id,
|
||||
editor_name: data.pos_admin?.name,
|
||||
edited_at: new Date(data.created_at),
|
||||
payment_code: data.code,
|
||||
status: data.status == STATUS.CANCEL ? STATUS.PENDING : data.status,
|
||||
payment_code: isCancel ? null : data.code,
|
||||
status: isCancel ? STATUS.PENDING : data.status,
|
||||
});
|
||||
} else {
|
||||
Object.assign(data, {
|
||||
|
@ -114,7 +116,7 @@ export function mappingRevertTransaction(data, type) {
|
|||
id: data.booking_id ?? data._id,
|
||||
creator_counter_no: Number(data.pos_number),
|
||||
settlement_date: new Date(data.created_at),
|
||||
payment_date: new Date(data.created_at),
|
||||
payment_date: isCancel ? null : new Date(data.created_at),
|
||||
invoice_date: new Date(data.created_at),
|
||||
payment_type: TransactionPaymentType.COUNTER,
|
||||
payment_type_counter:
|
||||
|
@ -122,7 +124,7 @@ export function mappingRevertTransaction(data, type) {
|
|||
? TransactionPaymentType.CC
|
||||
: data.payment_type,
|
||||
payment_card_information: data.card_information,
|
||||
payment_code_reference: data.payment_code,
|
||||
payment_code_reference: isCancel ? null : data.payment_code,
|
||||
discount_code_id: data.discount_code?.id,
|
||||
discount_code: data.discount_code?.code,
|
||||
discount_percentage: data.discount_code?.discount,
|
||||
|
@ -133,6 +135,28 @@ export function mappingRevertTransaction(data, type) {
|
|||
});
|
||||
}
|
||||
|
||||
if (isCancel) {
|
||||
Object.assign(data, {
|
||||
payment_type_method_id: null,
|
||||
payment_type_method_number: null,
|
||||
payment_type_method_name: null,
|
||||
payment_type_method_qr: null,
|
||||
});
|
||||
} else {
|
||||
Object.assign(data, {
|
||||
payment_type_method_id:
|
||||
data.payment_type_method?.id ?? data.payment_type_bank?.id,
|
||||
payment_type_method_number:
|
||||
data.payment_type_method?.account_number ??
|
||||
data.payment_type_bank?.account_number,
|
||||
payment_type_method_name:
|
||||
data.payment_type_method?.issuer_name ??
|
||||
data.payment_type_bank?.issuer_name,
|
||||
payment_type_method_qr:
|
||||
data.payment_type_method?.qr_image ?? data.payment_type_bank?.qr_image,
|
||||
});
|
||||
}
|
||||
|
||||
Object.assign(data, {
|
||||
payment_total_net_profit: data.payment_total,
|
||||
customer_category_id: data.customer_category?.id ?? null,
|
||||
|
@ -141,16 +165,6 @@ export function mappingRevertTransaction(data, type) {
|
|||
season_period_name: data.season_period?.holiday_name ?? null,
|
||||
season_period_type_id: data.season_period?.season_type?.id ?? null,
|
||||
season_period_type_name: data.season_period?.season_type?.name ?? null,
|
||||
payment_type_method_id:
|
||||
data.payment_type_method?.id ?? data.payment_type_bank?.id,
|
||||
payment_type_method_number:
|
||||
data.payment_type_method?.account_number ??
|
||||
data.payment_type_bank?.account_number,
|
||||
payment_type_method_name:
|
||||
data.payment_type_method?.issuer_name ??
|
||||
data.payment_type_bank?.issuer_name,
|
||||
payment_type_method_qr:
|
||||
data.payment_type_method?.qr_image ?? data.payment_type_bank?.qr_image,
|
||||
});
|
||||
|
||||
data.items?.map((item) => {
|
||||
|
|
|
@ -35,6 +35,7 @@ import { MidtransCallbackHandler } from './domain/usecases/handlers/midtrans-tra
|
|||
import { PdfMakeManager } from 'src/modules/configuration/export/domain/managers/pdf-make.manager';
|
||||
import { PaymentMethodDataService } from '../payment-method/data/services/payment-method-data.service';
|
||||
import { PaymentMethodModel } from '../payment-method/data/models/payment-method.model';
|
||||
import { TransactionDemographyModel } from './data/models/transaction-demography.model';
|
||||
|
||||
@Module({
|
||||
exports: [TransactionReadService],
|
||||
|
@ -44,6 +45,7 @@ import { PaymentMethodModel } from '../payment-method/data/models/payment-method
|
|||
[
|
||||
TransactionModel,
|
||||
TransactionItemModel,
|
||||
TransactionDemographyModel,
|
||||
TransactionTaxModel,
|
||||
TaxModel,
|
||||
SalesPriceFormulaModel,
|
||||
|
|
Loading…
Reference in New Issue