Skip to content

Order Models

Source: pharmanet/lib/core/models/order_model.dart

Order — @freezed

Field Type Description
id String UUID
orderNumber String Human-readable order #
userId String? FK to profiles
addressId String? FK to addresses
shippingAddress Map<String, dynamic>? Snapshot of address
subtotal double Pre-shipping total
shippingCost double Default: 0
taxAmount double Default: 0
discountAmount double Default: 0
totalAmount double Final total
paymentMethod String? Payment method used
paymentStatus String pending, paid, failed, refunded
orderStatus String pending, confirmed, processing, shipped, delivered, cancelled
notes String? Customer notes
adminNotes String? Admin/Seller notes
trackingNumber String? Delivery tracking
carrier String? Delivery carrier
prescriptionUrl String? Uploaded Rx image
prescriptionStatus String pending, verified, rejected
user Profile? Included user data
items List<OrderItem>? Order line items

OrderItem — @freezed

Field Type Description
id String UUID
orderId String FK to orders
productId String? FK to products
sellerId String? FK to sellers
variantCombinationId String? FK to variant combos
quantity int Units ordered
priceAtPurchase double Price snapshot
status String Per-item status
products Product? Included product

Payment — @freezed

Field Type Description
id String UUID
orderId String FK to orders
transactionId String? Chapa transaction ID
paymentMethod String? Method used
amount double Payment amount
currency String Default: ETB
status String pending, success, failed
chapaTxRef String? Chapa reference
chapaResponse Map<String, dynamic>? Raw webhook data
paymentData Map<String, dynamic>? Additional data
paidAt DateTime? Payment timestamp
refundedAt DateTime? Refund timestamp
refundReason String? Refund reason

OrderStatusHistory — @freezed

Field Type Description
id String UUID
orderId String FK to orders
oldStatus String? Previous status
newStatus String New status
updatedBy String? Who made the change
notes String? Change reason
createdAt DateTime? Timestamp