Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

Conflicts:
	app/models/loan.rb
  • Loading branch information...
commit 10dc43289c9c2854598144cafdeb4c4bb717e97f 2 parents dd4e980 + 84c3c73
Siddharth Sharma authored
View
15 app/controllers/cachers.rb
@@ -27,15 +27,16 @@ def generate
(@from_date..@to_date).each{|date| @model.update(:date => date)}
else
@model.update(:date => (@date || Date.today))
- if Branch.count > 0
- if @from_date and @to_date
- (@from_date..@to_date).each{|date| BranchCache.update(date)}
+ if Branch.count > 0
+ if @from_date and @to_date
+ (@from_date..@to_date).each{|date| BranchCache.update(date)}
+ else
+ BranchCache.update(@date || Date.today)
+ end
+ redirect request.referer
else
- BranchCache.update(@date || Date.today)
+ redirect url(:browse, :action => 'index'), :message => {:error => "No data found to generate report"}
end
- redirect request.referer
- else
- redirect url(:browse, :action => 'index'), :message => {:error => "No data found to generate report"}
end
end
View
1  app/controllers/centers.rb
@@ -101,6 +101,7 @@ def create(center)
@center.branch = @branch # set direct context
end
if @center.save
+ debugger
@center_meeting_day.center_id = @center.id
@center_meeting_day.save
if params[:format] and API_SUPPORT_FORMAT.include?(params[:format])
View
3  app/controllers/clients.rb
@@ -233,7 +233,8 @@ def bulk_entry
if params[:clients].keys.length > 0 # there are some errors
render # errors will be shown
else
- redirect resource(@center), :message => {:notice => "all clients succesfully added"}
+ return_to = session.user.role == :data_entry ? url(:data_entry) : resource(@center)
+ redirect return_to, :message => {:notice => "all clients succesfully added"}
end
end
end
View
5 app/models/cacher.rb
@@ -8,11 +8,6 @@ class Cacher
property :model_id, Integer, :nullable => false, :index => true, :unique => [:model_name, :date], :key => true
property :branch_id, Integer, :index => true, :key => true
property :center_id, Integer, :index => true, :key => true
-<<<<<<< HEAD
-
- property :funding_line_id, Integer, :index => true
-=======
->>>>>>> 53f1094295262f8d6c7e371a03dedd10ddff71af
property :scheduled_outstanding_total, Float, :nullable => false
property :scheduled_outstanding_principal, Float, :nullable => false
property :actual_outstanding_total, Float, :nullable => false
View
3  app/models/loan.rb
@@ -145,7 +145,7 @@ def set_bullet_installments
belongs_to :verified_by, :child_key => [:verified_by_user_id], :model => 'User'
belongs_to :repayment_style
- belongs_to :loan_pool
+ # belongs_to :loan_pool
belongs_to :organization, :parent_key => [:org_guid], :child_key => [:parent_org_guid], :nullable => true
property :parent_org_guid, String, :nullable => true
@@ -614,7 +614,6 @@ def make_payments(payments, context = :default, defer_update = false)
def pay_prorata(total, received_on)
# calculates total interest and principal payable in this amount and divides the amount proportionally
int_to_pay = prin_to_pay = amt_to_pay = 0
- $debug = true
# load relevant loan_history rows
loan_history.all( :order => [:date]).map do |lh|
next if amt_to_pay >= total or ((lh.interest_due + lh.principal_due) == 0)
View
2  app/views/center_meeting_days/_fields.html.haml
@@ -32,4 +32,4 @@
&nbsp;
to
&nbsp;
- = date_select_for @cmd, :valid_upto
+ = date_select_for @cmd, :valid_upto, :max_date => Date.new(2100,12,31)
View
2  app/views/centers/_fields.html.haml
@@ -1,3 +1,5 @@
+- if session.user.role == :data_entry
+ = hidden_field :name => "return", :value => "/data_entry"
%table{:style => "width: 80%"}
%tr
%td
View
11 app/views/clients/bulk_entry.html.haml
@@ -6,14 +6,15 @@
%th
In branch
%td
- = select :name => 'branch_id', :id => "branch_selector", :collection => Branch.all, :text_method => :name, :value_method => :id, :selected => params[:branch_id].to_s, :prompt => 'Select a branch', :selected => params[:branch_id]
+ = select :name => 'branch_id', :id => "branch_selector", :collection => Branch.all, :text_method => :name, :value_method => :id, :selected => params[:branch_id].to_s, :prompt => 'Select a branch', :selected => params[:branch_id], :class => 'chosen'
%tr
%th
and center
%td
- = select :name => 'center_id', :id => 'center_selector', :collection => Center.all(:branch_id => params[:branch_id]), :text_method => :name, :value_method => :id, :selected => params[:center_id].to_s, :prompt => 'Select a center', :selected => params[:center_id]
- %span.red
- = @errors[:center]
+ = select :name => 'center_id', :id => 'center_selector', :collection => Center.all(:branch_id => params[:branch_id]), :text_method => :name, :value_method => :id, :selected => params[:center_id].to_s, :prompt => 'Select a center', :selected => params[:center_id], :class => 'chosen', :style => "width: 300px"
+ - if @errors[:center]
+ %span.red
+ = @errors[:center]
%table
%thead
@@ -52,4 +53,4 @@
= text_field :name => "clients[#{i}][spouse_name]", :value => (params[:clients] and params[:clients][i.to_s][:spouse_name])
%th
= date_select "clients[#{i}][spouse_date_of_birth]",(params[:clients] and params[:clients][i.to_s][:spouse_date_of_birth]) , :id => "client_#{i}_spouse_dob", :min_date => Date.today-36500, :max_date => Date.today-1000
- = submit 'add clients'
+ = submit 'add clients'
View
2  config/misfit.rb
@@ -35,7 +35,7 @@ def controllers_from_models(role)
:admin => all_models,
:mis_manager => all_models_except([:user, :admin]),
:data_entry => {
- :all => [:client, :loan, :payment, :document, :client_group, :group, :insurance_company, :insurance_policy, :cgt, :grt, :staff_member],
+ :all => [:client, :loan, :payment, :document, :client_group, :group, :insurance_company, :insurance_policy, :cgt, :grt, :staff_member, :center],
},
:staff_member => {
:all => [:center, :client, :loan, :payment, :document, :client_group, :group, :comment, :insurance_company, :staff_member, :location, :branch_diary, :stock_register, :asset_register]
View
8 lib/datevector.rb
@@ -53,17 +53,17 @@ def get_next_n_dates(n, from = Date.today, override_to_date = false)
def get_dates(from = @from, to = @to)
# get the dates as specified by this vector from the from date uptil "to" if "to" is a Date, or else get "to" such dates if an integer
- raise ArgumentError.new("from and must be a date") unless from.class == Date
+ raise ArgumentError.new("from must be a date") unless from.class == Date
raise ArgumentError.new("to must be either a date or an Integer") unless (to.class == Date or to.class == Fixnum)
- d = from; rv = []; i = 0
+ d = @from; rv = []; i = 0
case @period
when :week
while (to.class == Date ? d <= to : i <= to)
[@what].flatten.map do |wday| # convert :tuesday into [:tuesday] so we can treat everything as an array
d = d.next_(wday)
- rv << d if (to.class == Date ? d <= to : i <= to)
+ rv << d if ((to.class == Date ? d <= to : i <= to) and d >= from)
d = d + ((@of_every - 1) * 7)
- i += 1
+ i = rv.count - 1
end
end
when :month
View
9 lib/extensions.rb
@@ -111,7 +111,8 @@ def allow_read_only
return rights_from_access_rules
end
- def _can_access?(route, params = nil)
+ def _can_access?(route, params = nil)
+ # boy, we really do need a new ACL!!
user_role = self.role
return true if user_role == :admin
return false if route[:controller] == "journals" and route[:action] == "edit"
@@ -144,6 +145,7 @@ def _can_access?(route, params = nil)
return(is_funder? and allow_read_only)
end
+
@staff ||= self.staff_member
return true if @action == "redirect_to_show"
if @controller=="documents" and CUD_Actions.include?(@action)
@@ -155,7 +157,10 @@ def _can_access?(route, params = nil)
end
if role == :data_entry
- return ["new", "edit", "create", "update"].include?(@action) if ["clients", "loans", "client_groups"].include?(@controller)
+ return true if @controller == "searches"
+ return ["new", "edit", "create", "update", "bulk_entry"].include?(@action) if ["clients", "loans", "client_groups", "centers", "data_entry/centers"].include?(@controller)
+ return ["centers"].include?(@action) if ["branches"].include?(@controller) # this is so data entry can get a list of centers on bulk add clients page.
+
return (@action == "disbursement_sheet" or @action == "day_sheet") if @controller == "staff_members"
end
View
66 spec/models/branch_spec.rb
@@ -27,12 +27,76 @@
@branch.name = nil
@branch.should_not be_valid
end
-
+
it "should not be valid with a name shorter than 3 characters" do
@branch.name = "ok"
@branch.should_not be_valid
end
+ it "should valid with a name more than 3 character" do
+ @branch.name = "branch"
+ @branch.should be_valid
+ end
+
+ it "should not be valid without a creation_date " do
+ @branch.creation_date= nil
+ @branch.should_not be_valid
+ end
+
+ it "should not be valid without a code" do
+ @branch.code= nil
+ @branch.should_not be_valid
+ end
+
+ it "should not be valid with a code greater than 10 character" do
+ @branch.code="1234567890123"
+ @branch.should_not be_valid
+ end
+
+ it "should be valid with code" do
+ @branch.code="ok"
+ @branch.should be_valid
+ end
+
+ it"should be valid without contact number" do
+ @branch.contact_number= nil
+ @branch.should be_valid
+ end
+
+ it "should not be valid with contact_number grater than 40 character" do
+ @branch.contact_number="12345678901234567890123456789012345678901234567890"
+ @branch.should_not be_valid
+ end
+
+ it "should be valid with contact_number less than 40 character" do
+ @branch.contact_number="1235678901234567890"
+ @branch.should be_valid
+ end
+
+ it"should be valid without landmark name" do
+ @branch.landmark= nil
+ @branch.should be_valid
+ end
+ it"should be valid with a landmark name less than 100 character" do
+ @branch.landmark="abcdefghijklmnopqrstuvwxyz"
+ @branch.should be_valid
+ end
+
+ it"should not be valid with a landmark name more than 100 character" do
+ @branch.landmark="abcdefghijklmnopqrstuvwxyzasdsdsdfsfghgfhgfghfhfghdfsdfgfdgfsfdgfdfsgfdgfdgfcgfdfghdfdgfdghdgfsgcghdgshgdgdfhdghfdghfhdgfdgdgfcgdddhfdghdghhjgjgjfghfhjghfghfgdjgdgfdfdfgfffhggfgfdgfdhgkhfkhjghgljghjftydtrsrfyufgxdfgfcgxdfzgfcgfzdszgfcgfzdfxjghcgfjhgyuflghjfjgdfxgc"
+ @branch.should_not be_valid
+ end
+
+ it"should not be valid without area_id" do
+ @branch.area_id=nil
+ @branch.should_not be_valid
+ end
+
+ it"should be valid with area_id" do
+ @branch.area_id="1"
+ @branch.should be_valid
+ end
+
it "should be able to 'have' centers" do
center = Factory(:center, :branch => @branch, :manager => @branch.manager)
center.should be_valid
Please sign in to comment.
Something went wrong with that request. Please try again.