Class: AdvancedBilling::CreditNoteLineItem
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- AdvancedBilling::CreditNoteLineItem
- Defined in:
- lib/advanced_billing/models/credit_note_line_item.rb
Overview
CreditNoteLineItem Model.
Instance Attribute Summary collapse
-
#component_id ⇒ Integer
The ID of the component being credited.
-
#description ⇒ String
Detailed description for the credit given by this line.
-
#discount_amount ⇒ String
The approximate discount of just this line.
-
#period_range_end ⇒ String
End date for the period credited by this line.
-
#period_range_start ⇒ String
Start date for the period credited by this line.
-
#price_point_id ⇒ Integer
The price point ID of the component being credited.
-
#product_id ⇒ Integer
The ID of the product being credited.
-
#product_version ⇒ Integer
The version of the product being credited.
-
#quantity ⇒ String
The quantity or count of units credited by the line item.
-
#subtotal_amount ⇒ String
The line subtotal, generally calculated as ‘quantity * unit_price`.
-
#tax_amount ⇒ String
The approximate tax of just this line.
-
#tiered_unit_price ⇒ TrueClass | FalseClass
When ‘true`, indicates that the actual pricing scheme for the line was tiered, so the `unit_price` shown is the blended average for all units.
-
#title ⇒ String
A short descriptor for the credit given by this line.
-
#total_amount ⇒ String
The non-canonical total amount for the line.
-
#uid ⇒ String
Unique identifier for the line item.
-
#unit_price ⇒ String
The price per unit for the line item.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
-
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
Instance Method Summary collapse
-
#initialize(uid = SKIP, title = SKIP, description = SKIP, quantity = SKIP, unit_price = SKIP, subtotal_amount = SKIP, discount_amount = SKIP, tax_amount = SKIP, total_amount = SKIP, tiered_unit_price = SKIP, period_range_start = SKIP, period_range_end = SKIP, product_id = SKIP, product_version = SKIP, component_id = SKIP, price_point_id = SKIP) ⇒ CreditNoteLineItem
constructor
A new instance of CreditNoteLineItem.
Methods inherited from BaseModel
Constructor Details
#initialize(uid = SKIP, title = SKIP, description = SKIP, quantity = SKIP, unit_price = SKIP, subtotal_amount = SKIP, discount_amount = SKIP, tax_amount = SKIP, total_amount = SKIP, tiered_unit_price = SKIP, period_range_start = SKIP, period_range_end = SKIP, product_id = SKIP, product_version = SKIP, component_id = SKIP, price_point_id = SKIP) ⇒ CreditNoteLineItem
Returns a new instance of CreditNoteLineItem.
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
# File 'lib/advanced_billing/models/credit_note_line_item.rb', line 163 def initialize(uid = SKIP, title = SKIP, description = SKIP, quantity = SKIP, unit_price = SKIP, subtotal_amount = SKIP, discount_amount = SKIP, tax_amount = SKIP, total_amount = SKIP, tiered_unit_price = SKIP, period_range_start = SKIP, period_range_end = SKIP, product_id = SKIP, product_version = SKIP, component_id = SKIP, price_point_id = SKIP) @uid = uid unless uid == SKIP @title = title unless title == SKIP @description = description unless description == SKIP @quantity = quantity unless quantity == SKIP @unit_price = unit_price unless unit_price == SKIP @subtotal_amount = subtotal_amount unless subtotal_amount == SKIP @discount_amount = discount_amount unless discount_amount == SKIP @tax_amount = tax_amount unless tax_amount == SKIP @total_amount = total_amount unless total_amount == SKIP @tiered_unit_price = tiered_unit_price unless tiered_unit_price == SKIP @period_range_start = period_range_start unless period_range_start == SKIP @period_range_end = period_range_end unless period_range_end == SKIP @product_id = product_id unless product_id == SKIP @product_version = product_version unless product_version == SKIP @component_id = component_id unless component_id == SKIP @price_point_id = price_point_id unless price_point_id == SKIP end |
Instance Attribute Details
#component_id ⇒ Integer
The ID of the component being credited. Will be ‘nil` for non-component credits.
104 105 106 |
# File 'lib/advanced_billing/models/credit_note_line_item.rb', line 104 def component_id @component_id end |
#description ⇒ String
Detailed description for the credit given by this line. May include proration details in plain text. Note: this string may contain line breaks that are hints for the best display format on the credit note.
26 27 28 |
# File 'lib/advanced_billing/models/credit_note_line_item.rb', line 26 def description @description end |
#discount_amount ⇒ String
The approximate discount of just this line. The value is approximated in cases where rounding errors make it difficult to apportion exactly a total discount among many lines. Several lines may have been summed prior to applying the discount to arrive at ‘discount_amount` for the invoice - backing that out to the discount on a single line may introduce rounding or precision errors.
56 57 58 |
# File 'lib/advanced_billing/models/credit_note_line_item.rb', line 56 def discount_amount @discount_amount end |
#period_range_end ⇒ String
End date for the period credited by this line. The format is ‘“YYYY-MM-DD”`.
89 90 91 |
# File 'lib/advanced_billing/models/credit_note_line_item.rb', line 89 def period_range_end @period_range_end end |
#period_range_start ⇒ String
Start date for the period credited by this line. The format is ‘“YYYY-MM-DD”`.
84 85 86 |
# File 'lib/advanced_billing/models/credit_note_line_item.rb', line 84 def period_range_start @period_range_start end |
#price_point_id ⇒ Integer
The price point ID of the component being credited. Will be ‘nil` for non-component credits.
109 110 111 |
# File 'lib/advanced_billing/models/credit_note_line_item.rb', line 109 def price_point_id @price_point_id end |
#product_id ⇒ Integer
The ID of the product being credited. This may be set even for component credits, so true product-only (non-component) credits will also have a nil ‘component_id`.
95 96 97 |
# File 'lib/advanced_billing/models/credit_note_line_item.rb', line 95 def product_id @product_id end |
#product_version ⇒ Integer
The version of the product being credited.
99 100 101 |
# File 'lib/advanced_billing/models/credit_note_line_item.rb', line 99 def product_version @product_version end |
#quantity ⇒ String
The quantity or count of units credited by the line item. This is a decimal number represented as a string. (See “About Decimal Numbers”.)
32 33 34 |
# File 'lib/advanced_billing/models/credit_note_line_item.rb', line 32 def quantity @quantity end |
#subtotal_amount ⇒ String
The line subtotal, generally calculated as ‘quantity * unit_price`. This is the canonical amount of record for the line - when rounding differences are in play, `subtotal_amount` takes precedence over the value derived from `quantity * unit_price` (which may not have the proper precision to exactly equal this amount).
47 48 49 |
# File 'lib/advanced_billing/models/credit_note_line_item.rb', line 47 def subtotal_amount @subtotal_amount end |
#tax_amount ⇒ String
The approximate tax of just this line. The value is approximated in cases where rounding errors make it difficult to apportion exactly a total tax among many lines. Several lines may have been summed prior to applying the tax rate to arrive at ‘tax_amount` for the invoice - backing that out to the tax on a single line may introduce rounding or precision errors.
65 66 67 |
# File 'lib/advanced_billing/models/credit_note_line_item.rb', line 65 def tax_amount @tax_amount end |
#tiered_unit_price ⇒ TrueClass | FalseClass
When ‘true`, indicates that the actual pricing scheme for the line was tiered, so the `unit_price` shown is the blended average for all units.
79 80 81 |
# File 'lib/advanced_billing/models/credit_note_line_item.rb', line 79 def tiered_unit_price @tiered_unit_price end |
#title ⇒ String
A short descriptor for the credit given by this line.
19 20 21 |
# File 'lib/advanced_billing/models/credit_note_line_item.rb', line 19 def title @title end |
#total_amount ⇒ String
The non-canonical total amount for the line. ‘subtotal_amount` is the canonical amount for a line. The invoice `total_amount` is derived from the sum of the line `subtotal_amount`s and discounts or taxes applied thereafter. Therefore, due to rounding or precision errors, the sum of line `total_amount`s may not equal the invoice `total_amount`.
74 75 76 |
# File 'lib/advanced_billing/models/credit_note_line_item.rb', line 74 def total_amount @total_amount end |
#uid ⇒ String
Unique identifier for the line item. Useful when cross-referencing the line against individual discounts in the ‘discounts` or `taxes` lists.
15 16 17 |
# File 'lib/advanced_billing/models/credit_note_line_item.rb', line 15 def uid @uid end |
#unit_price ⇒ String
The price per unit for the line item. When tiered pricing was used (i.e. not every unit was actually priced at the same price) this will be the blended average cost per unit and the ‘tiered_unit_price` field will be set to `true`.
39 40 41 |
# File 'lib/advanced_billing/models/credit_note_line_item.rb', line 39 def unit_price @unit_price end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 |
# File 'lib/advanced_billing/models/credit_note_line_item.rb', line 189 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. uid = hash.key?('uid') ? hash['uid'] : SKIP title = hash.key?('title') ? hash['title'] : SKIP description = hash.key?('description') ? hash['description'] : SKIP quantity = hash.key?('quantity') ? hash['quantity'] : SKIP unit_price = hash.key?('unit_price') ? hash['unit_price'] : SKIP subtotal_amount = hash.key?('subtotal_amount') ? hash['subtotal_amount'] : SKIP discount_amount = hash.key?('discount_amount') ? hash['discount_amount'] : SKIP tax_amount = hash.key?('tax_amount') ? hash['tax_amount'] : SKIP total_amount = hash.key?('total_amount') ? hash['total_amount'] : SKIP tiered_unit_price = hash.key?('tiered_unit_price') ? hash['tiered_unit_price'] : SKIP period_range_start = hash.key?('period_range_start') ? hash['period_range_start'] : SKIP period_range_end = hash.key?('period_range_end') ? hash['period_range_end'] : SKIP product_id = hash.key?('product_id') ? hash['product_id'] : SKIP product_version = hash.key?('product_version') ? hash['product_version'] : SKIP component_id = hash.key?('component_id') ? hash['component_id'] : SKIP price_point_id = hash.key?('price_point_id') ? hash['price_point_id'] : SKIP # Create object from extracted values. CreditNoteLineItem.new(uid, title, description, quantity, unit_price, subtotal_amount, discount_amount, tax_amount, total_amount, tiered_unit_price, period_range_start, period_range_end, product_id, product_version, component_id, price_point_id) end |
.names ⇒ Object
A mapping from model property names to API property names.
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/advanced_billing/models/credit_note_line_item.rb', line 112 def self.names @_hash = {} if @_hash.nil? @_hash['uid'] = 'uid' @_hash['title'] = 'title' @_hash['description'] = 'description' @_hash['quantity'] = 'quantity' @_hash['unit_price'] = 'unit_price' @_hash['subtotal_amount'] = 'subtotal_amount' @_hash['discount_amount'] = 'discount_amount' @_hash['tax_amount'] = 'tax_amount' @_hash['total_amount'] = 'total_amount' @_hash['tiered_unit_price'] = 'tiered_unit_price' @_hash['period_range_start'] = 'period_range_start' @_hash['period_range_end'] = 'period_range_end' @_hash['product_id'] = 'product_id' @_hash['product_version'] = 'product_version' @_hash['component_id'] = 'component_id' @_hash['price_point_id'] = 'price_point_id' @_hash end |
.nullables ⇒ Object
An array for nullable fields
156 157 158 159 160 161 |
# File 'lib/advanced_billing/models/credit_note_line_item.rb', line 156 def self.nullables %w[ component_id price_point_id ] end |
.optionals ⇒ Object
An array for optional fields
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
# File 'lib/advanced_billing/models/credit_note_line_item.rb', line 134 def self.optionals %w[ uid title description quantity unit_price subtotal_amount discount_amount tax_amount total_amount tiered_unit_price period_range_start period_range_end product_id product_version component_id price_point_id ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
238 239 240 241 242 243 244 |
# File 'lib/advanced_billing/models/credit_note_line_item.rb', line 238 def self.validate(value) return true if value.instance_of? self return false unless value.instance_of? Hash true end |