From 1d131518eb965346e7f649c2850fd01eb54841f0 Mon Sep 17 00:00:00 2001 From: Azizbek Khushvakov Date: Mon, 22 Apr 2024 17:35:56 +0500 Subject: [PATCH] [MODORDERS-1014] - Add "Bindery active" flag in POL with validation --- ramls/acq-models | 2 +- .../service/orders/PurchaseOrderLineService.java | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/ramls/acq-models b/ramls/acq-models index a7e3117c3..0da51efec 160000 --- a/ramls/acq-models +++ b/ramls/acq-models @@ -1 +1 @@ -Subproject commit a7e3117c364902f29d501e1dfbdf5b3c49e363ef +Subproject commit 0da51efec1a58b1f3d8b67b6a916049918693f2a diff --git a/src/main/java/org/folio/service/orders/PurchaseOrderLineService.java b/src/main/java/org/folio/service/orders/PurchaseOrderLineService.java index 5ceeb06ff..694d1041d 100644 --- a/src/main/java/org/folio/service/orders/PurchaseOrderLineService.java +++ b/src/main/java/org/folio/service/orders/PurchaseOrderLineService.java @@ -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; @@ -121,6 +122,7 @@ public Future saveOrderLine(PoLine poLine, RequestContext requestContext) public Future saveOrderLine(CompositePoLine compositePoLine, RequestContext requestContext) { PoLine poLine = HelperUtils.convertToPoLine(compositePoLine); + validateForBinadryActive(poLine); return saveOrderLine(poLine, requestContext); } @@ -529,5 +531,19 @@ private Future 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"); + } + } + } }