From 8f43907091df3c2fbb969bb4e285833bbaa948f8 Mon Sep 17 00:00:00 2001 From: shancheas Date: Wed, 16 Oct 2024 17:01:47 +0700 Subject: [PATCH 1/2] feat: add vip pass and video url to item --- .../1729072422409-item-video-and-vip-pass.ts | 21 +++++++++++++++++++ .../item/data/models/item.model.ts | 3 +++ .../item/domain/entities/item.entity.ts | 1 + .../item/infrastructure/dto/item.dto.ts | 9 ++++++++ .../data/models/vip-category.model.ts | 3 +++ .../domain/entities/vip-category.entity.ts | 1 + .../infrastructure/dto/vip-category.dto.ts | 9 ++++++++ 7 files changed, 47 insertions(+) create mode 100644 src/database/migrations/1729072422409-item-video-and-vip-pass.ts diff --git a/src/database/migrations/1729072422409-item-video-and-vip-pass.ts b/src/database/migrations/1729072422409-item-video-and-vip-pass.ts new file mode 100644 index 0000000..b3d345b --- /dev/null +++ b/src/database/migrations/1729072422409-item-video-and-vip-pass.ts @@ -0,0 +1,21 @@ +import { MigrationInterface, QueryRunner } from 'typeorm'; + +export class ItemVideoAndVipPass1729072422409 implements MigrationInterface { + name = 'ItemVideoAndVipPass1729072422409'; + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `ALTER TABLE "items" ADD "video_url" character varying`, + ); + await queryRunner.query( + `ALTER TABLE "vip_categories" ADD "has_vip_pass" boolean NOT NULL DEFAULT false`, + ); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `ALTER TABLE "vip_categories" DROP COLUMN "has_vip_pass"`, + ); + await queryRunner.query(`ALTER TABLE "items" DROP COLUMN "video_url"`); + } +} diff --git a/src/modules/item-related/item/data/models/item.model.ts b/src/modules/item-related/item/data/models/item.model.ts index 90f8ecf..7506733 100644 --- a/src/modules/item-related/item/data/models/item.model.ts +++ b/src/modules/item-related/item/data/models/item.model.ts @@ -28,6 +28,9 @@ export class ItemModel @Column('varchar', { name: 'image_url', nullable: true }) image_url: string; + @Column('varchar', { nullable: true }) + video_url: string; + @Column('enum', { name: 'item_type', enum: ItemType, diff --git a/src/modules/item-related/item/domain/entities/item.entity.ts b/src/modules/item-related/item/domain/entities/item.entity.ts index 90fa227..7ade51e 100644 --- a/src/modules/item-related/item/domain/entities/item.entity.ts +++ b/src/modules/item-related/item/domain/entities/item.entity.ts @@ -6,6 +6,7 @@ export interface ItemEntity extends BaseStatusEntity { name: string; item_type: ItemType; image_url: string; + video_url?: string; hpp: number; sales_margin: number; diff --git a/src/modules/item-related/item/infrastructure/dto/item.dto.ts b/src/modules/item-related/item/infrastructure/dto/item.dto.ts index 8ca6b9b..c6f739e 100644 --- a/src/modules/item-related/item/infrastructure/dto/item.dto.ts +++ b/src/modules/item-related/item/infrastructure/dto/item.dto.ts @@ -31,6 +31,15 @@ export class ItemDto extends BaseStatusDto implements ItemEntity { @ValidateIf((body) => body.image) image_url: string; + @ApiProperty({ + type: String, + required: false, + example: '...', + }) + @IsString() + @ValidateIf((body) => body.video_url) + video_url: string; + @ApiProperty({ type: 'string', required: true, diff --git a/src/modules/transaction/vip-category/data/models/vip-category.model.ts b/src/modules/transaction/vip-category/data/models/vip-category.model.ts index 2d9e5f5..d1feab0 100644 --- a/src/modules/transaction/vip-category/data/models/vip-category.model.ts +++ b/src/modules/transaction/vip-category/data/models/vip-category.model.ts @@ -12,6 +12,9 @@ export class VipCategoryModel @Column('varchar', { name: 'name' }) name: string; + @Column('boolean', { default: false }) + has_vip_pass: boolean; + @OneToMany(() => VipCodeModel, (model) => model.vip_category, { cascade: true, onDelete: 'CASCADE', diff --git a/src/modules/transaction/vip-category/domain/entities/vip-category.entity.ts b/src/modules/transaction/vip-category/domain/entities/vip-category.entity.ts index 49af3a2..d6667b7 100644 --- a/src/modules/transaction/vip-category/domain/entities/vip-category.entity.ts +++ b/src/modules/transaction/vip-category/domain/entities/vip-category.entity.ts @@ -2,4 +2,5 @@ import { BaseStatusEntity } from 'src/core/modules/domain/entities/base-status.e export interface VipCategoryEntity extends BaseStatusEntity { name: string; + has_vip_pass?: boolean; } diff --git a/src/modules/transaction/vip-category/infrastructure/dto/vip-category.dto.ts b/src/modules/transaction/vip-category/infrastructure/dto/vip-category.dto.ts index 5173949..eb46457 100644 --- a/src/modules/transaction/vip-category/infrastructure/dto/vip-category.dto.ts +++ b/src/modules/transaction/vip-category/infrastructure/dto/vip-category.dto.ts @@ -2,6 +2,7 @@ import { BaseStatusDto } from 'src/core/modules/infrastructure/dto/base-status.d import { VipCategoryEntity } from '../../domain/entities/vip-category.entity'; import { ApiProperty } from '@nestjs/swagger'; import { IsString } from 'class-validator'; +import { boolean } from 'mathjs'; export class VipCategoryDto extends BaseStatusDto implements VipCategoryEntity { @ApiProperty({ @@ -12,4 +13,12 @@ export class VipCategoryDto extends BaseStatusDto implements VipCategoryEntity { }) @IsString() name: string; + + @ApiProperty({ + name: 'has_vip_pass', + type: boolean, + required: false, + example: false, + }) + has_vip_pass: boolean; } From 6a8816aa90fe46f8780fe6a02831d738e185ad4e Mon Sep 17 00:00:00 2001 From: Firman Ramdhani <33869609+firmanramdhani@users.noreply.github.com> Date: Wed, 16 Oct 2024 18:31:55 +0700 Subject: [PATCH 2/2] feat: update filter report --- .../configs/cancel-transaction.ts | 11 +++++++++-- .../transaction-report/configs/giving-discounts.ts | 7 ++++++- .../configs/income-per-item-master.ts | 11 +++++++++-- .../transaction-report/configs/income-per-item.ts | 11 +++++++++-- .../configs/transaction-report/configs/income.ts | 11 +++++++++-- .../transaction-report/configs/reconciliation.ts | 13 +++++++++++-- .../configs/transaction-report/configs/tax.ts | 7 ++++++- 7 files changed, 59 insertions(+), 12 deletions(-) diff --git a/src/modules/reports/shared/configs/transaction-report/configs/cancel-transaction.ts b/src/modules/reports/shared/configs/transaction-report/configs/cancel-transaction.ts index 1e32c6c..468eee6 100644 --- a/src/modules/reports/shared/configs/transaction-report/configs/cancel-transaction.ts +++ b/src/modules/reports/shared/configs/transaction-report/configs/cancel-transaction.ts @@ -287,7 +287,8 @@ export default { filter_column: 'main__payment_date', field_type: FILTER_FIELD_TYPE.date_range_picker, filter_type: FILTER_TYPE.DATE_IN_RANGE_TIMESTAMP, - date_format: 'DD-MM-YYYY', + // date_format: 'DD-MM-YYYY', + date_format: 'YYYY-MM-DD', }, { @@ -338,7 +339,8 @@ export default { filter_column: 'refund__refund_date', field_type: FILTER_FIELD_TYPE.date_range_picker, filter_type: FILTER_TYPE.DATE_IN_RANGE_TIMESTAMP, - date_format: 'DD-MM-YYYY', + // date_format: 'DD-MM-YYYY', + date_format: 'YYYY-MM-DD', }, { filed_label: 'Kode Pengembalian', @@ -389,4 +391,9 @@ export default { filter_type: FILTER_TYPE.TEXT_MULTIPLE_CONTAINS, }, ], + customQueryColumn(column) { + if (column === 'main__payment_date') return 'main.payment_date'; + else if (column === 'refund__refund_date') return 'refund.refund_date'; + return; + }, }; diff --git a/src/modules/reports/shared/configs/transaction-report/configs/giving-discounts.ts b/src/modules/reports/shared/configs/transaction-report/configs/giving-discounts.ts index 315cea6..99a71ee 100644 --- a/src/modules/reports/shared/configs/transaction-report/configs/giving-discounts.ts +++ b/src/modules/reports/shared/configs/transaction-report/configs/giving-discounts.ts @@ -168,7 +168,8 @@ export default { filter_column: 'main__payment_date', field_type: FILTER_FIELD_TYPE.date_range_picker, filter_type: FILTER_TYPE.DATE_IN_RANGE_TIMESTAMP, - date_format: 'DD-MM-YYYY', + // date_format: 'DD-MM-YYYY', + date_format: 'YYYY-MM-DD', }, { filed_label: 'Tipe Rate', @@ -213,4 +214,8 @@ export default { filter_type: FILTER_TYPE.TEXT_MULTIPLE_CONTAINS, }, ], + customQueryColumn(column) { + if (column === 'main__payment_date') return 'main.payment_date'; + return; + }, }; diff --git a/src/modules/reports/shared/configs/transaction-report/configs/income-per-item-master.ts b/src/modules/reports/shared/configs/transaction-report/configs/income-per-item-master.ts index 201bb1e..62d46e8 100644 --- a/src/modules/reports/shared/configs/transaction-report/configs/income-per-item-master.ts +++ b/src/modules/reports/shared/configs/transaction-report/configs/income-per-item-master.ts @@ -286,7 +286,8 @@ export default { filter_column: 'main__payment_date', field_type: FILTER_FIELD_TYPE.date_range_picker, filter_type: FILTER_TYPE.DATE_IN_RANGE_TIMESTAMP, - date_format: 'DD-MM-YYYY', + // date_format: 'DD-MM-YYYY', + date_format: 'YYYY-MM-DD', }, { filed_label: 'Kepemilikan', @@ -360,7 +361,8 @@ export default { filter_column: 'refund__refund_date', field_type: FILTER_FIELD_TYPE.date_range_picker, filter_type: FILTER_TYPE.DATE_IN_RANGE_TIMESTAMP, - date_format: 'DD-MM-YYYY', + // date_format: 'DD-MM-YYYY', + date_format: 'YYYY-MM-DD', }, { filed_label: 'Kode Pengembalian', @@ -387,4 +389,9 @@ export default { filter_type: FILTER_TYPE.TEXT_MULTIPLE_CONTAINS, }, ], + customQueryColumn(column) { + if (column === 'main__payment_date') return 'main.payment_date'; + else if (column === 'refund__refund_date') return 'refund.refund_date'; + return; + }, }; diff --git a/src/modules/reports/shared/configs/transaction-report/configs/income-per-item.ts b/src/modules/reports/shared/configs/transaction-report/configs/income-per-item.ts index 45c6ff7..e091d99 100644 --- a/src/modules/reports/shared/configs/transaction-report/configs/income-per-item.ts +++ b/src/modules/reports/shared/configs/transaction-report/configs/income-per-item.ts @@ -256,7 +256,8 @@ export default { filter_column: 'main__payment_date', field_type: FILTER_FIELD_TYPE.date_range_picker, filter_type: FILTER_TYPE.DATE_IN_RANGE_TIMESTAMP, - date_format: 'DD-MM-YYYY', + // date_format: 'DD-MM-YYYY', + date_format: 'YYYY-MM-DD', }, { filed_label: 'Kepemilikan', @@ -318,7 +319,8 @@ export default { filter_column: 'refund__refund_date', field_type: FILTER_FIELD_TYPE.date_range_picker, filter_type: FILTER_TYPE.DATE_IN_RANGE_TIMESTAMP, - date_format: 'DD-MM-YYYY', + // date_format: 'DD-MM-YYYY', + date_format: 'YYYY-MM-DD', }, { filed_label: 'Kode Pengembalian', @@ -345,4 +347,9 @@ export default { filter_type: FILTER_TYPE.TEXT_MULTIPLE_CONTAINS, }, ], + customQueryColumn(column) { + if (column === 'main__payment_date') return 'main.payment_date'; + else if (column === 'refund__refund_date') return 'refund.refund_date'; + return; + }, }; diff --git a/src/modules/reports/shared/configs/transaction-report/configs/income.ts b/src/modules/reports/shared/configs/transaction-report/configs/income.ts index 3cedb85..b66bdf9 100644 --- a/src/modules/reports/shared/configs/transaction-report/configs/income.ts +++ b/src/modules/reports/shared/configs/transaction-report/configs/income.ts @@ -287,7 +287,8 @@ export default { filter_column: 'main__payment_date', field_type: FILTER_FIELD_TYPE.date_range_picker, filter_type: FILTER_TYPE.DATE_IN_RANGE_TIMESTAMP, - date_format: 'DD-MM-YYYY', + // date_format: 'DD-MM-YYYY', + date_format: 'YYYY-MM-DD', }, { @@ -338,7 +339,8 @@ export default { filter_column: 'refund__refund_date', field_type: FILTER_FIELD_TYPE.date_range_picker, filter_type: FILTER_TYPE.DATE_IN_RANGE_TIMESTAMP, - date_format: 'DD-MM-YYYY', + // date_format: 'DD-MM-YYYY', + date_format: 'YYYY-MM-DD', }, { filed_label: 'Kode Pengembalian', @@ -389,4 +391,9 @@ export default { filter_type: FILTER_TYPE.TEXT_MULTIPLE_CONTAINS, }, ], + customQueryColumn(column) { + if (column === 'main__payment_date') return 'main.payment_date'; + else if (column === 'refund__refund_date') return 'refund.refund_date'; + return; + }, }; diff --git a/src/modules/reports/shared/configs/transaction-report/configs/reconciliation.ts b/src/modules/reports/shared/configs/transaction-report/configs/reconciliation.ts index 2baef43..8063ad3 100644 --- a/src/modules/reports/shared/configs/transaction-report/configs/reconciliation.ts +++ b/src/modules/reports/shared/configs/transaction-report/configs/reconciliation.ts @@ -192,14 +192,16 @@ export default { filter_column: 'main__payment_date', field_type: FILTER_FIELD_TYPE.date_range_picker, filter_type: FILTER_TYPE.DATE_IN_RANGE_TIMESTAMP, - date_format: 'DD-MM-YYYY', + // date_format: 'DD-MM-YYYY', + date_format: 'YYYY-MM-DD', }, { filed_label: 'Tgl. Transaksi Bank', filter_column: 'main__payment_date_bank', field_type: FILTER_FIELD_TYPE.date_range_picker, filter_type: FILTER_TYPE.DATE_IN_RANGE_TIMESTAMP, - date_format: 'DD-MM-YYYY', + // date_format: 'DD-MM-YYYY', + date_format: 'YYYY-MM-DD', }, { filed_label: 'Tgl. Konfirmasi', @@ -253,4 +255,11 @@ export default { } return []; }, + customQueryColumn(column) { + if (column === 'main__payment_date') return 'main.payment_date'; + else if (column === 'main__payment_date_bank') { + return 'main.payment_date_bank'; + } + return; + }, }; diff --git a/src/modules/reports/shared/configs/transaction-report/configs/tax.ts b/src/modules/reports/shared/configs/transaction-report/configs/tax.ts index ed097fb..10e2339 100644 --- a/src/modules/reports/shared/configs/transaction-report/configs/tax.ts +++ b/src/modules/reports/shared/configs/transaction-report/configs/tax.ts @@ -105,7 +105,8 @@ export default { filter_column: 'main__payment_date', field_type: FILTER_FIELD_TYPE.date_range_picker, filter_type: FILTER_TYPE.DATE_IN_RANGE_TIMESTAMP, - date_format: 'DD-MM-YYYY', + // date_format: 'DD-MM-YYYY', + date_format: 'YYYY-MM-DD', }, { filed_label: 'Sumber', @@ -133,4 +134,8 @@ export default { filter_type: FILTER_TYPE.TEXT_MULTIPLE_CONTAINS, }, ], + customQueryColumn(column) { + if (column === 'main__payment_date') return 'main.payment_date'; + return; + }, };