Skip to content

Commit

Permalink
Minimal refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
sedrubal committed Jun 15, 2016
1 parent ef4112f commit 8f7004e
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions FabLabKasse/kassenbuch.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,11 @@
"""

from __future__ import print_function
from __future__ import unicode_literals
from __future__ import absolute_import

import sqlite3
import argparse
from datetime import datetime, timedelta
from decimal import Decimal, InvalidOperation
import dateutil.parser
Expand All @@ -41,7 +44,6 @@
import os
import random
import scriptHelper
import argparse
try:
import argcomplete
except ImportError:
Expand Down Expand Up @@ -361,9 +363,9 @@ def get_buchungen(self, from_date=None, until_date=None):

# TODO move filters to SQL query
if from_date:
buchungen = filter(lambda b: b.datum >= from_date, buchungen)
buchungen = [b for b in buchungen if b.datum >= from_date]
if until_date:
buchungen = filter(lambda b: b.datum < until_date, buchungen)
buchungen = [b for b in buchungen if b.datum < until_date]

return buchungen

Expand All @@ -379,9 +381,9 @@ def get_rechnungen(self, von=None, bis=None):
rechnungen.append(Rechnung.load_from_id(row[0], self.cur))

if von:
rechnungen = filter(lambda b: b.datum >= von, rechnungen)
rechnungen = [r for r in rechnungen if r.datum >= von]
if bis:
rechnungen = filter(lambda b: b.datum < bis, rechnungen)
rechnungen = [r for r in rechnungen if r.datum < bis]

return rechnungen

Expand Down Expand Up @@ -761,7 +763,7 @@ def parse_date(value):
return datetime.today() - timedelta(1)
else:
return dateutil.parser.parse(value)
if value is None:
if not value:
return None
else:
raise ValueError('cannot parse date value')
Expand Down Expand Up @@ -1387,10 +1389,7 @@ def check_number_greater_zero_or_minus_one(n):

for k in k.kunden:
letzte_zahlung = sorted(
map(
lambda b: b.datum,
filter(lambda b: b.betrag > 0, k.buchungen)
)
[b.datum for b in [b for b in k.buchungen if b.betrag > 0]]
)[:1]

if not letzte_zahlung:
Expand Down

2 comments on commit 8f7004e

@mgmax
Copy link
Member

@mgmax mgmax commented on 8f7004e Jun 15, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sinnvollere Commit-Messages wären gut...

@sedrubal
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Jo, ich werde mir Mühe geben.

Please sign in to comment.