Class: Colppy::Invoice::TaxTotal
- Inherits:
-
Object
- Object
- Colppy::Invoice::TaxTotal
- Includes:
- Utils
- Defined in:
- lib/colppy/resources/invoice.rb
Constant Summary collapse
- ATTRIBUTES_MAPPER =
{ alicuotaIva: :tax_factor, importeIva: :tax_amount, baseImpIva: :taxed_amount }.freeze
- DATA_KEYS_SETTERS =
ATTRIBUTES_MAPPER.values
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(params) ⇒ TaxTotal
constructor
A new instance of TaxTotal.
- #inspect ⇒ Object
- #save_parameters ⇒ Object
- #tax_name ⇒ Object
Methods included from Utils
Constructor Details
#initialize(params) ⇒ TaxTotal
Returns a new instance of TaxTotal.
270 271 272 |
# File 'lib/colppy/resources/invoice.rb', line 270 def initialize(params) @data = rename_params_hash(params, ATTRIBUTES_MAPPER, DATA_KEYS_SETTERS) end |
Class Method Details
.add_to_tax_breakdown(tax, amount, taxed_amount, breakdown = nil) ⇒ Object
256 257 258 259 260 261 |
# File 'lib/colppy/resources/invoice.rb', line 256 def self.add_to_tax_breakdown(tax, amount, taxed_amount, breakdown = nil) breakdown = breakdown || { tax_factor: tax, tax_amount: 0.0, taxed_amount: 0.0 } breakdown[:tax_amount] += amount breakdown[:taxed_amount] += taxed_amount breakdown end |
Instance Method Details
#inspect ⇒ Object
295 |
# File 'lib/colppy/resources/invoice.rb', line 295 def inspect; end |
#save_parameters ⇒ Object
287 288 289 290 291 292 293 |
# File 'lib/colppy/resources/invoice.rb', line 287 def save_parameters { alicuotaIva: tax_name, importeIva: @data[:tax_amount], baseImpIva: @data[:taxed_amount] } end |
#tax_name ⇒ Object
279 280 281 282 283 284 285 |
# File 'lib/colppy/resources/invoice.rb', line 279 def tax_name if @data[:tax_factor] % 1 == 0 @data[:tax_factor].to_i.to_s else @data[:tax_factor].to_s end end |