| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- class Ability
- include CanCan::Ability
- def initialize(user)
- # Define abilities for the passed in user here. For example:
- #
- # user ||= User.new # guest user (not logged in)
- # if user.admin?
- # can :manage, :all
- # else
- # can :read, :all
- # end
- #
- # 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.
- # If you pass :all it will apply to every resource. Otherwise pass a Ruby
- # class of the resource.
- #
- # The third argument is an optional hash of conditions to further filter the
- # objects.
- # For example, here the user can only update published articles.
- #
- # can :update, Article, :published => true
- #
- # See the wiki for details:
- # https://github.com/ryanb/cancan/wiki/Defining-Abilities
- alias_action :create, :read, :update, to: :cru
- user ||= User.new
- if user.usertype == "A" || user.usertype == "SS"
- # Cajas registradoras
- can :read, [AvailableProduct, CashOut, CashRegister, PaymentMethod, ProductsReturn]
- # Categorias
- can :manage, [BillingInformation, Category, Commission, Customer, Expense, Expensesconcept, Pointsale, PosConfig, Product, Promotion, ProductWaste, Purchase, Sale, Seller, Sellerscommission, SpecialPrice, Supplier, Transfer, Unit, User, Warehouse]
- can [:opened_cash_registers, :find_cash_outs_by_date], CashOut
- can :sales_reserved, Sale
- cannot [:delete, :liquidate_reserve], Sale
- cannot :create, [ProductWaste, Purchase, Sale]
- cannot [:debtors, :customer_sales], Customer
- elsif user.usertype == "G"
- # Cajas registradoras
- can :manage, [CashOut, CashRegister, Category, Credit, CreditPayment, Commission, Customer, Expense, OpenCashRegister, PrePurchase, Product, Promotion, ProductsReturn, ProductWaste, Purchase, Sale, Seller, Sellerscommission, Supplier, Transfer]
- # Categorias
- can :read, [AvailableProduct, Credit, CreditPayment, Expensesconcept, SpecialPrice, Unit]
- # Clientes
- can :cru, [BillingInformation, Commission, Credit, CreditPayment, Customer, Sellerscommission, User, Warehouse]
- cannot :opened_cash_registers, CashOut
- cannot :sales_per_month_report, Sale
- cannot :product_track, Product
- elsif user.usertype == "C"
- # Cajas registradoras
- can :read, [BillingInformation, Credit, CreditPayment, Customer, Expensesconcept, Seller, SpecialPrice, Product, Promotion]
- # ventas
- can :cru, [Credit, CreditPayment]
- can :manage, [CashOut, CashRegister, Credit, CreditPayment, Customer, Expense, OpenCashRegister, PreSale, Sale, Transfer, ProductsReturn, ProductWaste]
- cannot :opened_cash_registers, CashOut
- cannot :sales_per_month_report, Sale
- elsif user.usertype == "S"
- can :read, [BillingInformation, CashRegister, Customer, Expensesconcept, Seller, SpecialPrice, Product, Promotion]
- can :manage, [ProductWaste, Transfer]
- cannot [:debtors, :customer_sales], Customer
- end
- end
- end
|