Orders table
The Orders table in the FitStack - V2 schema has 23 columns, keyed by Id, with 5 foreign keys to Companies, Gyms, GymClients, Employees and 1 more. 2 columns in GymStockMovements and OrderLines reference it.
One sale. Glossary: Order; a Draft Order is the cart.
Columns (23)
| Column | Type | Constraints | Description |
|---|---|---|---|
| Id | uuid | primary key, not null | |
| CompanyId | uuid | not null, references Companies.Id | |
| GymId | uuid | not null, references Gyms.Id | Where it was sold or collected. |
| MemberId | uuid | references GymClients.Id | Null for a walk-in paying cash or by Terminal. |
| EmployeeId | uuid | references Employees.Id | Who rang it up; null for App/Web. |
| Number | character varying(32) | not null | Human-readable, per Company. |
| Status | text | not null | `OrderStatus`. |
| Channel | text | not null | `OrderChannel`. |
| PaymentMethod | text | `OrderPaymentMethod`. Null while Draft. | |
| SubtotalCents | integer | not null | |
| TaxCents | integer | not null | |
| TotalCents | integer | not null | |
| PlatformFeeCents | integer | not null | |
| Currency | character varying(3) | not null | |
| StripePaymentIntentId | text | ||
| StripeTaxCalculationId | text | ||
| StripeTerminalReaderId | uuid | references StripeTerminalReaders.Id | |
| PaidAt | timestamp with time zone | ||
| RefundedCents | integer | not null | |
| CreatedAt | timestamp with time zone | not null | |
| ModifiedAt | timestamp with time zone | ||
| IsDeleted | boolean | not null | |
| DeletedAt | timestamp with time zone |
Indexes (4)
(CompanyId, Number)unique (IX_Orders_CompanyId_Number)(GymId, PaidAt)(IX_Orders_GymId_PaidAt)(MemberId, CreatedAt)(IX_Orders_MemberId_CreatedAt)(StripePaymentIntentId)(IX_Orders_StripePaymentIntentId)
Relationships
Orders.CompanyIdreferencesCompanies.IdOrders.GymIdreferencesGyms.IdOrders.MemberIdreferencesGymClients.IdOrders.EmployeeIdreferencesEmployees.IdOrders.StripeTerminalReaderIdreferencesStripeTerminalReaders.IdGymStockMovements.OrderIdreferencesOrdersOrderLines.OrderIdreferencesOrders