import CheckConstraint from "@entity-access/entity-access/dist/decorators/CheckConstraint.js"; import Column from "@entity-access/entity-access/dist/decorators/Column.js"; import { RelateTo } from "@entity-access/entity-access/dist/decorators/Relate.js"; import Table from "@entity-access/entity-access/dist/decorators/Table.js"; import { StoreAccount } from "./StoreAccount.js"; import { StoreJournalLineItem } from "./StoreJournalLineItem.js"; import { StoreJournal } from "./StoreJournal.js"; @Table("StoreJournalEntries") @CheckConstraint({ name: "CC_Journal_Entries_Credit_Or_Debit", filter: (x) => (x.credit > 0 && x.debit === 0) || (x.credit === 0 && x.debit > 0) }) export class StoreJournalEntry { @Column({ dataType: "BigInt", key: true, generated: "identity" }) public entryID: number; @Column({ dataType: "BigInt" }) @RelateTo(StoreJournal, { property: (x) => x.journal, inverseProperty: (x) => x.entries, foreignKeyConstraint: { name: "FC_JournalEntry_Journal", onDelete: "cascade" } }) public journalID: number; @Column({ dataType: "BigInt" }) @RelateTo(StoreAccount, { property: (x) => x.storeAccount, inverseProperty: (x) => x.entries }) accountID: number; @Column({ dataType: "Decimal", default: () => 0 }) credit: number; @Column({ dataType: "Decimal", default: () => 0 }) debit: number; @Column({ dataType: "Decimal", nullable: true }) balance: number; @Column({ dataType: "Char", nullable: true }) description: string; @Column({ dataType: "BigInt", nullable: true }) @RelateTo({ type: () => StoreJournalLineItem, property: (x) => x.lineItem, inverseProperty: (x) => x.entries }) lineItemID: number; lineItem: StoreJournalLineItem; storeAccount: StoreAccount; journal: StoreJournal; }