Database Models Overview
SaleFlex.PyPOS uses a comprehensive database schema with over 80 models organized into logical categories. All models inherit from base classes that provide CRUD operations, audit trails, and soft delete functionality.
Core System Models
User and Store Management
- Cashier: User accounts for POS operators with authentication, permissions, and personal information
- Store: Store/outlet information including hardware configuration, system settings, and business details
- Table: Restaurant table management for table service operations
Location and Geography
- Country: Country master data with ISO codes and names
- City: City master data linked to countries
- District: District/region master data linked to cities
Currency and Payment
- Currency: Currency master data (USD, EUR, GBP, etc.)
- CurrencyTable: Currency exchange rates with historical tracking
- PaymentType: Payment method definitions (Cash, Card, Mobile Payment, etc.)
- ClosureCurrency: End-of-day currency reconciliation
Product Management Models
Product Core
- Product: Main product catalog with pricing, stock, descriptions, and product attributes
- ProductVariant: Product variations (size, color, style) linked to base products
- ProductAttribute: Product attributes and specifications (dimensions, weight, materials, etc.)
- ProductBarcode: Barcode associations for products (EAN, UPC, custom barcodes)
- ProductBarcodeMask: Barcode format definitions and validation rules
- ProductUnit: Measurement units (PCS, KG, L, M, etc.)
- ProductManufacturer: Manufacturer/brand information
Product Organization
- DepartmentMainGroup: Main product category groups
- DepartmentSubGroup: Sub-categories within main groups
Transaction Models
Transaction Headers
- TransactionHead: Main transaction record with customer, date, totals, and status
- TransactionHeadTemp: Temporary transaction header during transaction processing
- TransactionSequence: Transaction numbering sequences per document type
- TransactionDocumentType: Document type definitions (Sale, Return, Refund, etc.)
- TransactionLog: Transaction audit log for all transaction events
Transaction Details
- TransactionProduct: Line items in transactions (products sold)
- TransactionPayment: Payment records for transactions
- TransactionTax: Tax calculations per transaction
- TransactionDiscount: Discounts applied to transactions
- TransactionSurcharge: Surcharges applied to transactions
- TransactionTip: Tip/gratuity records
- TransactionTotal: Transaction totals summary
Campaign and Loyalty Models
Campaign Models
- CampaignType: Campaign type definitions (Product Discount, Basket Discount, etc.)
- Campaign: Promotional campaigns with rules, dates, and conditions
- CampaignRule: Detailed campaign rules (product filters, time restrictions, etc.)
- CampaignProduct: Products eligible for campaigns
- CampaignUsage: Campaign usage tracking per customer/transaction
- Coupon: Coupon/voucher definitions with barcode/QR code support
- CouponUsage: Coupon redemption tracking
Loyalty Program Models
- LoyaltyProgram: Loyalty program definitions with point earning rules
- LoyaltyTier: Membership tiers (Bronze, Silver, Gold, Platinum) with benefits
- CustomerLoyalty: Customer loyalty account with current points and tier
- LoyaltyPointTransaction: Point transaction history (earned, redeemed, expired)
Model Features
All models include:
- UUID Primary Keys: Unique identifiers for all records
- Audit Fields: Created/updated timestamps and user tracking
- Soft Delete: Records are marked as deleted rather than physically removed
- CRUD Operations: Standard create, read, update, delete methods
- Server Synchronization: Support for multi-store synchronization via
fk_server_id