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
-
.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
24 25 26 |
# File 'lib/magelex/bill_modifier.rb', line 24 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 |
# 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 end end |
.process_shipping_costs(bill) ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/magelex/bill_modifier.rb', line 15 def self.process_shipping_costs bill if bill.swiss? bill.total_0 += LexwareBill.floor2(bill.shipping_cost) else bill.tax_19 += bill.shipping_cost * 0.19 bill.total_19 += LexwareBill.floor2(bill.shipping_cost * 1.19) end 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)
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/magelex/bill_modifier.rb', line 32 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 |