|
|
@@ -11,12 +11,12 @@ class Ability
|
|
|
# can :read, :all
|
|
|
# end
|
|
|
#
|
|
|
- # The first argument to `can` is the action you are giving the user
|
|
|
+ # The first argument to `can` is the action you are giving the user
|
|
|
# permission to do.
|
|
|
# If you pass :manage it will apply to every action. Other common actions
|
|
|
# here are :read, :create, :update and :destroy.
|
|
|
#
|
|
|
- # The second argument is the resource the user can perform the action on.
|
|
|
+ # The second argument is the resource the user can perform the action on.
|
|
|
# If you pass :all it will apply to every resource. Otherwise pass a Ruby
|
|
|
# class of the resource.
|
|
|
#
|
|
|
@@ -28,41 +28,36 @@ class Ability
|
|
|
#
|
|
|
# See the wiki for details:
|
|
|
# https://github.com/ryanb/cancan/wiki/Defining-Abilities
|
|
|
- alias_action :create, :read, :update, :to => :cru
|
|
|
-
|
|
|
+ alias_action :create, :read, :update, to: :cru
|
|
|
+
|
|
|
user ||= User.new
|
|
|
-
|
|
|
- if user.usertype == "A"
|
|
|
- # Cajas registradoras
|
|
|
- can :read, [CashRegister, Purchase, PaymentMethod, ProductsReturn]
|
|
|
- # Categorías
|
|
|
|
|
|
- can :manage, [Category, Customer, BillingInformation, Expensesconcept, Pointsale, Product,
|
|
|
- Supplier, Unit, Sale, PosConfig, Purchase, SpecialPrice, ProductWaste, Seller, CashOut,
|
|
|
- Transfer, Expense, User, Warehouse, Commission, Sellerscommission]
|
|
|
+ if user.usertype == "A"
|
|
|
+ # Cajas registradoras
|
|
|
+ can :read, [CashRegister, Purchase, PaymentMethod, ProductsReturn]
|
|
|
+ # Categorias
|
|
|
+ can :manage, [Category, Customer, BillingInformation, Expensesconcept, Pointsale, Product, Supplier, Unit, Sale, PosConfig, Purchase, SpecialPrice, ProductWaste, Seller, CashOut, Transfer, Expense, User, Warehouse, Commission, Sellerscommission]
|
|
|
|
|
|
elsif user.usertype == "G"
|
|
|
- # Cajas registradoras
|
|
|
- can :manage, [CashRegister, Purchase, Product, PrePurchase, Seller, Sale, Expense, ProductWaste, Transfer, OpenCashRegister, CashOut, Supplier, Customer, Credit, CreditPayment, Commission, Sellerscommission, ProductsReturn]
|
|
|
-
|
|
|
- # Categorías
|
|
|
- can :read, [Category, SpecialPrice, Expensesconcept, Credit, CreditPayment, Unit]
|
|
|
- # Clientes
|
|
|
- can :cru, [Customer, BillingInformation, Pointsale, User, Warehouse, Credit, CreditPayment, Commission, Sellerscommission]
|
|
|
+ # Cajas registradoras
|
|
|
+ can :manage, [CashRegister, Purchase, Product, PrePurchase, Seller, Sale, Expense, ProductWaste, Transfer, OpenCashRegister, CashOut, Supplier, Customer, Credit, CreditPayment, Commission, Sellerscommission, ProductsReturn]
|
|
|
+ # Categorias
|
|
|
+ can :read, [Category, SpecialPrice, Expensesconcept, Credit, CreditPayment, Unit]
|
|
|
+ # Clientes
|
|
|
+ can :cru, [Customer, BillingInformation, Pointsale, User, Warehouse, Credit, CreditPayment, Commission, Sellerscommission]
|
|
|
|
|
|
elsif user.usertype == "C"
|
|
|
- # Cajas registradoras
|
|
|
- can :read, [Product, Pointsale, Customer, BillingInformation, Seller, SpecialPrice, Expensesconcept, Credit, CreditPayment]
|
|
|
- # ventas
|
|
|
- can :cru, [Credit, CreditPayment]
|
|
|
+ # Cajas registradoras
|
|
|
+ can :read, [Product, Pointsale, Customer, BillingInformation, Seller, SpecialPrice, Expensesconcept, Credit, CreditPayment]
|
|
|
+ # ventas
|
|
|
+ can :cru, [Credit, CreditPayment]
|
|
|
|
|
|
- can :manage, [CashRegister, PreSale, OpenCashRegister, Sale, Customer, Credit, CreditPayment, CashOut, Expense, Transfer, ProductsReturn]
|
|
|
+ can :manage, [CashRegister, PreSale, OpenCashRegister, Sale, Customer, Credit, CreditPayment, CashOut, Expense, Transfer, ProductsReturn, ProductWaste]
|
|
|
|
|
|
elsif user.usertype == "S"
|
|
|
- can :read, [CashRegister, Product, Pointsale, Customer, BillingInformation, Seller, SpecialPrice, Expensesconcept]
|
|
|
+ can :read, [CashRegister, Product, Pointsale, Customer, BillingInformation, Seller, SpecialPrice, Expensesconcept]
|
|
|
|
|
|
- can :manage, [Transfer, ProductWaste]
|
|
|
+ can :manage, [Transfer, ProductWaste]
|
|
|
end
|
|
|
-
|
|
|
end
|
|
|
end
|