Skip to content

Commit

Permalink
Start work on additional period state 'Locked'
Browse files Browse the repository at this point in the history
  • Loading branch information
Axel Liljencrantz committed Nov 8, 2011
1 parent 9d706a5 commit 4e71060
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
6 changes: 3 additions & 3 deletions app/models/period.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ class Period < ActiveRecord::Base
cattr_reader :per_page
@@per_page = 200

STATUSES = {0 => 'New', 1 => 'Open', 2 => 'Done', 3 => 'Closed'}
STATUSE_NAMES = {'New' => 0, 'Open' => 1, 'Done' => 2, 'Closed' => 3}
STATUSES = {0 => 'New', 1 => 'Open', 2 => 'Done', 3 => 'Locked', 4 => 'Closed'}
STATUSE_NAMES = {'New' => 0, 'Open' => 1, 'Done' => 2, 'Locked' => 3, 'Closed' => 4}

# options: from_year, from_nr, to_year, to_nr, company_id
# options: from_year, from_nr, to_year, to_nr, company_id
# if (from_year, to_year) are nil, it will return all periods of the company from year 1900 to year 3999
# if (to_year) is nil, it will return all periods until last period of the company until year 3999
# if (from_year) is nil, it will return all periods since first period of the company since year 1900
Expand Down
8 changes: 5 additions & 3 deletions app/views/periods/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<th>New</th>
<th>Open</th>
<th>Done</th>
<th>Locked</th>
<th>Closed</th>
<th>Open bills</th>
<th>Bills</th>
Expand All @@ -24,15 +25,16 @@
<tr>
<td><%= period.year %></td>
<td><%= period.nr %></td>

<% for status in (0..period.status - 1) %>
<td></td>
<% end %>
<% if period.status < 3 then %>
<% end %>
<% if period.status < 4 then %>
<td><%= link_to '-&gt;'.html_safe, elevate_status_period_path(period), :method => :post %></td>
<% else %>
<td>X</td>
<% end %>
<% for status in (period.status+1..3) %>
<% for status in (period.status+1..4) %>
<td></td>
<% end %>
<td><%= period.open_bills.count %></td>
Expand Down
5 changes: 5 additions & 0 deletions config/authorization_rules.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@
if_attribute :period => { :status => [ Period::STATUSE_NAMES['Open'], Period::STATUSE_NAMES['Done'] ] }
end

has_permission_on :journals, :to => :manage, :join_by => :and do
if_attribute :company_id => is {user.current_company.id}
if_attribute :period => { :status => [ Period::STATUSE_NAMES['Locked']] }
end

has_permission_on :bills, :to => :manage, :join_by => :and do
if_attribute :company_id => is {user.current_company.id}
if_attribute :period => { :status => [ Period::STATUSE_NAMES['Open'], Period::STATUSE_NAMES['Done'] ] }
Expand Down

0 comments on commit 4e71060

Please sign in to comment.