Repository navigation
RTO and insurance changes move extra discount, not the customer price - #299
Conversation
A lower RTO or insurance reduces Additional (Dealer) by the same rupees. An agreed pack-unit price above the new on-road cost stays the deal, a named pack unit accepts the real charges, and the scheme form follows the reduced discount. Co-authored-by: writerish07-pixel <writerish07-pixel@users.noreply.github.com>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ❌ Deployment failed View logs |
euler-crm | c976735 | Nov 21 2026, 07:42 AM |
There was a problem hiding this comment.
Devin Review found 2 potential issues.
3 flags not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)
| ex = round2(num(snap.get("exShowroom") or unit.get("exShowroom"))) | ||
| if ex > 0: | ||
| return cx > ex * 1.5 + DEAL_AMOUNT_EQUAL_RUPEES |
There was a problem hiding this comment.
🔴 Legacy pack totals double-count cheaper vehicles
On older packs with the order total copied to unit 1, pack_unit_cx_is_pack_rollup accepts totals below the new cutoff. Recompute then adds the sibling prices again, inflating the customer’s balance.
Learn more
Older pack price hydration could copy the lead’s commercial fields onto the first unit. The existing legacy data regression test covers a copied order total, but its total is far above the new cutoff. Price Structure runs recompute after an edit. Unit payable refresh keeps the copied Cx Demand as the first unit’s price when the cutoff misses it. Pack recompute then persists the inflated sum as payable and uses it for outstanding.
Example: A Storm with ₹12,00,000 ex-showroom has an agreed price of ₹11,80,000. A sibling costs ₹5,90,000. If unit 1 still carries the copied ₹17,70,000 pack total, the new ₹18,00,001 cutoff accepts it, and a price save writes ₹23,60,000 instead of ₹17,70,000.
Recommended fix: Distinguish explicit per-unit agreements from legacy copied totals using their source, with pack context available during reconciliation. Cover both a mixed-price pack with a copied total below the cutoff and a genuine unit agreement that exceeds GVC after a charge cut.
Was this helpful? React with 👍 or 👎 to provide feedback.
| ex = round2(num(snap.get("exShowroom") or unit.get("exShowroom"))) | ||
| if ex > 0: | ||
| return cx > ex * 1.5 + DEAL_AMOUNT_EQUAL_RUPEES |
There was a problem hiding this comment.
🔴 Missing extra income on pack sales
When an RTO or insurance cut exhausts the discount, pack_unit_cx_is_pack_rollup now preserves the higher agreed price. Recompute adds the difference to dealer margin only for single vehicles. Dealer Earnings omits the pack’s extra income.
Learn more
An owner can lower RTO and insurance through Price Structure. When the agreed price remains above the revised charges, unit payable refresh keeps the agreed price and records the positive gap as extra customer income. Lead recompute only derives that income directly for single vehicles, and its lead-level margin and earnings use that single-vehicle result. The Dealer Earnings register uses the persisted lead margin, so saving or reloading the report does not recover the omitted amount.
Example: A pack unit stays at ₹8,05,000 after its gross cost falls to ₹7,95,000 and the discount reaches zero. The unit records ₹10,000 in extra customer income, but none of that ₹10,000 reaches Dealer Earnings.
Recommended fix: Roll up extra customer income from the freshly computed pack units and include it exactly once in persisted margin and total earnings. Extend the large-cut regression to assert the lead-level margin and the earnings register contribution.
Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f191963b4d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| unit = unit or {} | ||
| ex = round2(num(snap.get("exShowroom") or unit.get("exShowroom"))) | ||
| if ex > 0: | ||
| return cx > ex * 1.5 + DEAL_AMOUNT_EQUAL_RUPEES |
There was a problem hiding this comment.
Keep low-ratio pack totals from locking as unit prices
For a mixed-SKU pack whose first unit costs much more than another vehicle, the pack total can be below 1.5× the first unit’s ex-showroom (for example, a Storm LR200 plus a HiRange SR). This returns false for a legacy pack roll-up copied onto unit 1, so _refresh_unit_payables treats the whole pack total as unit 1’s deal and then adds unit 2’s payable, overstating the customer balance and potentially blocking delivery.
Useful? React with 👍 / 👎.
A charge cut that exhausts Additional leaves the gap on each pack unit and in dealer margin. An order total copied onto the expensive unit is still dropped when it also covers the cheaper vehicle. Co-authored-by: writerish07-pixel <writerish07-pixel@users.noreply.github.com>
Summary
The confirmed rule is unchanged. When extra discount is ₹4,500 against list RTO ₹5,500 and insurance ₹19,000, changing those to ₹2,200 and ₹18,000 cuts extra discount by the same ₹4,300, to ₹200. Customer payable stays.
A full pass of the price, scheme, and pack paths found three places that did not follow that rule:
When the charge cut is larger than the extra discount, the gap stays extra income from the customer. On a pack that amount is summed once into dealer margin, so Dealer Earnings includes it.
Live check
Logged into the CRM as owner and edited a Turbo Max file that started at extra discount ₹4,500, RTO ₹5,500, insurance ₹19,000, payable ₹8,05,000.
Tests
tests/test_deal_pass_meet_cx.pycovers the ₹4,500 → ₹200 case on one vehicle and on pack unit 2, including the owner-field edit, and the case where the charge cut is larger than the discount (additional becomes ₹0, payable stays, and the ₹10,000 gap is in dealer margin). The scheme form test checks that Additional follows the saved price. A pack refresh test keeps a copied order total of ₹17,70,000 from being treated as the expensive unit's price.