Example #1
0
    def __init__(self, conf, account_name):
        self.conf = conf

        BuilderAware.__init__(self, join_to_file_dir(__file__, "main.glade"))

        self.plan = AccountsPlan()
        self.bank_acc = self.plan.get_by_name(account_name)

        self.last_in_num_param = self.conf.param('last_in_num_for_'+self.bank_acc._id)
        self.last_out_num_param = self.conf.param('last_out_num_for_'+self.bank_acc._id)

        self.update_saldo(date.today())
        self.on_date_month_changed(self.date)
        self.set_date(date.today())
        self.update_last_nums()

        self.window.set_title(
            conf.get('firm_name', 'WTF?') + ' | ' + self.bank_acc.name + ' ' + self.bank_acc.desc)

        self.window.show()
Example #2
0
    def __init__(self, inout, other_account, date, last_in, last_out, on_close=None):
        BuilderAware.__init__(self, join_to_file_dir(__file__, "transactions.glade"))
        self.on_close = on_close
        self.date = date

        self.transactions = transactions = sorted(other_account.transactions(
            date, date, income=inout, outcome=not inout), key=lambda r: r.num)

        last = last_in if inout else last_out

        def new():
            tran = Transaction()
            tran.what = ''
            tran.who = ''
            tran.date = date

            tran._isnew_ = True

            if inout:
                tran.to_acc = other_account.account_path
            else:
                tran.from_acc = other_account.account_path

            return tran

        def on_commit(dr, row):
            if not hasattr(row, 'num'):
                row.num = last.inc()

            row.save()

            if row.who:
                cached_choices[0].append(unicode(row.who))

            if row.what:
                cached_choices[1].append(unicode(row.what))

            if hasattr(row, '_isnew_'):
                del row._isnew_
                transactions.append(new())
                dr.jump_to_new_row(2)

        def on_error(dr, e):
            show_message(self.sw, str(e), 5000)

        def on_check(checks):
            for k, v in checks.iteritems():
                if k and v:
                    self.delete_btn.set_sensitive(True)
                    self.move_btn.set_sensitive(True)
                    return

            self.delete_btn.set_sensitive(False)
            self.move_btn.set_sensitive(False)


        choices = [(r._id, r.name) for _, r in accounts_walk(AccountsPlan().accounts(), True)]

        self.check_col = CheckBoxColumn(transactions, on_check)

        columns = [
            self.check_col,
            IntGridColumn('num', label='№', editable=False, width=3),
            AccountColumn('from_acc' if inout else 'to_acc', choices, label='Счет', width=4),
            AutocompleteColumn('who', get_who_choice(), label='Контрагент', width=15),
            FloatGridColumn('amount', label='Сколько', width=7),
            AutocompleteColumn('what', get_what_choice(), label='За что', width=10),
        ]

        self.tv = Grid(columns)
        self.sw.add(self.tv)

        transactions.append(new())
        self.tv.set_model(transactions, DirtyRow(self.tv, on_commit, on_error))
        self.tv.show_all()

        self.window.set_title(('Приход за ' if inout else 'Расход за ') + date.strftime('%d.%m.%Y'))
Example #3
0
 def __init__(self, conf):
     BuilderAware.__init__(self, join_to_file_dir(__file__, 'main.glade'))
     self.conf = conf
     self.prepare_customers_selector()
     self.current_point = None
Example #4
0
 def __init__(self):
     super(AccountsForm, self).__init__(join_to_file_dir(__file__, 'accounts.glade'))
     self.accounts = {}
     self.fill()
     self.init_form()