Skip to main content

Place ticket list (ticketService)

The ticketService is the sole source of place ticket history for reports and accounts (RN-TLC-18). It is the single gateway for historical ticket rows via GET place/ticketlst. Features must not call adhoc.DoRequest('place/ticketlst', …) directly.

Implementation: libs/upp-data/src/modules/tickets.ts
Contract: libs/upp-data/src/frontlib/tickets.mdc
Backend: server/src/App/Services/place/Ticketlst.php

Purpose

Problem (before)Solution
Income report and pay-account each cached ticketlst separatelyOne RAM cache per active place in ticketService
Repeated full-place fetches per accountShared cache + incremental sync on cache hit
Live TPV tickets missing from API list_MergeLiveTickets from PlaceView.tickets before hit/miss

Public API

SymbolRole
ticketService.Query(place, ini, end, mode?)Rows for period; mode 'CREATED' (default) or 'UPDATED'. Throws when offline — callers must guard with view.IsOnline.
TicketInfoLightweight row DTO (objid, created, updated, status, payment, price, account, invceac, …)
TICKET_LIST_CACHE_MAX10000 — max rows per place in RAM

There is no public Sync or Invalidate. Incremental sync runs inside Query on cache hit (RN-TLC-13).

Hit vs miss

PathHTTPResponse source
Miss (RN-TLC-01)One place/ticketlst with timestamp: 0 for the full requested periodMerged cache after API + live tickets. Miss when cache is empty or dateini is before the oldest row still stored (evicted history is not covered).
Hit (RN-TLC-03)Optional incremental with stored watermarkRAM only (live merge applied first)

Mixing partial API responses with historical cache rows to fill period gaps in a single Query is forbidden (RN-TLC-04). Live TPV tickets are not an exception — they are merged before the hit/miss decision (RN-TLC-11).

Limits

LimitValueRule
RAM per place10 000 rowsRN-TLC-05 — session cache evicts stalest by updated; current Query response is not truncated
Scope per Query~1 year (product)RN-TLC-06not enforced in ticketService. Reports: max step YEAR in upp-report-period, history up to 4 years back by changing period and reloading. Accounts: last natural year via accountService (rolling window). Wider history = several Query calls, not one request.
Places in RAM1 activeRN-TLC-10 — new place.objid discards previous cache
In-flight sync dedupplace.objid + calendar-day periodRN-TLC-16dateini start of day, dateend start of next day; response filter uses caller bounds

HTTP fetch and response mode

HTTP query params: place, dateini, dateend, timestamp (epoch seconds). There is no updated request flag; the server matches rows whose created OR updated falls within the requested period (incremental uses the same OR rule from max(timestamp, dateini)).

ConsumerQuery modeResponse filter (client)
Income report (upp-report-income)CREATEDRows with created in period
Pay account (accountService)UPDATEDRows with updated in period, then row.account === account.objid
Future monthly / clients reportsCREATEDReport-specific

mode only selects which timestamp column filters the client response from RAM; HTTP contract is shared.

Materialization to TicketView (volatile ObjectFactory + data.alives.get) is accountService responsibility for accounts; income maps to IncomeTicket locally.

Consumers (v4)

ModuleUsage
libs/feature/reports/.../upp-report-income.tsticketService.Query(..., 'CREATED')
libs/feature/account/src/modules/account.tsticketService.Query(..., 'UPDATED') → filter by account + materialize
upp-account-thumb / upp-account-edit / upp-account-viewAccountInfo.Tickets / Pending / Settled via accountService.bind (no ticketService in components)

Architecture check: rg "DoRequest('place/ticketlst'" libs/feature must return 0 (REG-TLC-05).

Offline

Query throws when !view.IsOnline (RN-TLC-14). accountService.Tickets / Pending / Settled return [] without calling Query (RN-PAC-12, RV-PAC-04, CA-PAC-OFF-01). Account ticket lists require connectivity.

Tests

SpecCoverage
libs/upp-data/src/specs/tickets.spec.tsHit/miss, eviction, live merge, offline, place switch
libs/feature/account/src/specs/account-service.spec.tsPer-account materialization, grouping, dedup sync (UT-PAC-20, REG-TLC-03)
libs/feature/account/src/specs/account-service-group.spec.tsPending grouping rules (RN-PAC-05…08)
libs/feature/reports/src/specs/upp-report-income.spec.tsDelegates to ticketService.Query
libs/feature/account/src/specs/upp-account-thumb.spec.tsAccountInfo.Tickets / offline thumb

Backend (PHP)

TestRole
server/tests/Unit/place/TicketlstActionTest.phpSQL period uses TICKET.created OR TICKET.updated (replaces former integration case for updated=1 only)
  • Sync and CachesyncService / cacheService (persistent session data; not ticket list RAM)
  • Ticket System — ticket lifecycle, commit, print
  • Data servicedataService, storage, alives
  • Functional contracts: libs/upp-data/src/frontlib/tickets.mdc, libs/upp-data/src/modules/model/views/payaccount.mdc
  • Future consumers (monthly / clients reports): must use ticketService.Query only — no parallel DoRequest('place/ticketlst') in features