Resolve a service's duration and price from the resource that performs it

The chain the spec asks for, plus the branch level that already has data:
resource+option, resource+service, branch override, then the item's own value.

Duration and price resolve independently. If they resolved together the first
override would silently swallow the other value — a resource that only differs
in how long it takes would also drop the branch's tariff.

Each resolved value carries where it came from. Without that, the panel cannot
label a number "from the branch" or "service default", and "why this number?"
becomes a four-table investigation.

Two rules worth stating: null means inherit while zero is a real value, so a
free service keeps its zero instead of inheriting the parent's price; and an
inactive offering is skipped whole, since "this resource does not perform this
right now" is not the same as "I have no opinion on the numbers".

The parent service is passed in rather than looked up from the item's group.
The booking flow already holds both, and a reverse query would be a second way
to answer a question that already has an answer in hand.

Eight tests: one per level with the other levels populated so the winner is
provable, plus independent resolution, the inactive skip, zero, and resolving
the service itself without a parent.

Suite 1272 green, phpstan at its 14-error baseline.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
hamed
2026-08-01 21:17:29 +03:30
co-authored by Claude Opus 5
parent 826b940c00
commit a70a98769b
4 changed files with 346 additions and 8 deletions
@@ -38,14 +38,14 @@
| # | مورد | وضعیت | یادداشت |
|---|---|---|---|
| ۲.۱ | `ResourceServiceResolver` با زنجیرهٔ چهارسطحی | | |
| ۲.۲ | `ResolvedServiceSpec` منبعِ هر مقدار را می‌گوید | | |
| ۲.۳ | مدت و قیمت **جدا** حل می‌شوند | | |
| ۲.۴ | تست سطح ۱ (منبع+گزینه) | | |
| ۲.۵ | تست سطح ۲ (منبع+سرویس) | | |
| ۲.۶ | تست سطح ۳ (شعبه) | | |
| ۲.۷ | تست سطح ۴ (پیش‌فرض آیتم) | | |
| ۲.۸ | تست مرزی: مدت از سطح ۱، قیمت از سطح ۳ | | |
| ۲.۱ | `ResourceServiceResolver` با زنجیرهٔ چهارسطحی | | `ResourceServiceResolver` — منبع+گزینه → منبع+سرویس → شعبه → پیش‌فرض آیتم |
| ۲.۲ | `ResolvedServiceSpec` منبعِ هر مقدار را می‌گوید | | `ResolvedServiceSpec` با `durationSource` و `priceSource` |
| ۲.۳ | مدت و قیمت **جدا** حل می‌شوند | | `testDurationAndPriceResolveIndependently` — مدت از سطح ۱، قیمت از سطح ۳ |
| ۲.۴ | تست سطح ۱ (منبع+گزینه) | | `testLevelOneResourcePlusOptionWins` سبز |
| ۲.۵ | تست سطح ۲ (منبع+سرویس) | | `testLevelTwoResourcePlusServiceWinsWhenTheOptionHasNothing` سبز |
| ۲.۶ | تست سطح ۳ (شعبه) | | `testLevelThreeBranchWinsWhenTheResourceHasNothing` سبز |
| ۲.۷ | تست سطح ۴ (پیش‌فرض آیتم) | | `testLevelFourFallsBackToTheItemItself` سبز |
| ۲.۸ | تست مرزی: مدت از سطح ۱، قیمت از سطح ۳ | | به‌علاوهٔ سه مرزی: ردیف غیرفعال رد می‌شود · قیمت صفر ارث نمی‌گیرد · حل خودِ سرویس بدون والد |
## ۳. فیلتر کاندیدها بر اساس سرویس