1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-12-02 13:24:20 +01:00
fab-manager/app/services/product_service.rb

26 lines
547 B
Ruby
Raw Normal View History

2022-07-13 15:06:46 +02:00
# frozen_string_literal: true
# Provides methods for Product
class ProductService
2022-08-16 18:53:11 +02:00
def self.list(filters)
products = Product.includes(:product_images)
if filters[:is_active].present?
state = filters[:disabled] == 'false' ? [nil, false] : true
products = products.where(is_active: state)
end
products
2022-07-13 15:06:46 +02:00
end
2022-08-04 14:02:19 +02:00
# amount params multiplied by hundred
def self.amount_multiplied_by_hundred(amount)
if amount.present?
v = amount.to_f
return nil if v.zero?
return v * 100
end
nil
end
2022-07-13 15:06:46 +02:00
end