#!/usr/bin/env python3 from datetime import date, timedelta from notifier import init, plural from notifier.providers import EmailNotify from prismasok import prisma from prismasok.util import load_credentials, sorted_items, print_items, total cardno, password = load_credentials() p = prisma.Prisma(cardno, password) ps = p.purchases(date.today() - timedelta(days=1)) if len(ps) > 0: n = init(email=EmailNotify('Prisma')) with n: n.subject = 'Prisma: {} purchase{s} yesterday'.format(len(ps), s=plural(len(ps))) for i, p in enumerate(ps, 1): data = sorted_items(p.items.data) print('Purchase #{}:'.format(i)) print_items(data) print('Total: {}'.format(p.total)) real_total = total(data) if (real_total != p.total): print('Real total: {}'.format(real_total)) print() n.notify()
#!/usr/bin/env python3 from datetime import date, timedelta import calendar from notifier import init from notifier.providers import EmailNotify from prismasok import prisma from prismasok.util import load_credentials, sorted_items, print_items, total today = date.today() last_month = date(today.year, today.month, 1) - timedelta(days=1) month, year = last_month.month, last_month.year last_day = calendar.monthrange(year, month)[1] cardno, password = load_credentials() p = prisma.Prisma(cardno, password) items = sorted_items(p.total_items(date(year, month, 1), date(year, month, last_day)).data) n = init(email=EmailNotify('Prisma')) with n: t = total(items) n.subject = 'Prisma: {} rub spent in {}'.format(t, calendar.month_name[month]) print_items(items) print('Total: {}'.format(t)) n.notify()