The engine has no word for what a booking consumes, so core picked one, and picked it inconsistently. Some strings say places, some say units, and neither is right for every resource: a hall sells places, a refuge sells nights or simply bookings, a bike hire sells bikes. Worse, a place is the name of a specific bookable thing that the dedicated yoyaku_placement module provides, so core naming its generic quantity that way borrows a word it does not own.

Today, counting only the quantity noun and not the verb or the placement seam:

  • src/Entity/Booking.php:73 describes quantity as the number of places this booking consumes.
  • src/Entity/BookingTariff.php:77 and src/Entity/BookingSlotTariff.php:69 describe a quota in places.
  • src/TransactionSummary.php:475 renders one place, or a count of places.
  • src/Plugin/ConstraintPolicy/TransactionQuantityLimit.php:73 says in places and not in bookings, while its own refusal says units.
  • src/Entity/BookingResource.php:97 says one booking per unit.

Proposed resolution

Make the unit a plugin type, and let a resource or a resource type name which one it sells.

  • A BookingUnit plugin, discovered by attribute as the other plugin types here are, owning its own singular and plural wording so that no call site writes a plural itself. That wording lives in the module providing the plugin and is translated through that module's .po file. A free text label on the resource could not do this: plural forms cannot be expressed in Config Translation, so a site typing its own noun would get 4 place where French wants 4 places.
  • Core ships the neutral default and nothing else. The place unit ships in yoyaku_placement, the module named after it, so the word leaves the engine entirely.
  • A custom module adds a unit by adding a plugin, with no engine change. That is the point: night, ticket, session, bike, whatever a site sells.
  • A booking_unit setting on the resource type, overridable on the resource, empty meaning inherit. This mirrors booking_mode, which already reads leave empty to inherit the resource type.
  • A call site holding a resource asks it for its unit. One that does not, such as a base field description on an entity that knows no resource, keeps the neutral wording.

A constraint policy already lets an operator word a refusal themselves through its message setting, so the unit gives those a better default rather than replacing that.

Remaining

Worth deciding here: whether the neutral default is called a unit, and whether a resource that runs in a venue should default to the place unit rather than having to be set to it, since the placement layer already knows.

Related: #3614828: Add a per-booker limit that sums units across everything it reaches uses the neutral wording in the strings it touches, so its per-booker limit is one of the call sites this converts.

Issue fork yoyaku-3614854

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

mably created an issue. See original summary.

mably’s picture

Status: Active » Needs review

  • mably committed 283da0e1 on 1.x
    feat: #3614854 Let a resource or resource type name the unit it sells,...
mably’s picture

Status: Needs review » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.