summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Reichel <sre@ring0.de>2013-01-13 18:47:54 +0100
committerSebastian Reichel <sre@ring0.de>2013-01-13 18:47:54 +0100
commitf89a9e9ef3113e21743e8896a06a0e21e7516616 (patch)
treee386d7b93b3bf90ceb9a399f6301135e3587bfa5
parenta4b729af5acb6207120fc0508043a7499b61caff (diff)
downloadserial-barcode-scanner-f89a9e9ef3113e21743e8896a06a0e21e7516616.tar.bz2
use guestprice for guest account in csv data
-rwxr-xr-xinvoice/generate-invoice.py31
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()