Compare commits

..

No commits in common. "f4387767a879821db5517c0c4e58dd5ff7267469" and "f30a23d3c47c814ac09c991def8184a32c8aae95" have entirely different histories.

21 changed files with 20 additions and 342 deletions

View File

@ -71,7 +71,6 @@ 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: [
@ -110,7 +109,6 @@ import { TransactionDemographyModel } from './modules/transaction/transaction/da
TransactionModel,
TransactionItemModel,
TransactionTaxModel,
TransactionDemographyModel,
UserModel,
VipCategoryModel,
VipCodeModel,

View File

@ -21,7 +21,6 @@ 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',

View File

@ -1,13 +0,0 @@
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"`);
}
}

View File

@ -1,85 +0,0 @@
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"`,
);
}
}

View File

@ -1,23 +0,0 @@
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"`);
}
}

View File

@ -1,55 +0,0 @@
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'`,
);
}
}

View File

@ -1,17 +0,0 @@
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"`,
);
}
}

View File

@ -50,7 +50,6 @@ 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: [
@ -64,7 +63,6 @@ import { TransactionDemographyModel } from 'src/modules/transaction/transaction/
TransactionModel,
TransactionTaxModel,
TransactionItemModel,
TransactionDemographyModel,
],
CONNECTION_NAME.DEFAULT,
),

View File

@ -3,5 +3,4 @@ export enum ItemType {
WAHANA = 'wahana',
BUNDLING = 'bundling',
FREE_GIFT = 'free gift',
OTHER = 'other',
}

View File

@ -91,8 +91,6 @@ 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',

View File

@ -41,27 +41,18 @@ 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,

View File

@ -42,13 +42,10 @@ 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`,

View File

@ -19,25 +19,14 @@ export class IndexItemRatesManager extends BaseIndexManager<ItemRateEntity> {
}
async afterProcess(): Promise<void> {
this.result.data?.map((rates) => {
const item = rates['item'];
this.result.data?.map((item) => {
const item_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,
};
});
Number(item['item']?.total_price ?? 0) == 0
? item['item']?.total_price
: item['item']?.base_price;
Object.assign(item, {
price: item.price ?? item_price,
bundling_items,
});
});
return;
@ -49,13 +38,7 @@ export class IndexItemRatesManager extends BaseIndexManager<ItemRateEntity> {
joinRelations: [],
// relation join and select (relasi yang ingin ditampilkan),
selectRelations: [
'season_period',
'season_period.season_type',
'item',
'item.bundling_items',
'bundling_items.item_rates',
],
selectRelations: ['season_period', 'season_period.season_type', 'item'],
// relation yang hanya ingin dihitung (akan return number)
countRelations: [],
@ -71,13 +54,6 @@ 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`,

View File

@ -45,9 +45,6 @@ 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`,

View File

@ -49,8 +49,6 @@ 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`,

View File

@ -29,8 +29,3 @@ export const TransactionModels = [
TransactionItemModel,
TransactionTaxModel,
];
export enum DemographyNationality {
LOCAL = 'local',
FOREIGN = 'foreign',
}

View File

@ -1,41 +0,0 @@
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;
}

View File

@ -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, OneToOne } from 'typeorm';
import { Column, Entity, OneToMany } from 'typeorm';
import { BaseStatusModel } from 'src/core/modules/data/model/base-status.model';
import {
TransactionType,
@ -12,7 +12,6 @@ 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
@ -243,13 +242,6 @@ 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,

View File

@ -1,10 +0,0 @@
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;
}

View File

@ -92,16 +92,14 @@ 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: isCancel ? null : data.code,
status: isCancel ? STATUS.PENDING : data.status,
payment_code: data.code,
status: data.status == STATUS.CANCEL ? STATUS.PENDING : data.status,
});
} else {
Object.assign(data, {
@ -116,7 +114,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: isCancel ? null : new Date(data.created_at),
payment_date: new Date(data.created_at),
invoice_date: new Date(data.created_at),
payment_type: TransactionPaymentType.COUNTER,
payment_type_counter:
@ -124,7 +122,7 @@ export function mappingRevertTransaction(data, type) {
? TransactionPaymentType.CC
: data.payment_type,
payment_card_information: data.card_information,
payment_code_reference: isCancel ? null : data.payment_code,
payment_code_reference: data.payment_code,
discount_code_id: data.discount_code?.id,
discount_code: data.discount_code?.code,
discount_percentage: data.discount_code?.discount,
@ -135,28 +133,6 @@ 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,
@ -165,6 +141,16 @@ 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) => {

View File

@ -35,7 +35,6 @@ 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],
@ -45,7 +44,6 @@ import { TransactionDemographyModel } from './data/models/transaction-demography
[
TransactionModel,
TransactionItemModel,
TransactionDemographyModel,
TransactionTaxModel,
TaxModel,
SalesPriceFormulaModel,