Class: Facturae::Line
- Inherits:
-
Object
- Object
- Facturae::Line
- Includes:
- Validatable
- Defined in:
- lib/facturae/models/line.rb
Overview
Represents a line in an invoice.
Constant Summary collapse
- UNIT_DEFAULT =
Default unit of measure code (units)
"01"
Instance Attribute Summary collapse
-
#article_code ⇒ String
The article code.
-
#charges ⇒ Array
The charges.
-
#discounts_and_rebates ⇒ Array
The discounts and rebates.
-
#gross_amount ⇒ Float
The gross amount.
-
#item_description ⇒ String
The item description.
-
#quantity ⇒ Float
The quantity.
-
#taxes_output ⇒ Object
Returns the value of attribute taxes_output.
-
#total_cost ⇒ Float
The total cost.
-
#unit_of_measure ⇒ Object
Returns the value of attribute unit_of_measure.
-
#unit_price_without_tax ⇒ Float
The unit price without tax.
Instance Method Summary collapse
-
#add_charge(reason, amount) ⇒ Object
-
#add_discount(reason, amount) ⇒ Object
-
#initialize(item_description:, quantity:, unit_price_without_tax:, total_cost:, **options) ⇒ Line
constructor
A new instance of Line.
Methods included from Validatable
Constructor Details
#initialize(item_description:, quantity:, unit_price_without_tax:, total_cost:, **options) ⇒ Line
Returns a new instance of Line.
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/facturae/models/line.rb', line 30 def initialize(item_description:, quantity:, unit_price_without_tax:, total_cost:, **) @item_description = item_description @quantity = quantity @unit_price_without_tax = unit_price_without_tax @total_cost = total_cost @article_code = .fetch(:article_code, nil) @unit_of_measure = .fetch(:unit_of_measure, UNIT_DEFAULT) @taxes_output = .fetch(:taxes_output, []) @discounts_and_rebates = [] @charges = [] @gross_amount = quantity * unit_price_without_tax end |
Instance Attribute Details
#article_code ⇒ String
The article code.
13 14 15 |
# File 'lib/facturae/models/line.rb', line 13 def article_code @article_code end |
#charges ⇒ Array
The charges.
13 14 15 |
# File 'lib/facturae/models/line.rb', line 13 def charges @charges end |
#discounts_and_rebates ⇒ Array
The discounts and rebates.
13 14 15 |
# File 'lib/facturae/models/line.rb', line 13 def discounts_and_rebates @discounts_and_rebates end |
#gross_amount ⇒ Float
The gross amount.
13 14 15 |
# File 'lib/facturae/models/line.rb', line 13 def gross_amount @gross_amount end |
#item_description ⇒ String
The item description.
13 14 15 |
# File 'lib/facturae/models/line.rb', line 13 def item_description @item_description end |
#quantity ⇒ Float
The quantity.
13 14 15 |
# File 'lib/facturae/models/line.rb', line 13 def quantity @quantity end |
#taxes_output ⇒ Object
Returns the value of attribute taxes_output.
19 20 21 |
# File 'lib/facturae/models/line.rb', line 19 def taxes_output @taxes_output end |
#total_cost ⇒ Float
The total cost.
13 14 15 |
# File 'lib/facturae/models/line.rb', line 13 def total_cost @total_cost end |
#unit_of_measure ⇒ Object
Returns the value of attribute unit_of_measure.
19 20 21 |
# File 'lib/facturae/models/line.rb', line 19 def unit_of_measure @unit_of_measure end |
#unit_price_without_tax ⇒ Float
The unit price without tax.
13 14 15 |
# File 'lib/facturae/models/line.rb', line 13 def unit_price_without_tax @unit_price_without_tax end |
Instance Method Details
#add_charge(reason, amount) ⇒ Object
47 48 49 |
# File 'lib/facturae/models/line.rb', line 47 def add_charge(reason, amount) @charges << { reason: reason, amount: amount } end |
#add_discount(reason, amount) ⇒ Object
43 44 45 |
# File 'lib/facturae/models/line.rb', line 43 def add_discount(reason, amount) @discounts_and_rebates << { reason: reason, amount: amount } end |