コード例 #1
0
ファイル: balanceupdateview.py プロジェクト: yeleman/anm
    def save_new_data(self):
        def actually_save():
            for row in self.data:
                account = row[-1]
                if not isinstance(account, Account):
                    continue

                budget = session.query(Budget).filter_by(account=account, \
                                                         period=self.period2)\
                                              .first()
                budget.amount = row[3]
                session.add(budget)
            session.commit()
        try:
            actually_save()
            self.refresh()
            raise_success(_(u"Budgets Updated!"), \
                          _(u"The budgets for %(period)s have been " \
                            u"successfully updated.") \
                            % {'period': self.period2.short_name()})
        except Exception as e:
            raise_success(_(u"Error updating budgets!"), \
                          _(u"There has been an error while trying to " \
                            u"save the new budgets:\n%(error)s") \
                            % {'error': e})
コード例 #2
0
ファイル: deleteview.py プロジェクト: fadiga/Power-Management
 def delete(self):
     op = self.data[self.box.currentIndex()]
     op.delete_instance()
     self.change_main_context(DashbordViewWidget)
     self.box.removeItem(self.box.currentIndex())
     if len(self.data) == 1:
         self.close()
     else:
         self.data.pop(self.box.currentIndex())
     raise_success(_(u"Deleting"), _(u"Operation succefully removed"))
コード例 #3
0
ファイル: deleteview.py プロジェクト: yeleman/anm
 def delete(self):
     op = self.data[self.box.currentIndex()]
     session.delete(op)
     session.commit()
     self.change_main_context(OperationWidget, account=self.account)
     self.box.removeItem(self.box.currentIndex())
     if len(self.data) == 1:
         self.close()
     else:
         self.data.pop(self.box.currentIndex())
     raise_success(_(u"Deleting"), _(u"Operation succefully removed"))
コード例 #4
0
ファイル: home.py プロジェクト: fadiga/zerin_pyside
    def transfer_credit(self, number):
        """ transfer amount credit"""
        date_send = datetime.now()
        amount = self.amount.text()
        if amount:
            transfer = Transfer(amount=self.amount.text(), number=number,
                                date=date_send)

            transfer.save()

            self.number.setText(u"70.00.00.00")
            self.amount.clear()
            self.table.refresh_()
            raise_success(u'Confirmation', u'Transfert effectué')
        else:
            raise_error(u"Erreur Montant",
                        u"Donner un montant s'il vous plait.")
コード例 #5
0
    def add_statement(self):
        ''' add statement '''
        types = {0: "balance", 1: "added", 2: "cut", 3: "recovery"}
        commit = False
        for data in self.list_data:
            date_op = data[0].text()
            time_op = data[1].text()
            type_op = types[data[2].currentIndex()]
            value_op = data[3].text()

            day, month, year = date_op.split('/')
            hour, minute = time_op.split(':')
            datetime_ = datetime(int(year), int(month), int(day), int(hour),
                                 int(minute))
            flag = False
            last_b = last_balance()
            if value_op:
                flag = True
            if type_op == "recovery" or type_op == "cut":
                flag = True
            if flag:
                if type_op == "added":
                    if last_b == None:
                        balance = int(value_op)
                    else:
                        balance = int(last_b) + int(value_op)
                if type_op == "balance":
                    balance = unicode(value_op)
                if type_op == "recovery" or type_op == "cut":
                    balance = unicode(last_b)

                try:
                    operation = Operation.create(date_op=datetime_,
                                                 type_=unicode(type_op),
                                                 value=unicode(value_op),
                                                 balance=balance)
                    raise_success(_(u"Confirmation"),
                                  _(u"Registered opération"))
                except:
                    raise
                    raise_error(_(u"Confirmation"),
                                _(u"There is no valid operation"))
        self.change_main_context(DashbordViewWidget)
コード例 #6
0
ファイル: exports.py プロジェクト: yeleman/anm
def export_database_as_excel():

    destination = QtGui.QFileDialog.getSaveFileName(QtGui.QWidget(), \
                                    _(u"Save Excel Export as..."), \
                                    "%s.xls" % datetime.now()\
                                                .strftime('%d-%m-%Y %Hh%M'), \
                                    "*.xls")
    if not destination:
        return
    try:
        write_xls(destination)
        raise_success(_(u"Database exported!"), \
                      _(u"The data have been successfully exported.\n" \
                        u"Keep that file private as it contains your data.\n" \
                        u"Export your data regularly."))
    except IOError:
        raise_error(_(u"Error in exporting Database!"), \
                    _(u"The database backup could not be exported.\n" \
                      u"Please verify that you selected a destination " \
                      u"folder which you have write permissions to.\n" \
                      u"Then retry.\n\n" \
                      u"Request assistance if the problem persist."))
コード例 #7
0
    def add_statement(self):
        """ add statement """
        types = {0: "balance", 1: "added", 2: "cut", 3: "recovery"}
        commit = False
        for data in self.list_data:
            date_op = data[0].text()
            time_op = data[1].text()
            type_op = types[data[2].currentIndex()]
            value_op = data[3].text()

            day, month, year = date_op.split("/")
            hour, minute = time_op.split(":")
            datetime_ = datetime(int(year), int(month), int(day), int(hour), int(minute))
            flag = False
            last_b = last_balance()
            if value_op:
                flag = True
            if type_op == "recovery" or type_op == "cut":
                flag = True
            if flag:
                if type_op == "added":
                    if last_b == None:
                        balance = int(value_op)
                    else:
                        balance = int(last_b) + int(value_op)
                if type_op == "balance":
                    balance = unicode(value_op)
                if type_op == "recovery" or type_op == "cut":
                    balance = unicode(last_b)

                try:
                    operation = Operation.create(
                        date_op=datetime_, type_=unicode(type_op), value=unicode(value_op), balance=balance
                    )
                    raise_success(_(u"Confirmation"), _(u"Registered opération"))
                except:
                    raise
                    raise_error(_(u"Confirmation"), _(u"There is no valid operation"))
        self.change_main_context(DashbordViewWidget)
コード例 #8
0
def export_database_as_file():
    destination = QtGui.QFileDialog.getSaveFileName(QtGui.QWidget(), \
                                    _(u"Save DB as..."), \
                                    "%s.db" % datetime.now()\
                                                .strftime('%d-%m-%Y %Hh%M'), \
                                    "*.db")
    if not destination:
        return

    try:
        shutil.copyfile(database.DB_FILE, destination)
        raise_success(_(u"Database exported!"), \
                      _(u"The Database has been successfuly exported.\n" \
                        u"Keep that file private as it contains your data.\n" \
                        u"Export your data regularly."))
    except IOError:
        raise_error(_(u"Error in exporting Database!"), \
                    _(u"The database backup could not be exported.\n" \
                      u"Please verify that you selected a destination " \
                      u"folder which you have write permissions to.\n" \
                      u"Then retry.\n\n" \
                      u"Request assistance if the problem persist."))
コード例 #9
0
ファイル: operationview.py プロジェクト: yeleman/anm
    def add_operation(self):
        ''' add operation '''
        year, month, day = self.invoice_date.text().split('-')
        invoice_date = date(int(year), int(month), int(day))
        period = period_for(invoice_date)

        try:
            amount = int(self.amount.text())
        except ValueError:
            amount = 0

        if self.order_number.text() and self.invoice_number.text() and \
            invoice_date and self.provider.text() and self.amount.text()\
            and invoice_date >= self.main_period.start_on and invoice_date <= \
            self.main_period.end_on and amount < self.balance:
            operation = Operation(unicode(self.order_number.text()),
                        unicode(self.invoice_number.text()), invoice_date, \
                        unicode(self.provider.text()), amount)
            operation.account = self.account
            operation.period = period
            session.add(operation)
            session.commit()
            raise_success(_(u'Confirmation'), _(u'Registered opération'))
            self.order_number.clear()
            self.invoice_number.clear()
            self.provider.clear()
            self.amount.clear()
            self.adjust_balance(period)
            self.refresh()
        elif invoice_date > self.main_period.end_on or\
             invoice_date < self.main_period.start_on:
            raise_error(_(u'Error date'), \
            _(u'The date is not included in the current quarter.'))
        elif amount >= self.balance:
            raise_error(_(u'Error money'),\
             _(u"There is not enough money for this operation."))
        else:
            raise_error(_(u'Error field'), _(u'You must fill in all fields.'))