Class: Billing::Charge
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Billing::Charge
- Extended by:
- BillTextParser
- Includes:
- BillItem
- Defined in:
- app/models/billing/charge.rb
Instance Attribute Summary collapse
-
#department ⇒ Object
Returns the value of attribute department.
-
#plu ⇒ Object
Returns the value of attribute plu.
-
#tax_group ⇒ Object
Returns the value of attribute tax_group.
Class Method Summary collapse
Instance Method Summary collapse
-
#find_tax_group_mapping_for(fiscal_driver) ⇒ Object
optimize and remove me!.
- #qtyprice ⇒ Object
Methods included from BillTextParser
parse_plu, parse_qty, parse_text
Instance Attribute Details
#department ⇒ Object
Returns the value of attribute department.
5 6 7 |
# File 'app/models/billing/charge.rb', line 5 def department @department end |
#plu ⇒ Object
Returns the value of attribute plu.
5 6 7 |
# File 'app/models/billing/charge.rb', line 5 def plu @plu end |
#tax_group ⇒ Object
Returns the value of attribute tax_group.
5 6 7 |
# File 'app/models/billing/charge.rb', line 5 def tax_group @tax_group end |
Class Method Details
.wild_args(*args) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'app/models/billing/charge.rb', line 41 def wild_args(*args) case when args.blank? || args.first.is_a?(Hash) then return {}.merge(*args) when args.size == 1 && args.first.is_a?(String) then if match = args.shift.match(/(\d+[.,]\d+\*|\d+\*|)(\d+[.,]\d+[A-Z]*|\d+[A-Z]*|)(#\d+|)(@\d+|)([+-]\d+[.,]\d+\%?|[+-]\d+\%?|)(\/\S+|)/) qty_s, price_s, plu_s, tax_group_s, mod_s, text = match.captures return { qty: parse_qty(qty_s), price: price_s.to_money, plu: parse_plu(plu_s), name: parse_text(text) } end else h = { price: args.shift.to_money } return args.any? ? h.merge(*args) : h end end |
Instance Method Details
#find_tax_group_mapping_for(fiscal_driver) ⇒ Object
optimize and remove me!
32 33 34 35 36 37 |
# File 'app/models/billing/charge.rb', line 32 def find_tax_group_mapping_for(fiscal_driver) # optimize and remove me! if tax_groups.present? && fiscal_driver.fiscal? #if billable provides tax groups (delegate) tax_group = tax_groups.find_by(percent_ratio: tax_ratio) tax_group.tax_group_fiscal_driver_mappings.find_by(extface_driver_id: fiscal_driver.id).try(:mapping) if tax_group end end |
#qtyprice ⇒ Object
28 29 30 |
# File 'app/models/billing/charge.rb', line 28 def qtyprice (qty || 1) * price end |