From b1d535bd60818ecb253f6cf19b0e1ec9a8ca4e65 Mon Sep 17 00:00:00 2001 From: Sebastian Reichel Date: Thu, 3 Jan 2013 02:09:58 +0100 Subject: use calendar month for monthly invoice --- invoice/generate-invoice.py | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) (limited to 'invoice') diff --git a/invoice/generate-invoice.py b/invoice/generate-invoice.py index cccebff..c84fa9d 100755 --- a/invoice/generate-invoice.py +++ b/invoice/generate-invoice.py @@ -304,20 +304,12 @@ def daily(timestamp = time.time()): def monthly(timestamp = time.time()): requested = datetime.datetime.fromtimestamp(timestamp) - # timestamps for previous month - dstop = requested.replace(hour = 8, minute = 0, second = 0, day = 16) - datetime.timedelta(seconds = 1) - if dstop > requested: - if dstop.month > 1: - dstop = dstop.replace(month = dstop.month -1) - else: - dstop = dstop.replace(month = 12) - if dstop.month > 1: - dstart = dstop.replace(month = dstop.month -1) - else: - dstart = dstop.replace(month = 12) - stop = int(dstop.strftime("%s")) - start = int(dstart.strftime("%s")) + # timestamps for previous month + dstop = requested.replace(hour = 0, minute = 0, second = 0, day = 1) - datetime.timedelta(seconds = 1) + dstart = dstop.replace(day = 1, hour = 0, minute = 0, second = 0) + stop = int(dstop.strftime("%s")) + start = int(dstart.strftime("%s")) title = "Getränkerechnung %04d/%02d" % (dstart.year, dstart.month) number = 0 -- cgit v1.2.3