def __init__(self):
        page.Page.__init__(self)
        self.config = config.avernusConfig()

        self.searchstring = ''
        self.b_show_transfer = True
        self.b_show_uncategorized = True
        self.single_category = None
        self.range_start = None
        self.range_end = None
        self.context_menu_setup = False
        self.builder = get_avernus_builder()
        self.charts_notebook = None

        self.widget = self.builder.get_object("account_vbox")
        self.hpaned = self.builder.get_object("account_hpaned")
        self.category_tree = self.builder.get_object("category_tree")
        self.start_entry = self.builder.get_object("start_entry")
        self.end_entry = self.builder.get_object("end_entry")
        self.search_entry = self.builder.get_object("search_entry")
        self.category_actiongroup = self.builder.get_object("category_actiongroup")
        self.category_context_menu = self.builder.get_object("category_context_menu")

        pre = self.config.get_option('account hpaned position', 'Gui')
        pos = pre or 600
        self.hpaned.set_position(int(pos))

        self._init_categories_tree()
        self._init_transactions_tree()
Example #2
0
    def __init__(self):
        builder = get_avernus_builder()
        self.window = builder.get_object("main_window")

        self.config = config.avernusConfig()
        self.window.set_title(avernus.__appname__)

        sb = sidebar.Sidebar()
        self.hpaned = builder.get_object("hpaned")
        self.account_page = AccountTransactionTab()
        self.portfolio_notebook = builder.get_object("portfolio_notebook")
        self.portfolio_pages = [PortfolioPositionsTab(),
                                TransactionsTab(),
                                DividendsTab(),
                                ClosedPositionsTab(),
                                ChartTab()
                                ]
        self.watchlist_page = watchlist_positions_page.WatchlistPositionsPage()
        self.asset_allocation_page = asset_allocation.AssetAllocation()
        sb.insert_report('asset allocation', _("Asset allocation"))
        sb.tree.expand_all()

        sb.connect("unselect", self.on_sidebar_unselect)
        sb.connect("select", self.on_sidebar_select)

        # connect signals
        handlers = [self, self.account_page, sb, self.watchlist_page, self.asset_allocation_page]
        handlers.extend(self.portfolio_pages)
        builder.connect_signals(HandlerFinder(handlers))

        # set min size
        screen = self.window.get_screen()
        width = int(screen.get_width() * 0.66)
        height = int(screen.get_height() * 0.66)
        self.window.set_size_request(width, height)

        size = self.config.get_option('size', section='Gui')
        if size is not None:
            width, height = eval(size)
            self.window.resize(width, height)

        pos = self.config.get_option('hpaned position', 'Gui') or width * 0.25
        self.hpaned.set_position(int(pos))

        # config entries are strings...
        if self.config.get_option('maximize', section='Gui') == 'True':
            self.window.maximize()
            self.maximized = True
        else:
            self.maximized = False

        # display everything
        self.window.show_all()
Example #3
0
    def __init__(self):
        Gtk.VBox.__init__(self)
        self.configParser = avernusConfig()

        section = self._add_section(_('Charts'))
        self._add_option(section, _('Include child categories'), 'categoryChildren')

        section = self._add_section(_('Category Assignments'))
        self._add_option(section, _('Include already categorized transactions'), 'assignments categorized transactions')

        section = self._add_section(_('Transactions'))
        self._add_option(section, _('Show horizontal grid lines'), 'transactionGrid')
Example #4
0
    def __init__(self, parent=None, account=None):
        Gtk.Dialog.__init__(self, self.TITLE, parent
                            , Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT,
                     (Gtk.STOCK_CANCEL, Gtk.ResponseType.REJECT,))
        self.set_size_request(self.WIDTH, self.HEIGHT)

        self.account = account
        self.config = config.avernusConfig()
        self.transactions = []
        self._init_widgets()

        response = self.run()
        self.process_result(response=response)
    def visible_cb(self, model, iterator, userdata):
        transaction = model[iterator][0]
        if transaction:
            # check settings
            if not self.b_show_transfer and transaction.transfer:
                return False
            if not self.b_show_uncategorized and not transaction.category:
                return False

            # check categoriess
            if self.single_category:
                # return False if the category does not match, move on to the
                # other checks if it does
                if not transaction.category:
                    # if it does not have a category, it cannot be true
                    return False
                if not transaction.category == self.single_category:
                    # if the category does not match the selected there is still
                    # the chance that recursive is activated
                    config = avernusConfig()
                    pre = config.get_option('categoryChildren', 'Account')
                    pre = pre == "True"
                    if pre:
                        # recursive is activated
                        parents = transaction.category.get_parent_categories()
                        if not self.single_category in parents:
                            # the selected category is also not one of the parents
                            return False
                    else:
                        # recursive is deactivated, wrong category
                        return False

            # check daterange
            if self.range_start and transaction.date < self.range_start \
                    or self.range_end and transaction.date > self.range_end:
                return False

            # check searchstring
            if not self.searchstring:
                return True
            if self.searchstring in transaction.description.lower() \
                    or self.searchstring in str(transaction.amount) \
                    or transaction.category and self.searchstring in transaction.category.name.lower():
                return True
        return False
    def __init__(self, account=None, parent=None):
        self.builder = Gtk.Builder()
        self.builder.add_from_file(get_ui_file("account/import_csv_dialog.glade"))
        self.dlg = self.builder.get_object("dialog")
        self.dlg.set_transient_for(parent)
        self.import_button = self.builder.get_object("import_button")
        self.builder.connect_signals(self)

        self.account = account
        self.config = config.avernusConfig()
        self.importer = csvimporter.CsvImporter()
        self.b_categories = self.config.get_option('category_assignments_on_import') == 'True'
        self.importer.do_categories = self.b_categories
        self.b_file = False
        self.b_account = not account is None

        self._init_widgets()
        self.dlg.show_all()
        response = self.dlg.run()
        self.process_result(response=response)
Example #7
0
def main():
    check_dependencies()
    try:
        init_translations()
        # Support for command line options.
        parser = optparse.OptionParser(version='%prog ' + avernus.__version__)
        parser.add_option("-d", "--debug", action="store_true", dest="debug", help=_("enable debug output"))
        parser.add_option("-f", "--file", dest="datafile", help="set database file")
        (options, args) = parser.parse_args()
        init_logger(options.debug)
        init_icons()
        db_file = options.datafile
        if db_file == None:
            configs = config.avernusConfig()
            default_file = os.path.join(config.config_path, 'avernus.db')
            db_file = configs.get_option('database file', default=default_file)

        from avernus.objects import db
        db.set_db(db_file)
        db.connect(True)

        GObject.threads_init()

        from avernus.gui.mainwindow import MainWindow
        main_window = MainWindow()
        try:
            Gtk.main()
        except:
            main_window.on_destroy()
            raise
    except:
        print "crashed ... !!"
        import traceback
        traceback.print_exc()
        db.close_session()
        threads.terminate_all()
        exit(1)
Example #8
0
    def __init__(self):
        Gtk.VBox.__init__(self)
        self.configParser = avernusConfig()

        section = self._add_section(_('Appearance'))
        self._add_option(section, _('Save vertical space'), 'smallPosition')
Example #9
0
    def __init__(self):
        Gtk.VBox.__init__(self)
        self.configParser = avernusConfig()

        section = self._add_section(_('Axis'))
        self._add_option(section, _('Normalize Y Axis'), 'normalize_y_axis')
Example #10
0
logger = logging.getLogger(os.path.basename(__file__))
logger.setLevel(logging.DEBUG)
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
consolehandler = logging.StreamHandler()
consolehandler.setFormatter(formatter)
logger.addHandler(consolehandler)

version = '1'

parser = optparse.OptionParser(version='%prog ' + version)
parser.add_option("-f", "--file", dest="datafile", help="set database file")
(options, args) = parser.parse_args()
db_file = options.datafile
if db_file == None:
# getting the database file
    configs = config.avernusConfig()
    default_file = os.path.join(config.config_path, 'avernus.db')
    db_file = configs.get_option('database file', default=default_file)

#building the database connection
con = None
# tables that do not need a sanity check
omitted_tables = ['container', 'source_info', 'meta', 'dimension']
# Reasons for omitting tables:
#    container: author does not know what could be checked (empty type??)
#    source_info: author does not know what this table stores
#    account_category: check does not fit standard functions

### TODO: More complex checks

table_names = []
def get_category(transaction):
    for rule in rules:
        # print "Probing rule ", rule, transaction.description
        if match_transaction(rule, transaction):
            return rule.category
    return None


def apply_categorization_rules(*args):
    if config.get_option('assignments categorized transactions', 'Account') == 'True':
        b_include_categorized = True
    else:
        b_include_categorized = False
    global rules
    rules = get_all_active_by_priority()
    transactions = account.get_all_transactions()
    # print "Size: ", len(transactions)
    for transaction in transactions:
        if b_include_categorized or transaction.category is None:
            cat = get_category(transaction)
            if cat != transaction.category:
                transaction.category = get_category(transaction)
                logger.debug("Category assignment %s -> %s"
                              % (transaction, cat))
            yield transaction


config = avernusConfig()
rules = get_all_active_by_priority()