Some resources are mutually exclusive per customer: a customer may hold only one active booking across a whole group of them at once. The motivating case is mountain refuges, where a hiker can book one refuge among all available refuges, not several. The engine has no way to group resources today (the pricing category is a per-slot tier, not a resource grouping), so this cannot be expressed.
Proposed resolution
Introduce a resource type, and express the rule as another order constraint on top of the system added in #3609485. Mutual exclusion is a property of the set, not of each resource, so it belongs on the type.
- A yoyaku_resource_type config entity (id, label, and an exclusive_per_customer flag), with schema, mirroring the existing tenant config entity. It is the home for type-level policy and can carry more later.
- A type entity-reference field on BookingResource, with a getType() accessor.
- A single_active_per_type OrderConstraint plugin: self-gating, it only bites on lines whose resource belongs to a type flagged exclusive_per_customer, then counts the customer's active (held or confirmed) bookings across every resource of that type (by the order's email) and reports a violation once more than one exists. The type is the exclusivity pool.
Enforcement reuses the OrderConstraintManager from #3609485 (confirmOrder plus validateOrder), so no new trigger wiring is needed.
Tests
OrderConstraintTest gains coverage: an exclusive type refuses a second booking across two of its resources, a different email does not collide, and a non-exclusive type allows several.
Issue fork yoyaku-3609522
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
Comment #3
mably commentedOpened a merge request with the resource type config entity and its exclusive_per_customer flag, the type reference field on BookingResource, the single_active_per_type order constraint, and the added OrderConstraintTest coverage.
Comment #5
mably commented