TariffPriceMatrixTrait
Contract of the tariff price list (region x gateway matrix), shared by the admin tariff forms of Bazaar, Comcat and Discussion.
The database holds exactly what the form shows:
- The currency axis of a cell is the currency of the gateway region relation, falling back
to the region currency; the front end takes the same axis
(PaymentFormPageTrait::prepareCurrency(),
PaymentForm\Traits\PriceTrait::resolveGateCurrency()). Only a row on the axis is reachable on the front end. - A filled price (also
0) is a price list row with the price, the region rate and the "active" flag from the form. - An empty price means the row does not exist (clearing a cell deletes the row). The front end shows an empty cell and an inactive row the same ("cannot be purchased"); a zero inactive row would only make the form (empty) and the database (0.000) differ.
- An empty price with "active" is rejected by the form; the front end would sell an active row without a price for 0.
- Rows off the axis (another currency for a region and gateway, typically after the gateway currency changed in a region) are shown in a read-only notice (the front end does not offer them) and saving leaves them unchanged.
The presenter provides $tariffRegions, $tariffGates, $tariffGateCurrencies and $editedTariff.
Table of Contents
Methods
- buildTariffOffAxisRows() : array<int, array{region: string, gate: string, currency: string, price: string, active: bool}>
- Returns the off-axis rows for the template (the notice in the price list), with region, gateway and currency as labels.
- isTariffPriceOffAxis() : bool
- Returns whether a price list row lies off the matrix axis (another currency, region or gateway outside the axes). The form does not edit such a row; saving carries it over unchanged ({@see \App\UI\Admin\System\Presenters\Traits\Forms\TariffFormTrait::tariffOffAxisPrices()} in the module form trait) and the template lists it in the notice.
- tariffAxisCurrencyId() : int|null
- Returns the currency of a region x gateway cell on the front end axis (gateway region relation, falling back to the region currency).
- tariffAxisKeys() : array<string, true>
- Returns the `region|gateway|currency` keys of all matrix cells the form edits.
- tariffQuickPriceFilled() : bool
- Returns whether a region has an express (quick) price filled. A row is created only when at least one field is filled or "active" is checked; an empty region means no row (the form shows empty, the database nothing).
Methods
buildTariffOffAxisRows()
Returns the off-axis rows for the template (the notice in the price list), with region, gateway and currency as labels.
private
buildTariffOffAxisRows(int $langId, array<int, array{regionId: int, gateId: int, currencyId: int, price: string, active: bool}> $offAxis) : array<int, array{region: string, gate: string, currency: string, price: string, active: bool}>
Parameters
- $langId : int
- $offAxis : array<int, array{regionId: int, gateId: int, currencyId: int, price: string, active: bool}>
Return values
array<int, array{region: string, gate: string, currency: string, price: string, active: bool}>isTariffPriceOffAxis()
Returns whether a price list row lies off the matrix axis (another currency, region or gateway outside the axes). The form does not edit such a row; saving carries it over unchanged ({@see \App\UI\Admin\System\Presenters\Traits\Forms\TariffFormTrait::tariffOffAxisPrices()} in the module form trait) and the template lists it in the notice.
private
isTariffPriceOffAxis(int|null $regionId, int|null $gateId, int|null $currencyId) : bool
Parameters
- $regionId : int|null
- $gateId : int|null
- $currencyId : int|null
Return values
booltariffAxisCurrencyId()
Returns the currency of a region x gateway cell on the front end axis (gateway region relation, falling back to the region currency).
private
tariffAxisCurrencyId(int $gateId, int $regionId, int|null $regionCurrencyId) : int|null
Parameters
- $gateId : int
- $regionId : int
- $regionCurrencyId : int|null
Return values
int|nulltariffAxisKeys()
Returns the `region|gateway|currency` keys of all matrix cells the form edits.
private
tariffAxisKeys() : array<string, true>
Return values
array<string, true>tariffQuickPriceFilled()
Returns whether a region has an express (quick) price filled. A row is created only when at least one field is filled or "active" is checked; an empty region means no row (the form shows empty, the database nothing).
private
tariffQuickPriceFilled(ArrayHash<string|int, mixed> $values, int $regionId) : bool
Parameters
- $values : ArrayHash<string|int, mixed>
- $regionId : int