Exemple #1
0
    def index_view(self):

        if request.method == 'POST':
            form = request.form.copy().to_dict()
            new_mapping = Mappings(source='ofx',
                                   keyword=form['keyword'],
                                   positive_credit_subaccount_id=form['subaccount'],
                                   negative_debit_subaccount_id=form['subaccount'],
                                   )
            try:
                db.session.add(new_mapping)
                db.session.commit()
            except IntegrityError:
                db.session.rollback()
            mapping_id, = (db.session.query(Mappings.id)
                           .filter(Mappings.source == 'ofx')
                           .filter(Mappings.keyword == form['keyword']).one())
            apply_single_ofx_mapping(mapping_id)
            return redirect(url_for('banking/transactions.index_view'))

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

        new_mapping_form = NewOFXTransactionMapping()

        self._template_args['new_mapping_form'] = new_mapping_form
        return super(TransactionsModelView, self).index_view()
Exemple #2
0
    def index_view(self):

        if request.method == 'POST':
            form = request.form.copy().to_dict()
            new_mapping = Mappings(
                source='ofx',
                keyword=form['keyword'],
                positive_credit_subaccount_id=form['subaccount'],
                negative_debit_subaccount_id=form['subaccount'],
            )
            try:
                db.session.add(new_mapping)
                db.session.commit()
            except IntegrityError:
                db.session.rollback()
            mapping_id, = (db.session.query(
                Mappings.id).filter(Mappings.source == 'ofx').filter(
                    Mappings.keyword == form['keyword']).one())
            apply_single_ofx_mapping(mapping_id)
            return redirect(url_for('banking/transactions.index_view'))

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

        new_mapping_form = NewOFXTransactionMapping()

        self._template_args['new_mapping_form'] = new_mapping_form
        return super(TransactionsModelView, self).index_view()
Exemple #3
0
 def favorite(self, expense_account, keyword):
     new_mapping = Mappings()
     new_mapping.source = 'ofx'
     new_mapping.keyword = keyword
     new_mapping.positive_credit_subaccount_id = expense_account
     new_mapping.negative_debit_subaccount_id = expense_account
     try:
         db.session.add(new_mapping)
         db.session.commit()
     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'))
Exemple #4
0
 def favorite(self, expense_account, keyword):
     new_mapping = Mappings()
     new_mapping.source = 'ofx'
     new_mapping.keyword = keyword
     new_mapping.positive_credit_subaccount_id = expense_account
     new_mapping.negative_debit_subaccount_id = expense_account
     try:
         db.session.add(new_mapping)
         db.session.commit()
     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'))