236 lines
7.4 KiB
Markdown
236 lines
7.4 KiB
Markdown
# Domain Entities Summary
|
|
|
|
This document provides an overview of all domain entities created based on the database schema.
|
|
|
|
## Created Domain Entities by Feature
|
|
|
|
### 1. Auth Feature (/lib/features/auth/domain/entities/)
|
|
- **user.dart** - User account with authentication and loyalty information
|
|
- Enums: UserRole, UserStatus, LoyaltyTier
|
|
- Supporting class: CompanyInfo
|
|
|
|
- **user_session.dart** - Active user session with device information
|
|
|
|
### 2. Products Feature (/lib/features/products/domain/entities/)
|
|
- **product.dart** - Product catalog item (UPDATED to match database schema)
|
|
- Product with images, specifications, 360 view, ERPNext integration
|
|
|
|
- **stock_level.dart** - Inventory stock level for products
|
|
- Available, reserved, and ordered quantities
|
|
|
|
- **category.dart** - Product category (existing)
|
|
|
|
### 3. Cart Feature (/lib/features/cart/domain/entities/)
|
|
- **cart.dart** - Shopping cart
|
|
- Cart-level totals and sync status
|
|
|
|
- **cart_item.dart** - Individual cart item
|
|
- Product reference, quantity, pricing
|
|
|
|
### 4. Orders Feature (/lib/features/orders/domain/entities/)
|
|
- **order.dart** - Customer order
|
|
- Enums: OrderStatus
|
|
- Supporting class: Address
|
|
|
|
- **order_item.dart** - Order line item
|
|
- Product, quantity, pricing, discounts
|
|
|
|
- **invoice.dart** - Invoice for orders
|
|
- Enums: InvoiceType, InvoiceStatus
|
|
- Payment tracking
|
|
|
|
- **payment_line.dart** - Payment transaction
|
|
- Enums: PaymentMethod, PaymentStatus
|
|
- Bank details, receipts
|
|
|
|
### 5. Loyalty Feature (/lib/features/loyalty/domain/entities/)
|
|
- **loyalty_point_entry.dart** - Points transaction
|
|
- Enums: EntryType, EntrySource, ComplaintStatus
|
|
- Points earned/spent tracking
|
|
|
|
- **gift_catalog.dart** - Redeemable gift catalog
|
|
- Enums: GiftCategory
|
|
- Availability and validity tracking
|
|
|
|
- **redeemed_gift.dart** - User-redeemed gift
|
|
- Enums: GiftStatus
|
|
- Voucher codes, QR codes, expiry
|
|
|
|
- **points_record.dart** - User-submitted invoice for points
|
|
- Enums: PointsStatus
|
|
- Invoice submission and approval
|
|
|
|
### 6. Projects Feature (/lib/features/projects/domain/entities/)
|
|
- **project_submission.dart** - Completed project submission
|
|
- Enums: ProjectType, SubmissionStatus
|
|
- Before/after photos, points earning
|
|
|
|
- **design_request.dart** - Design consultation request
|
|
- Enums: DesignStatus
|
|
- Project requirements, designer assignment
|
|
|
|
### 7. Quotes Feature (/lib/features/quotes/domain/entities/)
|
|
- **quote.dart** - Price quotation
|
|
- Enums: QuoteStatus
|
|
- Supporting class: DeliveryAddress
|
|
|
|
- **quote_item.dart** - Quote line item
|
|
- Price negotiation, discounts
|
|
|
|
### 8. Chat Feature (/lib/features/chat/domain/entities/)
|
|
- **chat_room.dart** - Chat conversation room
|
|
- Enums: RoomType
|
|
- Participants, context (order/quote)
|
|
|
|
- **message.dart** - Chat message
|
|
- Enums: ContentType
|
|
- Attachments, read status, product references
|
|
|
|
### 9. Notifications Feature (/lib/features/notifications/domain/entities/)
|
|
- **notification.dart** - User notification
|
|
- Type-based notifications (order, loyalty, promotion, system)
|
|
- Read status, push delivery
|
|
|
|
### 10. Showrooms Feature (/lib/features/showrooms/domain/entities/)
|
|
- **showroom.dart** - Virtual showroom display
|
|
- 360 views, gallery, metadata
|
|
|
|
- **showroom_product.dart** - Product used in showroom
|
|
- Quantity tracking
|
|
|
|
### 11. Account Feature (/lib/features/account/domain/entities/)
|
|
- **payment_reminder.dart** - Invoice payment reminder
|
|
- Enums: ReminderType
|
|
- Scheduling and delivery tracking
|
|
|
|
- **audit_log.dart** - System audit trail
|
|
- Action tracking, change history
|
|
|
|
### 12. Home Feature (/lib/features/home/domain/entities/)
|
|
- **member_card.dart** - Membership card (existing)
|
|
- Enums: MemberTier, MemberType
|
|
|
|
- **promotion.dart** - Promotion (existing)
|
|
|
|
## Entity Design Patterns
|
|
|
|
All entities follow these consistent patterns:
|
|
|
|
### Immutability
|
|
- All fields are `final`
|
|
- Constructor uses `const` when possible
|
|
- `copyWith()` method for creating modified copies
|
|
|
|
### Value Equality
|
|
- Proper `==` operator override
|
|
- `hashCode` override using `Object.hash()`
|
|
- `toString()` method for debugging
|
|
|
|
### Business Logic
|
|
- Computed properties (getters) for derived values
|
|
- Boolean checks (e.g., `isActive`, `isExpired`)
|
|
- Helper methods for common operations
|
|
|
|
### Type Safety
|
|
- Enums for status/type fields with `displayName` getters
|
|
- Nullable types (`?`) where appropriate
|
|
- List/Map types for collections and JSONB fields
|
|
|
|
### Documentation
|
|
- Comprehensive documentation comments
|
|
- Feature-level context
|
|
- Field descriptions
|
|
|
|
## Database Field Mapping
|
|
|
|
All entities map 1:1 with database schema:
|
|
- `varchar` → `String` or `String?`
|
|
- `numeric` → `double`
|
|
- `integer` → `int`
|
|
- `boolean` → `bool`
|
|
- `timestamp` → `DateTime`
|
|
- `date` → `DateTime`
|
|
- `jsonb` → `Map<String, dynamic>` or typed classes
|
|
- `inet` → `String?`
|
|
- `text` → `String?`
|
|
- Arrays → `List<T>`
|
|
|
|
## Enums Created
|
|
|
|
### Auth
|
|
- UserRole (customer, sales, admin, accountant, designer)
|
|
- UserStatus (pending, active, suspended, rejected)
|
|
- LoyaltyTier (none, gold, platinum, diamond)
|
|
|
|
### Orders
|
|
- OrderStatus (draft, confirmed, processing, ready, shipped, delivered, completed, cancelled, returned)
|
|
- InvoiceType (standard, proforma, creditNote, debitNote)
|
|
- InvoiceStatus (draft, submitted, partiallyPaid, paid, overdue, cancelled)
|
|
- PaymentMethod (cash, bankTransfer, creditCard, ewallet, check, other)
|
|
- PaymentStatus (pending, processing, completed, failed, refunded, cancelled)
|
|
|
|
### Loyalty
|
|
- EntryType (earn, redeem, adjustment, expiry)
|
|
- EntrySource (order, referral, redemption, project, pointsRecord, manual, birthday, welcome, other)
|
|
- ComplaintStatus (none, submitted, reviewing, approved, rejected)
|
|
- GiftCategory (voucher, product, service, discount, other)
|
|
- GiftStatus (active, used, expired, cancelled)
|
|
- PointsStatus (pending, approved, rejected)
|
|
|
|
### Projects
|
|
- ProjectType (residential, commercial, industrial, infrastructure, other)
|
|
- SubmissionStatus (pending, reviewing, approved, rejected)
|
|
- DesignStatus (pending, assigned, inProgress, completed, cancelled)
|
|
|
|
### Quotes
|
|
- QuoteStatus (draft, sent, accepted, rejected, expired, converted)
|
|
|
|
### Chat
|
|
- RoomType (direct, group, support, order, quote)
|
|
- ContentType (text, image, file, product, system)
|
|
|
|
### Account
|
|
- ReminderType (initial, dueDate, firstOverdue, secondOverdue, finalWarning)
|
|
|
|
## Key Features
|
|
|
|
### ERPNext Integration
|
|
Many entities include ERPNext reference fields:
|
|
- `erpnextCustomerId` (User)
|
|
- `erpnextItemCode` (Product)
|
|
- `erpnextSalesOrder` (Order)
|
|
- `erpnextInvoice` (Invoice)
|
|
- `erpnextPaymentEntry` (PaymentLine)
|
|
- `erpnextQuotation` (Quote)
|
|
- `erpnextEntryId` (LoyaltyPointEntry)
|
|
|
|
### Address Handling
|
|
Reusable address classes for different contexts:
|
|
- `Address` (Order entity)
|
|
- `DeliveryAddress` (Quote entity)
|
|
- Both with JSON serialization support
|
|
|
|
### Attachment Management
|
|
List-based attachment fields for multiple files:
|
|
- User attachments (ID cards, licenses)
|
|
- Project photos (before/after)
|
|
- Points record invoices
|
|
- Design request references
|
|
- Chat message files
|
|
|
|
### Audit Trail Support
|
|
- Creation timestamps (`createdAt`)
|
|
- Update timestamps (`updatedAt`)
|
|
- User tracking (`createdBy`, `processedBy`, `reviewedBy`)
|
|
- Change tracking (AuditLog entity)
|
|
|
|
## Next Steps
|
|
|
|
These domain entities are ready for:
|
|
1. Data layer model creation (extending entities with JSON serialization)
|
|
2. Repository interface definitions
|
|
3. Use case implementation
|
|
4. Provider/state management integration
|
|
|
|
All entities follow clean architecture principles with no external dependencies.
|