code update, readme added
This commit is contained in:
@@ -244,9 +244,9 @@ class SteVeReporter:
|
||||
print(f"Piekuur: {max_time.strftime('%d-%m %H:00')} "
|
||||
f"({max_hour['consumption']:.2f} kWh)")
|
||||
|
||||
# Bereken geschatte kosten (indicatief)
|
||||
print(f"\nGeschatte kosten (€0.30/kWh): €{total_consumption * 0.30:.2f}")
|
||||
print(f"Geschatte kosten (€0.10/kWh): €{total_consumption * 0.10:.2f}")
|
||||
# Bereken geschatte kosten (indicatief) - nu met correcte total_detailed
|
||||
print(f"\nGeschatte kosten (€0.30/kWh): €{total_detailed * 0.30:.2f}")
|
||||
print(f"Geschatte kosten (€0.10/kWh): €{total_detailed * 0.10:.2f}")
|
||||
|
||||
print("=" * 80)
|
||||
|
||||
@@ -295,16 +295,19 @@ def main():
|
||||
epilog="""
|
||||
Voorbeelden:
|
||||
# Toon lijst van laatste 10 transacties
|
||||
python3 steve_transaction_report.py --list
|
||||
python3 steve_transaction_report.py --host 192.168.178.201 --port 3307 --password 'geheim' --list
|
||||
|
||||
# Toon gedetailleerd rapport van transactie 1
|
||||
python3 steve_transaction_report.py --transaction 1
|
||||
python3 steve_transaction_report.py --host 192.168.178.201 --port 3307 --password 'geheim' --transaction 1
|
||||
|
||||
# Toon laatste 20 transacties
|
||||
python3 steve_transaction_report.py --list --limit 20
|
||||
# Toon laatste 20 transacties in lijst
|
||||
python3 steve_transaction_report.py --host 192.168.178.201 --port 3307 --password 'geheim' --list --limit 20
|
||||
|
||||
# Gebruik andere database credentials
|
||||
python3 steve_transaction_report.py --host 192.168.1.100 --user steve --password geheim --transaction 1
|
||||
# Toon alle transacties gedetailleerd (laatste 10)
|
||||
python3 steve_transaction_report.py --host 192.168.178.201 --port 3307 --password 'geheim'
|
||||
|
||||
# Toon laatste 5 transacties gedetailleerd
|
||||
python3 steve_transaction_report.py --host 192.168.178.201 --port 3307 --password 'geheim' --limit 5
|
||||
"""
|
||||
)
|
||||
|
||||
@@ -316,18 +319,13 @@ Voorbeelden:
|
||||
parser.add_argument('--password', required=True, help='Database wachtwoord')
|
||||
|
||||
# Actie opties
|
||||
parser.add_argument('--list', action='store_true', help='Toon overzicht van transacties')
|
||||
parser.add_argument('--transaction', type=int, metavar='ID', help='Toon gedetailleerd rapport van transactie ID')
|
||||
parser.add_argument('--limit', type=int, default=10, help='Aantal transacties bij --list (default: 10)')
|
||||
parser.add_argument('--list', action='store_true', help='Toon compact overzicht van transacties (tabel format)')
|
||||
parser.add_argument('--transaction', type=int, metavar='ID', help='Toon gedetailleerd rapport van specifieke transactie ID')
|
||||
parser.add_argument('--limit', type=int, default=10, help='Aantal transacties (default: 10)')
|
||||
parser.add_argument('--simple', action='store_true', help='Eenvoudig rapport zonder uurdetails')
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
# Minimaal één actie nodig
|
||||
if not args.list and not args.transaction:
|
||||
parser.print_help()
|
||||
sys.exit(1)
|
||||
|
||||
# Maak reporter object
|
||||
reporter = SteVeReporter(
|
||||
host=args.host,
|
||||
@@ -340,16 +338,30 @@ Voorbeelden:
|
||||
try:
|
||||
reporter.connect()
|
||||
|
||||
if args.list:
|
||||
reporter.list_transactions(limit=args.limit)
|
||||
|
||||
if args.transaction:
|
||||
# Toon specifieke transactie
|
||||
transactions = reporter.get_transactions(transaction_id=args.transaction)
|
||||
if transactions:
|
||||
reporter.print_transaction_report(transactions[0], detailed=not args.simple)
|
||||
else:
|
||||
print(f"✗ Transactie {args.transaction} niet gevonden")
|
||||
sys.exit(1)
|
||||
elif args.list:
|
||||
# Toon compact overzicht
|
||||
reporter.list_transactions(limit=args.limit)
|
||||
else:
|
||||
# Geen specifieke optie: toon alle transacties gedetailleerd
|
||||
transactions = reporter.get_transactions(limit=args.limit)
|
||||
if not transactions:
|
||||
print("Geen transacties gevonden.")
|
||||
else:
|
||||
print(f"\n{'=' * 80}")
|
||||
print(f"GEDETAILLEERDE RAPPORTEN VAN LAATSTE {len(transactions)} TRANSACTIES")
|
||||
print(f"{'=' * 80}")
|
||||
for i, trans in enumerate(transactions):
|
||||
if i > 0:
|
||||
print("\n\n")
|
||||
reporter.print_transaction_report(trans, detailed=not args.simple)
|
||||
|
||||
except KeyboardInterrupt:
|
||||
print("\n\nAfgebroken door gebruiker")
|
||||
|
||||
Reference in New Issue
Block a user