Method: Invoicing::Taxable::ClassInfo#convert

Defined in:
lib/invoicing/taxable.rb

#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(value.to_s)
  return value if from_status == to_status

  if to_status == :taxed
    all_options[:tax_logic].apply_tax({:model_object => object, :attribute => attr_without_suffix, :value => value})
  else
    all_options[:tax_logic].remove_tax({:model_object => object, :attribute => attr_without_suffix, :value => value})
  end
end