🍗 PCK ZRA Middleware Wiki

Audit Logging

Fiscal compliance demands that every invoice can be traced end to end. The middleware logs everything: inbound requests, outbound calls, data conversions and issued invoices — all tied together by a single transaction ID.

The transaction ID

Every inbound HTTP request is assigned a UUID transaction ID by the RequestResponseLoggingFilter, before authentication. That ID is attached to:

  1. The inbound request log entry
  2. The store tagging (once SellerName resolves to a store)
  3. The conversion log entries
  4. The outbound Chrilan request/response entries
  5. The final response log entry

One ID, complete story. When a store disputes a receipt, this is the key that reassembles the event.

What is stored, where

api_transactions

Full HTTP-level audit for every request and response, inbound and outbound:

Column groupContents
Identitytransaction_id (UUID), store_id
Routesource API, target API, endpoint, HTTP method
Payloadsrequest headers + body, response headers + body (LONGTEXT)
OutcomeHTTP status code, success flag, error message
Timingresponse time in milliseconds, created timestamp

conversion_logs

Data-transformation audit trail for every Taxint ↔ Chrilan conversion:

Column groupContents
Identitytransaction_id, store_id, conversion type
Formatssource format, target format, full source and target data
Rulesmapping rules applied
Outcomevalidation errors, success flag, processing time

fiscal_invoices

Every issued invoice, kept for refund lookups and audit:

Column groupContents
Identifiersaudit_number, receipt_number (ZRA rcptNo), sdc_id
Attributionstore_id, tpin, currency
Refundsis_refund flag, original_receipt_number linkage
Buyer addressbuyer_house_no, buyer_street, buyer_province (for POS check printing)

Logging configuration

PropertyDefaultControls
middleware.request-logging.enabledtrueInbound request capture
middleware.response-logging.enabledtrueResponse capture
middleware.transaction-logging.enabledtrueapi_transactions writes
middleware.conversion-logging.enabledtrueconversion_logs writes

Application logs use SLF4J/Logback with the pattern %d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n. Code standards prohibit System.out and printStackTrace() — all logging goes through the logger, and all API transactions go through LoggingService.

Retention

Infinite retention by design All transaction logs, conversion logs and fiscal invoices are kept forever. There is no automatic cleanup. The CleanupOldTransactions stored procedure exists for deliberate, manual purges only (e.g. after a data-retention decision by management).

Querying the audit trail directly

The portal's Reports screens cover daily needs. For deeper analysis, two database views and three stored procedures are provided — see Database schema:

What gets logged for a single invoice

1. api_transactions  ← POS request (headers + full Taxint body)
2. (store tagged: transaction updated with store_id)
3. conversion_logs   ← Taxint → Chrilan mapping (source, target, rules)
4. api_transactions  ← Chrilan request + response (full bodies, timing)
5. fiscal_invoices   ← receipt_number, sdc_id, audit_number persisted
6. conversion_logs   ← Chrilan → Taxint response mapping
7. api_transactions  ← response returned to POS