diff --git a/biweeklybudget/alembic/versions/9dc8545963be_account_interest_and_payoff_attributes.py b/biweeklybudget/alembic/versions/9dc8545963be_account_interest_and_payoff_attributes.py index 2285bb5f..4a9d891e 100644 --- a/biweeklybudget/alembic/versions/9dc8545963be_account_interest_and_payoff_attributes.py +++ b/biweeklybudget/alembic/versions/9dc8545963be_account_interest_and_payoff_attributes.py @@ -26,6 +26,14 @@ def upgrade(): nullable=True ) ) + op.add_column( + 'accounts', + sa.Column( + 'prime_rate_margin', + sa.Numeric(precision=5, scale=4), + nullable=True + ) + ) op.add_column( 'accounts', sa.Column( @@ -47,4 +55,5 @@ def upgrade(): def downgrade(): op.drop_column('accounts', 'min_payment_class_name') op.drop_column('accounts', 'interest_class_name') + op.drop_column('accounts', 'prime_rate_margin') op.drop_column('accounts', 'apr') diff --git a/biweeklybudget/flaskapp/templates/account.html b/biweeklybudget/flaskapp/templates/account.html index 86ef86f5..b9a4d368 100644 --- a/biweeklybudget/flaskapp/templates/account.html +++ b/biweeklybudget/flaskapp/templates/account.html @@ -40,6 +40,14 @@ APR {{ acct.apr|decimal_to_percent }}% + + Prime Rate Margin + {{ acct.prime_rate_margin|decimal_to_percent }} + + + Effective APR (calculated) + {{ acct.effective_apr|decimal_to_percent + Interest Class {{ acct.interest_class_name }} diff --git a/biweeklybudget/interest.py b/biweeklybudget/interest.py index 2da2c19b..3fb46bb2 100644 --- a/biweeklybudget/interest.py +++ b/biweeklybudget/interest.py @@ -110,7 +110,7 @@ def _make_statements(self, accounts): icharge = acct.latest_ofx_interest_charge istmt = icharge.first_statement_by_date icls = INTEREST_CALCULATION_NAMES[acct.interest_class_name]['cls']( - acct.apr + acct.effective_apr ) bill_period = _BillingPeriod(icharge.date_posted.date()) min_pay_cls = MIN_PAYMENT_FORMULA_NAMES[ diff --git a/biweeklybudget/models/account.py b/biweeklybudget/models/account.py index fd165106..b64c3fe9 100644 --- a/biweeklybudget/models/account.py +++ b/biweeklybudget/models/account.py @@ -115,6 +115,9 @@ class Account(Base, ModelAsDict): #: Finance rate (APR) for credit accounts apr = Column(Numeric(precision=5, scale=4)) + #: Margin added to the US Prime Rate to determine APR, for credit accounts + prime_rate_margin = Column(Numeric(precision=5, scale=4)) + #: Name of the :py:class:`biweeklybudget.interest._InterestCalculation` #: subclass used to calculate interest for this account. interest_class_name = Column(String(70)) @@ -310,3 +313,15 @@ def latest_ofx_interest_charge(self): logger.debug('Latest OFX Interest Charge for account %s: %s', self, t) return t + + @property + def effective_apr(self): + """ + Return the effective APR for a credit account. If + :py:attr:`~.prime_rate_margin` is not Null, return it. Otherwise, return + :py:attr:`~.apr`. + + :return: Effective account APR + :rtype: decimal.Decimal + """ + return self.apr