# B2B Pricing module (`role_pricing`)

Customer- and group-based B2B pricing: price lists, price rules, discount
classes and two customer-group registries.

The module id is a v0.1 holdover kept on purpose: WordPress roles are gone from
the model, but renaming it would touch every path and option key for no
user-visible change (plan D-13).

Spec (source of truth):
[`docs/specs/prc-customer-role-pricing/`](../../../../docs/specs/prc-customer-role-pricing/prc-customer-role-pricing.html) ·
Plan: [`docs/modules/role-pricing-implementation-plan.md`](../../../../docs/modules/role-pricing-implementation-plan.md) ·
Repo-side summary: [`docs/modules/role-pricing.md`](../../../../docs/modules/role-pricing.md) ·
**User guide:** [`docs/user-guide/index.html`](../../../../docs/user-guide/index.html)

The user guide documents this module as it shipped — every admin screen and every
REST route, with animated walkthroughs. Where it and the spec disagree, the guide
follows the code. Changing a label, a column or a route here means updating it
there too: `make check-user-guide` fails the build otherwise.

## What it does

A price list targets an audience — all customers, one customer, a **pricing
group** or a **line discount group** — and carries rules. A rule sets a unit
price, a line discount, or both, for a product, a variation, a **discount class**
or every product, optionally from a minimum quantity and within a date window.
For every shopper the engine resolves one discount first, then ranks every price
candidate at *that* discount and takes the lowest **net** amount. A matching rule
price applies even when the product's regular or sale price is lower — the
store's own prices are the fallback, never competitors (PRC-R-012).

The two customer-group registries are independent namespaces: `GOLD` in the
pricing registry and `GOLD` in the line-discount registry are two unrelated
groups, and a customer holds at most one from each. A pricing-group list defines
prices only, a line-discount-group list discounts only (PRC-R-029). Membership is
pricing data — it grants no WordPress role and no capability.

Two write channels share one validation path: wp-admin (screens under
**WooCommerce → Pricing**) and an integration pushing over the REST API with
WooCommerce keys. A list and a rule carry both stamps of PRC-R-019: `owner`, the
channel that created it, written once and immutable, and `updated_via`, the
channel that last wrote it. Only `owner` guards anything — a REST-API write or
delete against an admin-owned row is refused unless the request carries `force`,
and the response names what it refused.

## Admin surface

| Screen | Where |
| --- | --- |
| Price lists + list editor | WooCommerce → Pricing → Price lists |
| Generate rules in bulk | WooCommerce → Pricing → Price lists → a list → Generate rules |
| Quick Edit + bulk actions on rules | WooCommerce → Pricing → Price lists → a list → Rules |
| Bulk actions on lists | WooCommerce → Pricing → Price lists |
| Price preview (diagnostic) | WooCommerce → Pricing → Price preview |
| Discount classes registry | WooCommerce → Pricing → Discount classes |
| Pricing groups registry | WooCommerce → Pricing → Pricing groups |
| Line discount groups registry | WooCommerce → Pricing → Line discount groups |
| One group membership per registry | user profile → Pricing |
| Discount class | product edit → General, Quick Edit, Bulk Edit, Products filter |
| B2B Pricing panel (read-only) | product edit → Product data → B2B Pricing |
| Group columns + filters | Users list |
| Eight settings | WooCommerce → Settings → Pricing |

Screens render server-side and every **pricing** write — lists, rules, classes,
groups — goes through the module's REST API, so there is one validation path and
one cache invalidation. Adding a second write path for pricing data is the
regression the spec's §6.6.8 warns about.

The **Generate rules** dialog on the list editor is a second stated exception
(spec §5.4). Its selection, expansion and skip-on-conflict orchestration runs
server-side — it is the module's only admin form that posts to `admin-post.php`
rather than calling the API from the browser — but it is not a second write path:
a run composes one `POST …/rules/batch` against the module's own API
(`Authoring\RuleWriter`), so its rules are validated, channel-stamped and cache-
invalidated exactly like hand-typed ones. There is deliberately no REST
counterpart: the API's write vocabulary for rules stays upsert and replace
(PRC-R-026).

Two fields are the sanctioned exception (D30), because they live on WooCommerce's
own screens and must keep working with the module's master switch off: the
product editor's **Discount class** (`Classes\ClassAssignment`) and the profile's
two **membership** dropdowns (`Groups\ProfileSection`). Both write directly, but
through the same registry lookup, the same cache bump and the same `Groups\Membership`
service the REST path uses — which is what keeps them from being a second
validation path. The profile section saves on `profile_update`, because a
WordPress profile form cannot post anywhere else, and carries its own nonce,
capability check and webhook fire. Anything added to either needs the same
treatment.

WooCommerce's own REST endpoints carry the same two kinds of meta (PRC-R-042), and
are hooked rather than duplicated: `Rest\WcCustomersMeta` checks the
`_bccentralconnector_pricing_group` / `_bccentralconnector_line_discount_group` meta of a
`/wc/v3/customers` write through `Groups\Membership` before WooCommerce runs
(refusing a single write whole, and a batch item by item, put back in its own
position), writes it through the same service once the customer is saved, fires the
membership webhook by hand, and adds both keys back to the response's `meta_data`.
`Rest\WcProductsMeta` refuses a `/wc/v3/products` write naming an unknown
`_bccentralconnector_discount_class` through WooCommerce's per-item
`woocommerce_rest_pre_insert_product_object` filter. Both go off with the master
switch, as the module's own REST namespace does.

Three surfaces go *off* with the master switch rather than surviving it under the
D30 carve-out. Two are pure reads over data those screens write — the product
editor's read-only **B2B Pricing** panel (`Admin\ProductPricingPanel`, PRC-R-037)
and the Users list's **group columns and filters** (`Admin\UsersListColumns`,
PRC-R-039): the panel's every row links into a list editor the switch removes, and
the columns report on a module that is not running. The third, the role → default
groups mapping (`Groups\RoleDefaults`, PRC-R-036), is a *write*, and goes off for
the stronger reason that a switched-off module must not be writing membership meta
on user registration. Being a write, it announces itself too: like the profile
section it fires `bccentralconnector_customer_membership.updated` by hand, because the webhook
choke point sits on the REST API it never touches. The backfill announces one
event per page rather than one per customer.

`RoleDefaults` is blank-only in every direction — on user creation, on a role
assignment, and in the settings screen's one-time "Apply defaults to customers
without groups" backfill. There is deliberately no overwrite variant: blank-only is
what makes the defaults unable to fight an integration that has already priced a
customer, and a role change never revokes a membership. Roles here are a defaulting
*input*, not segmentation (D11).

## Permissions (PRC-R-017)

One capability, `manage_woocommerce`, governs every module surface — lists,
rules, discount classes, customer groups and memberships, on the admin and
machine channels alike. On the machine channel the check runs against the **key
owner's** user. A control a user lacks the capability for is absent, never
shown-but-disabled.

v0.1 had three tiers, the upper two guarding role mapping and role granting.
They went with the mechanism they defended: granting a segment used to grant a
WordPress role, a capability container, and group membership grants nothing.

## Storage

Five custom tables (prefix + `bccentralconnector_`), plus three meta-backed extras:

| Table | Holds |
| --- | --- |
| `bccentralconnector_price_lists` | Price lists (addressed by `id`) |
| `bccentralconnector_price_rules` | Price rules (upsert key: target + min quantity + start date, within the list) |
| `bccentralconnector_discount_classes` | Discount-class registry (id; unique `code`) |
| `bccentralconnector_pricing_groups` | Pricing-group registry (id; unique `code`) |
| `bccentralconnector_line_discount_groups` | Line-discount-group registry (id; unique `code`) |
| product meta `_bccentralconnector_discount_class` | A product's discount class |
| user meta `_bccentralconnector_pricing_group` | A customer's pricing group |
| user meta `_bccentralconnector_line_discount_group` | A customer's line discount group |

Custom tables rather than post meta because resolution has to be one indexed
query per asset and audience set, and integrators delta-read on `date_modified`.

The three registries are addressed by a numeric **`id`** and synced by a
**code** that follows the Business Central Code field (`Data\Code`): up to 20
characters, trimmed, any character but control characters, stored **in
capitals**, and never changed once created. Every column holding a code is
binary-collated, so case is folded (by normalizing) but accents are not —
`CACAK` and `ČAČAK` are two codes on any install. The class and membership
meta keys are normalized on write by `Support\CodeMeta` (a `sanitize_meta`
filter), so a CSV import or a plain `update_*_meta()` stores the same form.

The schema version lives in the `bccentralconnector_role_pricing_db_version` option and
drives upgrades; `Installer::maybe_install()` runs on `init`, on every request, and
`Install\Upgrades` carries the steps dbDelta cannot take (version 6: registry
ids and binary-collated codes). After a failed install the next try waits five
minutes (`Installer::RETRY_TRANSIENT`).

### Conventions

- Money is `decimal(19,4)`, percentages `decimal(7,4)`; both cross the API as
  strings and are normalized once on ingest with `wc_format_decimal()`.
  Candidates are compared at full precision and rounded only at the edge, when a
  price is handed to WooCommerce.
- Date windows are evaluated in the **store** timezone (`wp_date()`).
- `owner` and `updated_via` are set from the write channel, never from a payload;
  `owner` is written once and never rewritten.
- A price-list create accepts an `Idempotency-Key` header: replaying it returns
  the original response, including after the created list was deleted.
- A rules collection POST upserts on the natural key across amount spaces; a PUT
  is replace mode, and deletes what the payload omits except admin-owned rules.

## Performance

Resolution is one indexed query per asset and audience set, memoized per request
and keyed to a cache generation that every successful write bumps. **Per asset**,
not per page: a shop loop of *n* products costs *n* candidate queries, one each,
including for products no rule touches — repeated reads of the *same* product
(price, regular price, sale flag, price HTML) are what the memo makes free. A
store with no active rules pays a single "are there rules" probe per request and
nothing after it — its prices are stock WooCommerce. All three promises are
asserted as query counts in `tests/Integration/RolePricing/PerformanceTest.php`.

The generation counter is stored **autoloaded** (`Cache\CacheGeneration`). Every
request that prices anything reads it, and so does every request that does not —
the has-rules memo expires against it — so unautoloaded it costs a database query
per request where §5.3 budgets an object-cache read. `PerformanceTest` pins the
autoload flag itself, because the cost of losing it is invisible in every other
assertion.

The resolved-price memo is deliberately **per request**, not a persistent object
cache: a resolution also depends on the product's own regular and sale prices,
which a plain product edit changes without bumping the generation. See the note
on `Cache\ResolvedPriceCache`.

## Hooks exposed

Three filters are the module's entire public *extension* surface. Two are on the
resolution engine — `bccentralconnector_role_pricing_price` and
`bccentralconnector_pricing_audience_codes`; the third, `bccentralconnector_pricing_hidden_price_html`,
is the prompt catalog mode shows in place of a price, which PRC-R-035 requires
to be changeable. The price filter fires on the last amount the engine computes, after
price selection and discount application. The
audience filter fires on the shopper's `{pricing_group, line_discount_group}`
pair before candidates are queried, so a filter can move a shopper between
groups rather than trim the results afterwards. It was
`bccentralconnector_role_pricing_eligible_roles` in v0.1; that was its one and only rename.

Four actions exist as well, but only as the transport WooCommerce's webhook
system needs (a topic delivers on a WordPress action):
`bccentralconnector_role_pricing_{price_list,discount_class,customer_group,membership}_changed`.
Each fires once per successful write with a single argument — the topic payload,
`{ resource, updated_via, ids }` — so an integrator can drop the echo of its own push.
Subscribe through **WooCommerce → Settings → Advanced → Webhooks**, where they
appear as the `bccentralconnector_*.updated` topics; there is no per-rule topic, a rule write
reports its price list. See `Webhooks/Topics.php`.

## Tests

`tests/Unit/RolePricing/`, `tests/Integration/RolePricing/`,
`tests/e2e/role-pricing.spec.js`. The shared fixture base is
`tests/Integration/RolePricing/PricingTestCase.php` — build new integration tests
on it rather than adding factories.

### Acceptance-criteria map

Every criterion in the spec, and the test that carries it. Where a criterion has
a validation half and a resolution half, or an API half and a UI half, both are
listed; the criterion is only covered when both pass.

`make check-ac-map` resolves every reference below against the suite and CI runs
it, so a renamed test fails the build instead of leaving a row pointing at
nothing. A `...` continues the previous class, naming the tail of a sibling test.

**PRC-AC-037 – AC-043 are absent by design.** Spec v1.0 retires the order-total
discount feature (§12, D13) along with PRC-R-013 and PRC-UI-009/010, and the ids
are never reused — so the gap in the numbering below is deliberate, not a hole in
the coverage.

| AC | What it asserts | Test |
| --- | --- | --- |
| PRC-AC-001 | Activating a list turns its rules on; retiring it turns them off | `PriceListsApiTest::test_activation_turns_a_list_and_its_rules_on_and_deactivation_turns_them_off` · `ResolveApiTest::test_activating_a_list_makes_its_price_apply_and_deactivating_restores_the_regular_price` |
| PRC-AC-002 | A cheaper draft or inactive rule never wins | `PriceListsApiTest::test_a_draft_rule_is_never_activated_by_a_sibling_list` · `ResolveApiTest::test_activating_a_list_makes_its_price_apply_and_deactivating_restores_the_regular_price` |
| PRC-AC-003 | Same-key same-kind rules block activation regardless of amounts | `DuplicateCheckerTest::test_given_two_price_rules_on_one_key_with_different_amounts_then_activation_is_blocked` · `DuplicateCheckerTest::test_given_a_price_rule_and_a_discount_rule_on_one_key_then_they_compose` · `PriceListsApiTest::test_two_same_key_price_rules_with_different_amounts_block_activation` |
| PRC-AC-004 | Identical-amount duplicates also block; activation never deletes rows | `DuplicateCheckerTest::test_given_identical_rules_then_activation_is_blocked` · `PriceListsApiTest::test_identical_duplicate_rules_block_activation_and_nothing_is_deleted` |
| PRC-AC-005 | A same-key rule in another active list blocks; a different start date does not | `DuplicateCheckerTest::test_given_a_same_key_rule_in_another_active_list_then_activation_is_blocked` · `DuplicateCheckerTest::test_given_a_different_start_date_across_lists_then_it_is_a_different_key` · `DuplicateCheckerTest::test_given_the_same_start_date_but_a_different_end_date_then_they_still_collide` · `PriceListsApiTest::test_a_same_key_rule_in_another_active_list_blocks_activation` · `PriceListsApiTest::test_a_different_start_date_is_a_different_key_but_a_different_end_date_is_not` · `PriceListsApiTest::test_an_all_products_rule_in_another_active_list_blocks_activation` · e2e `a duplicate of a rule on another active list blocks activation and names it` |
| PRC-AC-006 | An inconsistent audience is rejected | `FieldRulesTest::test_given_an_all_customers_audience_with_a_value_then_it_is_rejected` · `PriceListsApiTest::test_an_inconsistent_audience_is_rejected_at_write` |
| PRC-AC-007 | With editing off, an active list is read-only except its status action | `PriceListsApiTest::test_the_admin_channel_cannot_edit_an_active_list_while_the_gate_is_closed` · `PriceListsScreenTest::test_active_row_offers_deactivate_not_delete` · e2e `an active list offers Deactivate but not Delete` |
| PRC-AC-008 | The draft round-trip stops a list's rules from applying | `ResolverTest::test_given_a_cheaper_draft_rule_then_it_is_reported_but_never_wins` · `ResolveApiTest::test_a_cheaper_draft_rule_never_wins_but_is_reported_on_request` |
| PRC-AC-009 | With editing on, a rule added to an active list is draft until verified | `PriceListsApiTest::test_with_editing_on_an_admin_rule_added_to_an_active_list_is_draft_until_verified` · `PriceListEditScreenTest::test_active_list_with_draft_rules_shows_verify_bar` |
| PRC-AC-010 | Deleting an active list is blocked until it is deactivated | `PriceListsApiTest::test_deleting_an_active_list_is_refused_until_it_is_deactivated` · e2e `an active list offers Deactivate but not Delete` |
| PRC-AC-011 | An incomplete rule cannot be saved | `RuleValidatorTest::test_given_a_price_rule_with_no_unit_price_then_it_is_rejected` (+ 3 siblings) · `RuleValidatorTest::test_given_a_zero_unit_price_then_it_is_accepted` (+ 3 zero siblings) · `PriceListsApiTest::test_an_incomplete_rule_is_never_stored` |
| PRC-AC-012 | An invalid type combination is impossible, in the form and at the API | `RuleValidatorTest::test_given_a_unit_price_on_a_discount_rule_then_it_is_rejected` (+ 2 siblings) · `PriceListsApiTest::test_a_mismatched_amount_is_rejected_naming_the_field` · e2e `the rule form makes an invalid type combination impossible` |
| PRC-AC-013 | An end date before a start date is a field error on header and rule alike | `FieldRulesTest::test_given_an_end_before_the_start_then_it_is_rejected` · `RuleValidatorTest::test_given_an_end_date_before_the_start_date_then_it_is_a_field_error` · `PriceListsApiTest::test_an_end_date_before_the_start_date_is_rejected_on_header_and_rule_alike` |
| PRC-AC-014 | A variation price supersedes a cheaper product-level price | `ResolverTest::test_given_a_variation_rule_then_it_beats_a_cheaper_product_rule` · `ResolveApiTest::test_a_variation_rule_beats_the_parent_products_cheaper_rule` |
| PRC-AC-015 | Every candidate is ranked at the one resolved discount, and the cheapest combination wins | `ResolverTest::test_every_price_candidate_is_ranked_at_the_one_resolved_discount` · `ResolverTest::test_a_bigger_resolved_discount_reranks_the_same_price_candidates` · `ResolverTest::test_a_candidate_that_disallows_line_discounts_is_ranked_at_its_plain_price` · `ResolveApiTest::test_every_candidate_is_reported_at_the_resolved_discount` |
| PRC-AC-016 | The highest discount wins among equally specific candidates | `ResolverTest::test_given_equally_specific_discounts_then_the_highest_percentage_wins` |
| PRC-AC-017 | The line-discount gate is the winning rule's flag; on the fallback the discount applies ungated | `ResolverTest::test_the_line_discount_gate` · `ResolverTest::test_a_withheld_discount_reports_why_and_names_no_winner` · `ResolverTest::test_on_the_fallback_the_discount_applies_to_an_active_sale_price` · `ResolveApiTest::test_a_resolved_discount_applies_once_to_the_sale_price_on_the_fallback` · `PriceDisplayTest::test_the_native_sale_fallback_keeps_native_sale_styling` |
| PRC-AC-018 | The two group registries resolve independently | `ResolverTest::test_the_two_registries_resolve_independently` · `ResolverTest::test_a_group_audience_is_excluded_when_the_shopper_is_in_the_other_registry` · `StorefrontTest::test_a_pricing_membership_never_grants_the_same_codes_line_discounts` · `DataTest::test_the_two_registries_have_distinct_tables_and_meta_keys` |
| PRC-AC-019 | Identical nets tie-break deterministically: lower list id, then lower rule id | `ResolverTest::test_given_identical_nets_then_the_earliest_rule_wins_whatever_its_flags` · `ResolverTest::test_the_tie_break_is_reported_identically_on_every_invocation` · `ResolverTest::test_a_lower_list_id_outranks_a_lower_rule_id` · `ResolverTest::test_equal_discounts_are_reported_as_a_tie_break_not_a_higher_discount` |
| PRC-AC-020 | A tier ladder wins tier by tier, in preview and through the blocks cart update; date bounds flip on the preview date | `ResolverTest::test_the_quantity_tier_ladder` · `ResolverTest::test_date_windows_are_inclusive` · `ResolveApiTest::test_a_quantity_tier_applies_at_its_minimum` · `CartOrdersTest::test_the_blocks_cart_update_prices_at_the_requested_quantity` |
| PRC-AC-021 | A matching rule price applies even when a native sale price is lower | `ResolverTest::test_a_matching_rule_price_applies_over_a_lower_native_sale` · `ResolverTest::test_a_shopper_matching_no_rule_gets_the_native_sale_price` · `PriceDisplayTest::test_a_rule_price_never_borrows_native_sale_styling` · `StorefrontTest::test_a_rule_price_applies_over_a_lower_native_sale` · `StorefrontTest::test_a_shopper_matching_no_rule_still_sees_the_native_sale` · `ResolveApiTest::test_a_rule_price_applies_over_a_lower_native_sale` · `ResolveApiTest::test_with_no_matching_rule_the_native_sale_price_is_the_fallback` · e2e `a group customer pays the contract price during a public sale` |
| PRC-AC-022 | A rule price renders without sale styling | `PriceDisplayTest::test_a_rule_price_renders_plainly_by_default` · `StorefrontTest::test_a_wholesale_rule_price_replaces_the_regular_price_plainly` |
| PRC-AC-023 | A rule change after checkout does not alter a placed order | `CartOrdersTest::test_a_placed_order_is_not_repriced_by_a_later_rule` |
| PRC-AC-024 | An admin-added line resolves at the order's customer and date, under any order storage | `CartOrdersTest::test_an_added_line_prices_at_the_orders_customer_and_date` · `..._under_hpos` |
| PRC-AC-025 | A refund derives from captured amounts and never re-runs resolution | `CartOrdersTest::test_a_refund_uses_captured_amounts_without_resolving` |
| PRC-AC-026 | With no customer, added lines resolve against all-customers only | `CartOrdersTest::test_an_added_line_with_no_customer_resolves_all_customers_only` |
| PRC-AC-055 | Zero is a valid amount: a 0.00 price rule is accepted, activates, and wins | `ResolverTest::test_a_zero_price_rule_is_a_value_and_wins` · `ResolveApiTest::test_a_zero_price_rule_is_accepted_and_wins` |
| PRC-AC-056 | An all-products discount applies only where no product- or class-level discount exists | `ResolverTest::test_an_all_products_discount_applies_only_where_no_nearer_level_exists` |
| PRC-AC-057 | The all-products level is evaluated per audience, not globally | `ResolverTest::test_the_all_products_level_is_evaluated_per_audience` |
| PRC-AC-060 | Exported orders carry captured prices as authoritative data | `CartOrdersTest::test_an_exported_order_carries_its_captured_prices` |
| PRC-AC-068 | A zero-percent discount never displaces a positive discount, at any specificity | `ResolverTest::test_a_zero_percent_variation_discount_displaces_nothing` · `ResolverTest::test_a_zero_percent_discount_stands_with_no_positive_competitor` |
| PRC-AC-072 | Level occupancy is existence-based, per audience — a 0% rule shadows its own audience's lower level only | `ResolverTest::test_a_zero_percent_rule_occupies_its_own_audiences_level` · `ResolverTest::test_one_audiences_occupied_level_does_not_shadow_another_audiences` · `ResolverTest::test_level_occupancy_ignores_the_minimum_quantity` · `ResolverTest::test_a_draft_rule_never_occupies_a_level` |
| PRC-AC-027 | Create a class, assign a product, and discount it with a class rule | `DiscountClassesApiTest::test_a_post_stores_the_code_in_capitals` · `DiscountClassesApiTest::test_a_differently_cased_code_is_the_same_class` · `SchemaTest::test_discount_class_crud_round_trips_case_insensitively` · `ClassAssignmentTest::test_the_general_panel_assigns_a_class_and_bumps_the_cache` |
| PRC-AC-028 | A class or all-products rule defining a price is rejected | `RuleValidatorTest::test_given_a_price_on_a_class_rule_then_it_is_rejected` · `RuleValidatorTest::test_an_all_products_rule_is_discount_only_and_addresses_nothing` · `DiscountClassesApiTest::test_a_class_rule_defining_a_price_is_rejected` · `DiscountClassesApiTest::test_an_all_products_rule_defining_a_price_is_rejected` |
| PRC-AC-029 | Bulk-assign a discount class from the Products list | `ClassAssignmentTest::test_bulk_edit_assigns_a_class_and_persists` · `..._the_filter_narrows_the_products_query` · e2e `bulk-assigns two products to a discount class` |
| PRC-AC-030 | A rule-referenced class is undeletable; a products-only one is not | `DiscountClassesApiTest::test_a_class_referenced_by_a_rule_cannot_be_deleted` · `..._a_class_used_only_by_products_is_deletable` |
| PRC-AC-031 | A list at a nonexistent group is rejected, succeeds once it exists; the registry constrains amounts | `CustomerGroupsApiTest::test_a_list_at_a_nonexistent_group_is_rejected_then_succeeds` · `CustomerGroupsApiTest::test_the_audience_registry_constrains_what_the_list_defines` · `RuleValidatorTest::test_the_audience_registry_constrains_the_amount_space` |
| PRC-AC-032 | The profile Pricing section assigns one group per registry, under the management capability | `ProfileSectionTest::test_each_dropdown_offers_only_its_own_registrys_groups` · `ProfileSectionTest::test_saving_the_form_sets_both_memberships_and_bumps_the_cache` · `ProfileSectionTest::test_a_user_without_the_capability_sees_no_section` |
| PRC-AC-033 | Profile saves and primary-role changes never disturb memberships | `ProfileSectionTest::test_a_membership_survives_a_primary_role_change` |
| PRC-AC-034 | A membership write is rejected across registries and accepted within one | `MembershipApiTest::test_a_wrong_registry_code_is_rejected_and_changes_nothing` · `MembershipTest::test_a_wrong_registry_code_is_rejected_and_names_where_it_belongs` · `ProfileSectionTest::test_a_wrong_registry_code_is_refused_with_a_visible_error` |
| PRC-AC-035 | Candidates span everyone, own, and group audiences only | `ResolveApiTest::test_a_customers_candidates_span_everyone_their_own_and_their_roles_only` |
| PRC-AC-036 | One management capability governs every module surface | `CapabilitiesTest::test_one_capability_governs_every_surface` · `CustomerGroupsApiTest::test_a_caller_without_the_capability_is_refused` · `MembershipApiTest::test_a_caller_without_the_capability_is_refused` · `ProfileSectionTest::test_a_user_without_the_capability_sees_no_section` |
| PRC-AC-044 | A machine sweep cannot touch a store-owned list without force | `PriceListsApiTest::test_a_full_sweep_cannot_touch_a_store_owned_list` · `OwnershipTest::test_the_guard_refuses_only_a_machine_write_against_an_admin_owned_row` · `OwnershipTest::test_a_refusal_names_the_row_and_its_owner` |
| PRC-AC-045 | Updated-via flips on an admin edit, owner never does; the next push overwrites and reports | `PriceListsApiTest::test_a_push_over_an_admin_edit_wins_and_says_so` · `PriceListsScreenTest::test_the_owner_and_updated_via_badges_read_independently` · `SchemaTest::test_price_list_crud_round_trips` |
| PRC-AC-046 | Replace mode deletes what the payload omits, retaining store-owned rules unless forced | `PriceListsApiTest::test_replace_mode_deletes_what_the_payload_omits_but_keeps_store_owned_rules` |
| PRC-AC-047 | Duplicate produces an isolated store-owned draft | `PriceListsApiTest::test_duplicate_produces_an_isolated_store_owned_draft` |
| PRC-AC-048 | Machine-readable product reads return stored prices | `ResolutionScopeTest::test_the_general_product_rest_api_is_out_of_scope` · `StorefrontTest::test_a_general_catalog_rest_read_returns_the_stored_price` |
| PRC-AC-049 | A pushed change is visible next load with no manual flush | `StorefrontTest::test_a_pushed_price_change_is_visible_after_the_generation_bump` |
| PRC-AC-050 | Shoppers with different group memberships never share cached variation prices | `VariationPricesTest::test_a_guest_and_a_group_member_never_share_a_bucket` · `VariationPricesTest::test_the_two_registries_salt_independently` · `StorefrontTest::test_groups_never_share_cached_variation_prices_in_either_order` |
| PRC-AC-051 | Writes need write credentials; rule errors are machine-readable | `RestFoundationTest::test_a_reader_may_read_but_not_write` · `CapabilitiesTest::test_a_refused_check_returns_the_module_error` · `PriceListsApiTest::test_a_mismatched_amount_is_rejected_naming_the_field` |
| PRC-AC-054 | A list's audience is frozen once it has rules, on both channels | `PriceListsApiTest::test_a_lists_audience_is_frozen_once_it_has_rules_on_both_channels` |
| PRC-AC-052 | The master switch restores stock pricing without data loss | `SettingsLifecycleTest::test_master_switch_off_restores_stock_pricing_and_unregisters_routes` · `SettingsLifecycleTest::test_the_sanctioned_non_rest_fields_keep_writing_while_the_module_is_off` · `WebhookTopicsTest::test_nothing_fires_while_the_module_is_switched_off` |
| PRC-AC-053 | Customer-group deletion integrity: referenced groups refuse, member-only groups dangle | `CustomerGroupsApiTest::test_a_group_targeted_by_a_list_cannot_be_deleted` · `CustomerGroupsApiTest::test_a_group_held_only_as_memberships_is_deletable` · `CustomerGroupsApiTest::test_a_list_in_the_other_registry_never_blocks_a_delete` |
| PRC-AC-059 | A replayed create with the same idempotency key never duplicates a list | `PriceListsApiTest::test_a_replayed_create_with_the_same_idempotency_key_never_duplicates_a_list` · `IdempotencyStoreTest::test_the_same_key_and_payload_replays_the_stored_response` · `IdempotencyStoreTest::test_the_same_key_with_a_different_payload_is_rejected` · `IdempotencyStoreTest::test_a_key_is_scoped_to_its_owner` |
| PRC-AC-076 | A machine write into an active list lands active or is rejected — never a silent draft | `PriceListsApiTest::test_a_machine_write_into_an_active_list_lands_active_or_is_rejected` · `PriceListsApiTest::test_a_machine_write_duplicating_another_active_lists_rule_is_rejected` · `PriceListsApiTest::test_a_machine_write_is_not_rejected_for_a_collision_it_did_not_cause` |
| PRC-AC-077 | Amount-space upsert matching: widen, narrow, and refuse ambiguity | `PriceListsApiTest::test_amount_space_upsert_matching_widens_narrows_and_refuses_ambiguity` · `SchemaTest::test_the_natural_key_ignores_amount_space_and_finds_every_match` · `DataTest::test_a_rules_natural_key_is_its_target_quantity_and_start_date` |
| PRC-AC-078 | Registry codes follow the Business Central Code field | `CodeTest::test_given_a_padded_mixed_case_code_when_normalized_then_it_is_trimmed_and_upper_cased` · `CustomerGroupsApiTest::test_given_accented_and_plain_codes_when_posted_then_they_are_two_groups` · `CustomerGroupsApiTest::test_given_an_invalid_code_when_posted_then_it_is_refused` · `DiscountClassesApiTest::test_a_code_with_a_space_is_accepted` · `SchemaTest::test_codes_differing_only_by_accents_are_two_rows_and_two_matches` · `ClassAssignmentTest::test_given_accented_codes_when_counting_products_then_each_class_counts_only_its_own` · `AdminAidsTest::test_given_accented_group_codes_when_filtering_users_then_each_code_lists_only_its_members` · `StorefrontTest::test_given_class_meta_in_any_casing_when_priced_then_the_class_discount_applies` · `StorefrontTest::test_given_a_membership_written_in_lower_case_when_priced_then_the_group_price_applies` |
| PRC-AC-079 | Registry rows are addressed by id, found by code, and keep their code | `CustomerGroupsApiTest::test_given_an_all_digit_code_when_addressed_then_the_url_takes_the_id_and_the_code_is_a_filter` · `CustomerGroupsApiTest::test_given_an_existing_code_when_posted_then_that_group_is_updated` · `CustomerGroupsApiTest::test_given_a_new_code_when_put_by_id_then_it_is_refused_and_the_same_code_is_not` · `CustomerGroupsApiTest::test_given_a_batch_when_run_then_updates_and_deletes_address_rows_by_id` · `DiscountClassesApiTest::test_a_class_is_read_updated_and_found_by_id_and_code` · `UpgradesTest::test_given_a_version_5_store_when_upgraded_then_codes_are_capitalized_everywhere_and_rows_get_ids` |
| PRC-AC-080 | A customer's groups ride WooCommerce's customer API | `WcCustomersMetaTest::test_given_group_meta_when_a_customer_is_created_then_the_memberships_are_saved_and_returned` · `WcCustomersMetaTest::test_given_one_key_when_a_customer_is_updated_then_the_other_registry_is_untouched_and_empty_clears` · `WcCustomersMetaTest::test_given_an_unknown_code_when_a_customer_is_created_then_nothing_is_saved` · `WcCustomersMetaTest::test_given_a_wrong_registry_code_when_a_customer_is_updated_then_nothing_is_saved` · `WcCustomersMetaTest::test_given_a_batch_with_bad_items_when_run_then_only_those_are_refused_in_place` · `WcCustomersMetaTest::test_given_a_woocommerce_that_keeps_protected_meta_when_groups_change_then_prices_and_webhook_follow` · `WcCustomersMetaTest::test_given_an_older_route_version_when_a_bad_code_is_sent_then_it_is_refused_too` |
| PRC-AC-081 | A product's class on WooCommerce's product API is checked | `WcProductsMetaTest::test_given_an_unknown_class_when_a_product_is_created_then_it_is_refused_and_not_saved` · `WcProductsMetaTest::test_given_a_known_class_in_any_casing_when_a_product_is_created_then_it_is_stored_canonical` · `WcProductsMetaTest::test_given_an_empty_class_when_a_product_is_updated_then_the_class_is_cleared` · `WcProductsMetaTest::test_given_a_batch_with_an_unknown_class_when_run_then_only_that_product_is_refused` |
| PRC-AC-058 | Membership writes are per registry: named set, absent untouched, empty clears | `MembershipTest::test_a_named_registry_is_set_and_an_absent_one_is_untouched` · `MembershipTest::test_an_explicit_empty_value_clears_only_that_registry` · `MembershipApiTest::test_a_named_registry_is_set_and_an_absent_one_is_untouched` · `MembershipApiTest::test_an_explicit_empty_value_clears_only_that_registry` |
| PRC-AC-061 | Generate rules by category with a price factor: drafts land rounded, defaults inherited, counts reported | `RuleGeneratorTest::test_generating_by_category_lands_rounded_drafts_that_inherit_the_header` · `RuleGeneratorTest::test_a_category_of_mixed_products_generates_expands_skips_and_re_runs_to_nothing` · `RuleGeneratorTest::test_the_ninety_nine_ending_is_applied_at_generation` · `RuleGeneratorTest::test_a_variable_product_expands_into_its_variations_and_is_never_a_skip` · `RuleGeneratorTest::test_a_category_selects_published_products_only` · `RoundingTest::test_a_factor_rounds_to_the_stores_price_decimals` · `RoundingTest::test_the_ninety_nine_ending_never_rounds_a_price_up` · e2e `generating from a category reports its counts and re-runs to nothing` |
| PRC-AC-062 | The generator skips duplicates on the effective key and priceless products, reporting both | `RuleGeneratorTest::test_the_generator_skips_duplicates_and_priceless_products_naming_both` · `RuleGeneratorTest::test_a_duplicate_skip_names_the_rule_in_its_own_amount_space` · e2e `generating from a category reports its counts and re-runs to nothing` |
| PRC-AC-063 | The generator obeys the list's amount space and the per-run cap | `RuleGeneratorTest::test_a_discount_only_list_offers_no_price_mode` · `RuleGeneratorTest::test_the_per_run_cap_generates_the_first_hundred_and_the_re_run_finishes` · `RuleGeneratorTest::test_in_discount_mode_a_variable_product_yields_one_product_level_rule` |
| PRC-AC-066 | Copying rules applies the factor to prices only and re-inherits the destination's defaults | `RuleGeneratorTest::test_copying_applies_the_factor_to_prices_only_and_re_inherits_the_destination` · `RuleGeneratorTest::test_a_copy_narrows_by_kind_and_by_named_products_or_classes` |
| PRC-AC-067 | Copying obeys the destination's amount space and skips duplicates, reporting per row | `RuleGeneratorTest::test_copying_obeys_the_destinations_amount_space_and_skips_duplicates` |
| PRC-AC-069 | Hiding prices from visitors covers every guest surface and reverts with the master switch | `StorefrontDisplayTest::test_hiding_prices_covers_every_guest_surface` · `StorefrontDisplayTest::test_hiding_prices_blanks_the_store_apis_price_fields_for_a_visitor` · `StorefrontDisplayTest::test_a_guest_cart_built_before_the_switch_empties_on_load` · `StorefrontDisplayTest::test_prices_and_purchasability_return_on_login_and_with_the_module_off` · e2e `a visitor sees the log-in prompt and cannot buy` · e2e `a guest cart built before the switch empties on load` |
| PRC-AC-070 | The quantity-pricing table shows the shopper's own tiers, per variation, on by default, and only while switched on | `StorefrontDisplayTest::test_the_quantity_table_shows_each_shoppers_own_tiers` · `StorefrontDisplayTest::test_the_quantity_table_stays_away_for_one_tier_and_when_switched_off` · `StorefrontDisplayTest::test_given_a_store_that_never_saved_the_setting_when_a_tiered_product_is_viewed_then_the_table_shows` · `StorefrontDisplayTest::test_the_quantity_table_is_per_variation` · `StorefrontDisplayTest::test_the_quantity_table_is_hidden_while_catalog_mode_is_on` |
| PRC-AC-071 | The "Regular price with savings" mode strikes through the regular price without ever flagging a sale | `PriceDisplayTest::test_savings_mode_keeps_the_regular_price_without_flagging_a_sale` · `PriceDisplayTest::test_savings_mode_falls_back_to_plain_when_the_rule_price_does_not_undercut` · `PriceDisplayTest::test_the_savings_percentage_is_measured_off_the_regular_price` · `StorefrontDisplayTest::test_the_savings_mode_strikes_through_without_ever_flagging_a_sale` · `StorefrontDisplayTest::test_changing_the_display_setting_is_live_on_the_next_load` · `StorefrontDisplayTest::test_the_savings_note_names_the_best_variation_saving` · `StorefrontDisplayTest::test_the_savings_note_claims_nothing_this_module_did_not_do` |
| PRC-AC-064 | Quick Edit edits scalar amounts inline, validates like the full form, flips an active rule to draft | `QuickBulkEditTest::test_a_quick_edit_of_a_price_flips_an_active_rule_to_draft` · `QuickBulkEditTest::test_a_quick_edit_runs_the_same_validation_as_the_full_form` · `QuickBulkEditTest::test_a_quick_edit_is_refused_on_an_active_list_with_editing_off` · `PriceListEditScreenTest::test_an_editable_grid_offers_quick_edit_and_bulk_actions` · `PriceListEditScreenTest::test_a_gated_active_grid_omits_quick_edit_and_bulk_actions` · e2e `a quick-edited price on an active list drops that rule to draft` |
| PRC-AC-065 | Bulk actions accept or reject per item with a summary; bulk activation sees earlier activations | `QuickBulkEditTest::test_bulk_activation_sees_the_lists_activated_earlier_in_the_run` · `QuickBulkEditTest::test_bulk_delete_skips_an_active_list_and_reports_it` · `QuickBulkEditTest::test_a_bulk_rule_action_degrades_per_rule` · `QuickBulkEditTest::test_bulk_activating_rules_runs_the_review_and_activate` · `QuickBulkEditTest::test_bulk_activating_rules_activates_only_the_selection` · `QuickBulkEditTest::test_a_rule_cannot_be_activated_under_a_list_that_is_not` · `PriceListEditScreenTest::test_an_active_grid_offers_bulk_activate` · `PriceListsScreenTest::test_the_table_offers_row_selection_and_bulk_actions` |
| PRC-AC-073 | The B2B Pricing panel lists every active rule that prices the product, read-only | `AdminAidsTest::test_the_panel_lists_every_active_rule_that_prices_the_product` · `AdminAidsTest::test_the_panel_of_an_untargeted_product_says_so_and_still_links_to_preview` · `AdminAidsTest::test_the_panel_goes_with_the_pricing_screens_when_the_module_is_off` · e2e `the product panel lists the class rule and the preview link pre-fills` |
| PRC-AC-074 | Role defaults fill blank memberships once and never overwrite anything | `RoleDefaultsTest::test_a_user_with_no_memberships_gets_both_defaults` · `RoleDefaultsTest::test_a_membership_already_held_is_never_overwritten` · `RoleDefaultsTest::test_only_the_blank_half_of_a_membership_pair_is_filled` · `RoleDefaultsTest::test_an_unmapped_role_fills_nothing` · `RoleDefaultsTest::test_the_first_mapped_role_wins_and_the_second_fills_what_is_left` · `RoleDefaultsTest::test_a_mapping_naming_a_deleted_group_leaves_the_membership_blank` · `RoleDefaultsTest::test_editing_the_mapping_is_wired_to_nothing` · `AdminAidsTest::test_role_defaults_fill_blank_memberships_once_and_never_overwrite` · `AdminAidsTest::test_the_backfill_fills_only_empty_memberships_and_reports_its_count` · `AdminAidsTest::test_the_settings_field_stores_a_valid_mapping_and_runs_the_backfill` |
| PRC-AC-075 | The Users list shows and filters by group memberships | `AdminAidsTest::test_the_users_list_shows_and_filters_by_group_memberships` |

Webhook topics (PRC-OQ-003) carry no acceptance criterion; their brief is covered
by `WebhooksTest`, `WebhookTopicsTest` and
`AdminAidsTest::test_a_role_default_fill_announces_the_membership_change`.
