Class: Comee::Core::ClientPrice
- Inherits:
-
Price
show all
- Defined in:
- app/models/comee/core/client_price.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Price
#approve, #approved?, #compute_status, #current?, #draft?, #future?, #past?, #validate_price_validity_dates
Class Method Details
.ransackable_associations(_auth_object = nil) ⇒ Object
48
49
50
|
# File 'app/models/comee/core/client_price.rb', line 48
def self.ransackable_associations(_auth_object = nil)
%w[product client product_lookup]
end
|
.ransackable_attributes(_auth_object = nil) ⇒ Object
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'app/models/comee/core/client_price.rb', line 34
def self.ransackable_attributes(_auth_object = nil)
%w[
id
valid_from
valid_to
price
status
product_id
client_id
previous_price_id
next_price_id
]
end
|
Instance Method Details
#margin_discount? ⇒ Boolean
30
31
32
|
# File 'app/models/comee/core/client_price.rb', line 30
def margin_discount?
ClientPrice.margin_types[margin_type] == ClientPrice.margin_types[:discount]
end
|
#margin_increase? ⇒ Boolean
26
27
28
|
# File 'app/models/comee/core/client_price.rb', line 26
def margin_increase?
ClientPrice.margin_types[margin_type] == ClientPrice.margin_types[:increase]
end
|
#validate_product_lookup ⇒ Object
16
17
18
19
20
21
22
23
24
|
# File 'app/models/comee/core/client_price.rb', line 16
def validate_product_lookup
return unless product_lookup && product && client
if product_lookup.itemable_id != client_id ||
product_lookup.itemable_type != "Comee::Core::Client" ||
product_lookup.product_id != product_id
errors.add(:product_lookup, "contains wrong client or product.")
end
end
|