Skip to content

SQL Views

For systems that consume APRO data at scale — BI tools, data warehouses, accounting exporters — the POS database exposes three read-only views that cover the core transactional footprint:

All three join via ReceiptId, so the full picture of a receipt is a three-table query.

1. vw_Receipts

One row per business transaction. The TransactionTypeId column distinguishes what the row represents.

ColumnTypeDescription
IdGUIDUnique transaction record ID.
TransactionIdGUIDUnique transaction ID.
TransactionTypeIdenumSee Transaction types.
DateTimedatetimeTime of the transaction.
ReceiptNrstringReceipt / invoice number.
TotalAmountdecimalReceipt total.
TipAmountdecimalTip (on settlements).
DiscountAmountdecimalTotal discount applied.
BusinessDaydateVirtual business day (fiscal).
BusinessIdintegerOperating company ID.
BusinessNamestringOperating company name.
TableIdintegerTable / spot ID.
TableNrintegerTable number.
TableNamestringTable name.
StaffIdintegerStaff ID.
StaffNrintegerPersonnel number.
StaffNamestringStaff name.
CustomerIdintegerCustomer ID.
CustomerNrintegerCustomer number.
CustomerNamestringCustomer name.
DeviceIdintegerDevice that performed the transaction.

Transaction types

TransactionTypeIdMeaning
1Booking (order at the table or self-service).
2Move (table change).
3Settlement (close with payment).
4Reversal (undo a booking).
5Retrieve receipt (undo a settlement).
14Outgoing invoice created.
25Outgoing invoice paid.

2. vw_Receipt_Items

Line items. Join to vw_Receipts on ReceiptId.

ColumnTypeDescription
ReceiptIdGUIDReceipt ID (join to vw_Receipts.Id).
TransactionIdGUIDTransaction ID.
ReceiptItemIdGUIDUnique line item ID.
ProductCategoryIdintegerCategory ID.
ProductCategoryNrintegerCategory number.
ProductCategoryNamestringCategory name.
ProductIdintegerProduct ID.
ProductNrintegerProduct number.
ProductNamestringProduct name.
QuantitydecimalQuantity sold.
OriginalPricedecimalOriginal unit price at the time of the sale.
EffectivePricedecimalEffective unit price after discounts.
OriginalAmountdecimalQuantity × original price.
EffectiveAmountdecimalQuantity × original price × discount factor.
DiscountAmountdecimalDiscount amount.
DiscountPercentagedecimalDiscount as a percentage of the original price.
TaxIdintegerTax rate ID.
TaxNamestringTax rate name.
TaxAmountdecimalTax rate as a decimal.

3. vw_Payments

Payments recorded against receipts. Join to vw_Receipts on ReceiptId.

ColumnTypeDescription
TransactionIdGUIDTransaction ID.
ReceiptIdGUIDReceipt ID.
PaymentIdGUIDUnique payment ID.
PredecessorReceiptIdGUIDPrior receipt this payment cancels / replaces (e.g. on a retrieved settlement).
DateTimedatetimeTime of the payment.
TotalAmountdecimalAmount paid.
PaymentTypeIdintegerPayment method ID.
PaymentTypeNrintegerPayment method number.
PaymentTypeNamestringPayment method name.

Example query

Turnover per business day, split by tax rate:

SELECT
r.BusinessDay,
ri.TaxName,
SUM(ri.EffectiveAmount) AS net_turnover
FROM vw_Receipts AS r
JOIN vw_Receipt_Items AS ri ON ri.ReceiptId = r.Id
WHERE r.TransactionTypeId = 3 -- settlements only
AND r.BusinessDay BETWEEN @from AND @to
GROUP BY r.BusinessDay, ri.TaxName
ORDER BY r.BusinessDay, ri.TaxName;