Referrals
Each patient has a single referral. The agreement lives in the clinic, in one currency, and can point to that person’s quote. Whoever creates it is noted.

Who refers
The referrer is a clinic patient, a staff member, or an outside partner with a name, phone, and email. If tied to a patient or a user, the name comes from that record. The same person is not registered twice, and a patient cannot be their own referrer. A referrer can be deactivated: an inactive one cannot enter a new agreement. If they already have referrals, they are not deleted.
The agreement
The commission is set in two ways. Collected is a percentage, from 0 to 100, on the deposits of that patient’s quote in the referral currency. Fixed amount is a closed figure. One of the two is required, and the quote has to belong to that same patient. If no currency is chosen, the clinic’s is used. The agreement starts pending. Marking it payable makes the system calculate the amount and set today’s date, unless the team writes another. If they later change the percentage, the amount, the quote, or the currency, the payable amount is calculated again. Returning it to pending clears that amount and that date.
The payment
Paid and partially paid are not chosen by hand. Payments to the referrer are recorded: amount, method, and date, always in the agreement currency. With the first payment the status becomes partially paid. When the sum reaches the payable amount, it becomes paid. Deleting the last payment returns it to payable. An agreement with payments is not deleted, and it is not voided or returned to pending until those payments are emptied. Voided is the close with no debt.
What leadership sees
The dashboard counts referrals created in the period, the payable amount by currency according to the date it became payable, and the amount paid by currency according to the payment date. Open accounts are the payable and the partially paid ones, regardless of the range. The ten referrers with the most commission generated stay at the top. Those two figures, payable and paid, can be set as the month’s goal.
MATEO ZAPATA