-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MODORDERS-989] - Implemented endpoint to restore piece status
- Loading branch information
Khamidulla Abdulkhakimov
authored and
Khamidulla Abdulkhakimov
committed
Jan 16, 2024
1 parent
cbe8a8a
commit 745930c
Showing
6 changed files
with
124 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#%RAML 1.0 | ||
title: Restoration | ||
baseUri: https://github.com/folio-org/mod-orders | ||
version: v1 | ||
protocols: [ HTTP, HTTPS ] | ||
|
||
documentation: | ||
- title: Orders Business Logic API | ||
content: <b>API for transition pieces status from unreceivable to expected</b> | ||
|
||
types: | ||
receiving-collection: !include acq-models/mod-orders/schemas/receivingCollection.json | ||
receiving-results: !include acq-models/mod-orders/schemas/receivingResults.json | ||
errors: !include raml-util/schemas/errors.schema | ||
UUID: | ||
type: string | ||
pattern: ^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$ | ||
|
||
traits: | ||
validate: !include raml-util/traits/validation.raml | ||
|
||
resourceTypes: | ||
post-with-200: !include rtypes/post-json-200.raml | ||
|
||
/orders/restore: | ||
displayName: Restore items | ||
description: | | ||
Receive items spanning one or more PO lines. The endpoint is used to: | ||
- receive pieces and associated inventory items | ||
- move a received piece back to "Expected" in case "receivedItems" element's "itemStatus" is "On order" | ||
type: | ||
post-with-200: | ||
requestSchema: receiving-collection | ||
responseSchema: receiving-results | ||
requestExample: !include acq-models/mod-orders/examples/receivingCollection.sample | ||
responseExample: !include acq-models/mod-orders/examples/receivingResults.sample | ||
is: [validate] | ||
post: | ||
description: Receive items spanning one or more PO lines |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package org.folio.helper; | ||
|
||
import io.vertx.core.Context; | ||
import io.vertx.core.Future; | ||
import org.folio.rest.core.models.RequestContext; | ||
import org.folio.rest.jaxrs.model.Piece; | ||
import org.folio.rest.jaxrs.model.ReceivingCollection; | ||
import org.folio.rest.jaxrs.model.ReceivingResults; | ||
|
||
import java.util.Map; | ||
|
||
public class RestoreHelper extends ReceivingHelper { | ||
|
||
public RestoreHelper(ReceivingCollection receivingCollection, Map<String, String> okapiHeaders, Context ctx) { | ||
super(receivingCollection, okapiHeaders, ctx); | ||
} | ||
|
||
public Future<ReceivingResults> restorePiece(ReceivingCollection restorationCollection, RequestContext requestContext) { | ||
return receiveItems(restorationCollection, requestContext); | ||
} | ||
|
||
@Override | ||
protected boolean isRevertToOnOrder(Piece piece) { | ||
return piece.getReceivingStatus() == Piece.ReceivingStatus.UNRECEIVABLE | ||
&& inventoryManager | ||
.isOnOrderItemStatus(piecesByLineId.get(piece.getPoLineId()).get(piece.getId())); | ||
} | ||
|
||
@Override | ||
protected void updatePieceWithReceivingInfo(Piece piece) { | ||
super.updatePieceWithReceivingInfo(piece); | ||
|
||
piece.setReceivedDate(null); | ||
piece.setReceivingStatus(Piece.ReceivingStatus.EXPECTED); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters