Dentolize · Invoice Discount Percentage Fix Walkthrough
On this pageIn one sentenceWhat actually changedWhy this is correctWho feels itHow to read the rest of this site

Invoice Discount Percentage Fix

In one sentence

The discount tile on the invoices screen used to divide by the wrong number, so it reported a discount percentage that was too high. This change makes it divide by the pre‑discount amount, so the percentage now reflects the real "percent off" a clinic gave.

Status: unreleased. This is a pre‑release change on the branch mo/fix_invoice_discount_percent_in_table_analytics (PR #356). Nothing in this document is live for customers yet — it describes what the code on this branch does today.

What actually changed

Two lines, in two files — the web and mobile versions of the same summary bar that sits above the invoices table.

FileWhat it rendersChange
packages/clinic-web/src/components/dashboard/finances/invoices/InvoiceInfo.js:118The Discount tile on the web invoices tabledenominator totaltotal + discount
packages/clinic-mobile/src/components/dashboard/finances/invoices/InvoicesInfo.js:99The Discount tile on the mobile invoices listdenominator totaltotal + discount

Before:

percentage = total ? (discount / total) * 100 : undefined

After:

percentage = total ? (discount / (total + discount)) * 100 : undefined

Why this is correct

An invoice's stored total is the amount after the discount has already been taken off (it is subtotal − discount + tax). Dividing the discount by that shrunken figure inflates the percentage. Adding the discount back — total + discount — reconstructs the amount the patient would have paid before the discount, which is the honest base for a "percent off" number.

Real numbers from the sandbox (invoices that carry a discount):

DiscountBase usedPercentage shown
Old code₺2,373.25₺18,301.75 (post‑discount total)13.0 %
New code₺2,373.25₺20,675.00 (pre‑discount total)11.5 %

The old number overstated the discount by 1.5 percentage points on this data set.

Who feels it

  • Accountants, owners, and managers who read the invoices analytics bar to see how much the clinic is discounting — they now get a trustworthy figure.
  • Nobody has to do anything. There is no new button, setting, or migration. The number simply corrects itself the next time the screen loads.

How to read the rest of this site

  1. Walkthrough — annotated screenshots of the exact screen, before/after math included.
  2. Feature breakdown — the discount fix in plain and technical terms, and how invoice totals are built.
  3. By team — a page written for each role (marketing, sales, support, training, stakeholders, quality).
  4. Glossary & data model — the terms and fields behind the numbers.