Example #1
0
def get_invoices(p_id):
    invoices = Invoice.query.filter_by(policy_id = p_id).all()
    payments = Payment.query.filter_by(policy_id = p_id).all()
    pa = PolicyAccounting(p_id)
    date_cursor = invoices[len(invoices)-1].cancel_date
    amt = pa.return_account_balance(date_cursor)
    return render_template('index.html', invoices=invoices, payments=payments, balance=amt)
Example #2
0
 def test_quarterly_on_last_installment_bill_date(self):
     self.policy.billing_schedule = "Quarterly"
     pa = PolicyAccounting(self.policy.id)
     invoices = Invoice.query.filter_by(policy_id=self.policy.id)\
                             .order_by(Invoice.bill_date).all()
     self.assertEquals(
         pa.return_account_balance(date_cursor=invoices[3].bill_date), 1200)
def get_invoices():
    if request.method == 'POST':
        #pull information from form submission
        policy_number = request.form['policy_number']
        date_cursor = request.form['date']

        #filter to policy number that was submitted
        policy = Policy.query.filter(Policy.policy_number == policy_number).first()
        if policy:
            pa = PolicyAccounting(policy.id)
            #filter invoices to policy that was submitted
            invoices = Invoice.query.filter(Invoice.policy_id == policy.id)\
                                    .filter(Invoice.deleted != 1).all()
            #filter paid invoices
            payments = Payment.query.filter(Payment.policy_id == policy.id).all()
            paid = len(payments)

            account_balance = pa.return_account_balance(date_cursor)

            return render_template('index.html', display=True, balance=account_balance, date=date_cursor, policy=policy_number,invoices=invoices, paid=paid)
        else:
            error = "Sorry the policy you entered may not exist."
            return render_template('index.html', display=False, error=error)

    else:
        error = "Error: Please try again!"
        return render_template('index.html', error=error)
Example #4
0
 def test_quarterly_on_second_installment_bill_date_with_full_payment(self):
     self.policy.billing_schedule = "Quarterly"
     pa = PolicyAccounting(self.policy.id)
     invoices = Invoice.query.filter_by(policy_id=self.policy.id)\
                             .order_by(Invoice.bill_date).all()
     self.payments.append(pa.make_payment(contact_id=self.policy.named_insured,
                                          date_cursor=invoices[1].bill_date, amount=600))
     self.assertEquals(pa.return_account_balance(date_cursor=invoices[1].bill_date), 0)
Example #5
0
 def test_quarterly_on_second_installment_bill_date_with_full_payment(self):
     self.policy.billing_schedule = "Quarterly"
     pa = PolicyAccounting(self.policy.id)
     invoices = Invoice.query.filter_by(policy_id=self.policy.id)\
                             .order_by(Invoice.bill_date).all()
     self.payments.append(
         pa.make_payment(contact_id=self.policy.named_insured,
                         date_cursor=invoices[1].bill_date,
                         amount=600))
     self.assertEquals(
         pa.return_account_balance(date_cursor=invoices[1].bill_date), 0)
    def test_quarterly_on_second_installment_bill_date_with_full_payment(self):
        self.policy.billing_schedule = "Quarterly"
        pa = PolicyAccounting(self.policy.id)
        invoices = Invoice.query.filter_by(policy_id=self.policy.id)\
                                .order_by(Invoice.bill_date).all()

        payment = pa.make_payment(contact_id=self.policy.named_insured,
                                  date_cursor=invoices[1].bill_date, amount=600)
        if payment:
            self.payments.append(payment)  # should be None, but keep track of it just in case

        # self.assertEquals(pa.return_account_balance(date_cursor=invoices[1].bill_date), 0) --original test, fails

        # new test, a better test that ensures the payment didn't go through
        self.assertEquals(pa.return_account_balance(date_cursor=invoices[1].bill_date), pa.policy.annual_premium/2)
Example #7
0
def index():
    # You will need to serve something up here.
    if request.method == 'POST':
        policy_num = request.form['policy_num']
        date_cursor = request.form['date']
        policy = Policy.query.filter(Policy.policy_number == policy_num).one()
        invoices = Invoice.query.filter_by(policy_id = policy.id)\
                                .filter(Invoice.bill_date <= date_cursor)\
                                .filter(Invoice.deleted == False)\
                                .all()
        payments = Payment.query.filter_by(policy_id = policy.id)\
                                .filter(Payment.transaction_date <= date_cursor)\
                                .all()
        
        pa = PolicyAccounting(policy.id)
        amt = pa.return_account_balance(date_cursor)
        return render_template('index.html', policy_number=policy_num, date_posted=date_cursor, invoices=invoices, payments=payments, balance=amt)
    else:
        return render_template('index.html', invoices = [], payments = [])
Example #8
0
 def test_quarterly_on_eff_date(self):
     self.policy.billing_schedule = "Quarterly"
     pa = PolicyAccounting(self.policy.id)
     self.assertEquals(pa.return_account_balance(date_cursor=self.policy.effective_date), 300)
Example #9
0
 def test_annual_on_eff_date(self):
     self.policy.billing_schedule = "Annual"
     pa = PolicyAccounting(self.policy.id)
     self.assertEquals(pa.return_account_balance(date_cursor=self.policy.effective_date), 1200)
Example #10
0
 def test_quarterly_on_last_installment_bill_date(self):
     self.policy.billing_schedule = "Quarterly"
     pa = PolicyAccounting(self.policy.id)
     invoices = Invoice.query.filter_by(policy_id=self.policy.id)\
                             .order_by(Invoice.bill_date).all()
     self.assertEquals(pa.return_account_balance(date_cursor=invoices[3].bill_date), 1200)
Example #11
0
 def test_quarterly_on_eff_date(self):
     self.policy.billing_schedule = "Quarterly"
     pa = PolicyAccounting(self.policy.id)
     self.assertEquals(
         pa.return_account_balance(date_cursor=self.policy.effective_date),
         300)
Example #12
0
 def test_annual_on_eff_date(self):
     self.policy.billing_schedule = "Annual"
     pa = PolicyAccounting(self.policy.id)
     self.assertEquals(
         pa.return_account_balance(date_cursor=self.policy.effective_date),
         1200)