diff --git a/src/entity/brilink_merchant_product_items.ts b/src/entity/brilink_merchant_product_items.ts new file mode 100644 index 0000000..8acc1f0 --- /dev/null +++ b/src/entity/brilink_merchant_product_items.ts @@ -0,0 +1,54 @@ +import { Column, CreateDateColumn, DeleteDateColumn, Entity, JoinTable, ManyToOne, PrimaryGeneratedColumn, UpdateDateColumn } from "typeorm"; +import { Status } from "../types/status"; +import { BrilinkProductCategory } from "./brilink_product_categories"; +import { BrilinkProductItem } from "./brilink_product_items"; +import { BrilinkMerchant } from "./brilink_merchants"; + +@Entity("brilink_merchant_product_items", { schema: "brilinks" }) +export class BrilinkMerchantProductItem { + @PrimaryGeneratedColumn("uuid") + id: string; + + @ManyToOne(() => BrilinkMerchant, { onDelete: "RESTRICT" }) + @JoinTable() + merchant: BrilinkMerchant; + + @ManyToOne(() => BrilinkProductItem, { onDelete: "RESTRICT" }) + @JoinTable() + product_item: BrilinkProductItem; + + @Column({ + type: "float8", + nullable: false, + default: 0, + }) + price_merchant: number; + + @Column({ + type: "float8", + nullable: false, + default: 0, + }) + price_sale: number; + + @Column() + @CreateDateColumn() + created_at: Date; + + @Column({ type: "varchar", length: 255 }) + created_by: string; + + @Column({ nullable: true }) + @UpdateDateColumn() + updated_at: Date; + + @Column({ type: "varchar", length: 255, nullable: true }) + updated_by: string; + + @Column({ nullable: true }) + @DeleteDateColumn() + deleted_at: Date; + + @Column({ type: "varchar", length: 255, nullable: true }) + deleted_by: string; +} diff --git a/src/entity/brilink_product_categories.ts b/src/entity/brilink_product_categories.ts new file mode 100644 index 0000000..7b5e16a --- /dev/null +++ b/src/entity/brilink_product_categories.ts @@ -0,0 +1,74 @@ +import { Column, CreateDateColumn, DeleteDateColumn, Entity, JoinTable, ManyToOne, PrimaryGeneratedColumn, UpdateDateColumn } from "typeorm"; +import { BrilinkProductCategorySupplier } from "../types/brilink"; +import { BrilinkTerminalMenu } from "./brilink_terminal_menus"; +import { Status } from "../types/status"; + +@Entity("brilink_product_categories", { schema: "brilinks" }) +export class BrilinkProductCategory { + @PrimaryGeneratedColumn("uuid") + id: string; + + @ManyToOne(() => BrilinkTerminalMenu, { onDelete: "NO ACTION" }) + @JoinTable() + terminal_menu: BrilinkTerminalMenu; + + @Column({ + nullable: false, + length: 128, + unique: true, + }) + code: string; + + @Column({ + nullable: false, + length: 128, + }) + name: string; + + @Column({ + nullable: false, + length: 4096, + default: "", + }) + description: string; + + @Column({ + nullable: false, + length: 4096, + default: "", + }) + logo: string; + + @Column({ + nullable: false, + length: 64, + }) + status: Status; + + @Column({ + nullable: false, + length: 64, + }) + supplier: BrilinkProductCategorySupplier; + + @Column() + @CreateDateColumn() + created_at: Date; + + @Column({ type: "varchar", length: 255 }) + created_by: string; + + @Column({ nullable: true }) + @UpdateDateColumn() + updated_at: Date; + + @Column({ type: "varchar", length: 255, nullable: true }) + updated_by: string; + + @Column({ nullable: true }) + @DeleteDateColumn() + deleted_at: Date; + + @Column({ type: "varchar", length: 255, nullable: true }) + deleted_by: string; +} diff --git a/src/entity/brilink_product_items.ts b/src/entity/brilink_product_items.ts new file mode 100644 index 0000000..df0f7a4 --- /dev/null +++ b/src/entity/brilink_product_items.ts @@ -0,0 +1,99 @@ +import { Column, CreateDateColumn, DeleteDateColumn, Entity, JoinTable, ManyToOne, PrimaryGeneratedColumn, UpdateDateColumn } from "typeorm"; +import { Status } from "../types/status"; +import { BrilinkProductCategory } from "./brilink_product_categories"; +import { BrilinkProductType } from "./brilink_product_types"; + +@Entity("brilink_product_items", { schema: "brilinks" }) +export class BrilinkProductItem { + @PrimaryGeneratedColumn("uuid") + id: string; + + @ManyToOne(() => BrilinkProductCategory, { onDelete: "RESTRICT" }) + @JoinTable() + product_category: BrilinkProductCategory; + + @ManyToOne(() => BrilinkProductType, { onDelete: "RESTRICT" }) + @JoinTable() + product_type: BrilinkProductType; + + @Column({ + nullable: false, + length: 128, + unique: true, + }) + code: string; + + @Column({ + nullable: false, + length: 128, + }) + name: string; + + @Column({ + nullable: false, + length: 128, + default: "", + }) + subtitle: string; + + @Column({ + nullable: false, + length: 4096, + default: "", + }) + description: string; + + @Column({ + type: "float8", + nullable: false, + default: 0, + }) + price_base: number; + + @Column({ + type: "float8", + nullable: false, + default: 0, + }) + price_merchant: number; + + @Column({ + type: "float8", + nullable: false, + default: 0, + }) + price_sale: number; + + @Column({ + nullable: false, + length: 64, + }) + status: Status; + + @Column({ + type: "jsonb", + nullable: true, + }) + supplier_prop: Record; + + @Column() + @CreateDateColumn() + created_at: Date; + + @Column({ type: "varchar", length: 255 }) + created_by: string; + + @Column({ nullable: true }) + @UpdateDateColumn() + updated_at: Date; + + @Column({ type: "varchar", length: 255, nullable: true }) + updated_by: string; + + @Column({ nullable: true }) + @DeleteDateColumn() + deleted_at: Date; + + @Column({ type: "varchar", length: 255, nullable: true }) + deleted_by: string; +} diff --git a/src/entity/brilink_product_types.ts b/src/entity/brilink_product_types.ts new file mode 100644 index 0000000..37f502f --- /dev/null +++ b/src/entity/brilink_product_types.ts @@ -0,0 +1,62 @@ +import { Column, CreateDateColumn, DeleteDateColumn, Entity, JoinTable, ManyToOne, PrimaryGeneratedColumn, UpdateDateColumn } from "typeorm"; +import { BrilinkProductCategorySupplier } from "../types/brilink"; +import { BrilinkTerminalMenu } from "./brilink_terminal_menus"; +import { Status } from "../types/status"; +import { BrilinkProductCategory } from "./brilink_product_categories"; + +@Entity("brilink_product_types", { schema: "brilinks" }) +export class BrilinkProductType { + @PrimaryGeneratedColumn("uuid") + id: string; + + @ManyToOne(() => BrilinkProductCategory, { onDelete: "RESTRICT" }) + @JoinTable() + product_category: BrilinkProductCategory; + + @Column({ + nullable: false, + length: 128, + unique: true, + }) + code: string; + + @Column({ + nullable: false, + length: 128, + }) + name: string; + + @Column({ + nullable: false, + length: 4096, + default: "", + }) + description: string; + + @Column({ + nullable: false, + length: 64, + }) + status: Status; + + @Column() + @CreateDateColumn() + created_at: Date; + + @Column({ type: "varchar", length: 255 }) + created_by: string; + + @Column({ nullable: true }) + @UpdateDateColumn() + updated_at: Date; + + @Column({ type: "varchar", length: 255, nullable: true }) + updated_by: string; + + @Column({ nullable: true }) + @DeleteDateColumn() + deleted_at: Date; + + @Column({ type: "varchar", length: 255, nullable: true }) + deleted_by: string; +} diff --git a/src/index.ts b/src/index.ts index af69c74..3e9d760 100644 --- a/src/index.ts +++ b/src/index.ts @@ -158,6 +158,7 @@ import { BrilinkDiscountModule, BrilinkDiscountStatus, BrilinkDiscountType, + BrilinkProductCategorySupplier, } from "./types/brilink"; import { BrilinkMerchant } from "./entity/brilink_merchants"; @@ -180,6 +181,10 @@ import { BrilinkMerchantSettlement } from "./entity/brilink_merchant_settlements import { BrilinkMembership } from "./entity/brilink_memberships"; import { BrilinkMembershipCard } from "./entity/brilink_membership_cards"; import { BrilinkDiscount } from "./entity/brilink_discounts"; +import { BrilinkProductCategory } from "./entity/brilink_product_categories"; +import { BrilinkProductType } from "./entity/brilink_product_types"; +import { BrilinkProductItem } from "./entity/brilink_product_items"; +import { BrilinkMerchantProductItem } from "./entity/brilink_merchant_product_items"; import { BriapiConfig } from "./entity/briapi_configs"; import { BriapiLog } from "./entity/briapi_logs"; @@ -335,6 +340,11 @@ export { BrilinkDiscountStatus, BrilinkDiscountType, BrilinkDiscount, + BrilinkProductCategorySupplier, + BrilinkProductCategory, + BrilinkProductType, + BrilinkProductItem, + BrilinkMerchantProductItem, BriapiConfig, BriapiLog, BriapiAppendixBank, diff --git a/src/types/brilink.ts b/src/types/brilink.ts index 03d0130..8ced2ef 100644 --- a/src/types/brilink.ts +++ b/src/types/brilink.ts @@ -1,136 +1,143 @@ export enum BrilinkMerchantStatus { - "active" = "active", - "inactive" = "inactive", -}; + "active" = "active", + "inactive" = "inactive", +} export enum BrilinkTerminalType { - "edc" = "edc", -}; + "edc" = "edc", +} export enum BrilinkTerminalCondition { - "new" = "new", - "good" = "good", - "minor_damage" = "minor_damage", - "damaged" = "damaged", - "unusabel" = "unusable", - "disposed" = "disposed", - "lost" = "lost", -}; + "new" = "new", + "good" = "good", + "minor_damage" = "minor_damage", + "damaged" = "damaged", + "unusabel" = "unusable", + "disposed" = "disposed", + "lost" = "lost", +} export enum BrilinkTerminalOnline { - "online" = "online", - "offline" = "offline", - "block" = "block" + "online" = "online", + "offline" = "offline", + "block" = "block", } export enum BrilinkBalanceType { - "merchant" = "merchant", - "terminal" = "terminal" + "merchant" = "merchant", + "terminal" = "terminal", } export enum BrilinkBalanceCode { - "brizzi" = "brizzi", - "remittance" = "remittance" + "brizzi" = "brizzi", + "remittance" = "remittance", } export enum BrilinkBalanceMutationType { - "credit" = "credit", - "debit" = "debit", + "credit" = "credit", + "debit" = "debit", } export enum BrilinkBalanceMutationCodePrefixType { - "credit" = "CR", - "debit" = "DB" + "credit" = "CR", + "debit" = "DB", } export enum BrilinkBalanceMutationActvity { - "topup" = "topup", - "transfer" = "transfer", - "withdrawal" = "withdrawal", + "topup" = "topup", + "transfer" = "transfer", + "withdrawal" = "withdrawal", } export enum BrilinkBalanceMutationCodePrefixActvity { - "topup" = "1", - "transfer" = "2", - "withdrawal" = "3" + "topup" = "1", + "transfer" = "2", + "withdrawal" = "3", } export enum BrilinkBalanceSourceType { - "account" = "account", - "merchant" = "merchant", - "terminal" = "terminal", + "account" = "account", + "merchant" = "merchant", + "terminal" = "terminal", } export enum BrilinkBalanceDestinationType { - "account" = "account", - "merchant" = "merchant", - "terminal" = "terminal", - "brizzi" = "brizzi" + "account" = "account", + "merchant" = "merchant", + "terminal" = "terminal", + "brizzi" = "brizzi", } export enum BrilinkBalanceMutationStatus { - "pending" = "pending", - "process" = "process", - "success" = "success", - "fail" = "fail", - "reject" = "reject" + "pending" = "pending", + "process" = "process", + "success" = "success", + "fail" = "fail", + "reject" = "reject", } export enum BrilinkBalanceTopupCodePrefix { - "account" = "ACC", - "merchant" = "MCH", - "terminal" = "TML", - "brizzi" = "BRZ" + "account" = "ACC", + "merchant" = "MCH", + "terminal" = "TML", + "brizzi" = "BRZ", } export enum BrilinkTransactionType { - "brizzi" = "brizzi", - "remittance" = "remittance" + "brizzi" = "brizzi", + "remittance" = "remittance", + "mobile" = "mobile", } export enum BrilinkTransactionCodePrefixType { - "brizzi" = "BRZ", - "remittance" = "RTC" + "brizzi" = "BRZ", + "remittance" = "RTC", + "mobile" = "MBL", } export enum BrilinkTransactionActivity { - "topup" = "topup", - "payment" = "payment", - "purchase" = "purchase" + "topup" = "topup", + "payment" = "payment", + "purchase" = "purchase", } export enum BrilinkTransactionCodePrefixActivity { - "topup" = "1", - "payment" = "2", - "purchase" = "3" + "topup" = "1", + "payment" = "2", + "purchase" = "3", } export enum BrilinkTransactionStatus { - "pending" = "pending", - "process" = "process", - "success" = "success", - "fail" = "fail", + "unpaid" = "unpaid", + "pending" = "pending", + "process" = "process", + "success" = "success", + "fail" = "fail", } export enum BrilinkMerchantSettlementStatus { - "pending" = "pending", - "process" = "process", - "success" = "success", - "fail" = "fail", + "pending" = "pending", + "process" = "process", + "success" = "success", + "fail" = "fail", } export enum BrilinkDiscountType { - "fix" = "fix", - "percentage" = "percentage", + "fix" = "fix", + "percentage" = "percentage", } export enum BrilinkDiscountStatus { - "scheduled" = "scheduled", - "active" = "active", - "inactive" = "inactive", - "expired" = "expired", + "scheduled" = "scheduled", + "active" = "active", + "inactive" = "inactive", + "expired" = "expired", } export enum BrilinkDiscountModule { - "brizzi" = "brizzi" + "brizzi" = "brizzi", +} + +export enum BrilinkProductCategorySupplier { + "tcel" = "tcel", }