mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-28 01:53:25 +00:00
Remove the unlock condition in shipment controller
This assumes unlock is always true so the shipment's fee adjustments always opens and closes.
This commit is contained in:
@@ -25,13 +25,12 @@ $(document).ready(function() {
|
||||
var link = $(this);
|
||||
var shipment_number = link.data('shipment-number');
|
||||
var selected_shipping_rate_id = link.parents('tbody').find("select#selected_shipping_rate_id[data-shipment-number='" + shipment_number + "']").val();
|
||||
var unlock = link.parents('tbody').find("input[name='open_adjustment'][data-shipment-number='" + shipment_number + "']:checked").val();
|
||||
var url = Spree.url( Spree.routes.orders_api + "/" + order_number + "/shipments/" + shipment_number + ".json");
|
||||
|
||||
$.ajax({
|
||||
type: "PUT",
|
||||
url: url,
|
||||
data: { shipment: { selected_shipping_rate_id: selected_shipping_rate_id, unlock: unlock } }
|
||||
data: { shipment: { selected_shipping_rate_id: selected_shipping_rate_id } }
|
||||
}).done(function( msg ) {
|
||||
window.location.reload();
|
||||
}).error(function( msg ) {
|
||||
|
||||
@@ -28,19 +28,14 @@ module Api
|
||||
authorize! :read, Spree::Shipment
|
||||
@shipment = @order.shipments.find_by!(number: params[:id])
|
||||
params[:shipment] ||= []
|
||||
unlock = params[:shipment].delete(:unlock)
|
||||
|
||||
if unlock == 'yes'
|
||||
@shipment.fee_adjustment.fire_events(:open)
|
||||
end
|
||||
@shipment.fee_adjustment.fire_events(:open)
|
||||
|
||||
if @shipment.update(shipment_params)
|
||||
@order.updater.update_totals_and_states
|
||||
end
|
||||
|
||||
if unlock == 'yes'
|
||||
@shipment.fee_adjustment.close
|
||||
end
|
||||
@shipment.fee_adjustment.close
|
||||
|
||||
render json: @shipment.reload, serializer: Api::ShipmentSerializer, status: :ok
|
||||
end
|
||||
|
||||
@@ -62,7 +62,7 @@ describe "spree/admin/orders/edit.html.haml" do
|
||||
|
||||
it "doesn't display closed associated adjustments" do
|
||||
render
|
||||
|
||||
|
||||
expect(rendered).to_not have_content "Associated adjustment closed"
|
||||
end
|
||||
end
|
||||
@@ -102,7 +102,7 @@ describe "spree/admin/orders/edit.html.haml" do
|
||||
|
||||
it "doesn't display closed associated adjustments" do
|
||||
render
|
||||
|
||||
|
||||
expect(rendered).to_not have_content "Associated adjustment closed"
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user