diff --git a/app/controllers/admin/counties_controller.rb b/app/controllers/admin/counties_controller.rb index 20ef4c7..17bac16 100644 --- a/app/controllers/admin/counties_controller.rb +++ b/app/controllers/admin/counties_controller.rb @@ -7,7 +7,6 @@ class Admin::CountiesController < Admin::BaseController # GET /counties.xml def index @counties = County.where(:is_visible => true) - respond_to do |format| format.html # index.html.erb format.xml { render :xml => @counties } @@ -18,7 +17,10 @@ def index # GET /counties/1.xml def show @county = County.find(params[:id]) - + @county_tax_zone = CountyTaxZone.where(:county_id => @county.id)[0] + unless @county_tax_zone.nil? + @tax_zone = @county_tax_zone.tax_zone + end respond_to do |format| format.html # show.html.erb format.xml { render :xml => @county } @@ -29,7 +31,6 @@ def show # GET /counties/new.xml def new @county = County.new - respond_to do |format| format.html # new.html.erb format.xml { render :xml => @county } @@ -39,13 +40,20 @@ def new # GET /counties/1/edit def edit @county = County.find(params[:id]) + @county_tax_zone = CountyTaxZone.where(:county_id => @county.id)[0] + unless @county_tax_zone.nil? + @from = @county_tax_zone.from + @tax_zone = @county_tax_zone.tax_zone + unless @tax_zone.nil? + @number = @tax_zone.number + end + end end # POST /counties # POST /counties.xml def create @county = County.new(params[:county]) - respond_to do |format| if @county.save format.html { redirect_to([:admin, @county], :notice => 'County was successfully created.') } @@ -60,10 +68,10 @@ def create # PUT /counties/1 # PUT /counties/1.xml def update - @county = County.find(params[:id]) - + @county = County.find(params[:id]) + county_tax_zone = CountyTaxZone.where(:county_id => @county.id)[0] respond_to do |format| - if @county.update_attributes(params[:county]) + if county_tax_zone.update_attributes(params[:county]["county_tax_zone"]) and county_tax_zone.update_attributes(params[:county]["tax_zone"]) format.html { redirect_to([:admin, @county], :notice => 'County was successfully updated.') } format.xml { head :ok } else @@ -78,8 +86,7 @@ def update def destroy @county = County.find(params[:id]) @county.is_visible = false - state = @county.save - puts "woops", @county, @county.is_visible, state + state = @county.save respond_to do |format| format.html { redirect_to(admin_counties_url) } format.xml { head :ok } diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 6c93330..0069fae 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -3,8 +3,8 @@ class ApplicationController < ActionController::Base before_filter :set_locale_now, :authenticate_user!, :init_auth + before_filter :deactivated, :except => [:sign_out] before_filter :company_required, :if => proc { current_user } - helper :all # include all helpers, all the time attr_accessor :me @@ -20,11 +20,21 @@ class ApplicationController < ActionController::Base # filter_parameter_logging :password protected + + + def set_locale_now I18n.locale = session[:locale] = params[:locale] || session[:locale] || I18n.default_locale end + + def deactivated + if self.class != Devise::SessionsController && current_user && !current_user.active + return redirect_to destroy_user_session_path + end + end + def init_auth company_id = session[:company_id] Authorization.current_user = current_user diff --git a/app/controllers/assignments_controller.rb b/app/controllers/assignments_controller.rb index b349fad..9737426 100644 --- a/app/controllers/assignments_controller.rb +++ b/app/controllers/assignments_controller.rb @@ -1,5 +1,8 @@ class AssignmentsController < ApplicationController + attr_accessor :assignment + around_filter Log.log(:assignment), :only => [:update, :create] + def new @assignment = Assignment.new @other_info = {:comp => nil, :num => nil} diff --git a/app/controllers/journals_controller.rb b/app/controllers/journals_controller.rb index f0fbc7b..f796237 100644 --- a/app/controllers/journals_controller.rb +++ b/app/controllers/journals_controller.rb @@ -37,6 +37,7 @@ def show # GET /journals/new.xml def new @journal = Journal.new :journal_type_id => params[:journal_type_id] + @append = false if !@journal.journal_type raise "No journal type specified" end @@ -50,6 +51,7 @@ def new # GET /journals/1/edit def edit + @append = @journal.period.append_only? end # POST /journals @@ -64,10 +66,14 @@ def create @journal.company = @me.current_company params[:journal_operations].each do |key, value| + value.delete(:old) op = JournalOperation.new(value) - op.company = @me.current_company - @journal.journal_operations.push op + if op.amount != 0.0 && op.amount != nil + op.company = @me.current_company + @journal.journal_operations.push op + end end + @journal.save! cnt = @journal.journal_type.counter(@me.current_company) @@ -93,34 +99,52 @@ def update respond_to do |format| Journal.transaction do begin + append = @journal.period.append_only? - @journal.journal_operations.each do - |op| - if op.closed_operation then - op.closed_operation.journal_operations.each do - |op2| - op2.closed_operation = nil - op2.save + if append + params[:journal_operations].each do + |key, value| + if !value[:old] + op = JournalOperation.new(value) + if op.amount != 0.0 && op.amount != nil + op.company = @me.current_company + @journal.journal_operations.push op + end + end + end + @journal.save! + else + @journal.journal_operations.each do + |op| + if op.closed_operation then + op.closed_operation.journal_operations.each do + |op2| + op2.closed_operation = nil + op2.save + end end end - end - - @journal.update_attributes(params[:journal]) or raise ActiveRecord::Rollback - @journal.journal_operations.clear - params[:journal_operations].each do - |key, value| - op = JournalOperation.new(value) - op.company = @me.current_company - @journal.journal_operations.push op - end - @journal.save! + + @journal.update_attributes(params[:journal]) or raise ActiveRecord::Rollback + @journal.journal_operations.clear + params[:journal_operations].each do + |key, value| + value.delete(:old) + op = JournalOperation.new(value) + if op.amount != 0.0 && op.amount != nil + op.company = @me.current_company + @journal.journal_operations.push op + end + end + @journal.save! - cnt = @journal.journal_type.counter(@me.current_company) - if cnt.adjust_outside_of_sequence - cnt.counter = @journal.number+1 - cnt.save + cnt = @journal.journal_type.counter(@me.current_company) + if cnt.adjust_outside_of_sequence + cnt.counter = @journal.number+1 + cnt.save + end end - + flash[:notice] = 'Journal was successfully updated.' format.html { redirect_to(@journal) } format.xml { head :ok } diff --git a/app/controllers/reports_controller.rb b/app/controllers/reports_controller.rb index 7eccdef..5c95065 100644 --- a/app/controllers/reports_controller.rb +++ b/app/controllers/reports_controller.rb @@ -167,26 +167,30 @@ def ledger_balance end def ledger_journal - + accounts = nil periods = nil - journal_operations = nil params[:offset] ||= 0 @journal_operations = [] @count = 0; where = nil + #if specified accounts range is taken between from_account_number and to_account_number if !params[:from_account_number].blank? && !params[:to_account_number].blank? where = ["number BETWEEN ? AND ?", params[:from_account_number], params[:to_account_number]] elsif !params[:from_account_number].blank? + #from_account specified but not to_account where = ["number >= ?", params[:from_account_number]] elsif !params[:to_account_number].blank? + #to_account specified but not from_account where = ["number <= ?", params[:to_account_number]] end - + if where.nil? + #if no accounts specified where = ["is_result_account = ?"] - else + else + #if one of the accounts at least is specified where[0] += " AND is_result_account = ?" end where << false @@ -236,6 +240,9 @@ def ledger_journal where[0] += " AND unit_id = ?" where << params[:unit_id] end + unless params[:car_id].blank? + where[0] += " AND car_id = ?" + end @journal_operations = JournalOperation.joins(:journal).joins(:account).where(where).order( "account_id, journals.period_id, journal_operations.created_at").includes( diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 334a992..1a5c5e8 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -3,13 +3,15 @@ class UsersController < ApplicationController filter_resource_access - + + attr_accessor :user + around_filter Log.log(:user), :only => [:update, :create] def new - @user = User.new + @user = User.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @journal } - end + end end def create @@ -43,8 +45,6 @@ def index end def update - @user = User.find(params[:id]) - respond_to do |format| # don't update password if blank if params[:user][:password].blank? @@ -63,8 +63,6 @@ def update end def show - @user = User.find(params[:id]) - respond_to do |format| format.html # show.html.erb format.xml { render :xml => @user } @@ -72,7 +70,6 @@ def show end def edit - @user = User.find(params[:id]) 3.times { @user.assignments.build } end end diff --git a/app/models/county.rb b/app/models/county.rb index 2eea3ab..426f76f 100644 --- a/app/models/county.rb +++ b/app/models/county.rb @@ -1,3 +1,5 @@ class County < ActiveRecord::Base has_many :county_tax_zones + accepts_nested_attributes_for :county_tax_zones, :allow_destroy => false + validates_presence_of :name, :allow_nil => false end diff --git a/app/models/county_tax_zone.rb b/app/models/county_tax_zone.rb index 5838ebc..dca3bf4 100644 --- a/app/models/county_tax_zone.rb +++ b/app/models/county_tax_zone.rb @@ -1,3 +1,4 @@ class CountyTaxZone < ActiveRecord::Base belongs_to :county + belongs_to :tax_zone end diff --git a/app/models/journal.rb b/app/models/journal.rb index 21d9a17..7c97bf3 100644 --- a/app/models/journal.rb +++ b/app/models/journal.rb @@ -72,7 +72,7 @@ def self.report_ledger_balance(periods_to_balance, periods_to_balance_previous, inner join journal_operations on journals.id = journal_operations.journal_id inner join accounts on journal_operations.account_id = accounts.id where journals.company_id = #{company.id} - and periods.id in (#{_periods_to_balance}) + and periods.id in (#{_periods_to_balance}) and accounts.is_result_account = false" unless unit.blank? sql += " and journal_operations.unit_id = #{unit.id}" @@ -98,7 +98,7 @@ def self.report_ledger_balance(periods_to_balance, periods_to_balance_previous, inner join journal_operations on journals.id = journal_operations.journal_id inner join accounts on journal_operations.account_id = accounts.id where journals.company_id = #{company.id} - and periods.id in (#{_periods_to_balance_last}) + and periods.id in (#{_periods_to_balance_last}) and accounts.is_result_account = false" unless unit.blank? sql += " and journal_operations.unit_id = #{unit.id}" diff --git a/app/models/period.rb b/app/models/period.rb index 356f5c2..c4cdbbd 100644 --- a/app/models/period.rb +++ b/app/models/period.rb @@ -82,6 +82,10 @@ def elevate_status end self.status += 1 end + + def append_only? + return self.status == STATUSE_NAMES['Locked'] + end def to_s sprintf("%d %.2d", self.year, self.nr) diff --git a/app/models/tax_zone.rb b/app/models/tax_zone.rb index 383ca79..479bb60 100644 --- a/app/models/tax_zone.rb +++ b/app/models/tax_zone.rb @@ -1,3 +1,5 @@ class TaxZone < ActiveRecord::Base has_many :tax_zone_taxes + has_many :county_tax_zones + accepts_nested_attributes_for :county_tax_zones, :allow_destroy => false end diff --git a/app/models/tax_zone_tax.rb b/app/models/tax_zone_tax.rb index 2410df5..b926df0 100644 --- a/app/models/tax_zone_tax.rb +++ b/app/models/tax_zone_tax.rb @@ -1,4 +1,3 @@ class TaxZoneTax < ActiveRecord::Base belongs_to :tax_zone - end diff --git a/app/models/user.rb b/app/models/user.rb index 1da26c9..3b057c4 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -10,7 +10,12 @@ class User < ActiveRecord::Base has_many :assignments, :include => [:company, :role], :order => "companies.name" accepts_nested_attributes_for :assignments, :allow_destroy => true, :reject_if => proc { |attrs| attrs["company_id"].blank? || attrs["role_id"].blank? } + + def log_include + [:assignments] + end + # Include default devise modules. Others available are: # :token_authenticatable, :confirmable, :lockable, :timeoutable and :activatable, :registerable devise :database_authenticatable, :recoverable, :rememberable, @@ -33,7 +38,8 @@ def role_symbols end def open_periods(company = self.current_company) - Period.where(:company_id => company.id, :status => Period::STATUSE_NAMES['Open']) + + Period.where(:company_id => company.id, :status => [1,2,3]) end # declarative_auth wants a login attribute for the introspection ui diff --git a/app/views/admin/counties/_form.html.erb b/app/views/admin/counties/_form.html.erb index 8e928ad..6ff92c4 100644 --- a/app/views/admin/counties/_form.html.erb +++ b/app/views/admin/counties/_form.html.erb @@ -1,21 +1,14 @@ <%= form_for([:admin,@county]) do |f| %> - <% if @county.errors.any? %> -
-

<%= pluralize(@county.errors.count, "error") %> prohibited this county from being saved:

+ + <%= f.error_messages %> - -
- <% end %> - -
- <%= f.label :name %>
+

+ <%= f.label :name %> <%= f.text_field :name %> -

+

+

- <%= f.submit %> + <%= f.submit %>
+ <% end %> diff --git a/app/views/admin/counties/edit.html.erb b/app/views/admin/counties/edit.html.erb index 239f821..6dda727 100644 --- a/app/views/admin/counties/edit.html.erb +++ b/app/views/admin/counties/edit.html.erb @@ -1,10 +1,78 @@

Editing county

-<% if @county.is_visible == true %> - <%= render 'form' %> +<% if @county.is_visible == true %> + + <% if @county_tax_zone == nil %> + <%= t(:editing_county_error, :scope => :counties) %> + + <% else %> + + <%= form_for([:admin,@county]) do |f| %> + + <% if @county.errors.any? %> +
+

<%= pluralize(@county.errors.count, "error") %> prohibited this county from being saved:

+ +
+ <% end %> + +
+ +

+ <%= @county.name %> +

+ + <%= f.fields_for :county_tax_zone do |county_tax_zone| %> + + <% if @tax_zone.nil? %> +

+ <%= county_tax_zone.label :from %> + <%= county_tax_zone.text_field :from, :class=> :datepicker %> +

+ <% else %> +

+ <%= county_tax_zone.label :from %> + <%= county_tax_zone.text_field :from, :value => @from, :class=> :datepicker %> +

+ <% end %> + + <% end %> + + <%= f.fields_for :tax_zone do |tax_zone| %> + <% if @tax_zone.nil? %> +

+ <%= tax_zone.label :number %> + <%= tax_zone.select :tax_zone_id, TaxZone.all.collect {|p| [p.number, p.id]}, :include_blank => " " %> +

+

+ <% else %> +

+ <%= tax_zone.label :number %> + <%= tax_zone.select :tax_zone_id, TaxZone.all.collect {|p| [p.number, p.id]} %> +

+ <% end %> + <% end %> +
+ +
+ +
+ <%= f.submit %> +
+ + <% end %> + +<% end %> + <% else %> - <%= t(:deleting_county_error, :scope => :counties) -%> + <%= t(:deleting_county_error, :scope => :counties) %> <% end %> +
+ <%= link_to 'Show', [:admin, @county] %> | <%= link_to 'Back', admin_counties_path %> diff --git a/app/views/admin/counties/show.html.erb b/app/views/admin/counties/show.html.erb index 2820eaa..e0138e9 100644 --- a/app/views/admin/counties/show.html.erb +++ b/app/views/admin/counties/show.html.erb @@ -1,10 +1,26 @@

<%= notice %>

- + + <% if @county_tax_zone.nil? %> + +

+ Name : + <%= @county.name %> +

+ + <% else %> +

- Name: + Name : <%= @county.name %> -

- <%= @county.is_visible %> +

+ +

+ Tax zone :
+ Number : <%= @tax_zone.number %>
+ Effective date : <%= @county_tax_zone.from %>
+

+ + <% end %> <%= link_to 'Edit', edit_admin_county_path(@county) %> | <%= link_to 'Back', admin_counties_path %> diff --git a/app/views/journals/_form.html.erb b/app/views/journals/_form.html.erb index d2f1dbb..41b7b75 100644 --- a/app/views/journals/_form.html.erb +++ b/app/views/journals/_form.html.erb @@ -8,7 +8,8 @@ projectList: <%= raw(@projects_all.all.to_json) %>, accountList: <%= raw(@accounts_all.to_json) %>, journalOperationList: <%= raw(@journal.journal_operations.all.to_json) %>, - readOnly: <%= @readonly?"true":"false" %> + readOnly: <%= @readonly ? "true":"false" %>, + append: <%= @append ? "true":"false" %> }; @@ -16,6 +17,49 @@ <%= form_for(@journal) do |f| %> <%= f.error_messages %> + +<% if @readonly || @append then %> + +

+ <%= f.label :journal_type, t(:type, :scope => :journals) %>
+ <%= @journal.journal_type %> +

+

+ <%= f.label :number, t(:number, :scope => :journals) %>
+ <%= @journal.number %> + +

+

+ <%= f.label :period_id, "Period" %>
+ <%= @journal.period %> +

+

+ <%= f.label :journal_date, t(:journal_date, :scope => :journals) %>
+ <%= f.hidden_field :journal_date, :class => :datepicker %> + <%= @journal.journal_date %> +

+ +

+ <%= f.label :due_date, t(:due_date, :scope => :journals) %>
+ <%= @journal.due_date %> +

+ +

+ <%= f.label :kid, t(:kid, :scope => :journals) %>
+ <%= @journal.kid %> + +

+

+ <%= f.label :bill_number, t(:bill_number, :scope => :bills) %>
+ <%= @journal.bill_number %> +

+

+ <%= f.label :description, t(:description, :scope => :global) %>
+ <%= @journal.description %> +

+ +<% else %> +

<%= f.label :journal_type, t(:type, :scope => :journals) %>
<%= @journal.journal_type %> @@ -32,40 +76,21 @@

<%= f.label :period_id, "Period" %>
- <%= if @readonly then - @journal.period - else - f.select :period_id, @me.open_periods.reverse.collect {|p| [ p, p.id ] } - end %> + <%= f.select :period_id, @me.open_periods.reverse.collect {|p| [ p, p.id ] } %>

<%= f.label :journal_date, t(:journal_date, :scope => :journals) %>
- <%= if @readonly then - @journal.journal_date - f.hidden_field :journal_date - else - f.text_field :journal_date, :class => :datepicker - end %> + <%= f.text_field :journal_date, :class => :datepicker %>

<%= f.label :due_date, t(:due_date, :scope => :journals) %>
- <%= if @readonly then - @journal.due_date - f.hidden_field :due_date - else - f.text_field :due_date, :class => :datepicker - end %> + <%= f.text_field :due_date, :class => :datepicker %>

<%= f.label :kid, t(:kid, :scope => :journals) %>
- <%= if @readonly then - @journal.kid - else - f.text_field :kid - end - %> + <%= f.text_field :kid %>

@@ -80,13 +105,11 @@

<%= f.label :description, t(:description, :scope => :global) %>
- <%= if @readonly then - @journal.description - else - f.text_field :description - end %> + <%= f.text_field :description %>

+<% end %> +

<% if !@readonly %> diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 8873355..24a4689 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -1,123 +1,124 @@ + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> - - - DODO - <%= stylesheet_link_tag 'datepicker' %> - <%= stylesheet_link_tag 'journals' %> - <%= stylesheet_link_tag 'dodo' %> - <%= stylesheet_link_tag 'application' %> - <%= stylesheet_link_tag 'jquery-ui' %> - <%= javascript_include_tag :defaults %> - <%= javascript_include_tag "dodo" %> - <%= javascript_include_tag "date" %> - <%= javascript_include_tag "journals" %> - <%= javascript_include_tag "payment_runs" %> - <%= javascript_include_tag "jquery-ui" %> - <%= javascript_include_tag "submitaction" %> - <%= javascript_include_tag "validateField" %> - - -

-
- <% if flash[:error] %> -
- <%= flash[:error] %> -
- <% end %> - <% if flash[:alert] %> -
- <%= flash[:alert] %> -
- <% end %> - <% if flash[:notice] %> -
- <%= flash[:notice] %> -
- <% end %> -
+
+ <% if flash[:error] %> +
+ <%= flash[:error] %> +
+ <% end %> + <% if flash[:alert] %> +
+ <%= flash[:alert] %> +
+ <% end %> + <% if flash[:notice] %> +
+ <%= flash[:notice] %> +
+ <% end %> +
-
-
- <%= yield %> -
+
+
+ <%= yield %> +
+
-
- - + + diff --git a/app/views/reports/index.html.erb b/app/views/reports/index.html.erb index a0ce0c8..235a949 100644 --- a/app/views/reports/index.html.erb +++ b/app/views/reports/index.html.erb @@ -168,9 +168,13 @@ options_from_collection_for_select(@projects, "id", "to_s"), :include_blank => true %> - + + <%= t(:car, :scope=>:reports) %> + <%= select_tag :car_id, + options_from_collection_for_select(@cars, "id", "to_s"), + :include_blank => true %> diff --git a/app/views/reports/ledger_balance.html.erb b/app/views/reports/ledger_balance.html.erb index 6c059cb..6c2bb97 100644 --- a/app/views/reports/ledger_balance.html.erb +++ b/app/views/reports/ledger_balance.html.erb @@ -6,6 +6,9 @@ <% unless @project.blank?%>

<%= t(:project, :scope=>:reports) %>: <%= @project %>

<% end %> +<% unless @car.blank?%> +

<%= t(:car, :scope=>:reports) %>: <%= @car %>

+<% end %> <% unless @journal_type.blank?%>

<%= t(:journal_type, :scope=>:reports) %>: <%= @journal_type %>

<% end %> @@ -69,7 +72,7 @@ - + diff --git a/app/views/reports/ledger_journal.html.erb b/app/views/reports/ledger_journal.html.erb index 30150ed..96d23b7 100644 --- a/app/views/reports/ledger_journal.html.erb +++ b/app/views/reports/ledger_journal.html.erb @@ -47,4 +47,4 @@
<%= t(:unit, :scope=>:reports) %><%= t(:result, :scope=>:reports) %>
-
+
\ No newline at end of file diff --git a/app/views/shared/_period_picker.html.erb b/app/views/shared/_period_picker.html.erb index d23e380..ac76c65 100644 --- a/app/views/shared/_period_picker.html.erb +++ b/app/views/shared/_period_picker.html.erb @@ -1,16 +1,16 @@
-<%= form_tag "", :method => :get do %> -
-<%= label :first_period, t('period_picker.first_period') %> -<%= select_tag 'first_period', options_for_select(current_user.current_company.periods.map {|e| e.to_s}, first_period) %> -
-
+ <%= form_tag "", :method => :get do %> +
-<%= label :first_period, t('period_picker.last_period') %> -<%= select_tag 'last_period', options_for_select(current_user.current_company.periods.map {|e| e.to_s}, last_period) %> -
-<%= submit_tag t('global.filter') %> -<% end %> + <%= label :first_period, t('period_picker.last_period') %> + <%= select_tag 'last_period', options_for_select(current_user.current_company.periods.order("year, nr").reverse.map {|e| e.to_s}, last_period) %> +
+
+ <%= label :first_period, t('period_picker.first_period') %> + <%= select_tag 'first_period', options_for_select(current_user.current_company.periods.order("year, nr").map {|e| e.to_s}, first_period) %> +
+ <%= submit_tag t('global.filter') %> + <% end %>
diff --git a/app/views/users/edit.html.erb b/app/views/users/edit.html.erb index b80b3e9..6907df9 100644 --- a/app/views/users/edit.html.erb +++ b/app/views/users/edit.html.erb @@ -34,10 +34,10 @@ <% end %> <% if assignment.object.company == @company || assignment.object.company == nil %> <% if (assignment.object.user == current_user && name == "user_admin")%> - <%= assignment.select :company_id, [[@company.name, @company.id]], {:include_blank => "Select company"}, :disabled => "disabled" %> + <%= assignment.select :company_id, [[@company.name, @company.id]], {:include_blank => false}, :disabled => "disabled" %> <%= assignment.select :role_id, Role.all.map {|r| [r.name, r.id]}, {:include_blank => "Select role"}, :disabled => "disabled" %> <% else %> - <%= assignment.select :company_id, [[@company.name, @company.id]], :include_blank => "Select company" %> + <%= assignment.select :company_id, [[@company.name, @company.id]], :include_blank => false %> <%= assignment.select :role_id, Role.all.map {|r| [r.name, r.id]}, :include_blank => "Select role" %> <%= assignment.check_box '_destroy' %> <%= assignment.label '_destroy' %> diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb index 2aec323..02b63d3 100644 --- a/app/views/users/index.html.erb +++ b/app/views/users/index.html.erb @@ -11,11 +11,7 @@ <% for user in @users.uniq %> - <% if user.active == false %> - - <% else %> - - <% end %> + <%= user.email %> diff --git a/config/authorization_rules.rb b/config/authorization_rules.rb index 9c9defd..730d6ed 100644 --- a/config/authorization_rules.rb +++ b/config/authorization_rules.rb @@ -7,7 +7,7 @@ has_permission_on :admin_users, :to => [:create, :read, :update, :edit] has_permission_on :admin_admins, :to => :manage has_permission_on :admin_company, :to => :manage - has_permission_on :admin_counties, :to => :manage + has_permission_on :admin_counties, :to => [:manage,:delete] has_permission_on :admin_tax_zones, :to => :manage has_permission_on :admin_tax_zone_taxes, :to => :manage has_permission_on :admin_county_tax_zones, :to => :manage diff --git a/config/locales/en.yml b/config/locales/en.yml index acf075a..20d1cdd 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -494,6 +494,7 @@ en: counties: deleting_county_error: This county mustn't be deleted ! + editing_county_error: This county can't be edited ! Check your database ! assignment: assignment_apply: "Apply to new company" diff --git a/db/migrate/20100928184827_create_journal_types.rb b/db/migrate/20100928184827_create_journal_types.rb index 5ed6223..b3f7ec3 100644 --- a/db/migrate/20100928184827_create_journal_types.rb +++ b/db/migrate/20100928184827_create_journal_types.rb @@ -6,7 +6,7 @@ def self.up t.timestamps end - JournalType.create!(:name=>'Weekly Sale') + # JournalType.create!(:name=>'Weekly Sale') end def self.down diff --git a/db/migrate/20111104144940_ledgers_add_county.rb b/db/migrate/20111104144940_ledgers_add_county.rb new file mode 100644 index 0000000..39e2cae --- /dev/null +++ b/db/migrate/20111104144940_ledgers_add_county.rb @@ -0,0 +1,9 @@ +class LedgersAddCounty < ActiveRecord::Migration + def self.up + add_column :ledgers, :county_id, :integer + end + + def self.down + remove_column :ledgers, :county_id + end +end diff --git a/db/migrate/20111104145622_paychecks_add_county.rb b/db/migrate/20111104145622_paychecks_add_county.rb new file mode 100644 index 0000000..24f533a --- /dev/null +++ b/db/migrate/20111104145622_paychecks_add_county.rb @@ -0,0 +1,9 @@ +class PaychecksAddCounty < ActiveRecord::Migration + def self.up + add_column :paychecks, :county_id, :integer + end + + def self.down + remove_column :paychecks, :county_id + end +end diff --git a/public/favicon.ico b/public/favicon.ico index e69de29..e785370 100644 Binary files a/public/favicon.ico and b/public/favicon.ico differ diff --git a/public/javascripts/journals.js b/public/javascripts/journals.js index 35462f1..7d53c26 100644 --- a/public/javascripts/journals.js +++ b/public/javascripts/journals.js @@ -468,7 +468,7 @@ var journals = { var opTable = $('#operations')[0]; var row = opTable.insertRow(opTable.rows.length); - + var ac = function (content, className) { var c = this.insertCell(this.cells.length); if (className) { @@ -479,8 +479,7 @@ var journals = { }; row.addCell = ac; - - + var row2 = opTable.insertRow(opTable.rows.length); row2.addCell = ac; @@ -550,16 +549,22 @@ var journals = { journals.update(); } journals.filterSelectors(); + journals.filterDefaultSelectors(); }, /** Add all predefined journal_operation lines from the DODO.journalOperationList array. */ addPredefined: function(){ + var oldReadOnly = DODO.readOnly; + DODO.readOnly = DODO.append || oldReadOnly; lines = DODO.journalOperationList; + var form = $("form.edit_journal"); for (var i=0; i").attr("name", "journal_operations[" + i + "][old]")); + } journals.updateVat(false); journals.update(); @@ -569,8 +574,11 @@ var journals = { } $("#journal_journal_date")[0].onchange = function (e) { journals.filterSelectors(); + journals.filterDefaultSelectors(); } journals.filterSelectors(); + journals.filterDefaultSelectors(); + DODO.readOnly = oldReadOnly; }, columnOf: function(input) @@ -634,12 +642,18 @@ var journals = { for (var j=0; j= from && date <= to) { + if (from === null && to === null) { + $("#unit_"+i).append($("