Skip to content

Commit

Permalink
[MODORDERS-1014] - Add "Bindery active" flag in POL with validation
Browse files Browse the repository at this point in the history
  • Loading branch information
azizbekxm committed Apr 22, 2024
1 parent 0f9996b commit 1d13151
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
import org.folio.rest.jaxrs.model.Error;
import org.folio.rest.jaxrs.model.Location;
import org.folio.rest.jaxrs.model.Parameter;
import org.folio.rest.jaxrs.model.Physical;
import org.folio.rest.jaxrs.model.PoLine;
import org.folio.rest.jaxrs.model.PoLineCollection;
import org.folio.rest.jaxrs.model.ProductId;
Expand Down Expand Up @@ -121,6 +122,7 @@ public Future<Void> saveOrderLine(PoLine poLine, RequestContext requestContext)

public Future<Void> saveOrderLine(CompositePoLine compositePoLine, RequestContext requestContext) {
PoLine poLine = HelperUtils.convertToPoLine(compositePoLine);
validateForBinadryActive(poLine);
return saveOrderLine(poLine, requestContext);
}

Expand Down Expand Up @@ -529,5 +531,19 @@ private Future<Void> updateSearchLocations(PoLine poLine, RequestContext request
.map(poLine::withSearchLocationIds)
.mapEmpty();
}

private void validateForBinadryActive(PoLine poLine) {
if (poLine.getIsBindaryActive()) {
if (!poLine.getOrderFormat().equals(PoLine.OrderFormat.PHYSICAL_RESOURCE) ||
poLine.getOrderFormat().equals(PoLine.OrderFormat.P_E_MIX))
throw new IllegalArgumentException("When PoLine is bindary active, its format type must be " +
PoLine.OrderFormat.PHYSICAL_RESOURCE + " or " + PoLine.OrderFormat.P_E_MIX);

if (!poLine.getPhysical().getCreateInventory().equals(Physical.CreateInventory.INSTANCE_HOLDING_ITEM)) {
throw new IllegalArgumentException("When PoLine is bindary active, only '" +
Physical.CreateInventory.INSTANCE_HOLDING_ITEM + "' option can be used");
}
}
}
}

0 comments on commit 1d13151

Please sign in to comment.