Class: Zuora::RatePlanCharge
- Inherits:
-
ZObject
- Object
- SimpleDelegator
- ZObject
- Zuora::RatePlanCharge
show all
- Defined in:
- lib/active_zuora/rate_plan_charge.rb
Instance Method Summary
collapse
Methods inherited from ZObject
#==, all, attribute_names, #attributes, build_filter_statments, client, convert_date, create, destroy, #destroy, exclude_query_attributes, excluded_query_attributes, extra_attributes, find, #id, #initialize, klass_name, new_from_zobject, query_attribute_names, #to_zobject, #type, update_attributes, valid_id, valid_session?, where, zobject_class, #zobject_class
Constructor Details
This class inherits a constructor from Zuora::ZObject
Instance Method Details
#charge_quantity ⇒ Object
39
40
41
|
# File 'lib/active_zuora/rate_plan_charge.rb', line 39
def charge_quantity
quantity || 1
end
|
#charge_tier_query(identifier_name, identifier_value) ⇒ Object
20
21
22
23
24
|
# File 'lib/active_zuora/rate_plan_charge.rb', line 20
def charge_tier_query(identifier_name, identifier_value)
query = "#{identifier_name} = '#{identifier_value}'"
query += " and endingUnit >= #{charge_quantity} and startingUnit <= #{charge_quantity}" if chargeModel == "Volume Pricing"
query
end
|
#discount? ⇒ Boolean
59
60
61
|
# File 'lib/active_zuora/rate_plan_charge.rb', line 59
def discount?
price < list_price
end
|
#discount_percent ⇒ Object
63
64
65
|
# File 'lib/active_zuora/rate_plan_charge.rb', line 63
def discount_percent
list_price.zero? ? nil : (1 - price / list_price) * 100
end
|
#list_price ⇒ Object
51
52
53
|
# File 'lib/active_zuora/rate_plan_charge.rb', line 51
def list_price
product_rate_plan_charge_tier.price
end
|
#price ⇒ Object
43
44
45
|
# File 'lib/active_zuora/rate_plan_charge.rb', line 43
def price
super || rate_plan_charge_tier.price
end
|
#product_rate_plan_charge ⇒ Object
26
27
28
|
# File 'lib/active_zuora/rate_plan_charge.rb', line 26
def product_rate_plan_charge
@product_rate_plan_charge ||= ProductRatePlanCharge.find(self.productRatePlanChargeId)
end
|
#product_rate_plan_charge_tier ⇒ Object
15
16
17
18
|
# File 'lib/active_zuora/rate_plan_charge.rb', line 15
def product_rate_plan_charge_tier
query = charge_tier_query("productRatePlanChargeId", productRatePlanChargeId)
@product_rate_plan_charge_tier ||= ProductRatePlanChargeTier.where(query).first
end
|
#rate_plan ⇒ Object
6
7
8
|
# File 'lib/active_zuora/rate_plan_charge.rb', line 6
def rate_plan
@rate_plan ||= RatePlan.find(self.ratePlanId)
end
|
#rate_plan_charge_tier ⇒ Object
10
11
12
13
|
# File 'lib/active_zuora/rate_plan_charge.rb', line 10
def rate_plan_charge_tier
query = charge_tier_query("ratePlanChargeId", id)
@rate_plan_charge_tier ||= RatePlanChargeTier.where(query).first
end
|
#total_list_price ⇒ Object
55
56
57
|
# File 'lib/active_zuora/rate_plan_charge.rb', line 55
def total_list_price
charge_quantity * list_price
end
|
#total_price ⇒ Object
47
48
49
|
# File 'lib/active_zuora/rate_plan_charge.rb', line 47
def total_price
charge_quantity * price
end
|
#unload_usages ⇒ Object
34
35
36
37
|
# File 'lib/active_zuora/rate_plan_charge.rb', line 34
def unload_usages
@usages = nil
self
end
|
#usages ⇒ Object
30
31
32
|
# File 'lib/active_zuora/rate_plan_charge.rb', line 30
def usages
@usages ||= Usage.where(:chargeId => id)
end
|