Пример #1
0
    def process(self, commit, *args, **kwargs):
        data = commit.data

        loan = Loan()

        loan.id = data.get("id")
        loan.open = data.get("open")
        loan.approved = data.get("approved")
        loan.position = data.get("position")
        loan.expiration = data.get("expiration")
        loan.amount = data.get("amount")
        loan.cosigner = data.get("cosigner")
        loan.model = data.get("model")
        loan.creator = data.get("creator")
        loan.oracle = data.get("oracle")
        loan.borrower = data.get("borrower")
        loan.callback = data.get("callback")
        loan.salt = data.get("salt")
        loan.loanData = data.get("loanData")
        loan.created = data.get("created")
        loan.descriptor = Descriptor(**data.get("descriptor"))
        loan.currency = data.get("currency")
        loan.status = data.get("status")
        # loan.commits.append(commit)
        commit.save()
        loan.save()
Пример #2
0
def newloans():
    from coinage import db
    from customers.models import Customer
    from models import Interest, Loan
    try:
        if not current_user.can_create:
            return redirect(url_for('loans.loans'))
        form = AddForm()
        _customer = Customer.query.with_entities(
            Customer.id, Customer.name).order_by(Customer.name)
        interest = Interest.query.order_by(Interest.value)
        form.customer_name.choices = form.comaker_name.choices = [
            (g.id, g.name) for g in _customer
        ]
        form.interest.choices = [(g.value, g.name) for g in interest]
        if request.method == 'GET':
            form.interest.data = 5
            form.payment.data = 0
            form.total_payment.data = 0
        if request.method == 'POST':
            if form.validate_on_submit():
                try:
                    loan = Loan()
                    loan.customer_id = form.customer_name.data
                    loan.date_release = request.form['date_rel']
                    loan.amount = Decimal(form.amount.data.replace(',', ''))
                    loan.date_due = request.form['date_due']
                    loan.interest = form.interest.data
                    loan.total_payable = Decimal(
                        form.total_payable.data.replace(',', ''))
                    loan.payment = Decimal(form.payment.data.replace(',', ''))
                    loan.total_payment = Decimal(
                        form.total_payment.data.replace(',', ''))
                    loan.outstanding_balance = Decimal(
                        form.outstanding_balance.data.replace(',', ''))
                    db.session.add(loan)
                    db.session.commit()
                    flash(u'Record was successfully created.', 'success')
                    return redirect(url_for('loans.loans'))
                except Exception as e:
                    flash(e.message, 'danger')
            else:
                flash(form.errors, 'danger')

        return render_template("addloan.html", form=form)
    except TemplateNotFound:
        abort(404)
Пример #3
0
def newloans():
    from coinage import db
    from customers.models import Customer
    from models import Interest, Loan
    try:
        if not current_user.can_create:
            return redirect(url_for('loans.loans'))
        form = AddForm()
        _customer = Customer.query.with_entities(Customer.id, Customer.name).order_by(Customer.name)
        interest = Interest.query.order_by(Interest.value)
        form.customer_name.choices = form.comaker_name.choices = [(g.id, g.name) for g in _customer]
        form.interest.choices = [(g.value, g.name) for g in interest]
        if request.method == 'GET':
            form.interest.data = 5
            form.payment.data = 0
            form.total_payment.data = 0
        if request.method == 'POST':
            if form.validate_on_submit():
                try:
                    loan = Loan()
                    loan.customer_id = form.customer_name.data
                    loan.date_release = request.form['date_rel']
                    loan.amount = Decimal(form.amount.data.replace(',', ''))
                    loan.date_due = request.form['date_due']
                    loan.interest = form.interest.data
                    loan.total_payable = Decimal(form.total_payable.data.replace(',', ''))
                    loan.payment = Decimal(form.payment.data.replace(',', ''))
                    loan.total_payment = Decimal(form.total_payment.data.replace(',', ''))
                    loan.outstanding_balance = Decimal(form.outstanding_balance.data.replace(',', ''))
                    db.session.add(loan)
                    db.session.commit()
                    flash(u'Record was successfully created.', 'success')
                    return redirect(url_for('loans.loans'))
                except Exception as e:
                    flash(e.message, 'danger')
            else:
                flash(form.errors, 'danger')

        return render_template("addloan.html", form=form)
    except TemplateNotFound:
        abort(404)