Class: Invoicing::Taxable::ClassInfo
- Inherits:
-
ClassInfo::Base
- Object
- ClassInfo::Base
- Invoicing::Taxable::ClassInfo
- Defined in:
- lib/invoicing/taxable.rb
Overview
:nodoc:
Instance Attribute Summary
Attributes inherited from ClassInfo::Base
#all_args, #all_options, #current_args, #current_options, #model_class, #new_args, #previous_info
Instance Method Summary collapse
-
#convert(object, attr_without_suffix, value, from_status, to_status) ⇒ Object
Performs the conversion between taxed and untaxed values.
Methods inherited from ClassInfo::Base
#get, #initialize, #method, #option_defaults, #set
Constructor Details
This class inherits a constructor from Invoicing::ClassInfo::Base
Instance Method Details
#convert(object, attr_without_suffix, value, from_status, to_status) ⇒ Object
Performs the conversion between taxed and untaxed values. Arguments from_status
and to_status
must each be either :taxed
or :untaxed
.
351 352 353 354 355 356 357 358 359 360 361 |
# File 'lib/invoicing/taxable.rb', line 351 def convert(object, attr_without_suffix, value, from_status, to_status) return nil if value.nil? value = BigDecimal.new(value.to_s) return value if from_status == to_status if to_status == :taxed [:tax_logic].apply_tax({:model_object => object, :attribute => attr_without_suffix, :value => value}) else [:tax_logic].remove_tax({:model_object => object, :attribute => attr_without_suffix, :value => value}) end end |