diff options
author | Sebastian Reichel <sre@ring0.de> | 2013-01-13 18:47:54 +0100 |
---|---|---|
committer | Sebastian Reichel <sre@ring0.de> | 2013-01-13 18:47:54 +0100 |
commit | f89a9e9ef3113e21743e8896a06a0e21e7516616 (patch) | |
tree | e386d7b93b3bf90ceb9a399f6301135e3587bfa5 | |
parent | a4b729af5acb6207120fc0508043a7499b61caff (diff) | |
download | serial-barcode-scanner-f89a9e9ef3113e21743e8896a06a0e21e7516616.tar.bz2 |
use guestprice for guest account in csv data
-rwxr-xr-x | invoice/generate-invoice.py | 31 |
1 files changed, 12 insertions, 19 deletions
diff --git a/invoice/generate-invoice.py b/invoice/generate-invoice.py index 6782b31..9592191 100755 --- a/invoice/generate-invoice.py +++ b/invoice/generate-invoice.py @@ -191,25 +191,18 @@ def generate_invoice_text(user, title, subject, start=0, stop=0, temporary=False return result def get_invoice_amount(user, start=0, stop=0): - if user < 0: - return 0 - else: - query = "SELECT SUM(memberprice) FROM users, sales purch, prices \ - WHERE users.id = ? AND users.id = purch.user AND purch.product = prices.product \ - AND purch.timestamp >= ? AND purch.timestamp <= ? AND prices.valid_from = \ - (SELECT valid_from FROM prices WHERE product = purch.product AND \ - valid_from < purch.timestamp ORDER BY valid_from DESC LIMIT 1) GROUP BY users.id" - amount = 0 - - connection = sqlite3.connect('shop.db') - c = connection.cursor() - c.execute(query, (user, start, stop)) - - for row in c: - amount += row[0] - - c.close() - return amount + query = "SELECT SUM(price) FROM invoice WHERE user = ? AND timestamp >= ? AND timestamp <= ?"; + amount = 0 + + connection = sqlite3.connect('shop.db') + c = connection.cursor() + c.execute(query, (user, start, stop)) + + for row in c: + amount += row[0] + + c.close() + return amount def generate_mail(receiver, subject, message, pdfdata, timestamp=time.time(), cc = None): msg = MIMEMultipart() |