Module: StandaloneDeliveriesHelper

Defined in:
app/helpers/standalone_deliveries_helper.rb

Overview

== Schema Information

Table name: standalone_deliveries

id :integer not null, primary key
store_id :integer
origin_address_id :integer
destination_address_id :integer
service_code :string
shipping_rates :hstore is an Array
actual_shipping_cost :decimal(, )
state :string
shipping_account_number :string
billing_postal_code :string

Instance Method Summary collapse

Instance Method Details



19
20
21
# File 'app/helpers/standalone_deliveries_helper.rb', line 19

def add_standalone_delivery_shipment_link(name)
  link_to name, "#", onclick: "$('#shipments').append('#{j(render(:partial => 'shipment_field', :locals => {:remove_link => true, :package => WarehousePackage.new, :shipment => Shipment.new(:state => 'awaiting_label')}))}');return false", class: 'btn btn-outline-primary'
end

#standalone_delivery_icon_for_state(state) ⇒ Object



23
24
25
# File 'app/helpers/standalone_deliveries_helper.rb', line 23

def standalone_delivery_icon_for_state( state )
  { open: 'circle', packaged: 'dropbox', ship_rated: 'envelope', ship_labeled: 'envelope', complete: 'check'}[state.to_sym]
end

#standalone_delivery_ship_commands(standalone_delivery = @standalone_delivery) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'app/helpers/standalone_deliveries_helper.rb', line 32

def standalone_delivery_ship_commands( standalone_delivery = @standalone_delivery )
  opts = []
  with_options( class: 'btn btn-outline-primary block-ui-on-click' ) do |defaults|
    if standalone_delivery.ready_to_label?
      opts << blocking_submit_button(label: "Generate Ship Label(s)")
    elsif standalone_delivery.ship_labeled?
      opts << defaults.link_to( "Void Ship Label(s)", void_ship_labels_standalone_delivery_path( standalone_delivery ), data: { turbo_confirm: "Are you sure you want to void the ship label(s)?", turbo_method: :put } )
    end
    if standalone_delivery.ready_to_rate?
      opts << defaults.link_to( standalone_delivery.ship_rated? ? "Refresh Shipping Rates" : "Get Shipping Rates", find_ship_rates_standalone_delivery_path(@standalone_delivery), data: { turbo_method: :put } )
    end
  end
  opts
end

#standalone_delivery_ship_rate_for_select(standalone_delivery = @standalone_delivery) ⇒ Object



27
28
29
30
# File 'app/helpers/standalone_deliveries_helper.rb', line 27

def standalone_delivery_ship_rate_for_select( standalone_delivery = @standalone_delivery )
  standalone_delivery.shipping_rates.map{|pr| ["#{pr["service_name"]}: #{number_to_currency(pr["total_charges"].to_f)}", pr["service_code"]]}
  # standalone_delivery.shipping_rates.map{|pr| ["#{ShippingOption.active.where(country: standalone_delivery.origin_address.country_iso).where(service_code: pr["service_code"]).first.description}: #{number_to_currency(pr["total_charges"].to_f)}", pr["service_code"]]}
end