Module: Magelex::BillModifier
- Defined in:
- lib/magelex/bill_modifier.rb
Class Method Summary collapse
- .adjust_order_number(bill) ⇒ Object
-
.process(bills) ⇒ Object
shifts to total_0 for swiss orders, consumes the shipping cost (19) and adjusts the order number takes single bill or list of bills.
- .process_shipping_costs(bill) ⇒ Object
- .remove_herr_frau_name(bill) ⇒ Object
-
.swissify(bill) ⇒ Object
total0 consumes total and resets others, if check passes shipping costs should be consumed before this has to be layed out in a graph or documented properly (what happens when).
Class Method Details
.adjust_order_number(bill) ⇒ Object
25 26 27 |
# File 'lib/magelex/bill_modifier.rb', line 25 def self.adjust_order_number bill bill.order_nr.to_s.gsub!(/^e-/, '') end |
.process(bills) ⇒ Object
shifts to total_0 for swiss orders, consumes the shipping cost (19) and adjusts the order number takes single bill or list of bills
7 8 9 10 11 12 13 14 |
# File 'lib/magelex/bill_modifier.rb', line 7 def self.process bills [*bills].each do |bill| swissify bill process_shipping_costs bill adjust_order_number bill remove_herr_frau_name bill end end |
.process_shipping_costs(bill) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/magelex/bill_modifier.rb', line 16 def self.process_shipping_costs bill if bill.swiss? bill.total_0 += bill.shipping_cost else bill.tax_19 += bill.shipping_cost * 0.19 bill.total_19 += (bill.shipping_cost * 1.19) end end |
.remove_herr_frau_name(bill) ⇒ Object
44 45 46 47 |
# File 'lib/magelex/bill_modifier.rb', line 44 def self.remove_herr_frau_name bill bill.customer_name.gsub!(/^Herr /, '') bill.customer_name.gsub!(/^Frau /, '') end |
.swissify(bill) ⇒ Object
total0 consumes total and resets others, if check passes shipping costs should be consumed before this has to be layed out in a graph or documented properly (what happens when)
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/magelex/bill_modifier.rb', line 33 def self.swissify bill return if !bill.swiss? bill.incorrect_tax += (bill.total_19 - bill.total_19 / 1.19) bill.incorrect_tax += (bill.total_7 - bill.total_7 / 1.07) bill.total_0 += (bill.total_19 / 1.19) bill.total_19 = 0 bill.total_0 += (bill.total_7 / 1.07) bill.total_7 = 0 end |