示例#1
0
    def index_view(self):
        if request.method == 'POST':
            form = request.form.copy().to_dict()
            new_mapping = Mappings()
            new_mapping.source = 'amazon'
            new_mapping.keyword = form['keyword']
            new_mapping.positive_debit_subaccount_id = form['subaccount']
            new_mapping.positive_credit_subaccount_id = 'Amazon Suspense Account'
            new_mapping.negative_debit_subaccount_id = 'Amazon Suspense Account'
            new_mapping.negative_credit_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 == 'amazon').filter(
                    Mappings.keyword == form['keyword']).one())
            apply_single_amazon_mapping(mapping_id)
            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()
示例#2
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'))
示例#3
0
    def index_view(self):
        if request.method == 'POST':
            form = request.form.copy().to_dict()
            new_mapping = Mappings()
            new_mapping.source = 'amazon'
            new_mapping.keyword = form['keyword']
            new_mapping.positive_debit_subaccount_id = form['subaccount']
            new_mapping.positive_credit_subaccount_id = 'Amazon Suspense Account'
            new_mapping.negative_debit_subaccount_id = 'Amazon Suspense Account'
            new_mapping.negative_credit_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 == 'amazon')
                           .filter(Mappings.keyword == form['keyword']).one())
            apply_single_amazon_mapping(mapping_id)
            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()
示例#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'))