Cleanup and formatting
This commit is contained in:
parent
50d4f066e3
commit
3c5fc31778
6 changed files with 22 additions and 24 deletions
|
@ -4,9 +4,6 @@ import sys
|
||||||
|
|
||||||
import click
|
import click
|
||||||
import colorful as cf
|
import colorful as cf
|
||||||
from sqlalchemy import create_engine
|
|
||||||
from sqlalchemy.ext.declarative import declarative_base
|
|
||||||
from sqlalchemy.orm import sessionmaker
|
|
||||||
|
|
||||||
from schmeckels.helper import create_tag, get_rules, get_session
|
from schmeckels.helper import create_tag, get_rules, get_session
|
||||||
from schmeckels.models import Tag, Transaction
|
from schmeckels.models import Tag, Transaction
|
||||||
|
|
|
@ -54,8 +54,8 @@ class Sparkasse_MT940(Bank):
|
||||||
data = t.data
|
data = t.data
|
||||||
date = data["date"]
|
date = data["date"]
|
||||||
amount = int(data["amount"].amount * 100)
|
amount = int(data["amount"].amount * 100)
|
||||||
iban = data.get("applicant_iban","")
|
iban = data.get("applicant_iban", "")
|
||||||
name = data.get("applicant_name","")
|
name = data.get("applicant_name", "")
|
||||||
description = data["purpose"]
|
description = data["purpose"]
|
||||||
|
|
||||||
yield models.Transaction(date=date, name=name, iban=iban, amount=amount, description=description)
|
yield models.Transaction(date=date, name=name, iban=iban, amount=amount, description=description)
|
||||||
|
|
|
@ -8,7 +8,7 @@ from sqlalchemy import create_engine
|
||||||
from sqlalchemy.ext.declarative import declarative_base
|
from sqlalchemy.ext.declarative import declarative_base
|
||||||
from sqlalchemy.orm import sessionmaker
|
from sqlalchemy.orm import sessionmaker
|
||||||
|
|
||||||
from schmeckels import autosort, importer, info, models, serve, sort, validate, stats, restart
|
from schmeckels import autosort, importer, info, models, restart, serve, sort, stats, validate
|
||||||
from schmeckels.helper import build_database_filename, build_rules_filename, get_data_dir
|
from schmeckels.helper import build_database_filename, build_rules_filename, get_data_dir
|
||||||
|
|
||||||
__version__ = "0.0.1"
|
__version__ = "0.0.1"
|
||||||
|
|
|
@ -4,7 +4,7 @@ import sys
|
||||||
import click
|
import click
|
||||||
from sqlalchemy import create_engine
|
from sqlalchemy import create_engine
|
||||||
|
|
||||||
from schmeckels.helper import build_database_filename, build_rules_filename, get_data_dir, get_session, get_rules
|
from schmeckels.helper import build_database_filename, build_rules_filename, get_data_dir, get_rules, get_session
|
||||||
from schmeckels.models import Tag, Transaction
|
from schmeckels.models import Tag, Transaction
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ def command():
|
||||||
print("Found {} unsorted transcations".format(len(unsorted)))
|
print("Found {} unsorted transcations".format(len(unsorted)))
|
||||||
|
|
||||||
for t in unsorted:
|
for t in unsorted:
|
||||||
print("-"*20)
|
print("-" * 20)
|
||||||
print(" Name: {}".format(t.name))
|
print(" Name: {}".format(t.name))
|
||||||
print(" IBAN: {}".format(t.iban))
|
print(" IBAN: {}".format(t.iban))
|
||||||
print(" Datum: {}".format(t.date))
|
print(" Datum: {}".format(t.date))
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
#! /usr/bin/env python3
|
#! /usr/bin/env python3
|
||||||
from sqlalchemy import create_engine
|
from datetime import date, datetime
|
||||||
from schmeckels.models import Tag, Transaction
|
|
||||||
from schmeckels.helper import format_amount, get_session
|
|
||||||
import click
|
|
||||||
from math import floor
|
from math import floor
|
||||||
from datetime import datetime, date
|
|
||||||
from sqlalchemy import func, and_
|
import click
|
||||||
from dateutil.relativedelta import relativedelta
|
from dateutil.relativedelta import relativedelta
|
||||||
|
from sqlalchemy import and_, create_engine, func
|
||||||
|
|
||||||
|
from schmeckels.helper import format_amount, get_session
|
||||||
|
from schmeckels.models import Tag, Transaction
|
||||||
|
|
||||||
|
|
||||||
@click.command(name="stats")
|
@click.command(name="stats")
|
||||||
|
@ -20,8 +21,8 @@ def command():
|
||||||
|
|
||||||
# Get start and end of timerange
|
# Get start and end of timerange
|
||||||
year = 2022
|
year = 2022
|
||||||
start_date = date(year=year,month=1,day=1)
|
start_date = date(year=year, month=1, day=1)
|
||||||
end_date = date(year=year,month=12,day=31)
|
end_date = date(year=year, month=12, day=31)
|
||||||
|
|
||||||
for tag in tags:
|
for tag in tags:
|
||||||
if tag.name.find(":") < 0 and tag.name != "Privatentnahme":
|
if tag.name.find(":") < 0 and tag.name != "Privatentnahme":
|
||||||
|
@ -58,24 +59,24 @@ def command():
|
||||||
|
|
||||||
# Ausgaben
|
# Ausgaben
|
||||||
for name, data in outgoing.items():
|
for name, data in outgoing.items():
|
||||||
print(" {:<30} {:>10} €".format(name.name, data['sum']))
|
print(" {:<30} {:>10} €".format(name.name, data["sum"]))
|
||||||
print("-"*44)
|
print("-" * 44)
|
||||||
print(" {:<30} {:>10} €".format("AUSGABEN", format_amount(sum_outgoing)))
|
print(" {:<30} {:>10} €".format("AUSGABEN", format_amount(sum_outgoing)))
|
||||||
print("\n")
|
print("\n")
|
||||||
|
|
||||||
# Einnahmen
|
# Einnahmen
|
||||||
for name, data in incoming.items():
|
for name, data in incoming.items():
|
||||||
print(" {:<30} {:>10} €".format(name.name, data['sum']))
|
print(" {:<30} {:>10} €".format(name.name, data["sum"]))
|
||||||
print("-"*44)
|
print("-" * 44)
|
||||||
print(" {:<30} {:>10} €".format("EINNAHMEN", format_amount(sum_incoming)))
|
print(" {:<30} {:>10} €".format("EINNAHMEN", format_amount(sum_incoming)))
|
||||||
print("\n")
|
print("\n")
|
||||||
|
|
||||||
# Entnahmen
|
# Entnahmen
|
||||||
for name, data in withdrawal.items():
|
for name, data in withdrawal.items():
|
||||||
print(" {:<30} {:>10} €".format(name.name, data['sum']))
|
print(" {:<30} {:>10} €".format(name.name, data["sum"]))
|
||||||
print("-"*44)
|
print("-" * 44)
|
||||||
print(" {:<30} {:>10} €".format("ENTNAHME", format_amount(sum_withdrawal)))
|
print(" {:<30} {:>10} €".format("ENTNAHME", format_amount(sum_withdrawal)))
|
||||||
|
|
||||||
print("\n")
|
print("\n")
|
||||||
print("="*44)
|
print("=" * 44)
|
||||||
print(" {:<30} {:>10} €".format("GEWINN", format_amount(sum_incoming+sum_outgoing)))
|
print(" {:<30} {:>10} €".format("GEWINN", format_amount(sum_incoming + sum_outgoing)))
|
||||||
|
|
Loading…
Add table
Reference in a new issue