← Back to Manara Bugs · View issue #152 in MantisBT
Reported by: Khaled Tarabay on 2026-07-30T14:29:14+01:00
Assigned to: Claude
Resolved by: Claude on 2026-08-01T07:26:21+01:00
Severity: major
Priority: normal
Reproducibility: always
Category: General
Description: Unchecking “Supplier” (or “Client”) on a contact that still has a real, unpaid, linked Purchase Bill (or Sale invoice) doesn't just relabel the contact — it removes the corresponding summary tile from the contact's own detail page entirely, hiding a genuinely outstanding balance from the one page a staff member would normally check first, even though the exact same figure remains correct and visible on /contacts and in /billing. Created contact 81 (DH RoleFlip2 344832, Supplier+Client) and recorded a real $123.45 Purchase, raising Purchase Bill LG-INV-193 (id 282, Issued). Before any edit, the contact page correctly read YOU OWE $123.45. Edited the contact and unchecked is_supplier only (leaving is_client alone, name/phone/email untouched) — the save completed cleanly with zero field errors, and the header correctly updated to read just “Client” instead of “Supplier & Client.”
After that edit, re-loading /contacts/81 fresh: the YOU OWE tile is not present at all — not “$0.00,” the label and figure are both gone from the page, as if there were nothing to compute. Yet in the same response:
The ledger table further down the same page still lists the original Purchase transaction row, still reading balance $123.45, still Issued. /contacts (the list page) still shows this exact contact's row with $123.45 in the “You owe” column — correct, and directly contradicting what its own detail page now shows. /billing/282 still shows the Purchase Bill as Issued, BALANCE DUE $123.45, fully intact and payable. Reproduced the mirror-image case independently on a fresh contact (82, DH RoleFlip3 398347): recorded a $64.20 Sale, then removed is_client instead of is_supplier. Same result in the other direction — THEY OWE YOU vanishes from the contact page while /contacts list still correctly shows $64.20 for that row. Also confirmed on a third contact (72, DH RoleFlip 763029) that the underlying transaction and its Pay control keep working end-to-end after the role edit — paying the now-tile-hidden Purchase Bill through the still-present ledger row correctly settled it to Paid/$0.00 — so this is not data loss, it's specifically the top-of-page summary tile silently disappearing while the ledger table beneath it, /contacts, and /billing all continue to report the real number correctly.
This is a genuine same-page-load drift between two aggregates computed from identical underlying data (the tile vs. the ledger table three sections below it), and a cross-page drift against /contacts. A manager reviewing a contact's page after cleaning up its role flags (a plausible real workflow — e.g. a former Supplier relationship ending while a final unpaid bill is still outstanding) would see no indication whatsoever that money is still owed, unless they scroll to the raw ledger table or separately check the /contacts list. The fix is almost certainly that the tile's visibility is being gated on the contact's current role flags rather than on whether any transactions of that kind actually exist with an outstanding balance — the tile should be shown whenever the underlying balance is non-zero, independent of the contact's present-day role checkboxes, exactly as the ledger table and /contacts list already correctly do.
Steps to Reproduce: Create a contact with both is_supplier and is_client checked. Record a real Purchase, leaving it unpaid. Confirm the contact page shows a non-zero YOU OWE tile. Edit the contact and uncheck is_supplier only. Save — confirm no field errors and the header now reads “Client.” Reload /contacts/<id> — the YOU OWE tile/label is absent from the page. In the same page load, scroll to the ledger table below — the original Purchase row and its balance are still there, still payable. Separately open /contacts (the list) — the same contact's row still correctly shows the owed amount in the “You owe” column, contradicting what its own detail page just showed. Repeat symmetrically with is_client removed against an unpaid Sale — THEY OWE YOU vanishes the same way.
Resolution: Fixed. The “You owe” / “They owe you” tiles on the contact page were gated on the current role flags, so unchecking Supplier/Client while an unpaid Purchase Bill / Sale invoice still existed hid the tile entirely — while /contacts, /billing, and the ledger table below all kept showing the real figure (same-page aggregate drift).
FIX: contacts/show.php now shows each tile when its role flag is set OR its underlying balance is non-zero (showOwe = canPurchase || balances[owe] > 0; mirror for owed), with the meta text adjusted to not assume the role — matching how the ledger table and the /contacts list already behave. (balancesFor() also now excludes void-linked rows, per #151.)
File: app/views/contacts/show.php. No schema change.
FIX: contacts/show.php now shows each tile when its role flag is set OR its underlying balance is non-zero (showOwe = canPurchase || balances[owe] > 0; mirror for owed), with the meta text adjusted to not assume the role — matching how the ledger table and the /contacts list already behave. (balancesFor() also now excludes void-linked rows, per #151.)
File: app/views/contacts/show.php. No schema change.
| Date | User | Field | Change |
|---|---|---|---|
| 2026-07-30T14:29:14+01:00 | Khaled Tarabay | issue-new | New Issue |
| 2026-08-01T07:26:12+01:00 | Claude | Assigned To | ⇒ Claudine |
| 2026-08-01T07:26:16+01:00 | Claude | tag-added | Tag Attached: done-by-claude |
| 2026-08-01T07:26:18+01:00 | Claude | note-added | Note Added: 0000110 |
| 2026-08-01T07:26:21+01:00 | Claude | Status | new ⇒ resolved |
Synced automatically from MantisBT issue #152.