fix(item) perbaikan module item
continuous-integration/drone/tag Build is passing
Details
continuous-integration/drone/tag Build is passing
Details
parent
321d13568f
commit
50cbaa38c1
|
@ -1,15 +0,0 @@
|
||||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
|
||||||
|
|
||||||
export class Item1718085330130 implements MigrationInterface {
|
|
||||||
name = 'Item1718085330130';
|
|
||||||
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "items" ADD "image" character varying`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(`ALTER TABLE "items" DROP COLUMN "image"`);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||||
|
|
||||||
|
export class Item1718097870787 implements MigrationInterface {
|
||||||
|
name = 'Item1718097870787'
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`CREATE TYPE "public"."items_status_enum" AS ENUM('active', 'cancel', 'confirmed', 'draft', 'expired', 'inactive', 'pending', 'refunded', 'rejected', 'settled', 'waiting')`);
|
||||||
|
await queryRunner.query(`CREATE TYPE "public"."items_item_type_enum" AS ENUM('tiket masuk', 'wahana', 'bundling', 'free gift')`);
|
||||||
|
await queryRunner.query(`CREATE TYPE "public"."items_limit_type_enum" AS ENUM('no limit', 'time limit', 'qty limit')`);
|
||||||
|
await queryRunner.query(`CREATE TABLE "items" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "creator_id" character varying(36), "creator_name" character varying(125), "editor_id" character varying(36), "editor_name" character varying(125), "created_at" bigint NOT NULL, "updated_at" bigint NOT NULL, "status" "public"."items_status_enum" NOT NULL DEFAULT 'draft', "name" character varying NOT NULL, "image" character varying, "item_type" "public"."items_item_type_enum" NOT NULL DEFAULT 'tiket masuk', "hpp" bigint, "sales_margin" integer, "total_price" bigint, "base_price" bigint, "use_queue" boolean NOT NULL DEFAULT false, "show_to_booking" boolean NOT NULL DEFAULT false, "limit_type" "public"."items_limit_type_enum" NOT NULL DEFAULT 'no limit', "limit_value" integer, "item_category_id" uuid, "tenant_id" uuid, CONSTRAINT "PK_ba5885359424c15ca6b9e79bcf6" PRIMARY KEY ("id"))`);
|
||||||
|
await queryRunner.query(`CREATE TABLE "item_bundlings" ("item_bundling_id" uuid NOT NULL, "item_id" uuid NOT NULL, CONSTRAINT "PK_da8e062f97fe862c3e60ed929b5" PRIMARY KEY ("item_bundling_id", "item_id"))`);
|
||||||
|
await queryRunner.query(`CREATE INDEX "IDX_a50e7abf2caba4d0394f3726b8" ON "item_bundlings" ("item_bundling_id") `);
|
||||||
|
await queryRunner.query(`CREATE INDEX "IDX_edb9c8d945303a725f6b8648a0" ON "item_bundlings" ("item_id") `);
|
||||||
|
await queryRunner.query(`ALTER TABLE "items" ADD CONSTRAINT "FK_205e327d4c1bf3cdc00852845e6" FOREIGN KEY ("item_category_id") REFERENCES "item_categories"("id") ON DELETE CASCADE ON UPDATE CASCADE`);
|
||||||
|
await queryRunner.query(`ALTER TABLE "items" ADD CONSTRAINT "FK_d7d027b642add7f0e77c36b874f" FOREIGN KEY ("tenant_id") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE`);
|
||||||
|
await queryRunner.query(`ALTER TABLE "item_bundlings" ADD CONSTRAINT "FK_a50e7abf2caba4d0394f3726b86" FOREIGN KEY ("item_bundling_id") REFERENCES "items"("id") ON DELETE CASCADE ON UPDATE CASCADE`);
|
||||||
|
await queryRunner.query(`ALTER TABLE "item_bundlings" ADD CONSTRAINT "FK_edb9c8d945303a725f6b8648a00" FOREIGN KEY ("item_id") REFERENCES "items"("id") ON DELETE CASCADE ON UPDATE CASCADE`);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE "item_bundlings" DROP CONSTRAINT "FK_edb9c8d945303a725f6b8648a00"`);
|
||||||
|
await queryRunner.query(`ALTER TABLE "item_bundlings" DROP CONSTRAINT "FK_a50e7abf2caba4d0394f3726b86"`);
|
||||||
|
await queryRunner.query(`ALTER TABLE "items" DROP CONSTRAINT "FK_d7d027b642add7f0e77c36b874f"`);
|
||||||
|
await queryRunner.query(`ALTER TABLE "items" DROP CONSTRAINT "FK_205e327d4c1bf3cdc00852845e6"`);
|
||||||
|
await queryRunner.query(`DROP INDEX "public"."IDX_edb9c8d945303a725f6b8648a0"`);
|
||||||
|
await queryRunner.query(`DROP INDEX "public"."IDX_a50e7abf2caba4d0394f3726b8"`);
|
||||||
|
await queryRunner.query(`DROP TABLE "item_bundlings"`);
|
||||||
|
await queryRunner.query(`DROP TABLE "items"`);
|
||||||
|
await queryRunner.query(`DROP TYPE "public"."items_limit_type_enum"`);
|
||||||
|
await queryRunner.query(`DROP TYPE "public"."items_item_type_enum"`);
|
||||||
|
await queryRunner.query(`DROP TYPE "public"."items_status_enum"`);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -38,6 +38,9 @@ export class ItemModel
|
||||||
@Column('int', { name: 'sales_margin', nullable: true })
|
@Column('int', { name: 'sales_margin', nullable: true })
|
||||||
sales_margin: number;
|
sales_margin: number;
|
||||||
|
|
||||||
|
@Column('bigint', { name: 'total_price', nullable: true })
|
||||||
|
total_price: number;
|
||||||
|
|
||||||
@Column('bigint', { name: 'base_price', nullable: true })
|
@Column('bigint', { name: 'base_price', nullable: true })
|
||||||
base_price: number;
|
base_price: number;
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ export interface ItemEntity extends BaseStatusEntity {
|
||||||
|
|
||||||
hpp: number;
|
hpp: number;
|
||||||
sales_margin: number;
|
sales_margin: number;
|
||||||
|
total_price: number;
|
||||||
base_price: number;
|
base_price: number;
|
||||||
limit_type: LimitType;
|
limit_type: LimitType;
|
||||||
limit_value: number;
|
limit_value: number;
|
||||||
|
|
|
@ -41,6 +41,7 @@ export class DetailItemManager extends BaseDetailManager<ItemEntity> {
|
||||||
`${this.tableName}.limit_value`,
|
`${this.tableName}.limit_value`,
|
||||||
`${this.tableName}.hpp`,
|
`${this.tableName}.hpp`,
|
||||||
`${this.tableName}.sales_margin`,
|
`${this.tableName}.sales_margin`,
|
||||||
|
`${this.tableName}.total_price`,
|
||||||
`${this.tableName}.base_price`,
|
`${this.tableName}.base_price`,
|
||||||
`${this.tableName}.use_queue`,
|
`${this.tableName}.use_queue`,
|
||||||
`${this.tableName}.show_to_booking`,
|
`${this.tableName}.show_to_booking`,
|
||||||
|
|
|
@ -69,6 +69,15 @@ export class ItemDto extends BaseStatusDto implements ItemEntity {
|
||||||
@ValidateIf((body) => body.item_type.toLowerCase() != ItemType.FREE_GIFT)
|
@ValidateIf((body) => body.item_type.toLowerCase() != ItemType.FREE_GIFT)
|
||||||
sales_margin: number;
|
sales_margin: number;
|
||||||
|
|
||||||
|
@ApiProperty({
|
||||||
|
type: Number,
|
||||||
|
required: false,
|
||||||
|
example: 100000,
|
||||||
|
})
|
||||||
|
@IsNumber()
|
||||||
|
@ValidateIf((body) => body.item_type.toLowerCase() == ItemType.BUNDLING)
|
||||||
|
total_price: number;
|
||||||
|
|
||||||
@ApiProperty({
|
@ApiProperty({
|
||||||
type: Number,
|
type: Number,
|
||||||
required: false,
|
required: false,
|
||||||
|
|
Loading…
Reference in New Issue