Permalink
Browse files

Merge branch 'master' of git.mostfit.in:mostfit

  • Loading branch information...
2 parents a93b760 + eec22a5 commit cd75bea3c4cbcc4fbef97e686120b17e1b6a538d Siddharth committed Jun 27, 2011
@@ -133,7 +133,6 @@ def bulk_update_funding_line
@loans = Loan.all(:funding_line => nil).paginate(:page => params[:page], :per_page => 20)
display @loans
else
- debugger
@results = {}
@loans = Loan.all(:id => params[:loan].keys)
@loans.each do |loan|
@@ -42,7 +42,6 @@ def create(insurance_product)
end
def update(id, insurance_product)
- debugger
@insurance_product = InsuranceProduct.get(id)
raise NotFound unless @insurance_product
fees = []
View
@@ -45,29 +45,29 @@ def create
@loan.loan_product = @loan_product
msg = {}
if @loan.save
- debugger
msg[:notice] = "Loan '#{@loan.id}' was successfully created"
- params[:fees].keys.each do |fee_id|
- debugger
- @app_fee = []
- @fee = Fee.get(fee_id)
- if @fee
- payable_models ||= Fee::PAYABLE.map{|m| [m[0], [m[1], m[2]]]}.to_hash
- method = payable_models[@fee.payable_on][1] if @fee
- if params.include?(:fee_date)
- if params[:fee_date].empty?
- date = (@loan.insurance_policy.send(method) if @loan.insurance_policy.respond_to?(method))
- else
- date = (Date.strptime(params[:fee_date], Mfi.first.date_format))
+ if params[:fees]
+ params[:fees].keys.each do |fee_id|
+ @app_fee = []
+ @fee = Fee.get(fee_id)
+ if @fee
+ payable_models ||= Fee::PAYABLE.map{|m| [m[0], [m[1], m[2]]]}.to_hash
+ method = payable_models[@fee.payable_on][1] if @fee
+ if params.include?(:fee_date)
+ if params[:fee_date].empty?
+ date = (@loan.insurance_policy.send(method) if @loan.insurance_policy.respond_to?(method))
+ else
+ date = (Date.strptime(params[:fee_date], Mfi.first.date_format))
+ end
+ end
+ if date
+ @app_fees << ApplicableFee.new(:applicable_on => date, :amount => params[:insurance_policy][:premium], :fee => @fee,
+ :applicable_id => @loan.id, :applicable_type => 'Loan')
end
end
- if date
- @app_fees << ApplicableFee.new(:applicable_on => date, :amount => params[:insurance_policy][:premium], :fee => @fee,
- :applicable_id => @loan.id, :applicable_type => 'Loan')
- end
+ result = @app_fees.map{|f| f.save}
+ msg[:error] = "However, #{result.select{|r| false}.count} insurance premium could not be applied as a fee" if result.include?[false]
end
- result = @app_fees.map{|f| f.save}
- msg[:error] = "However, #{result.select{|r| false}.count} insurance premium could not be applied as a fee" if result.include?[false]
end
redirect(params[:return] || resource(@branch, @center, @client), :message => msg)
else
@@ -97,7 +97,7 @@ def disbursement_sheet(id)
file = @staff_member.generate_disbursement_pdf(@date)
filename = File.join(Merb.root, "doc", "pdfs", "staff", @staff_member.name, "disbursement_sheets", "disbursement_#{@staff_member.id}_#{@date.strftime('%Y_%m_%d')}.pdf")
if file
- send_data(File.read(file), :filename => filename)
+ send_data(File.read(filename), :filename => filename)
else
redirect resource(@staff_member), :message => {:notice => "No centers for collection today"}
end
@@ -300,9 +300,14 @@ def chart(url, width=430, height=200, id=nil)
end
def centers_paying_today_collection(date)
- [["","---"]] + Center.paying_today(session.user, date).map {|c| [c.id.to_s,c.name]}
+ Center.paying_today(session.user, date).reduce({}) do |h, c|
+ key = "Branch: #{c.branch.name}"
+ value = [c.id.to_s, c.name]
+ (h[key] ||= []) << value
+ h
+ end
end
-
+
def audit_trail_url
"/audit_trails?"+params.to_a.map{|x| "audit_for[#{x[0]}]=#{x[1]}"}.join("&")
end
@@ -19,6 +19,7 @@ class AccountingPeriod
validates_with_method :cannot_overlap
validates_with_method :closing_done_sequentially
+ validates_with_method :all_account_balances_are_verified_before_closing_accounting_period
def <=>(other)
return (end_date <=> other.begin_date) if other.respond_to?(:begin_date) && other.begin_date
@@ -110,4 +111,11 @@ def to_s
"Accounting period #{name} beginning #{begin_date.strftime("%d-%B-%Y")} through #{end_date.strftime("%d-%B-%Y")}"
end
+ def all_account_balances_are_verified_before_closing_accounting_period
+ return true unless self.closed
+ AccountBalance.all(:accounting_period => self).each do |ab|
+ return [false,"#{ab.account.name} has not been verified for this period"] unless ab.verified?
+ end
+ return true
+ end
end
View
@@ -19,9 +19,9 @@ class Fee
[:client_date_joined, Client, :date_joined],
[:loan_installment_dates, Loan, :installment_dates],
[:policy_issue_date, InsurancePolicy, :date_from],
- [:policy_loan_application_date, InsurancePolicy, :loan_applied_on],
- [:policy_loan_approval_date, InsurancePolicy, :loan_approved_on],
- [:policy_loan_disbursal_date, InsurancePolicy, :loan_disbursal_date],
+ #[:policy_loan_application_date, InsurancePolicy, :loan_applied_on],
+ #[:policy_loan_approval_date, InsurancePolicy, :loan_approved_on],
+ #[:policy_loan_disbursal_date, InsurancePolicy, :loan_disbursal_date],
[:penalty, Loan, nil]
]
FeeDue = Struct.new(:applicable, :paid, :due)
@@ -73,7 +73,7 @@ def description
end
def Fee.fees_for_insurance_products(fees)
- fees.select {|fee| fee.payable_on == :policy_issue_date}
+ fees.select {|fee| fee.payable_on.to_s =~ /policy/}
end
def self.payable_dates
@@ -33,11 +33,11 @@ def description
"#{insurance_product.name}: Rs.#{sum_insured}"
end
- [:applied_on, :approved_on, :disbursal_date].each do |p|
- define_method "loan_#{p}" do
- loan.send(p) if loan
- end
- end
+ # [:applied_on, :approved_on, :disbursal_date].each do |p|
+ # define_method "loan_#{p}" do
+ # loan.send(p) if loan
+ # end
+ # end
private
def set_status
View
@@ -9,7 +9,7 @@ class Loan
before :save, :update_scheduled_maturity_date
after :save, :update_history_caller # also seems to do updates
after :save, :levy_fees
- before :create, :update_cycle_number
+ after :create, :update_cycle_number
before :destroy, :verified_cannot_be_deleted
# after :destroy, :update_history
@@ -74,6 +74,21 @@ class Loan
property :_scheduled_maturity_date, Date
+ # Caching baby!
+
+ property :staleness_frequency, Integer
+
+ property :c_center_id, Integer
+ property :c_branch_id, Integer
+ property :c_scheduled_maturity_date, Date
+ property :c_maturity_date, Date
+ property :c_actual_first_payment_date, Date
+ property :c_last_status, Integer
+ property :c_principal_received, Float
+ property :c_interest_received, Float
+ property :c_last_payment_received_on, Date
+ property :c_last_payment_id, Integer
+ property :c_stale?, Boolean
# property :taken_over_on, Date
# property :taken_over_on_installment_number, Integer
View
@@ -25,7 +25,6 @@ def unverify_account_balances
if account_balance and account_balance.verified?
account_balance.verified_by = nil
account_balance.verified_on = nil
- debugger
return [false, "Error, Account was not Un-Verfied"] unless account_balance.save
end
end
@@ -47,6 +47,7 @@ def generate
if self.center_id
groups = {}
+ @center = Center.get(center_id)
@center.client_groups.each{|g|
groups[g.id] = g
}
@@ -33,7 +33,11 @@
%td{:colspan => 3}
- absent_count = Attendance.all(:status => "absent").count.to_f
- total_count = Attendance.all.count.to_f
- = ((1 - (absent_count/total_count))*100).round(2)
+ - attendance = (1 - (absent_count/total_count))*100
+ - if attendance > 0
+ = (attendance).round(2)
+ - else
+ = "-"
%tr
%td
Closed/repaid loans (number)
@@ -64,3 +64,4 @@
= @clients.count
clients in this center
= link_to 'Create new client', resource(@branch, @center, :clients, :new), :class => "add"
+ = link_to "Bulk entry of loans", url(:enter_loans, :action => :bulk_form, :query => @center), :class => "edit"
@@ -45,6 +45,7 @@
%p
= link_to 'edit this center\'s details', resource(@branch, @center, :edit), :class => "edit"
= link_to 'add a new client', resource(@branch, @center, :clients, :new), :class => "add"
+ = link_to "Bulk entry of loans", url(:enter_loans, :action => :bulk_form, :query => @center), :class => "edit"
%div.tab_container
%ul.tabs
%li#centers
@@ -204,7 +204,7 @@
%th
Centers repaying today
%td
- = select :name => 'center_id', :collection => centers_paying_today_collection(@date), :selected => session[:center_id]
+ = select :name => 'center_id', :collection => centers_paying_today_collection(@date), :selected => session[:center_id], :prompt => 'Select a center'
%tr
%th
or any other center
@@ -31,20 +31,37 @@
Premium
%td
= text_field :premium
- %tr{:style => "background-color:#fff370"}
- %td
- Apply premium as
- %td
- - @loan_product.insurance_product.fees.each do |f|
- %ul
- %li
- = check_box(:name => "fee_#{f.id}", :checked => true)
- = f.name
- %tr{:style => "background-color:#fff370"}
- %td
- payable on
- %td
- = date_select :fee_date, nil
+ -# - if @insurance_policy.id.nil? and @loan_product
+ -# %tr{:style => "background-color:#fff370"}
+ -# %td
+ -# Apply premium as
+ -# %td
+ -# - @loan_product.insurance_product.fees.each do |f|
+ -# %ul
+ -# %li
+ -# = check_box(:name => "fee_#{f.id}", :checked => true)
+ -# = f.name
+ -# %tr{:style => "background-color:#fff370"}
+ -# %td
+ -# payable on
+ -# %td
+ -# = date_select :fee_date, nil
+ -# - elsif not @insurance_policy.loan.nil?
+ -# %tr{:style => "background-color:#fff370"}
+ -# %td
+ -# Apply premium as
+ -# %td
+ -# - @loan_product = LoanProduct.get(@insurance_policy.loan.loan_product_id) if @loan_product.nil?
+ -# - @loan_product.insurance_product.fees.each do |f|
+ -# %ul
+ -# %li
+ -# = check_box(:name => "fee_#{f.id}", :checked => true)
+ -# = f.name
+ -# %tr{:style => "background-color:#fff370"}
+ -# %td
+ -# payable on
+ -# %td
+ -# = date_select :fee_date, nil
%tr
%td
Date from
View
@@ -8,12 +8,12 @@ msgid "मंजूर\340\245\200"
msgstr "मंजूर\340\245\200"
msgctxt "center.approval.no_center"
-msgid "किसी भी केन्द्र से जुड़\340\245\200"
-msgstr "किसी भी केन्द्र से जुड़\340\245\200"
+msgid "किसी भी केंद्र से जुड़ा नहीं "
+msgstr "किसी भी केंद्र से जुड़ा नहीं "
msgctxt "center.approval.not_approval"
msgid "कोई मंजूरी आ\340\244\234"
-msgstr "कोई मंजूरी आ\340\244\234"
+msgstr "आज कोई मंजूरी नहीं "
msgctxt "center.approval.on_time"
msgid "समय प\340\244\260"
@@ -33,15 +33,15 @@ msgstr "स्थित\340\244\277"
msgctxt "center.disbursal.label"
msgid "प्रार्थनापत्रो\340\244\202"
-msgstr "प्रार्थनापत्रो\340\244\202"
+msgstr "वितरण "
msgctxt "center.disbursal.no_group"
msgid "नहीं किसी भी समूह से जुड़\340\245\207"
msgstr "नहीं किसी भी समूह से जुड़\340\245\207"
msgctxt "center.disbursal.not_disbursal"
msgid "आज कोई प्रार्थनापत्रो\340\244\202"
-msgstr "आज कोई प्रार्थनापत्रो\340\244\202"
+msgstr "आज कोई वितरण नहीं "
msgctxt "center.disbursal.on_time"
msgid "समय प\340\244\260"
@@ -104,8 +104,8 @@ msgid "भुगता\340\244\250"
msgstr "भुगता\340\244\250"
msgctxt "center.payment.table.principal"
-msgid "प्रधानाचार्\340\244\257"
-msgstr "प्रधानाचार्\340\244\257"
+msgid "मूल धन"
+msgstr "मूल धन"
msgctxt "center.payment.table.total"
msgid "कु\340\244\262"
@@ -149,11 +149,11 @@ msgstr "इस दिन एक बैठक दा नहीं ह\340\245\210
msgctxt "center.weeksheet.record_link"
msgid "इन गतिविधियों रिकार्\340\244\241"
-msgstr "इन गतिविधियों रिकार्\340\244\241"
+msgstr "इन गतिविधिवोको रिकॉर्ड की जी ये "
msgctxt "center.weeksheet.title"
msgid "सप्ताह %{week} बैठक मेनू केंद्र के लिए %{name}"
-msgstr "सप्ताह %{week} बैठक मेनू केंद्र के लिए %{name}"
+msgstr "केंद्र %{name} के लिए मीटिंग : सप्ताह क्रं . %{week}"
msgctxt "region.error.validation.manager_not_present"
msgid "प्रबंधक रिक्त नहीं होना चाहि\340\244\217"
@@ -232,8 +232,8 @@ msgid "संपादन करन\340\244\276"
msgstr "संपादन करन\340\244\276"
msgctxt "region.index.table.id"
-msgid "इन ना\340\244\256"
-msgstr "इन ना\340\244\256"
+msgid "अनुक्रमाणिका "
+msgstr "अनुक्रमाणिका "
msgctxt "region.index.table.name"
msgid "ना\340\244\256"
Oops, something went wrong.

0 comments on commit cd75bea

Please sign in to comment.