Add role_invoices
This new role allows users to create invoices without role_finance. Users can then only modify their own created invoices until somebody with the role_finance sets the paid_on value.
This commit is contained in:
parent
273969ac90
commit
1315103a7d
20 changed files with 73 additions and 20 deletions
|
|
@ -13,6 +13,10 @@ class Invoice < ActiveRecord::Base
|
|||
# Replace numeric seperator with database format
|
||||
localize_input_of :amount, :deposit, :deposit_credit
|
||||
|
||||
def user_can_edit?(user)
|
||||
user.role_finance? || (user.role_invoices? && !self.paid_on && self.created_by.id == user.id)
|
||||
end
|
||||
|
||||
# Amount without deposit
|
||||
def net_amount
|
||||
amount - deposit + deposit_credit
|
||||
|
|
|
|||
|
|
@ -143,7 +143,12 @@ class User < ActiveRecord::Base
|
|||
def role_finance?
|
||||
groups.detect {|group| group.role_finance?}
|
||||
end
|
||||
|
||||
|
||||
# Checks the invoices role
|
||||
def role_invoices?
|
||||
groups.detect {|group| group.role_invoices?}
|
||||
end
|
||||
|
||||
# Checks the article_meta role
|
||||
def role_article_meta?
|
||||
groups.detect {|group| group.role_article_meta?}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue