Skip to content

SQL Views

When you need direct SQL access to the POS — usually because APRO is installed on-premise alongside existing systems — the cash register database exposes a stable set of read-only views. They are intentionally shaped for the two most common consumers:

  • On-premise integrations — accounting bridges, kitchen displays, stock management, loyalty engines — anything that runs inside the same network and wants a low-latency feed without going through REST.
  • Existing BI workflows — Power BI, Tableau, Qlik, Metabase, Excel, native SQL Server Analysis Services — any tool that already understands SQL Server connections. Point the connector at the views and you get receipts, line items, payments and product master in the shape a data warehouse expects.

Views are read-only, queryable over the standard SQL Server protocol, and never join to operational tables that mutate under load — they are safe to drive dashboards and scheduled ETL jobs against.

Overview

ViewWhat it contains
vw_ReceiptsOne row per business transaction.
vw_Receipt_ItemsLine items. Join on ReceiptId.
vw_PaymentsPayments. Join on ReceiptId.
vw_TransactionsLight transaction index.
vw_TransactionTypesTransaction-type lookup.
vw_Bi_ExportDenormalized receipt × item + payment summary — start here for Power BI.
vw_products_and_categoriesProduct master with category.

1. vw_Receipts

One row per business transaction. The TransactionType column distinguishes what the row represents; amounts are signed — reversal transactions (TransactionType = 4) return the booking with a negated amount so a plain SUM(TotalAmount) already nets them out.

ColumnTypeDescription
IdGUIDUnique transaction record ID.
TransactionIdGUIDTransaction ID (join key for vw_Receipt_Items, vw_Payments).
TransactionTypeenumSee Transaction types.
TransactionTypeNamestringHuman-readable transaction type.
ReceiptNrstringReceipt / invoice number.
TotalAmountdecimalGross total (signed — negative on reversals).
TipAmountdecimalTip (signed).
ReceiptDiscountAmountdecimalDiscount applied to the whole receipt (signed).
BookDatedatetimeBooking timestamp.
BusinessDaydateVirtual fiscal business day.
ParentIdGUID | nullPredecessor receipt (e.g. retrieved settlement → original).
PaymentGroupIdinteger | nullPayment group ID (e.g. Umsatzwirksam).
PaymentGroupNamestring | nullPayment group name — useful as a turnover filter.
BusinessIdintegerOperating company ID.
BusinessNamestringOperating company name.
TableIdintegerTable ID.
TableNrintegerTable number.
TableNamestringTable label.
AreaIdintegerArea / section ID (Bereich).
AreaNrintegerArea number.
AreaNamestringArea name (e.g. Restaurant, Bar, Terrasse).
StaffIdintegerStaff ID.
StaffNrintegerPersonnel number.
StaffNamestringStaff name.
CustomerIdintegerCustomer ID.
CustomerNrintegerCustomer number.
CustomerNamestringCustomer name.
DeviceIdintegerDevice that performed the transaction.

Transaction types

Only transactions with a TransactionType in (1, 2, 3, 4, 5, 14, 24, 25) are exposed through this view. The authoritative mapping lives in vw_TransactionTypes and is also joined onto every row via TransactionTypeName.

TransactionTypeMeaning
1Booking — order at the table or self-service.
2Move — table change.
3Settlement — paid receipt.
4Reversal — undoes a booking (amounts negated).
5Retrieve receipt — undoes a settlement.
14Outgoing invoice created.
24Outgoing invoice — ancillary (see vw_TransactionTypes).
25Outgoing invoice paid.

2. vw_Receipt_Items

Line items. Join to vw_Receipts on ReceiptId / TransactionId. Values are signed the same way as the parent receipt.

ColumnTypeDescription
TransactionIdGUIDTransaction ID.
ReceiptIdGUIDReceipt ID (join to vw_Receipts.Id).
ReceiptItemIdGUIDUnique line item ID.
BookedItemIdGUIDUnderlying booking ID (shared by bookings and their reversals).
BookedItemDatedatetimeBooking timestamp.
ProductCategoryIdintegerCategory (Sparte) ID.
ProductCategoryNrintegerCategory number.
ProductCategoryNamestringCategory name.
ProductCategoryAccountingNrstringAccounting account number for the category.
ProductIdintegerProduct ID.
ProductNrintegerProduct number.
ProductNamestringProduct name.
QuantitydecimalQuantity (signed on reversals / retrievals).
OriginalPricedecimalUnit price at the time of sale (signed on reversals).
EffectivePricedecimalDiscounted unit price (signed on reversals).
OriginalAmountdecimalQuantity × OriginalPrice (signed).
EffectiveAmountdecimalQuantity × OriginalPrice × discount factor (signed).
DiscountAmountdecimalDiscount amount in money (signed on reversals / retrievals).
DiscountPercentagedecimalDiscount as % of the original price.
DiscountTypestringRABATT OFF for plain discounts, otherwise the campaign name (e.g. Happy Hour). Empty string if no discount.
TaxIdintegerTax rate ID.
TaxNamestringTax rate name.
TaxAmountdecimalTax rate as decimal.
TransactionTypeIdenumSame codes as vw_Receipts.TransactionType.

3. vw_Payments

Payments recorded against receipts. Only settlements and their reversals are exposed (TransactionType in (3, 4, 5, 14, 24, 25)).

ColumnTypeDescription
TransactionIdGUIDTransaction ID.
ReceiptIdGUIDReceipt ID.
PaymentIdGUIDUnique payment ID.
TotalAmountdecimalAmount paid (signed).
PaymentTypeIdintegerPayment method ID.
PaymentTypeNrintegerPayment method number.
PaymentTypeNamestringPayment method name (e.g. Bar, Kreditkarte, Gutschein).
DateTimedatetimePayment timestamp.
PredecessorReceiptIdGUID | nullWhen a settlement is retrieved, the original receipt it cancels.
Detailsstring | nullFree-form payment metadata (e.g. card masked PAN, voucher code).

4. vw_Transactions

Light index of every transaction. Useful for watermark-based ETL (pulling only new rows since the last checkpoint).

ColumnTypeDescription
TransactionIdGUIDTransaction ID.
TransactionTypeenumTransaction type.
TransactionTypeNamestringHuman-readable name.
BookDatedatetimeTimestamp of the transaction.
DeviceIdintegerDevice that performed it.

5. vw_TransactionTypes

Lookup for every transaction type the POS emits.

ColumnTypeDescription
IdintegerTransaction-type ID.
BezeichnungstringHuman-readable name (German).

6. vw_Bi_Export

The one-stop view for BI tools. Denormalized join of every turnover-relevant receipt with every line item, plus a comma-separated summary of the payment methods used on the receipt. Point Power BI or Tableau at this view and you have everything needed for revenue, margin, mix and payment-method dashboards without writing joins.

Columns are the union of vw_Receipts and vw_Receipt_Items (minus TransactionTypeId, which lives only on the receipt side), plus:

ColumnTypeDescription
PaymentsstringComma-separated list of PaymentTypeName values for the receipt (e.g. "Bar,Kreditkarte"). NULL on non-settlement rows.

Power BI example

  1. Get data → SQL Server database — server + database as provided.
  2. Import or DirectQuery mode, using the read-only user.
  3. Pick dbo.vw_Bi_Export as the fact table.
  4. Optionally add dbo.vw_Transactions, dbo.vw_Payments, dbo.vw_products_and_categories as companion tables and relate on TransactionId / ProductId.

Import mode is normally sufficient — the views are already aggregated to transaction grain and refresh in seconds for a typical venue.

7. vw_products_and_categories

Product master with category. Useful as a dimension alongside vw_Bi_Export when the BI tool wants product names to stay stable even if historical rows predate a rename.

ColumnTypeDescription
ProductIdintegerProduct ID.
ProductNrintegerProduct number.
ProductNamestringProduct name.
ProductCategoryIdintegerCategory ID.
ProductCategoryNrintegerCategory number.
ProductCategoryNamestringCategory name.
PricedecimalCurrent list price (Preis1).

Only products where Geloescht = 0 (not soft-deleted) are included.

Example queries

Turnover per business day, split by tax rate — for a monthly KPI chart:

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.TransactionType IN (3, 4, 5) -- settlements + reversals net out
AND r.BusinessDay BETWEEN @from AND @to
GROUP BY r.BusinessDay, ri.TaxName
ORDER BY r.BusinessDay, ri.TaxName;

Top-10 products for the current month, using the BI view directly:

SELECT TOP 10
ProductName,
SUM(Quantity) AS units_sold,
SUM(EffectiveAmount) AS net_turnover
FROM vw_Bi_Export
WHERE BusinessDay >= DATEFROMPARTS(YEAR(GETDATE()), MONTH(GETDATE()), 1)
AND TransactionType IN (3, 4, 5)
GROUP BY ProductName
ORDER BY net_turnover DESC;

Cash vs. card split for a single business day:

SELECT
PaymentTypeName,
SUM(TotalAmount) AS total
FROM vw_Payments
WHERE CAST(DateTime AS date) = @businessDay
GROUP BY PaymentTypeName;