Унификация расчёта стоимости заказа: checkout ↔ manager - #476
Open
Ibochkarev wants to merge 2 commits into
Open
Conversation
Extract OrderCostEngine for shared delivery/payment math, align web payment commission base with manager (cart + delivery), and register manager recalculator in DI.
Ibochkarev
force-pushed
the
feat/issue-366-unify-order-cost-engine
branch
from
July 29, 2026 11:31
4d3e2dd to
c03e18d
Compare
Add unit tests in OrderCostEngineTest for the math edge cases called out in #366 review: - Delivery free-threshold: cart at/above free_delivery_amount → 0; just below → weight_price × weight + price; free_delivery_amount = 0 disables it - Percent delivery price applied to cart - Payment percent surcharge base = cart + delivery (#372): 3% of 1500 = 45, total 1545; fixed and empty-price surcharges
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Описание
Общий слой формул стоимости заказа для витрины и менеджера вместо дублирования в
OrderCostCalculator,ManagerOrderCostRecalculator,DeliveryиPayment.OrderCostEngine— delivery (weight, free threshold, price/%), payment surcharge, commission basecart + delivery,composeBreakdown()черезOrderService::clampComputedTotalOrderCostCalculator) — MODX cost events; payment fee считается от cart+delivery ([Bug] Комиссия оплаты %: storefront считает от cart, manager — от cart+delivery #372);getTotalCostпередаёт уже посчитанные cart/delivery вgetPaymentCost(один проход pipeline)ManagerOrderCostRecalculator) — modes/warnings/log; default handlers делегируют в enginems3_manager_order_cost_recalculatorвServiceRegistry,OrdersControllerберёт сервис из контейнераCloses #366
Тип изменений
Поведение storefront:
%-комиссия оплаты теперь от cart + delivery (как в manager), раньше web брал только cart. Осознанное выравнивание (#372). Округление/clamp без изменений.Связанные Issues
Closes #366
Refs #372, #373, #338, #363, #361
Как это было протестировано?
OrderCostEngineTest.php: commission base, #372 (1000+500 → 3% = 45), wiring grep, single-passgetTotalCost.composer ci:php)Чеклист
Дополнительные заметки
Events (документировано в docblocks):
msOnBefore/GetCartCost,DeliveryCost,PaymentCost,OrderCostauto/manual/force_provider) и warningsDeferred: runtime unit-тесты delivery formulas без MODX stub;
OrderFinalizeServicepayment fee (#373) — отдельный issue; полный runtime integration smoke с mock modX.