Class: Spree::OrderUpdater
- Inherits:
-
Object
- Object
- Spree::OrderUpdater
- Defined in:
- app/models/spree/order_updater_decorator.rb
Instance Method Summary collapse
- #is_needed_to_create_adjustment? ⇒ Boolean
- #super_update_adjustments ⇒ Object
- #super_update_payment_state ⇒ Object
- #super_update_shipment_state ⇒ Object
-
#update_adjustments ⇒ Object
this method is intended to add adjustment to old transactions which was created without our plugin.
- #update_payment_state ⇒ Object
- #update_shipment_state ⇒ Object
Instance Method Details
#is_needed_to_create_adjustment? ⇒ Boolean
11 12 13 14 15 16 17 18 19 |
# File 'app/models/spree/order_updater_decorator.rb', line 11 def is_needed_to_create_adjustment? settings = Spree::ExactorSetting.get_settings if order.completed? and ['complete', 'canceled', 'resumed'].include?(order.state) if settings and order.completed_at >= settings.effective_date return true end end return false end |
#super_update_adjustments ⇒ Object
7 |
# File 'app/models/spree/order_updater_decorator.rb', line 7 alias :super_update_adjustments :update_adjustments |
#super_update_payment_state ⇒ Object
8 |
# File 'app/models/spree/order_updater_decorator.rb', line 8 alias :super_update_payment_state :update_payment_state |
#super_update_shipment_state ⇒ Object
9 |
# File 'app/models/spree/order_updater_decorator.rb', line 9 alias :super_update_shipment_state :update_shipment_state |
#update_adjustments ⇒ Object
this method is intended to add adjustment to old transactions which was created without our plugin
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/models/spree/order_updater_decorator.rb', line 22 def update_adjustments if !is_needed_to_create_adjustment? super_update_adjustments return end count_of_tax_adj = order.adjustments.reload.tax.size current_tax_adj = order.adjustments.reload.tax.first unless count_of_tax_adj == 0 or (count_of_tax_adj==1 and !current_tax_adj.originator.nil? and current_tax_adj.originator.is_exactor_default?) order.adjustments.tax.each(&:destroy) return end if count_of_tax_adj == 0 TaxRate.match(order).each { |rate| rate.adjust(order) } end super_update_adjustments end |
#update_payment_state ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 |
# File 'app/models/spree/order_updater_decorator.rb', line 40 def update_payment_state super_update_payment_state exactor_connector = SpreeExactorConnector::SpreeExactorConnector.new # due to unknown reasons payment_state is paid when user add first line item into order # so, we need to check order state too if order.payment_state=='paid' and order.state == 'complete' exactor_connector.do_payment_completed!(order) elsif order.current_payment and order.current_payment.state == 'void' and order.current_payment.previous_state == 'completed' exactor_connector.do_refund_payment!(order) end end |
#update_shipment_state ⇒ Object
52 53 54 55 56 57 58 |
# File 'app/models/spree/order_updater_decorator.rb', line 52 def update_shipment_state super_update_shipment_state if (order.shipment_state=='shipped') exactor_connector = SpreeExactorConnector::SpreeExactorConnector.new exactor_connector.do_shipped!(order) end end |