Skip to content
This repository has been archived by the owner on Nov 12, 2020. It is now read-only.

Commit

Permalink
feat: user tax rate offsets
Browse files Browse the repository at this point in the history
  • Loading branch information
Quantumlyy committed Sep 19, 2020
1 parent f512dff commit 6e56aa9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
23 changes: 21 additions & 2 deletions src/lib/orm/entities/UserEconomyEntity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,31 @@ import { UserEntity } from "./UserEntity";

@Entity("user_economy", { schema: "public" })
export class UserEconomyEntity extends BaseEntity {
@Column("bigint", { name: "balance", default: 0, transformer: kBigIntTransformer })
@Column("bigint", { name: "balance", transformer: kBigIntTransformer, default: 0 })
public balance = 0;

@Column("bigint", { name: "vault", default: 0, transformer: kBigIntTransformer })
@Column("bigint", { name: "vault", transformer: kBigIntTransformer, default: 0 })
public vault = 0;

// #region Overall balance periodic tax collection
@Column("boolean", { name: "collect_taxes", default: false })
public collectTaxes = false;

@Column("timestamp without time zone", { name: "last_tax_collection", nullable: true, default: () => "null" })
public lastTaxCollection?: Date | null = null;
// #endregion Overall balance periodic tax collection

// #region Global tax rate offsets
@Column("numeric", { name: "tax_offset_general", precision: 8, default: 0 })
public toGeneral = 0;

@Column("numeric", { name: "tax_offset_gambling", precision: 8, default: 0 })
public toGambling = 0;

@Column("numeric", { name: "tax_offset_sales", precision: 8, default: 0 })
public toSales = 0;
// #endregion Global tax rate offsets

@OneToOne(() => UserEntity, { primary: true, onDelete: "CASCADE" })
@JoinColumn()
public user?: UserEntity;
Expand Down
5 changes: 5 additions & 0 deletions src/lib/structures/DbSet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { GuildRepository } from "@orm/repositories/GuildRepository";
import { UserRepository } from "@orm/repositories/UserRepository";
import type { Connection } from "typeorm";
import { UserGametagEntity } from "@orm/entities/UserGametagEntity";
import { UserEconomyEntity } from "@orm/entities/UserEconomyEntity";

export class DbSet {

Expand All @@ -23,6 +24,10 @@ export class DbSet {
return this.connection.getRepository(UserGametagEntity);
}

public get userEconomyEntities() {
return this.connection.getRepository(UserEconomyEntity);
}

public static async connect() {
return new DbSet(await connect());
}
Expand Down

0 comments on commit 6e56aa9

Please sign in to comment.