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
- #add_standalone_delivery_shipment_link(name) ⇒ Object
- #standalone_delivery_icon_for_state(state) ⇒ Object
- #standalone_delivery_ship_commands(standalone_delivery = @standalone_delivery) ⇒ Object
- #standalone_delivery_ship_rate_for_select(standalone_delivery = @standalone_delivery) ⇒ Object
Instance Method Details
#add_standalone_delivery_shipment_link(name) ⇒ Object
19 20 21 22 |
# 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
24 25 26 |
# File 'app/helpers/standalone_deliveries_helper.rb', line 24 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
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'app/helpers/standalone_deliveries_helper.rb', line 33 def standalone_delivery_ship_commands(standalone_delivery = @standalone_delivery) opts = [] btn_class = 'btn btn-outline-primary' if standalone_delivery.ready_to_label? opts << (label: "Generate Ship Label(s)") elsif standalone_delivery.ship_labeled? opts << link_to("Void Ship Label(s)", void_ship_labels_standalone_delivery_path(standalone_delivery), class: btn_class, data: { controller: 'ui-blocker', turbo_confirm: "Are you sure you want to void the ship label(s)?", turbo_method: :put }) end if standalone_delivery.ready_to_rate? opts << link_to(standalone_delivery.ship_rated? ? "Refresh Shipping Rates" : "Get Shipping Rates", find_ship_rates_standalone_delivery_path(@standalone_delivery), class: btn_class, data: { controller: 'ui-blocker', turbo_method: :put }) end opts end |
#standalone_delivery_ship_rate_for_select(standalone_delivery = @standalone_delivery) ⇒ Object
28 29 30 31 |
# File 'app/helpers/standalone_deliveries_helper.rb', line 28 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 |