eldinosaur's picture
PocketAccountant: custom ledger UI + deterministic agent (engine, ledger, retrieval, classifier)
c55ab5e verified
Raw
History Blame Contribute Delete
2.54 kB
"""End-to-end engine demo — no model, just the deterministic math.
Run from the project root: python -m scripts.demo
It walks through a month in the life of a freelance designer under RESICO, then
shows the same income under the general regime for comparison, an IVA position, a
health check, and the USA bonus mode.
"""
import sys
# Windows consoles default to cp1252; force UTF-8 so the breakdown glyphs render.
try:
sys.stdout.reconfigure(encoding="utf-8")
except (AttributeError, ValueError):
pass
from src.engine import (
cash_runway_months,
current_ratio,
federal_income_tax,
isr_provisional_monthly,
iva_monthly,
profit_margin,
quarterly_estimated_tax,
resico_isr_monthly,
schedule_c_net_profit,
self_employment_tax,
taxable_base,
)
def section(title):
print("\n" + "═" * 64)
print(title)
print("═" * 64)
def show(result):
print(result.explain())
def main():
# --- A month for a freelance designer ---------------------------------
income = 45000 # MXN invoiced this month
deductions = 12000 # software, rent share, equipment
section("MEXICO · RESICO (flat rate on income)")
show(resico_isr_monthly(income))
section("MEXICO · General regime (income − deductions, progressive)")
base = taxable_base(income, deductions)
print(f"Taxable base = {income}{deductions} = {base}")
show(isr_provisional_monthly(base))
print("\n→ For this profile RESICO is dramatically cheaper. The agent would "
"flag that and explain why.")
section("MEXICO · IVA position for the month")
# 16% collected on 45,000 of sales; paid 16% on 12,000 of deductible buys.
show(iva_monthly(iva_trasladado=45000 * 0.16, iva_acreditable=12000 * 0.16))
section("HEALTH CHECK")
show(current_ratio(150000, 100000))
show(profit_margin(income - deductions, income))
show(cash_runway_months(90000, 30000))
# --- USA bonus mode ----------------------------------------------------
section("USA · self-employed (Schedule C)")
net = schedule_c_net_profit(100000, 40000)
show(net)
se = self_employment_tax(net.amount)
show(se)
inc_tax = federal_income_tax(net.amount)
show(inc_tax)
show(quarterly_estimated_tax(inc_tax.amount, se.amount))
print("\nEvery number above came from the deterministic engine, with its source "
"attached. The LLM's job is only to choose which to call and explain it.")
if __name__ == "__main__":
main()