QIIUB

Multi-tenant, Offline-First POS Platform — Database Schema Summary

140
Total Tables
18
Central DB
88
Merchant (dbo)
~35
Reference (ref)
127
Features
9
Design Docs
dbo Business tables
ref Seed/lookup tables
audit Audit trail
sync Sync infrastructure

Central Database (QIIUBCentral)

Partner & Merchant Management 6

SchemaTablePurpose
dboPartnerChannel partner registry (BCPOS Group house partner + external partners). IsHousePartner flag. Merchants belong to exactly one partner.
dboPartnerUserMaps users to partners with PartnerRole (PartnerAdmin/PartnerSupport). UQ on UserId — one partner per user.
dboMerchantMerchant registry (PublicId, Code, Name). PartnerId FK (NOT NULL) + nullable MerchantGroupId. IndustryTemplate (Shop/Pharmacy/Hardware). 3 verticals.
dboDatabaseServerSQL Server instances hosting merchant databases
dboDatabaseRecordLogical databases with Elastic Pool assignment
dboMerchantDatabaseMaps each merchant to its operational database

Identity & Access 2

SchemaTablePurpose
dboApplicationUserASP.NET Core Identity (extended with FirstName, LastName). Users can be merchant users, partner users, or SystemAdmin.
dboUserMerchantMaps users to merchants with UserRole (SystemAdmin/Admin/Manager/Cashier)

Module System 3

SchemaTablePurpose
dboModuleDefinitionRegistry of 31+ available modules (seeded)
dboMerchantModuleWhich modules are active per merchant
dboMerchantFeatureFlagGranular feature toggles per merchant

Devices & Audit 2

SchemaTablePurpose
dboDeviceRegistrationPOS terminals, kiosks, legacy connectors (IoT Hub link)
dboSystemAuditLogSystem-level events (merchant creation, user management, partner actions). MerchantId + PartnerId FKs for scoped audit queries.

Group Loyalty 5

SchemaTablePurpose
dboMerchantGroupMulti-company group registry. Links merchants owned by the same business owner for shared loyalty/gift cards/reporting. See loyalty-group-architecture.
dboGroupLoyaltyProgramGroup-level loyalty program definition: PointsPerDollar, RedemptionRate, MinPointsToRedeem. Multiple programs per group.
dboGroupLoyaltyProgramMerchantJunction: which merchants participate in which group loyalty program. Per-merchant opt-in.
dboGroupLoyaltyAccountLoyalty member accounts shared across group. Identified by phone number. PointsBalance cached.
dboGroupLoyaltyTransactionAppend-only ledger: Earn, Redeem, Adjust, Void, Expire. Tracks SourceMerchantId per transaction.

Merchant Database (per merchant)

Organization & Infrastructure 6

SchemaTablePurpose
dboLocationPhysical stores / branches
dboLocationGroupLogical groupings for reporting/pricing
dboLocationGroupMemberJunction: Location ↔ LocationGroup
dboTerminalIndividual POS registers
dboEmployeeStaff (replaces separate Cashier + SalesRep)
dboEmployeeRoleEmployee role assignments

Product Catalog 18

SchemaTablePurpose
dboCategoryHierarchical categories (ParentCategoryId). Root categories = departments.
dboProductCategoryJunction: Product ↔ Category (N:M). Primary category lives on Product.CategoryId and is also represented here (ADR-0044).
dboSupplierVendor master
dboProductMaster product record. Includes MSRP, TrackSerialNumbers, and lifecycle Status enum (Draft / Active / Inactive — replaces IsActive boolean per ADR-0065).
dboProductOptionDimension definitions (Size, Color, Material)
dboProductOptionValueValues per dimension (S, M, L, XL)
dboProductVariantSKU-level combinations (Size+Color). Includes PriceLowerBound/PriceUpperBound for override guardrails.
dboProductVariantOptionValueJunction: Variant ↔ OptionValue
dboProductBarcodeSecondary/alternate barcodes per variant. Barcode format (UPC-A, EAN-13, ISBN, PLU, Internal, Custom) is never stored — computed from the value via BarcodeHelper.DetectType(). See ADR-0047.
dboProductPricePrice tiers (Retail, Wholesale, VIP)
dboPriceTierPrice tier definitions
dboProductSupplierProduct ↔ Supplier with costs, lead times
dboProductImageMultiple images per product
dboProductAlertPOS pop-up messages per product: age verification (21+/18+), warnings, info notes. AlertType via ref.AlertType. Maps from RMH ItemMessage.
dboKitComponentBundle / kit items
dboUnitOfMeasureEA, LB, FT, CS, etc.
dboUnitOfMeasureConversionConversion factors between UoMs
dboSerialNumberSerial number registry with Status lifecycle (Available/Sold/Returned/Unavailable). Up to 3 S/N per unit. Linked to ProductVariant, Location, SaleLineItem, PurchaseReceiptLine. See schema-tenant §6.11.

Tax 5

SchemaTablePurpose
dboTaxGroupNamed bundle of rates a product can be assigned to (e.g., "PR IVU Standard"). Has Description and IsActive.
dboTaxRateIndividual tax row reusable across groups (state IVU, municipal, federal excise). Code is unique per merchant. Carries IsCompounding (RMS Tax.IncludePreviousTax), ShowOnReceipt, IsIncludedInPrice.
dboTaxGroupRateM:N junction TaxGroup ↔ TaxRate. Per-group Priority drives compounding base + receipt order. ADR-0063.
dboCustomerTaxProfileB2B classification (e.g., "Reseller PR SC 2914"). RequiresCert, IsActive. Triggers conditional remap of a sale line's TaxGroup.
dboCustomerTaxProfileMapOne mapping rule on a profile. FromTaxGroupId = null is the catch-all. Specific match wins over catch-all.

Customer Management 3

SchemaTablePurpose
dboCustomerMaster customer (tier, tax exemption, loyalty, DefaultDiscountPercent)
dboCustomerAddressBilling / shipping addresses
dboCustomerStatsCached lifetime totals (sales, visits)

Sales Transactions 6

SchemaTablePurpose
dboSaleMaster transaction (Status, Type, Totals)
dboSaleLineItemLine items in a sale
dboSalePaymentPayment methods applied to sale
dboSaleTaxTax detail per rate per sale
dboReasonCodeReasons for returns, voids, discounts
dboReturnTrackingCross-store return quantity guard

Payments 1

SchemaTablePurpose
dboPaymentMethodCash, Card, Check, AccountCharge, GiftCard

Orders & Quotes 4

SchemaTablePurpose
dboOrderCustomer orders (Quote, Layaway, BackOrder, etc.)
dboOrderLineItemLine items in an order
dboOrderPaymentDeposits / payments collected on order
dboOrderHistoryAudit trail of order status changes

Shifts & Cash Management 7

SchemaTablePurpose
dboShiftBatch/shift with 22+ denormalized totals
dboShiftCountTender counts per shift by payment method
dboShiftTaxTotalTax totals per rate per shift
dboCashMovementDrops, Payouts, Pickups
dboNonSaleEventDrawer opens, X/Z reports, blind closeouts
dboShiftSegmentTerminal session within a floating shift. Tracks which terminal an employee used and when (start/end). Enables terminal movement history.
dboDailySalesPre-aggregated daily totals by 5 dimensions (Category, Supplier, Register, Cashier, SalesRep) + LocationId. Generated locally, synced to cloud.

Inventory & Supply Chain 16

SchemaTablePurpose
dboLocationProductPer variant per location (qty, price, cost, tax)
dboInventoryMovementAppend-only movement ledger
dboPurchaseOrderPurchase order header
dboPurchaseOrderLinePO line items (qty, UoM, cost)
dboPurchaseReceiptReceiving document (separate from PO)
dboPurchaseReceiptLineReceipt lines with actual qty, cost variance
dboDistributionWarehouse → store allocation header
dboDistributionLinePer-item allocation
dboDistributionAllocationPer-store qty + acknowledgement
dboTransferOrderStore ↔ store transfer (two-sided)
dboTransferOrderLineTransfer line items
dboTransferConfirmationReceiver acknowledges (partial/full/rejected)
dboStockCountPhysical count header
dboStockCountItemItems counted with variance
dboInventoryAdjustmentAdjustment document with reason code
dboAdjustmentLineAdjustment line items

Price & Cost Management 4

SchemaTablePurpose
dboPriceChangePrice change campaign (Draft → Approved → Applied)
dboPriceChangeLinePer-item price change in campaign
dboPriceChangeLocationWhich locations get the price change
dboCostChangeSupplier cost updates, receiving variance

Gift Cards 2

SchemaTablePurpose
dboGiftCardGift card master (balance, expiry, status)
dboGiftCardActivityActivation, reload, redemption, adjustment

Accounts Receivable 6

SchemaTablePurpose
dboAccountGroupAccount classifications (Contractor, Government)
dboAccountCharge account (credit limit, payment terms)
dboAccountContactMany-to-many: Customer ↔ Account
dboAccountLedgerCharges, payments, credit/debit memos
dboAccountLedgerDetailPayment application (which charge was paid)
dboAccountStatementPeriodic statement generation

Loyalty 3

SchemaTablePurpose
dboLoyaltyProgramProgram definitions (point values, tiers)
dboLoyaltyAccountCustomer enrollment in loyalty
dboLoyaltyTransactionPoints earned / redeemed / adjusted

Promotions 3

SchemaTablePurpose
dboPromotionCampaign (date range, active flag)
dboPromotionRuleRule type (% off, Buy X Get Y, fixed price)
dboCouponCoupon codes with redemption tracking

Multi-Currency 2

SchemaTablePurpose
dboCurrencyCurrency codes and names
dboExchangeRateDaily exchange rates (immutable, date-versioned)

Labor / Time Clock 3

SchemaTablePurpose
dboTimeEntryEmployee time clock (clock in/out, break minutes denormalized from TimeBreak, JobRoleId, photo URLs + override audit per ADR-0041)
dboTimeBreakDiscrete break punches per shift — start/end timestamps, paid vs unpaid (ADR-0046)
dboJobRoleEmployee roles with pay rates (cashier, server, bartender)

Extensibility & Configuration 4

SchemaTablePurpose
dboCustomFieldDefinitionMerchant-defined custom fields per entity
dboMerchantSettingMerchant-level operational config
dboLocationSettingPer-location config (overrides merchant)
dboTerminalSettingPer-terminal config (overrides location)

Document Sequencing 1

SchemaTablePurpose
dboDocumentSequenceAtomic numbering (PO-000142, RCV-000089)

Audit 1

SchemaTablePurpose
auditAuditEntryData-level audit trail (who changed what, JSON diff)

Sync & Offline 4

SchemaTablePurpose
syncSyncLogSync session records (timestamp, device, direction)
syncSyncCommandPrioritized command queue for offline ops
syncChangeLogEntity-level change tracking (delta sync)
syncDeviceSyncStatePer-device sync watermarks. Tracks last successful sync timestamp per entity type per device.

Label Printing 3

SchemaTablePurpose
dboLabelSizePhysical label dimensions (width, height, DPI). Atomic IsDefault promotion.
dboLabelTemplateZPL/TSPL label templates with placeholder merge fields. Location-scoped pricing.
dboPrintJobPrint job queue for label batch printing.

AI Credit System (Central) 5

SchemaTablePurpose
dboAiCreditAccountPer-merchant AI credit balance. Links to AiCreditPlan.
dboAiCreditPlanCredit plan definitions (Free, Pro, Enterprise). Monthly allocation, per-credit cost.
dboAiCreditTransactionAppend-only ledger of credit allocations, usages, top-ups, and adjustments.
dboAiRequestLogEvery AI completion request — prompt, response, token counts, cost, latency.
dboAiPromptReusable AI prompt templates. System and merchant-scoped.

Reference / Lookup Tables (ref schema) ~35

SchemaTablePurpose
refSaleStatusInProgress, Held, Completed, Voided
refSaleTypeSale, Return, Exchange
refOrderStatusDraft, Confirmed, InProgress, ReadyForPickup, Completed, Cancelled
refOrderTypeQuote, Layaway, BackOrder, WorkOrder, SpecialOrder
refShiftStatusOpen, Closed
refGiftCardStatusPending, Active, Expired, Suspended
refAccountStatusActive, Suspended, Closed
refTimeEntryStatusOpen, Closed, Adjusted
refPaymentMethodTypeCash, Card, Check, AccountCharge, GiftCard, External
refCommissionTypeNone, PercentOfSale, PercentOfProfit, Fixed
refAddressTypeBilling, Shipping
refMovementTypeSale, Return, Receipt, Adjustment, TransferOut, TransferIn, Count, Distribution
refDocumentTypePO, Receipt, Distribution, Transfer, Adjustment, StockCount, PriceChange
refReasonCodeCategoryReturn, Discount, Adjustment, Void, PriceOverride, AR_*
refPurchaseOrderStatusDraft, Submitted, PartiallyReceived, FullyReceived, Closed, Cancelled
refPurchaseReceiptStatusDraft, Completed, Cancelled
refDistributionStatusDraft, Allocated, Shipped, Completed, Cancelled
refTransferOrderStatusDraft, Submitted, Shipped, InTransit, PartiallyReceived, Received, Closed, Cancelled
refTransferConfirmationTypeShipped, Received, PartialReceived, Rejected
refAdjustmentStatusDraft, Completed, Cancelled
refStockCountStatusInProgress, Completed, Cancelled
refPriceChangeStatusDraft, PendingApproval, Approved, Applied, Cancelled, Rejected
refCostChangeTypeSupplierIncrease, SupplierDecrease, ManualAdjustment, ReceivingVariance
refAccountLedgerEntryTypeCharge, Payment, CreditMemo, DebitMemo, FinanceCharge
refPaymentTermsTypeDueOnReceipt, NetDays, EndOfMonth
refCreditLimitEnforcementWarn, Block, None
refPromotionRuleTypePercentOff, AmountOff, BuyXGetY, FixedPrice
refPromotionTargetTypeProduct, Category, EntireSale
refGiftCardActivityTypeActivation, Reload, Redemption, Adjustment, Expiration
refLoyaltyTransactionTypeEarn, Redeem, Adjust
refNonSaleEventTypeNoSale, Aborted, XReport, ZReport, ZZReport, BlindCloseout
refSyncCommandStatusPending, InProgress, Completed, Failed, Cancelled
refSyncDirectionUpload, Download
refChangeTypeInsert, Update, Delete
refBarcodeTypeAuto-detected barcode format: UPC_A(0), EAN_13(1), EAN_8(2), ISBN(3), Custom(9)
refSerialNumberStatusAvailable(0), Sold(1), Returned(2), Unavailable(3)
refAlertTypeAgeVerification(0), Warning(1), Info(2)