Why it was needed
Every report pulled from Vivenu on its own and answered the same questions in its own way: what counts as a sale rather than a refund, transfer, or upgrade; who gets credit; whether a buyer is a group, a company, or an individual; and what the club actually kept. The same question got different numbers depending on which report asked it.
The ledger answers each of those questions once, in code, and every report reads the answer instead of working it out again.
What I built
A process that pulls new and changed Vivenu transactions every few minutes and stores each one once, keyed by its Vivenu id. A set of rules then labels every row: paid or not, buyer type, account owner, and commission owner. Each row records the version of the rules that labeled it.
Some calls need a person. Those go in an override table, and an override is applied on every later refresh, so a decision made once is never guessed again.
How it is used
Rep pay reports are built from the ledger. The commission owner on each row decides who is credited for a sale, and when a sale is split or reassigned by hand, the override carries into every later report.
What changed
Reports that read the ledger return the same number for the same question. Time saved has not been measured.
The rest of this page is technical.
How it works
The rules are plain functions: the same order in gives the same labels out. No step asks an AI model to judge a transaction. When an order changes in Vivenu (a refund, a transfer, a payment arriving) its row is updated and labeled again.
Before a refresh is published, a check confirms that every report counts paid orders the same way. If the check fails, the refresh stops and the previous data stays in place.
Code
def is_paid(status, payment_status, real_price=None,
require_price=False, txn_id=None):
# A canceled order keeps its old payment status in Vivenu,
# so the order status is checked first.
if status not in COMPLETE_STATUSES:
return False
if payment_status not in PAID_STATUSES:
# A card dispute the club won keeps Vivenu's CHARGEBACK flag.
if not (payment_status == "CHARGEBACK"
and txn_id in WON_DISPUTE_TXN_IDS):
return False
if require_price and float(real_price or 0) <= 0:
return False
return True
Access and data protection
The ledger holds buyer records, so it runs on a private server that is not reachable from the public internet. Dashboards read a read-only copy, and nothing outside the server can write to the ledger.
Decisions and limits
- Rules in code rather than judgment per transaction, so a report gives the same answer every time it runs.
- A disputed card payment counts as unpaid until the club confirms it won the dispute.
- Built with AI coding tools from rules I wrote and tested against club records.

