feat(statistics): implement top alert stocks, top last sales, top supplier debts, and top selling products endpoints with SQL queries
This commit is contained in:
@@ -28,6 +28,35 @@ model BankAccount {
|
||||
branch BankBranch @relation("Bank_Accounts_branchId_fkey", fields: [branchId], references: [id])
|
||||
inventoryBankAccounts InventoryBankAccount[]
|
||||
purchaseReceiptPayments PurchaseReceiptPayments[]
|
||||
bankAccountTransactions BankAccountTransaction[]
|
||||
bankAccountBalances BankAccountBalance[]
|
||||
|
||||
@@map("Bank_Accounts")
|
||||
}
|
||||
|
||||
model BankAccountTransaction {
|
||||
id Int @id @default(autoincrement())
|
||||
bankAccountId Int
|
||||
type BankAccountTransactionType
|
||||
amount Decimal @db.Decimal(15, 2)
|
||||
balanceAfter Decimal @db.Decimal(15, 2)
|
||||
referenceId Int
|
||||
referenceType BankTransactionRefType
|
||||
description String? @db.Text
|
||||
createdAt DateTime @default(now()) @db.Timestamp(0)
|
||||
|
||||
bankAccount BankAccount @relation(fields: [bankAccountId], references: [id])
|
||||
|
||||
@@index([bankAccountId])
|
||||
@@map("Bank_Account_Transactions")
|
||||
}
|
||||
|
||||
model BankAccountBalance {
|
||||
bankAccountId Int @unique
|
||||
balance Decimal @db.Decimal(15, 2)
|
||||
updatedAt DateTime @updatedAt @db.Timestamp(0)
|
||||
|
||||
bankAccount BankAccount @relation(fields: [bankAccountId], references: [id])
|
||||
|
||||
@@map("Bank_Account_Balance")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user