Skip to content

Commit

Permalink
Merge branch 'master' of [email protected]:lodo/lodo
Browse files Browse the repository at this point in the history
  • Loading branch information
Axel Liljencrantz committed Jul 28, 2010
2 parents 02371b8 + dfe1647 commit 60755d7
Show file tree
Hide file tree
Showing 23 changed files with 407 additions and 239 deletions.
5 changes: 3 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
source 'http://rubygems.org'

gem 'rails', '3.0.0.beta4'
gem 'bundler', '>=1.0.0.rc.1'

gem 'rails', '3.0.0.rc'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
Expand All @@ -9,7 +11,6 @@ gem 'rails', '3.0.0.beta4'
gem 'pg'

gem 'ruby_parser'
gem 'bundler'
gem "machinist"
gem "faker"
gem "devise", "1.1.rc2"
Expand Down
4 changes: 1 addition & 3 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,9 @@ def company_required
end

def permission_denied
# raise 'snopp'
print "LAAAAAAAAAAAAAAAAAAAA: " + current_user.role_symbols.inspect
msg = I18n.t("access_denied")
flash[:error] = msg
logger.info "Error: #{msg}, user: #{current_user}, url: #{request.request_uri}, pid: #{Process.pid}, Time: #{Time.now}"
logger.info "Error: #{msg}, user: #{current_user}, url: #{request.fullpath}, pid: #{Process.pid}, Time: #{Time.now}"
redirect_to root_url
end

Expand Down
4 changes: 2 additions & 2 deletions app/controllers/paycheck_line_templates_controller.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
class PaycheckLineTemplatesController < ApplicationController
before_filter :setup_form



def setup_form
@accounts = current_user.current_company.accounts
@units = current_user.current_company.units
Expand All @@ -13,6 +11,7 @@ def setup_form
# GET /paycheck_line_templates
# GET /paycheck_line_templates.xml
def index
raise "asdlfkjsldjkfee"
@paycheck_line_templates = PaycheckLineTemplate.all

respond_to do |format|
Expand All @@ -24,6 +23,7 @@ def index
# GET /paycheck_line_templates/1
# GET /paycheck_line_templates/1.xml
def show
raise "dslkfjasldfjas"
@paycheck_line_template = PaycheckLineTemplate.find(params[:id])

respond_to do |format|
Expand Down
7 changes: 7 additions & 0 deletions app/controllers/paycheck_lines_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ class PaycheckLinesController < ApplicationController
# GET /paycheck_lines
# GET /paycheck_lines.xml
def index
raise "aksljdfklasdf"
@paycheck_lines = PaycheckLine.all

respond_to do |format|
Expand All @@ -13,6 +14,7 @@ def index
# GET /paycheck_lines/1
# GET /paycheck_lines/1.xml
def show
raise "lsadkfjljwefl"
@paycheck_line = PaycheckLine.find(params[:id])

respond_to do |format|
Expand All @@ -24,6 +26,7 @@ def show
# GET /paycheck_lines/new
# GET /paycheck_lines/new.xml
def new
raise "sdfjdlaskjflkwjdsf"
@paycheck_line = PaycheckLine.new

respond_to do |format|
Expand All @@ -34,12 +37,14 @@ def new

# GET /paycheck_lines/1/edit
def edit
raise "asdljfjadsf"
@paycheck_line = PaycheckLine.find(params[:id])
end

# POST /paycheck_lines
# POST /paycheck_lines.xml
def create
raise "aklsdfjlaksdjf"
@paycheck_line = PaycheckLine.new(params[:paycheck_line])

respond_to do |format|
Expand All @@ -56,6 +61,7 @@ def create
# PUT /paycheck_lines/1
# PUT /paycheck_lines/1.xml
def update
raise "aklsdfjslkdf"
@paycheck_line = PaycheckLine.find(params[:id])

respond_to do |format|
Expand All @@ -72,6 +78,7 @@ def update
# DELETE /paycheck_lines/1
# DELETE /paycheck_lines/1.xml
def destroy
raise "asdklfjsahdf"
@paycheck_line = PaycheckLine.find(params[:id])
@paycheck_line.destroy

Expand Down
22 changes: 0 additions & 22 deletions app/controllers/paycheck_templates_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,26 +52,4 @@ def create
end
end

# GET /paycheck_line_templates/1/edit
def edit
raise "NOT IMPLEMENTED"

respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @paycheck_line_template }
end
end

# DELETE /paycheck_line_templates/1
# DELETE /paycheck_line_templates/1.xml
def destroy
raise "NOT IMPLEMENTED"
@paycheck_line_template = PaycheckLineTemplate.find(params[:id])
@paycheck_line_template.destroy

respond_to do |format|
format.html { redirect_to(paycheck_line_templates_url) }
format.xml { head :ok }
end
end
end
2 changes: 1 addition & 1 deletion app/controllers/vat_accounts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class VatAccountsController < ApplicationController
# GET /vat_accounts
# GET /vat_accounts.xml
def index
@vat_accounts = VatAccount.with_permissions_to(:index).all(:order => "accounts.number", :include => :target_account)
@vat_accounts = VatAccount.with_permissions_to(:index).where(:company_id => current_user.current_company.id).order("accounts.number").includes("target_account")

respond_to do |format|
format.html # index.html.erb
Expand Down
18 changes: 16 additions & 2 deletions app/models/company.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ class Company < ActiveRecord::Base
has_many :periods
has_many :journals

has_many :paycheck_line_templates

# company acting as a template on create
attr_accessor :template_company_id
after_create :init_from_template, :if => proc { !self.template_company_id.blank? }
Expand Down Expand Up @@ -70,20 +72,34 @@ def init_from_template
accounts[acc.id].update_attributes!(:vat_account_id => vat_accounts[acc.vat_account_id].id)
end

units = {}
# copy units. shallow, copying addresses doesn't make sense..
template.units.each do |unit|
u = Unit.new(unit.attributes)
u.company = self
u.address = Address.create!
u.save!
units[unit.id] = u
end

projects = {}
# copy projects. not copying addresses.
template.projects.each do |project|
p = Project.new(project.attributes)
p.company = self
p.address = Address.create!
p.save!
projects[project.id] = p
end

# copy salary templates
template.paycheck_line_templates.where(:employee_id => nil).each do |line|
l = PaycheckLineTemplate.new(line.attributes)
l.company = self
l.account = accounts[line.account_id]
l.unit = units[line.unit_id]
l.project = projects[line.project_id]
l.save!
end

end
Expand All @@ -97,8 +113,6 @@ def employees

def paychecks
r = Paycheck.where(:employee_id => employees).joins([:employee, :period]).order("periods.year desc, periods.nr desc, lower(ledgers.name)")
print r.to_sql
print "..."
r
end

Expand Down
2 changes: 2 additions & 0 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ class Application < Rails::Application
:secret => '29e52c8e64c464b41e52b98c9cceb4e43d1d8870df42124cd96be3c4004179720c0326431b0126f1f27d9c65bd834d1028c8f745ddcc8484e32ff0ac3e7d75fa'
}

# define js asset loading order (:all adds :defaults in front)
config.action_view.javascript_expansions = { :defaults => ['jquery', 'rails'] }
end
end

Expand Down
2 changes: 1 addition & 1 deletion config/authorization_rules.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
has_permission_on :accounts, :to => :create

has_permission_on :vat_accounts, :to => :manage do
# if_attribute :company_id => is {user.current_company.id}
if_attribute :company_id => is {user.current_company.id}
end
has_permission_on :vat_accounts, :to => :create

Expand Down
3 changes: 3 additions & 0 deletions config/environments/development.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
Lodo::Application.configure do
# Settings specified here will take precedence over those in config/environment.rb

# log deprecation warnings
config.active_support.deprecation = :log

# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the webserver when you make code changes.
Expand Down
4 changes: 4 additions & 0 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,8 @@
# Enable threaded mode
# config.threadsafe!
config.action_mailer.default_url_options = { :host => "localhost" }

# log deprecation warnings
config.active_support.deprecation = :stderr
end

2 changes: 2 additions & 0 deletions config/environments/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,7 @@
# config.active_record.schema_format = :sql

config.action_mailer.default_url_options = { :host => "localhost" }

config.active_support.deprecation = :stderr
end

7 changes: 0 additions & 7 deletions config/initializers/jquery.rb

This file was deleted.

11 changes: 11 additions & 0 deletions db/migrate/20100726113926_change_paycheck_line_templates.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class ChangePaycheckLineTemplates < ActiveRecord::Migration
def self.up
change_column :paycheck_line_templates, :employee_id, :integer, :null => true
change_column :paycheck_line_templates, :company_id, :integer, :null => false
end

def self.down
change_column :paycheck_line_templates, :employee_id, :integer, :null => false
change_column :paycheck_line_templates, :company_id, :integer, :null => true
end
end
Loading

0 comments on commit 60755d7

Please sign in to comment.