Пример #1
0
from pacioli.extensions import admin
from pacioli.models import (db, Paystubs, PaystubItems)
from pacioli.views import PrivateModelView

admin.add_view(PrivateModelView(Paystubs, db.session, category='Payroll'))


class PaystubItemsModelView(PrivateModelView):
    form_choices = dict(description=[
        ('Bonus Earnings',
         'Bonus Earnings'), ('Federal Income Tax', 'Federal Income Tax'),
        ('Health Insurance Premium', 'Health Insurance Premium'
         ), ('Long Term Disability Benefit', 'Long Term Disability Benefit'),
        ('Long Term Disability Company Portion',
         'Long Term Disability Company Portion'
         ), ('Medicare Tax',
             'Medicare Tax'), ('NY City Income Tax', 'NY City Income Tax'),
        ('NY State Income Tax',
         'NY State Income Tax'), ('Post-Tax Transit', 'Post-Tax Transit'),
        ('Pre-Tax Transit',
         'Pre-Tax Transit'), ('Regular Earnings', 'Regular Earnings'),
        ('Roth 401k Contribution', 'Roth 401k Contribution'
         ), ('Social Security Tax', 'Social Security Tax')
    ])
    form_columns = ('description', 'this_period', 'year_to_date', 'statutory',
                    'paystub', 'rate', 'hours')


admin.add_view(
    PaystubItemsModelView(PaystubItems, db.session, category='Payroll'))
Пример #2
0
    def index_view(self, subaccount=None, period_interval=None, period=None, cumulative=None):
        period_interval = request.view_args.get('period_interval', 'YYYY-MM')
        if not request.view_args.get('period', None):
            most_recent_period, = (self.session.query(db.func.to_char(JournalEntries.timestamp, period_interval))
                       .order_by(db.func.to_char(JournalEntries.timestamp, period_interval).desc()).first())
            request.view_args['period'] = most_recent_period

        self._template_args['period_interval'] = period_interval
        self._template_args['period'] = request.view_args['period']
        self._template_args['period_intervals'] = [('YYYY', 'Annual'), ('YYYY-Q', 'Quarterly'), ('YYYY-MM', 'Monthly'), ('YYYY-MM-DD', 'Daily')]
        self._template_args['periods'] = (self.session.query(db.func.to_char(JournalEntries.timestamp, self._template_args['period_interval']))
                                          .order_by(db.func.to_char(JournalEntries.timestamp, self._template_args['period_interval'])
                                                    .desc()).distinct().limit(30))
        self._template_args['periods'] = [p[0] for p in self._template_args['periods']]
        return super(JournalEntriesView, self).index_view()
admin.add_view(JournalEntriesView(DetailedJournalEntries, db.session, category='Bookkeeping', endpoint='journalentries', name='Journal Entries'))


class TaxonomyModelView(PrivateModelView):
    form_extra_fields = dict(name=StringField('Name'))
    column_searchable_list = ['name']
    create_modal = True
    edit_modal = True


class SubaccountsModelView(PrivateModelView):
    column_list = ('name', 'parent')
    column_labels = dict(parent='Account')


class AccountsModelView(PrivateModelView):
Пример #3
0
                        db.func.to_char(JournalEntries.timestamp,
                                        period_interval_name)).distinct():
                    transaction = connection.begin()

                    params = dict(debit_subaccount=debit_subaccount,
                                  credit_subaccount=credit_subaccount,
                                  period_interval_name=period_interval_name,
                                  period_name=period_name)
                    connection.execute(query_text, **params)
                    transaction.commit()
                    transaction.close()
        connection.close()
        return redirect(url_for('trialbalances.index_view'))


admin.add_view(
    TrialBalancesView(TrialBalances, db.session, category='Accounting'))


class IncomeStatementsView(PrivateModelView):
    list_template = 'financial_statements.html'
    column_list = ('subaccount', 'net_changes')
    # column_default_sort = {'field': 'net_changes',
    #                        'sort_desc': True,
    #                        'absolute_value': True}
    column_default_sort = ('net_changes', True)
    column_searchable_list = ['subaccount']
    column_filters = column_list
    column_sortable_list = column_list
    column_formatters = dict(net_changes=fs_linked_currency_formatter)

    can_edit = False
Пример #4
0
                                         allow_blank=False)

        new_mapping_form = NewTransactionMapping()

        self._template_args['new_mapping_form'] = new_mapping_form
        return super(AmazonItemView, self).index_view()

    @expose('/apply-all-mappings/')
    def apply_all_mappings_view(self):
        apply_all_mappings()
        return redirect(url_for('amazonitems.index_view'))


admin.add_view(
    AmazonItemView(AmazonTransactions,
                   db.session,
                   endpoint='amazonitems',
                   name='Amazon Items',
                   category='Amazon'))


class AmazonOrdersView(PrivateModelView):
    can_edit = False
    can_create = False
    can_delete = False
    can_export = True
    column_display_actions = False

    column_list = ('id', 'order_date')
    column_filters = column_list
    column_searchable_list = column_list
    # column_default_sort = {'field': 'order_date', 'sort_desc': True, 'absolute_value': False}
Пример #5
0
    def index_view(self, subaccount=None, period_interval=None, period=None, cumulative=None):
        period_interval = request.view_args.get('period_interval', 'YYYY-MM')
        if not request.view_args.get('period', None):
            most_recent_period, = (self.session.query(db.func.to_char(JournalEntries.timestamp, period_interval))
                       .order_by(db.func.to_char(JournalEntries.timestamp, period_interval).desc()).first())
            request.view_args['period'] = most_recent_period

        self._template_args['period_interval'] = period_interval
        self._template_args['period'] = request.view_args['period']
        self._template_args['period_intervals'] = [('YYYY', 'Annual'), ('YYYY-Q', 'Quarterly'), ('YYYY-MM', 'Monthly'), ('YYYY-MM-DD', 'Daily')]
        self._template_args['periods'] = (self.session.query(db.func.to_char(JournalEntries.timestamp, self._template_args['period_interval']))
                                          .order_by(db.func.to_char(JournalEntries.timestamp, self._template_args['period_interval'])
                                                    .desc()).distinct().limit(30))
        self._template_args['periods'] = [p[0] for p in self._template_args['periods']]
        return super(JournalEntriesView, self).index_view()
admin.add_view(JournalEntriesView(DetailedJournalEntries, db.session, category='Bookkeeping', endpoint='journalentries', name='Journal Entries'))


class TaxonomyModelView(PrivateModelView):
    form_extra_fields = dict(name=StringField('Name'))
    column_searchable_list = ['name']
    create_modal = True
    edit_modal = True


class SubaccountsModelView(PrivateModelView):
    column_list = ('name', 'description', 'parent', 'tax_tags')
    column_labels = dict(parent='Account')
    column_filters = column_list
    column_searchable_list = column_list[:-1]
    column_formatters = dict(description=html_formatter)
Пример #6
0
            return redirect(url_for('amazonitems.index_view'))

        class NewTransactionMapping(Form):
            keyword = HiddenField()
            subaccount = AjaxSelectField(loader=self.ajax_subaccount_loader, allow_blank=False)

        new_mapping_form = NewTransactionMapping()

        self._template_args['new_mapping_form'] = new_mapping_form
        return super(AmazonItemView, self).index_view()

    @expose('/apply-all-mappings/')
    def apply_all_mappings_view(self):
        apply_all_mappings()
        return redirect(url_for('amazonitems.index_view'))
admin.add_view(AmazonItemView(AmazonTransactions, db.session, endpoint='amazonitems', name='Amazon Items', category='Amazon'))


class AmazonOrdersView(PrivateModelView):
    can_edit = False
    can_create = False
    can_delete = False
    can_export = True
    column_display_actions = False

    column_list = ('id', 'order_date')
    column_filters = column_list
    column_searchable_list = column_list
    column_default_sort = {'field': 'order_date', 'sort_desc': True, 'absolute_value': False}
    column_labels = dict(id='ID')
admin.add_view(AmazonOrdersView(AmazonOrders, db.session, category='Amazon'))
Пример #7
0
        except IntegrityError:
            db.session.rollback()
        mapping_id, = (db.session.query(Mappings.id).filter(Mappings.source == 'ofx')
                       .filter(Mappings.keyword == keyword).one())
        apply_single_ofx_mapping(mapping_id)
        return redirect(url_for('banking/transactions.index_view'))

    @expose('/apply-all-mappings/')
    def apply_all_mappings_view(self):
        apply_all_mappings()
        return redirect(url_for('banking/transactions.index_view'))


admin.add_view(TransactionsModelView(model=Transactions,
                                     session=db.session,
                                     name='Transactions',
                                     category='Banking',
                                     endpoint='banking/transactions'))


class AccountsFromModelView(OFXModelView):
    column_default_sort = {'field': 'id', 'sort_desc': False, 'absolute_value': False}
    column_list = ['id', 'name', 'subclass']
    column_searchable_list = ['name']
    column_filters = column_list
    column_labels = dict(name='Name', subclass='Account Type', id='ID')
    column_formatters = dict(subclass=account_formatter)

    can_edit = True
    form_columns = ['name']
Пример #8
0
from pacioli.extensions import admin
from pacioli.models import (db, Paystubs, PaystubItems)
from pacioli.views import PrivateModelView

admin.add_view(PrivateModelView(Paystubs, db.session, category='Payroll'))


class PaystubItemsModelView(PrivateModelView):
    form_choices = dict(description=[('Bonus Earnings', 'Bonus Earnings'),
                                     ('Federal Income Tax', 'Federal Income Tax'),
                                     ('Health Insurance Premium', 'Health Insurance Premium'),
                                     ('Long Term Disability Benefit', 'Long Term Disability Benefit'),
                                     ('Long Term Disability Company Portion', 'Long Term Disability Company Portion'),
                                     ('Medicare Tax', 'Medicare Tax'),
                                     ('NY City Income Tax', 'NY City Income Tax'),
                                     ('NY State Income Tax', 'NY State Income Tax'),
                                     ('Post-Tax Transit', 'Post-Tax Transit'),
                                     ('Pre-Tax Transit', 'Pre-Tax Transit'),
                                     ('Regular Earnings', 'Regular Earnings'),
                                     ('Roth 401k Contribution', 'Roth 401k Contribution'),
                                     ('Social Security Tax', 'Social Security Tax')])
    form_columns = ('description', 'this_period', 'year_to_date', 'statutory', 'paystub', 'rate', 'hours')

admin.add_view(PaystubItemsModelView(PaystubItems, db.session, category='Payroll'))
Пример #9
0
from pacioli.extensions import admin
from pacioli.functions.ofx_functions import sync_ofx
from pacioli.models import (db, Users, Roles, Connections, Mappings,
                            ConnectionResponses, MappingOverlaps)
from pacioli.views import PrivateModelView
from pacioli.views.utilities import date_formatter, link_mapping_formatter, link_transaction_search_formatter


class UserModelView(PrivateModelView):
    column_list = ('id', 'email', 'active', 'confirmed_at', 'current_login_at',
                   'last_login_ip', 'current_login_ip', 'login_count')
    column_formatters = dict(confirmed_at=date_formatter,
                             current_login_at=date_formatter)


admin.add_view(UserModelView(Users, db.session, category='Admin'))
admin.add_view(PrivateModelView(Roles, db.session, category='Admin'))


class ConnectionsModelView(PrivateModelView):
    list_template = 'connections.html'
    column_list = ('id', 'source', 'type', 'url', 'org', 'fid',
                   'routing_number', 'account_number', 'user', 'synced_at')
    form_choices = dict(type=[('Checking', 'Checking'), ('Savings', 'Savings'),
                              ('Credit Card', 'Credit Card')],
                        source=[('ofx', 'ofx'), ('amazon', 'amazon'),
                                ('gmail', 'gmail')])
    column_editable_list = column_list[1:]
    column_labels = dict(id='ID', url='URL', fid='FID')
    column_formatters = dict(synced_at=date_formatter)
Пример #10
0
                        db.func.to_char(JournalEntries.timestamp,
                                        period_interval_name)).distinct():
                    transaction = connection.begin()

                    params = dict(debit_subaccount=debit_subaccount,
                                  credit_subaccount=credit_subaccount,
                                  period_interval_name=period_interval_name,
                                  period_name=period_name)
                    connection.execute(query_text, **params)
                    transaction.commit()
                    transaction.close()
        connection.close()
        return redirect(url_for('trialbalances.index_view'))


admin.add_view(TrialBalancesView(TrialBalances, db.session,
                                 category='Accounting'))


class IncomeStatementsView(PrivateModelView):
    list_template = 'financial_statements.html'
    column_list = ('subaccount', 'net_changes')
    column_default_sort = {'field': 'net_changes',
                           'sort_desc': True,
                           'absolute_value': True}
    column_searchable_list = ['subaccount']
    column_filters = column_list
    column_sortable_list = column_list
    column_formatters = dict(net_changes=fs_linked_currency_formatter)

    can_edit = False
    can_create = False
Пример #11
0
from flask import url_for, redirect
from flask_admin import expose
from pacioli.extensions import admin
from pacioli.functions.ofx_functions import sync_ofx
from pacioli.models import (db, Users, Roles, Connections, Mappings, ConnectionResponses, MappingOverlaps)
from pacioli.views import PrivateModelView
from pacioli.views.utilities import date_formatter, link_mapping_formatter, link_transaction_search_formatter


class UserModelView(PrivateModelView):
    column_list = ('id', 'email', 'active', 'confirmed_at', 'current_login_at',
                   'last_login_ip', 'current_login_ip', 'login_count')
    column_formatters = dict(confirmed_at=date_formatter, current_login_at=date_formatter)


admin.add_view(UserModelView(Users, db.session, category='Admin'))
admin.add_view(PrivateModelView(Roles, db.session, category='Admin'))


class ConnectionsModelView(PrivateModelView):
    list_template = 'connections.html'
    column_list = ('id', 'source', 'type', 'url', 'org', 'fid', 'routing_number',
                   'account_number', 'user', 'synced_at')
    form_choices = dict(type=[('Checking', 'Checking'), ('Savings', 'Savings'), ('Credit Card', 'Credit Card')],
                        source=[('ofx', 'ofx'), ('amazon', 'amazon'), ('gmail', 'gmail')])
    column_editable_list = column_list[1:]
    column_labels = dict(id='ID', url='URL', fid='FID')
    column_formatters = dict(synced_at=date_formatter)

    def create_model(self, form):
        # TODO: store the password in an encrypted form
Пример #12
0
            db.session.rollback()
        mapping_id, = (db.session.query(
            Mappings.id).filter(Mappings.source == 'ofx').filter(
                Mappings.keyword == keyword).one())
        apply_single_ofx_mapping(mapping_id)
        return redirect(url_for('banking/transactions.index_view'))

    @expose('/apply-all-mappings/')
    def apply_all_mappings_view(self):
        apply_all_mappings()
        return redirect(url_for('banking/transactions.index_view'))


admin.add_view(
    TransactionsModelView(model=Transactions,
                          session=db.session,
                          name='Transactions',
                          category='Banking',
                          endpoint='banking/transactions'))


class AccountsFromModelView(OFXModelView):
    # column_default_sort = {'field': 'id', 'sort_desc': False, 'absolute_value': False}
    column_default_sort = ('id', False)
    column_list = ['id', 'name', 'subclass']
    column_searchable_list = ['name']
    column_filters = column_list
    column_labels = dict(name='Name', subclass='Account Type', id='ID')
    column_formatters = dict(subclass=account_formatter)

    can_edit = True
    form_columns = ['name']