68 lines
1.8 KiB
Plaintext
68 lines
1.8 KiB
Plaintext
// Financial Management Domain
|
|
// Contains financial records, transactions, and currency models
|
|
|
|
// Financial-specific Enums
|
|
enum TransactionType {
|
|
INCOME
|
|
EXPENSE
|
|
INVESTMENT
|
|
LOAN
|
|
LOAN_PAYMENT
|
|
INSURANCE_PAYMENT
|
|
TAX_PAYMENT
|
|
GRANT
|
|
SUBSIDY
|
|
REFUND
|
|
}
|
|
|
|
enum TransactionStatus {
|
|
PENDING
|
|
APPROVED
|
|
COMPLETED
|
|
REJECTED
|
|
CANCELLED
|
|
FAILED
|
|
}
|
|
|
|
// Financial Models
|
|
model FinancialRecord {
|
|
id String @id @default(cuid())
|
|
farmerId String
|
|
farmId String?
|
|
plotId String?
|
|
type TransactionType
|
|
category String
|
|
subcategory String?
|
|
amount Decimal
|
|
currencyId String @default("idr")
|
|
currency Currency @relation(fields: [currencyId], references: [id])
|
|
description String
|
|
transactionDate DateTime
|
|
paymentMethod PaymentMethod?
|
|
receiptNumber String?
|
|
invoiceNumber String?
|
|
referenceNumber String?
|
|
taxAmount Decimal? @default(0)
|
|
bankAccount String?
|
|
payee String? // who received payment
|
|
approvedBy String? // admin who approved
|
|
status TransactionStatus @default(PENDING)
|
|
notes String?
|
|
attachmentUrls String[]
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
// Relations
|
|
farmer Farmer @relation(fields: [farmerId], references: [id])
|
|
farm Farm? @relation(fields: [farmId], references: [id])
|
|
plot Plot? @relation(fields: [plotId], references: [id])
|
|
|
|
@@index([farmerId, farmId])
|
|
@@index([type])
|
|
@@index([transactionDate])
|
|
@@index([status])
|
|
@@index([category])
|
|
@@index([paymentMethod])
|
|
@@index([amount])
|
|
@@map("financial_records")
|
|
} |