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:
Arthur Vieira
2022-05-26 09:13:26 -03:00
parent 0fb9cc0f2a
commit 95010fcd12
3 changed files with 5 additions and 11 deletions

View File

@@ -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 ) {

View File

@@ -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

View File

@@ -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