-
Notifications
You must be signed in to change notification settings - Fork 0
/
pge_bill_paid.py
40 lines (32 loc) · 1.01 KB
/
pge_bill_paid.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import sqlite3
from lib import utils
from lib import constants
import logbook
def main():
database = 'well.sqlite'
logger = logbook.Logger('pge_bill_paid')
utils.backup_file(database)
db = sqlite3.connect(database)
db.row_factory = sqlite3.Row
cur = db.cursor()
# get date_paid
payment_date = utils.prompt_for_current_date("Date paid")
# get amount
payment_amount = utils.prompt_for_amount("Amount paid")
const = constants.Constants()
# mark the bill paid in the activity account
payment_amount = payment_amount * -1
exec_str = f"""
INSERT INTO activity (date, type, amount, note)
VALUES (?, ?, ?, ?)
"""
params = (payment_date, const.pge_bill_paid, payment_amount, "PGE bill paid")
logger.trace(params)
cur.execute(exec_str, params)
# save, then close the cursor and db
db.commit()
cur.close()
db.close()
if __name__ == '__main__':
utils.init_logging('logs/pge_bill_paid.log')
main()