Skip to content

Commit

Permalink
added *_defaulted_today fields to loan_history and cacher.
Browse files Browse the repository at this point in the history
  • Loading branch information
Siddharth Sharma committed Dec 15, 2011
1 parent 791213e commit 7b1c287
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
13 changes: 13 additions & 0 deletions app/models/cacher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,19 @@ def total_default
(principal_in_default + interest_in_default).abs
end

def principal_defaulted_today
[scheduled_principal_due - principal_paid,0].max
end

def interest_defaulted_today
[scheduled_interest_due - interest_paid,0].max
end

def total_defaulted_today
principal_defaulted_today + interest_defaulted_today
end


def icash_interest_in_default
[0,interest_in_default + total_advance_outstanding].min
end
Expand Down
12 changes: 12 additions & 0 deletions app/models/loan_history.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,18 @@ def total_default
(principal_in_default + interest_in_default).abs.round(2)
end

def principal_defaulted_today
[scheduled_principal_due - principal_paid,0].max
end

def interest_defaulted_today
[scheduled_interest_due - interest_paid,0].max
end

def total_defaulted_today
principal_defaulted_today + interest_defaulted_today
end

# this adjusts defaulted interest against advance principal
def icash_interest_in_default
[0,interest_in_default + total_advance_outstanding].min
Expand Down
2 changes: 1 addition & 1 deletion app/views/report_formats/_fields.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
});
});
});
- keys = (Cacher::COLS + Cacher::FLOW_COLS).map(&:to_s) + ["icash_interest_in_default", "icash_total_in_default", "status"]
- keys = (Cacher::COLS + Cacher::FLOW_COLS).map(&:to_s) + ["icash_interest_in_default", "icash_total_in_default", "principal_defaulted_today", "interest_defaulted_today", "total_defaulted_today", "status"]
- report_keys = @report_format.keys ? @report_format.keys.map(&:to_s) : []
- remaining_keys = keys - report_keys
%table.form#user_group_form
Expand Down

0 comments on commit 7b1c287

Please sign in to comment.