152 lines
5.4 KiB
Python
152 lines
5.4 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Currency Ledger Report Generator - Working Version with Real Data Parsing
|
|
"""
|
|
|
|
import csv
|
|
from datetime import datetime
|
|
import os
|
|
from collections import defaultdict
|
|
|
|
def parse_sc_transactions():
|
|
"""Parse live SC transactions and calculate totals"""
|
|
ledger_file = os.path.join(os.path.dirname(__file__), '..', 'ledger', 'smartup-credits', 'transactions.csv')
|
|
|
|
total_minted = 0
|
|
total_redeemed = 0
|
|
transactions = []
|
|
|
|
try:
|
|
with open(ledger_file, 'r') as f:
|
|
reader = csv.DictReader(f)
|
|
for row in reader:
|
|
# Skip comment lines and empty rows
|
|
if not row['timestamp'].startswith('#') and row['timestamp'] != '':
|
|
transactions.append(row)
|
|
amount = int(row['amount'])
|
|
if row['type'] == 'SC':
|
|
total_minted += amount
|
|
elif row['type'] == 'REDEEM':
|
|
total_redeemed += amount
|
|
except FileNotFoundError:
|
|
pass
|
|
|
|
return total_minted, total_redeemed, transactions
|
|
|
|
def parse_treasury_balance():
|
|
"""Parse treasury balance and get latest state"""
|
|
ledger_file = os.path.join(os.path.dirname(__file__), '..', 'ledger', 'treasury', 'balance.csv')
|
|
|
|
latest_balance = {
|
|
'total_eur_balance': 0,
|
|
'sc_outstanding': 0,
|
|
'sc_liability_eur': 0
|
|
}
|
|
|
|
try:
|
|
with open(ledger_file, 'r') as f:
|
|
reader = csv.DictReader(f)
|
|
for row in reader:
|
|
# Skip comment lines and get latest entry
|
|
if not row['timestamp'].startswith('#') and row['timestamp'] != '':
|
|
latest_balance = {
|
|
'total_eur_balance': float(row['total_eur_balance']),
|
|
'sc_outstanding': int(row['sc_outstanding']),
|
|
'sc_liability_eur': float(row['sc_liability_eur'])
|
|
}
|
|
except FileNotFoundError:
|
|
pass
|
|
|
|
return latest_balance
|
|
|
|
def generate_pending_sc_summary():
|
|
"""Generate pending SC summary report"""
|
|
print("⏳ PENDING SC SUMMARY REPORT")
|
|
print("=" * 32)
|
|
|
|
ledger_file = os.path.join(os.path.dirname(__file__), '..', 'ledger', 'pending-sc', 'transactions.csv')
|
|
|
|
total_pending = 0
|
|
by_tranche = defaultdict(int)
|
|
|
|
try:
|
|
with open(ledger_file, 'r') as f:
|
|
reader = csv.DictReader(f)
|
|
for row in reader:
|
|
if not row['timestamp'].startswith('#') and row['timestamp'] != '':
|
|
amount = int(row['amount'])
|
|
total_pending += amount
|
|
tranche = row['vesting_tranche'] or 'immediate'
|
|
by_tranche[tranche] += amount
|
|
|
|
print(f"Total Pending SC: {total_pending:,}")
|
|
|
|
if by_tranche:
|
|
print(f"\n📊 BY VESTING TRANCHE:")
|
|
for tranche, amount in by_tranche.items():
|
|
print(f" {tranche}: {amount:,} SC")
|
|
|
|
except FileNotFoundError:
|
|
print("📝 No pending SC transactions")
|
|
|
|
def main():
|
|
"""Generate comprehensive financial report"""
|
|
|
|
print("📈 SMARTUP ZERO FINANCIAL REPORTS")
|
|
print(f"Generated: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}")
|
|
print("=" * 50)
|
|
|
|
# Parse live SC data
|
|
total_minted, total_redeemed, transactions = parse_sc_transactions()
|
|
sc_outstanding = total_minted - total_redeemed
|
|
|
|
print("📊 SMARTUP CREDITS SUMMARY")
|
|
print("=" * 30)
|
|
print(f"Total SC Minted: {total_minted:,}")
|
|
print(f"Total SC Redeemed: {total_redeemed:,}")
|
|
print(f"SC Outstanding: {sc_outstanding:,}")
|
|
|
|
if transactions:
|
|
print(f"\n📝 RECENT TRANSACTIONS:")
|
|
for tx in transactions[-3:]: # Show last 3
|
|
print(f" {tx['timestamp'][:10]} | {tx['amount']} SC → {tx['to']} | {tx['reference']}")
|
|
else:
|
|
print("📝 No live SC transactions yet")
|
|
|
|
print()
|
|
generate_pending_sc_summary()
|
|
|
|
# Parse treasury data
|
|
treasury = parse_treasury_balance()
|
|
|
|
print("\n💰 TREASURY HEALTH REPORT")
|
|
print("=" * 30)
|
|
print(f"💶 EUR Treasury: €{treasury['total_eur_balance']:.2f}")
|
|
print(f"🪙 SC Outstanding: {treasury['sc_outstanding']:,} SC")
|
|
print(f"💸 SC Liability: €{treasury['sc_liability_eur']:.2f}")
|
|
|
|
# Calculate 3x rule compliance
|
|
if treasury['total_eur_balance'] == 0:
|
|
if treasury['sc_outstanding'] == 0:
|
|
print("✅ 3x Rule: COMPLIANT (no live SC outstanding)")
|
|
else:
|
|
print("⚠️ 3x Rule: PENDING (SC outstanding but no treasury funding yet)")
|
|
else:
|
|
ratio = treasury['sc_outstanding'] / (treasury['total_eur_balance'] * 3)
|
|
if ratio <= 1:
|
|
print(f"✅ 3x Rule: COMPLIANT ({ratio:.1%} of limit)")
|
|
else:
|
|
print(f"❌ 3x Rule: VIOLATION ({ratio:.1%} of limit)")
|
|
|
|
# Financial health assessment
|
|
print(f"\n📊 FINANCIAL HEALTH: {'EXCELLENT' if treasury['sc_outstanding'] <= 1000 else 'GOOD' if treasury['sc_outstanding'] <= 10000 else 'NEEDS_FUNDING'}")
|
|
if treasury['total_eur_balance'] == 0 and treasury['sc_outstanding'] > 0:
|
|
print(" • SC holders earning value through effort-based work")
|
|
print(" • Treasury funding needed for SC redemption capability")
|
|
|
|
print("\n" + "=" * 50)
|
|
print("💡 All ledger data is public and auditable in git history")
|
|
|
|
if __name__ == "__main__":
|
|
main()
|