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
-
#billing_schedule_item_id ⇒ Integer
The price point ID of the component being credited.
-
#component_id ⇒ Integer
The ID of the component being credited.
-
#custom_item ⇒ TrueClass | FalseClass
The price point 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 ⇒ Date
End date for the period credited by this line.
-
#period_range_start ⇒ Date
Start date for the period credited by this line.
-
#prepaid_allocation_expires_at ⇒ Date
The date a prepaid allocation is set to expire.
-
#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.
-
#tax_included ⇒ TrueClass | FalseClass
Whether the unit price for this line item is tax-inclusive.
-
#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, tax_included: 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, billing_schedule_item_id: SKIP, custom_item: SKIP, prepaid_allocation_expires_at: SKIP, additional_properties: {}) ⇒ CreditNoteLineItem
constructor
A new instance of CreditNoteLineItem.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
Methods inherited from BaseModel
#check_for_conflict, #get_additional_properties, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(uid: SKIP, title: SKIP, description: SKIP, quantity: SKIP, unit_price: SKIP, subtotal_amount: SKIP, discount_amount: SKIP, tax_amount: SKIP, tax_included: 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, billing_schedule_item_id: SKIP, custom_item: SKIP, prepaid_allocation_expires_at: SKIP, additional_properties: {}) ⇒ CreditNoteLineItem
Returns a new instance of CreditNoteLineItem.
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 235 236 |
# File 'lib/advanced_billing/models/credit_note_line_item.rb', line 199 def initialize(uid: SKIP, title: SKIP, description: SKIP, quantity: SKIP, unit_price: SKIP, subtotal_amount: SKIP, discount_amount: SKIP, tax_amount: SKIP, tax_included: 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, billing_schedule_item_id: SKIP, custom_item: SKIP, prepaid_allocation_expires_at: SKIP, additional_properties: {}) # Add additional model properties to the instance. additional_properties.each do |_name, _value| instance_variable_set("@#{_name}", _value) end @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 @tax_included = tax_included unless tax_included == 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 @billing_schedule_item_id = billing_schedule_item_id unless billing_schedule_item_id == SKIP @custom_item = custom_item unless custom_item == SKIP unless prepaid_allocation_expires_at == SKIP @prepaid_allocation_expires_at = prepaid_allocation_expires_at end end |
Instance Attribute Details
#billing_schedule_item_id ⇒ Integer
The price point ID of the component being credited. Will be ‘nil` for non-component credits.
124 125 126 |
# File 'lib/advanced_billing/models/credit_note_line_item.rb', line 124 def billing_schedule_item_id @billing_schedule_item_id end |
#component_id ⇒ Integer
The ID of the component being credited. Will be ‘nil` for non-component credits.
114 115 116 |
# File 'lib/advanced_billing/models/credit_note_line_item.rb', line 114 def component_id @component_id end |
#custom_item ⇒ TrueClass | FalseClass
The price point ID of the component being credited. Will be ‘nil` for non-component credits.
129 130 131 |
# File 'lib/advanced_billing/models/credit_note_line_item.rb', line 129 def custom_item @custom_item 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 ⇒ Date
End date for the period credited by this line. The format is ‘“YYYY-MM-DD”`.
99 100 101 |
# File 'lib/advanced_billing/models/credit_note_line_item.rb', line 99 def period_range_end @period_range_end end |
#period_range_start ⇒ Date
Start date for the period credited by this line. The format is ‘“YYYY-MM-DD”`.
94 95 96 |
# File 'lib/advanced_billing/models/credit_note_line_item.rb', line 94 def period_range_start @period_range_start end |
#prepaid_allocation_expires_at ⇒ Date
The date a prepaid allocation is set to expire. Only present on line items representing prepaid component allocations. The format is ‘“YYYY-MM-DD”`.
134 135 136 |
# File 'lib/advanced_billing/models/credit_note_line_item.rb', line 134 def prepaid_allocation_expires_at @prepaid_allocation_expires_at end |
#price_point_id ⇒ Integer
The price point ID of the component being credited. Will be ‘nil` for non-component credits.
119 120 121 |
# File 'lib/advanced_billing/models/credit_note_line_item.rb', line 119 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`.
105 106 107 |
# File 'lib/advanced_billing/models/credit_note_line_item.rb', line 105 def product_id @product_id end |
#product_version ⇒ Integer
The version of the product being credited.
109 110 111 |
# File 'lib/advanced_billing/models/credit_note_line_item.rb', line 109 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 |
#tax_included ⇒ TrueClass | FalseClass
Whether the unit price for this line item is tax-inclusive. When ‘true`, `unit_price` already includes tax and `tax_amount` represents the portion of the price attributable to tax. When `false`, any applicable tax is added on top of the price. The value is inherited from the source price point’s ‘tax_included` setting. Custom or ad-hoc line items (which have no associated price point) always return `false`.
75 76 77 |
# File 'lib/advanced_billing/models/credit_note_line_item.rb', line 75 def tax_included @tax_included 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.
89 90 91 |
# File 'lib/advanced_billing/models/credit_note_line_item.rb', line 89 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`.
84 85 86 |
# File 'lib/advanced_billing/models/credit_note_line_item.rb', line 84 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.
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 |
# File 'lib/advanced_billing/models/credit_note_line_item.rb', line 239 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 tax_included = hash.key?('tax_included') ? hash['tax_included'] : 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 billing_schedule_item_id = hash.key?('billing_schedule_item_id') ? hash['billing_schedule_item_id'] : SKIP custom_item = hash.key?('custom_item') ? hash['custom_item'] : SKIP prepaid_allocation_expires_at = hash.key?('prepaid_allocation_expires_at') ? hash['prepaid_allocation_expires_at'] : SKIP # Clean out expected properties from Hash. additional_properties = hash.reject { |k, _| names.value?(k) } # Create object from extracted values. CreditNoteLineItem.new(uid: uid, title: title, description: description, quantity: quantity, unit_price: unit_price, subtotal_amount: subtotal_amount, discount_amount: discount_amount, tax_amount: tax_amount, tax_included: tax_included, total_amount: total_amount, tiered_unit_price: tiered_unit_price, period_range_start: period_range_start, period_range_end: period_range_end, product_id: product_id, product_version: product_version, component_id: component_id, price_point_id: price_point_id, billing_schedule_item_id: billing_schedule_item_id, custom_item: custom_item, prepaid_allocation_expires_at: prepaid_allocation_expires_at, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
# File 'lib/advanced_billing/models/credit_note_line_item.rb', line 137 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['tax_included'] = 'tax_included' @_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['billing_schedule_item_id'] = 'billing_schedule_item_id' @_hash['custom_item'] = 'custom_item' @_hash['prepaid_allocation_expires_at'] = 'prepaid_allocation_expires_at' @_hash end |
.nullables ⇒ Object
An array for nullable fields
190 191 192 193 194 195 196 197 |
# File 'lib/advanced_billing/models/credit_note_line_item.rb', line 190 def self.nullables %w[ component_id price_point_id billing_schedule_item_id prepaid_allocation_expires_at ] end |
.optionals ⇒ Object
An array for optional fields
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
# File 'lib/advanced_billing/models/credit_note_line_item.rb', line 164 def self.optionals %w[ uid title description quantity unit_price subtotal_amount discount_amount tax_amount tax_included total_amount tiered_unit_price period_range_start period_range_end product_id product_version component_id price_point_id billing_schedule_item_id custom_item prepaid_allocation_expires_at ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
302 303 304 305 306 307 308 |
# File 'lib/advanced_billing/models/credit_note_line_item.rb', line 302 def self.validate(value) return true if value.instance_of? self return false unless value.instance_of? Hash true end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 |
# File 'lib/advanced_billing/models/credit_note_line_item.rb', line 326 def inspect class_name = self.class.name.split('::').last "<#{class_name} uid: #{@uid.inspect}, title: #{@title.inspect}, description:"\ " #{@description.inspect}, quantity: #{@quantity.inspect}, unit_price:"\ " #{@unit_price.inspect}, subtotal_amount: #{@subtotal_amount.inspect}, discount_amount:"\ " #{@discount_amount.inspect}, tax_amount: #{@tax_amount.inspect}, tax_included:"\ " #{@tax_included.inspect}, total_amount: #{@total_amount.inspect}, tiered_unit_price:"\ " #{@tiered_unit_price.inspect}, period_range_start: #{@period_range_start.inspect},"\ " period_range_end: #{@period_range_end.inspect}, product_id: #{@product_id.inspect},"\ " product_version: #{@product_version.inspect}, component_id: #{@component_id.inspect},"\ " price_point_id: #{@price_point_id.inspect}, billing_schedule_item_id:"\ " #{@billing_schedule_item_id.inspect}, custom_item: #{@custom_item.inspect},"\ " prepaid_allocation_expires_at: #{@prepaid_allocation_expires_at.inspect},"\ " additional_properties: #{get_additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
311 312 313 314 315 316 317 318 319 320 321 322 323 |
# File 'lib/advanced_billing/models/credit_note_line_item.rb', line 311 def to_s class_name = self.class.name.split('::').last "<#{class_name} uid: #{@uid}, title: #{@title}, description: #{@description}, quantity:"\ " #{@quantity}, unit_price: #{@unit_price}, subtotal_amount: #{@subtotal_amount},"\ " discount_amount: #{@discount_amount}, tax_amount: #{@tax_amount}, tax_included:"\ " #{@tax_included}, total_amount: #{@total_amount}, tiered_unit_price:"\ " #{@tiered_unit_price}, period_range_start: #{@period_range_start}, period_range_end:"\ " #{@period_range_end}, product_id: #{@product_id}, product_version: #{@product_version},"\ " component_id: #{@component_id}, price_point_id: #{@price_point_id},"\ " billing_schedule_item_id: #{@billing_schedule_item_id}, custom_item: #{@custom_item},"\ " prepaid_allocation_expires_at: #{@prepaid_allocation_expires_at}, additional_properties:"\ " #{get_additional_properties}>" end |