Created
March 25, 2012 21:49
-
-
Save svs/2200124 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class LoanHistory | |
include DataMapper::Resource | |
property :loan_id, Integer, :key => true | |
property :date, Date, :key => true # the day that this record applies to | |
property :created_at, DateTime # automatic, nice for benchmarking runs | |
# some properties for similarly named methods of a loan: | |
property :scheduled_outstanding_total, Decimal, :nullable => false | |
property :scheduled_outstanding_principal, Decimal, :nullable => false | |
property :actual_outstanding_total, Decimal, :nullable => false | |
property :actual_outstanding_principal, Decimal, :nullable => false | |
property :actual_outstanding_interest, Decimal, :nullable => false | |
property :scheduled_principal_due, Decimal, :nullable => false | |
property :scheduled_interest_due, Decimal, :nullable => false | |
property :principal_due, Decimal, :nullable => false # this is total principal due - total interest due | |
property :interest_due, Decimal, :nullable => false # and represents the amount payable today | |
property :principal_due_today, Decimal, :nullable => false # this is the principal and interest | |
property :interest_due_today, Decimal, :nullable => false #that has become payable today | |
property :principal_paid, Decimal, :nullable => false | |
property :interest_paid, Decimal, :nullable => false | |
property :total_principal_due, Decimal, :nullable => false | |
property :total_interest_due, Decimal, :nullable => false | |
property :total_principal_paid, Decimal, :nullable => false | |
property :total_interest_paid, Decimal, :nullable => false | |
property :advance_principal_paid, Decimal, :nullable => false # these three rows | |
property :advance_interest_paid, Decimal, :nullable => false # are for the total advance paid on the | |
property :total_advance_paid, Decimal, :nullable => false # loan, without adjustments | |
property :advance_principal_paid_today, Decimal, :nullable => false | |
property :advance_interest_paid_today, Decimal, :nullable => false | |
property :total_advance_paid_today, Decimal, :nullable => false | |
property :advance_principal_adjusted, Decimal, :nullable => false | |
property :advance_interest_adjusted, Decimal, :nullable => false | |
property :advance_principal_adjusted_today, Decimal, :nullable => false | |
property :advance_interest_adjusted_today, Decimal, :nullable => false | |
property :total_advance_adjusted_today, Decimal, :nullable => false | |
property :advance_principal_outstanding, Decimal, :nullable => false # | |
property :advance_interest_outstanding, Decimal, :nullable => false # these are adjusted balances | |
property :total_advance_outstanding, Decimal, :nullable => false # | |
property :principal_in_default, Decimal, :nullable => false | |
property :interest_in_default, Decimal, :nullable => false | |
property :total_fees_due, Decimal, :nullable => false | |
property :total_fees_paid, Decimal, :nullable => false | |
property :fees_due_today, Decimal, :nullable => false | |
property :fees_paid_today, Decimal, :nullable => false | |
property :principal_at_risk, Decimal, :nullable => false | |
property :status, Enum.send('[]', *STATUSES) | |
property :last_status, Enum.send('[]', *STATUSES) | |
# add a column per status to track approvals, disbursals, etc. both count and amount | |
STATUSES.each do |status| | |
property "#{status.to_s}_count".to_sym, Integer, :nullable => false, :default => 0 | |
property status, Decimal, :nullable => false, :default => 0 | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment