Пример #1
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)
Пример #2
0
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)
Пример #3
0
 def test_monthly_billing_schedule(self):
     self.policy.billing_schedule = "Monthly"
     self.assertFalse(self.policy.invoices)
     pa = PolicyAccounting(self.policy.id)
     self.assertEquals(len(self.policy.invoices),
                       12)  #assertEquals is the test
     self.assertEquals(self.policy.invoices[0].amount_due,
                       self.policy.annual_premium / 12)
Пример #4
0
 def test_annual_billing_schedule(self):
     self.policy.billing_schedule = "Annual"
     #No invoices currently exist
     self.assertFalse(self.policy.invoices)
     #Invoices should be made when the class is initiated
     pa = PolicyAccounting(self.policy.id)
     self.assertEquals(len(self.policy.invoices), 1)
     self.assertEquals(self.policy.invoices[0].amount_due,
                       self.policy.annual_premium)
Пример #5
0
 def test_cancel_policy(self):
     """
         Test to see if descriptive_cancel_policy successfully cancels policy in database.
     """
     pa = PolicyAccounting(self.policy.id)
     pa.descriptive_cancel_policy("This policy is canceled.")
     self.assertEquals(self.policy.description, "This policy is canceled.")
     self.assertEquals(self.policy.cancel_date, datetime.now().date())
     self.assertEquals(self.policy.status, "Canceled")
Пример #6
0
def view_policy():
    policy_number = request.args['policy_number']
    date = request.args['date']
    date = datetime.datetime.strptime(date, '%Y%m%d').date()
    policy = Policy.query.filter_by(policy_number=policy_number).one()
    pa = PolicyAccounting(policy.id)
    if policy is None:
        abort(404)

    return render_template('view-policy.html', policy=policy, date=date, pa=pa)
Пример #7
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)
Пример #8
0
 def test_change_billing_schedule(self):
     p1 = Policy('Test Policy', date(2015, 01, 01), 500)
     p1.billing_schedule = 'Quarterly'
     db.session.add(p1)
     db.session.commit()
     pa = PolicyAccounting(p1.id)
     self.assertEquals(len(pa.policy.invoices), 4)
     self.assertEquals(pa.policy.invoices[0].amount_due,
                       pa.policy.annual_premium / 4)
     pa.change_billing_schedule('Monthly')
     #filters out deleted invoices
     active_invoices = Invoice.query.filter_by(policy_id = pa.policy.id)\
                         .filter(Invoice.deleted != 1)\
                         .all()
     self.assertEquals(len(active_invoices), 12)
     self.assertEquals(active_invoices[0].amount_due,
                       pa.policy.annual_premium / 12)
Пример #9
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)
Пример #10
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)