payment checkpoint 2

This commit is contained in:
2025-07-31 23:11:59 +05:30
parent 23e4eb6b7c
commit 5810328711
9 changed files with 1292 additions and 200 deletions

View File

@@ -27,6 +27,8 @@ model User {
appointments Appointment[]
claims Claim[]
insuranceCredentials InsuranceCredential[]
// reverse relations
updatedPayments Payment[] @relation("PaymentUpdatedBy")
}
model Patient {
@@ -114,7 +116,7 @@ model Claim {
staff Staff? @relation("ClaimStaff", fields: [staffId], references: [id])
serviceLines ServiceLine[]
payment Payment?
payment Payment?
}
enum ClaimStatus {
@@ -125,15 +127,15 @@ enum ClaimStatus {
}
model ServiceLine {
id Int @id @default(autoincrement())
claimId Int
procedureCode String
procedureDate DateTime @db.Date
oralCavityArea String?
toothNumber String?
toothSurface String?
billedAmount Float
claim Claim @relation(fields: [claimId], references: [id], onDelete: Cascade)
id Int @id @default(autoincrement())
claimId Int
procedureCode String
procedureDate DateTime @db.Date
oralCavityArea String?
toothNumber String?
toothSurface String?
billedAmount Float
claim Claim @relation(fields: [claimId], references: [id], onDelete: Cascade)
servicePayments ServiceLinePayment[]
}
@@ -185,6 +187,7 @@ model Payment {
patientId Int
userId Int
claimId Int @unique
updatedById Int?
totalBilled Decimal @db.Decimal(10, 2)
totalPaid Decimal @default(0.00) @db.Decimal(10, 2)
totalDue Decimal @db.Decimal(10, 2)
@@ -194,12 +197,15 @@ model Payment {
notes String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
claim Claim @relation(fields: [claimId], references: [id], onDelete: Cascade)
updatedBy User? @relation("PaymentUpdatedBy", fields: [updatedById], references: [id])
transactions PaymentTransaction[]
servicePayments ServiceLinePayment[]
@@index([id])
@@index([claimId])
@@index([patientId])
}
model PaymentTransaction {
@@ -212,9 +218,7 @@ model PaymentTransaction {
payerName String?
notes String?
createdAt DateTime @default(now())
payment Payment @relation(fields: [paymentId], references: [id], onDelete: Cascade)
@@index([paymentId])
}
@@ -225,10 +229,8 @@ model ServiceLinePayment {
paidAmount Decimal @db.Decimal(10, 2)
adjustedAmount Decimal @default(0.00) @db.Decimal(10, 2)
notes String?
payment Payment @relation(fields: [paymentId], references: [id], onDelete: Cascade)
serviceLine ServiceLine @relation(fields: [serviceLineId], references: [id], onDelete: Cascade)
@@index([paymentId])
@@index([serviceLineId])
}
@@ -247,4 +249,4 @@ enum PaymentMethod {
CASH
CARD
OTHER
}
}