Exemplo n.º 1
0
def balance_graph():
    balance_x = [(op.date_op.strftime(_(u"%d/%b")).decode('utf-8'))
                 for op in Operation.select().filter(type_="balance").order_by(("date_op"))]
    balance_y = [(op.balance) for op in Operation.select()\
                                                 .order_by(("date_op"))\
                                                 .filter(type_="balance")]
    return balance_x, balance_y
Exemplo n.º 2
0
def balance_graph():
    balance_x = [(op.date_op.strftime(_(u"%d/%b")).decode('utf-8'))
                 for op in Operation.select().filter(
                     type_="balance").order_by(("date_op"))]
    balance_y = [(op.balance) for op in Operation.select()\
                                                 .order_by(("date_op"))\
                                                 .filter(type_="balance")]
    return balance_x, balance_y
Exemplo n.º 3
0
def last_operation(type_op=""):
    """ last operation """
    if type_op != "":
        try:
            return Operation.select().filter(Operation.type == type_op)\
                                               .order_by(("date_op", "desc")).get()

        except:
            raise
            return 0
    else:
        try:
            return Operation.select().\
                             order_by(("date_op", "desc")).get().date_op
        except:
            raise
            pass
Exemplo n.º 4
0
def last_operation(type_op=""):
    """ last operation """
    if type_op != "":
        try:
            return Operation.select().filter(Operation.type == type_op)\
                                               .order_by(("date_op", "desc")).get()

        except:
            raise
            return 0
    else:
        try:
            return Operation.select().\
                             order_by(("date_op", "desc")).get().date_op
        except:
            raise
            pass
Exemplo n.º 5
0
def last_balance():
    """ last balance """
    try:
        last_balance = Operation.select().order_by(("date_op", "desc")).get()
        return last_balance.balance

    except AttributeError:
        raise
        pass
Exemplo n.º 6
0
def last_balance():
    """ last balance """
    try:
        last_balance = Operation.select().order_by(("date_op", "desc")).get()
        return last_balance.balance

    except AttributeError:
        raise
        pass
Exemplo n.º 7
0
def consumption():
    """ Calculation of consumption per day. """
    list_consump = []
    data_balance = [(op.balance, op.date_op, op.type_) for op in Operation.select().order_by(("date_op"))]

    for i in range(len(data_balance) -1):
        if data_balance[i + 1][2] == "balance":
            list_consump.append((data_balance[i][1], abs(int(data_balance[i][0])
                                 - int(data_balance[i + 1][0]))))
    return list_consump
Exemplo n.º 8
0
def consumption():
    """ Calculation of consumption per day. """
    list_consump = []
    data_balance = [(op.balance, op.date_op, op.type_)
                    for op in Operation.select().order_by(("date_op"))]

    for i in range(len(data_balance) - 1):
        if data_balance[i + 1][2] == "balance":
            list_consump.append(
                (data_balance[i][1],
                 abs(int(data_balance[i][0]) - int(data_balance[i + 1][0]))))
    return list_consump
Exemplo n.º 9
0
def handle_message(message):
    check = Qiwi(token_qiwi)
    elements_to_check = check.find_pay(str(message.from_user.id),
                                       check.get_history())
    # print(elements_to_check)
    if elements_to_check['total']['amount'] == 10 and elements_to_check[
            'total']['currency'] == 643:
        my_database = Operation()
        if my_database.select(str(message.from_user.id),
                              elements_to_check['date']):
            bot.send_message(message.chat.id,
                             f'Новых платежей от вас не поступало')
        else:
            my_database.commit(str(message.from_user.id),
                               elements_to_check['date'])
            bot.send_message(message.chat.id, f'Логин:{12}\nПароль:{1}')
    else:
        bot.send_message(message.chat.id, 'Ожидаются данный')
Exemplo n.º 10
0
def build_balance_report(filename=None, format='pdf'):
    ''' PDF: List of balances '''
    if not filename:
        filename = get_temp_filename('pdf')

    doc = Document(title=_(u"List of balances"))

    table = Table(4)
    table.add_header_row([
        Text(_(u"Date")),
        Text(_(u"Type")),
        Text(_(u"Value")),
        Text(_(u"Balance"))
    ])

    # column widths
    table.set_column_width(20, 0)
    table.set_column_width(10, 2)
    table.set_column_width(15, 3)

    # column alignments
    table.set_alignment(Table.ALIGN_LEFT, column=0)
    table.set_alignment(Table.ALIGN_LEFT, column=1)
    table.set_alignment(Table.ALIGN_RIGHT, column=2)
    table.set_alignment(Table.ALIGN_RIGHT, column=3)

    operations = [(op.date_op, op.type_, op.value, op.balance) \
                    for op in Operation.select().order_by(("date_op"))
                    .filter(type_="balance")]

    for operation in operations:
        table.add_row([
            Text(unicode(operation[0])),
            Text(unicode(operation[1])),
            Text(formatted_number(operation[2])),
            Text(formatted_number(operation[3]))
        ])

    doc.add_element(table)

    gen = PDFGenerator(doc, filename)
    gen.render_document()

    return gen.get_filename()
Exemplo n.º 11
0
def build_balance_report(filename=None, format='pdf'):
    ''' PDF: List of balances '''
    if not filename:
        filename = get_temp_filename('pdf')

    doc = Document(title=_(u"List of balances"))

    table = Table(4)
    table.add_header_row([
            Text(_(u"Date")),
            Text(_(u"Type")),
            Text(_(u"Value")),
            Text(_(u"Balance"))])

    # column widths
    table.set_column_width(20, 0)
    table.set_column_width(10, 2)
    table.set_column_width(15, 3)

    # column alignments
    table.set_alignment(Table.ALIGN_LEFT, column=0)
    table.set_alignment(Table.ALIGN_LEFT, column=1)
    table.set_alignment(Table.ALIGN_RIGHT, column=2)
    table.set_alignment(Table.ALIGN_RIGHT, column=3)

    operations = [(op.date_op, op.type_, op.value, op.balance) \
                    for op in Operation.select().order_by(("date_op"))
                    .filter(type_="balance")]

    for operation in operations:
        table.add_row([
            Text(unicode(operation[0])),
            Text(unicode(operation[1])),
            Text(formatted_number(operation[2])),
            Text(formatted_number(operation[3]))])

    doc.add_element(table)

    gen = PDFGenerator(doc, filename)
    gen.render_document()

    return gen.get_filename()
Exemplo n.º 12
0
    def set_data_for(self):

        self.data = [(op.date_op.strftime(_(u'%x %Hh:%Mmn')), op.type_,
                      formatted_number(op.value), formatted_number(op.balance))
                     for op in Operation.select().order_by(('date_op', 'asc'))]
Exemplo n.º 13
0
    def __init__(self, parent, *args, **kwargs):
        QtGui.QDialog.__init__(self, parent, *args, **kwargs)

        self.data = Operation.select().order_by("date_op")

        title = QtGui.QLabel()
        self.setWindowTitle(_(u"Delete an operation"))
        if self.data == []:
            title.setText(_(u"There is no operation removed for this account"))
            ok_butt = QtGui.QPushButton(_(u"OK"))
            ok_butt.clicked.connect(self.close)

            vbox = QtGui.QVBoxLayout()
            vbox.addWidget(title)
            vbox.addWidget(ok_butt)
            self.setLayout(vbox)
        else:
            title.setText(_(u"Select a statement has deleted"))
            title.setAlignment(QtCore.Qt.AlignHCenter)
            title_hbox = QtGui.QHBoxLayout()
            title_hbox.addWidget(title)

            #Combobox widget
            # self.box = QtGui.QComboBox()
            # for index in xrange(0, self.data.count()):
            #     op = self.data[index]
            #     sentence = _(u"%(date_op)s - %(type)s - " \
            #                  u"%(value)s/%(balance)s ")\
            #                  % {'date_op': op.date_op, \
            #                     'type': op.type, \
            #                     'value': op.value, \
            #                     'balance': formatted_number(op.balance)}
            #     self.box.addItem(sentence, QtCore.QVariant(op.id))
            self.box = QtGui.QComboBox()
            for index in self.data:
                op = index
                sentence = _(u"%(date_op)s - %(type)s - " \
                             u"%(value)s/%(balance)s ")\
                             % {'date_op': op.date_op, \
                                'type': op.type_, \
                                'value': op.value, \
                                'balance': formatted_number(op.balance)}
                self.box.addItem(sentence, QtCore.QVariant(op.id))

            combo_hbox = QtGui.QHBoxLayout()
            combo_hbox.addWidget(self.box)

            #delete and cancel hbox
            button_hbox = QtGui.QHBoxLayout()

            #Delete Button widget.
            delete_but = QtGui.QPushButton(_(u"Delete"))
            delete_but.clicked.connect(self.delete)
            #Cancel Button widget.
            cancel_but = QtGui.QPushButton(_(u"Cancel"))
            cancel_but.clicked.connect(self.cancel)

            button_hbox.addWidget(cancel_but)
            button_hbox.addWidget(delete_but)
            #Create the QVBoxLayout contenaire.
            vbox = QtGui.QVBoxLayout()
            vbox.addLayout(title_hbox)
            vbox.addLayout(combo_hbox)
            vbox.addLayout(button_hbox)
            self.setLayout(vbox)
Exemplo n.º 14
0
    def set_data_for(self):

        self.data = [(op.date_op.strftime(_(u'%x %Hh:%Mmn')), op.type_,
                     formatted_number(op.value), formatted_number(op.balance))
                     for op in Operation.select().order_by(('date_op', 'asc'))]