Skip to content

Commit

Permalink
[MODORDERS-1209-2]. Update Send Claims and Piece Batch Update models …
Browse files Browse the repository at this point in the history
…with new properties (#1070)

* [MODORDERS-1209-2]. Update Send Claims and Piece Batch Update models with new properties

* [MODORDERS-1209-2]. Add test coverage to PieceUtil

* [MODORDERS-1209-2]. Add missing PieceUtilTestNested

* [MODORDERS-1209-2]. Add integration details validation to Send Claims

* [MODORDERS-1209-2]. Change validation to throw an exception

* [MODORDERS-1209-2]. Throw http exception for all handled exception cases

* [MODORDERS-1209-2]. Add tenant validation to integration details

* [MODORDERS-1209-2]. Remove unnecessary tenant validation
  • Loading branch information
BKadirkhodjaev authored Dec 20, 2024
1 parent f0f3832 commit 8ab6e5d
Show file tree
Hide file tree
Showing 17 changed files with 457 additions and 189 deletions.
17 changes: 0 additions & 17 deletions src/main/java/org/folio/models/claiming/ClaimingError.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
@Getter
@AllArgsConstructor
public enum IntegrationDetailField {
TENANT("tenant"),
EXPORT_TYPE_SPECIFIC_PARAMETERS("exportTypeSpecificParameters"),
VENDOR_EDI_ORDERS_EXPORT_CONFIG("vendorEdiOrdersExportConfig"),
CLAIM_PIECE_IDS("claimPieceIds");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ public class PieceBatchStatusUpdateHolder extends BasePieceFlowHolder {
@Getter
private Piece.ReceivingStatus receivingStatus;
@Getter
private Integer claimingInterval;
@Getter
private String internalNote;
@Getter
private String externalNote;
@Getter
private List<Piece> pieces;
private String poLineId;

Expand Down
9 changes: 8 additions & 1 deletion src/main/java/org/folio/rest/core/exceptions/ErrorCodes.java
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,14 @@ public enum ErrorCodes {
RECEIVING_WORKFLOW_INCORRECT_FOR_BINDARY_ACTIVE("receivingWorkflowIncorrectForBindaryActive", "When PoLine is bindery active, its receiving workflow must be set to 'Independent order and receipt quantity'"),
BIND_ITEM_MUST_INCLUDE_EITHER_HOLDING_ID_OR_LOCATION_ID("bindItemMustIncludeEitherHoldingIdOrLocationId", "During binding pieces, the bindItem object must have either holdingId or locationId field populated"),
BUDGET_NOT_FOUND_FOR_FISCAL_YEAR("budgetNotFoundForFiscalYear", "Could not find an active budget for a fund with the current fiscal year of another fund in the fund distribution"),
LAST_PIECE("lastPiece", "The piece cannot be deleted because it is the last piece for the poLine with Receiving Workflow 'Synchronized order and receipt quantity' and cost quantity '1'"),;
LAST_PIECE("lastPiece", "The piece cannot be deleted because it is the last piece for the poLine with Receiving Workflow 'Synchronized order and receipt quantity' and cost quantity '1'"),
CANNOT_SEND_CLAIMS_PIECE_IDS_ARE_EMPTY("cannotSendClaimsPieceIdsAreEmpty", "Cannot send claims, piece ids are empty"),
CANNOT_FIND_PIECES_WITH_LATE_STATUS_TO_PROCESS("cannotFindPiecesWithLatestStatusToProcess", "Cannot find pieces with LATE status to process"),
CANNOT_RETRIEVE_CONFIG_ENTRIES("cannotRetrieveConfigEntries", "Cannot retrieve config entries"),
CANNOT_GROUP_PIECES_BY_VENDOR("cannotGroupPiecesByVendorMessage", "Cannot group pieces by vendor"),
CANNOT_CREATE_JOBS_AND_UPDATE_PIECES("cannotCreateJobsAndUpdatePieces", "Cannot create jobs and update pieces"),
CANNOT_FIND_PIECE_BY_ID("cannotFindPieceById", "Cannot find a piece by '%s' id"),
UNABLE_TO_GENERATE_CLAIMS_FOR_ORG_NO_INTEGRATION_DETAILS("unableToGenerateClaimsForOrgNoIntegrationDetails", "Unable to generate claims for %s because no claim integrations exist");

private final String code;
private final String description;
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/org/folio/rest/impl/PiecesAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,10 @@ public void getOrdersPiecesRequests(List<String> pieceIds, String status, Map<St
@Override
public void putOrdersPiecesBatchStatus(PieceBatchStatusCollection pieceBatchStatusCollection, Map<String, String> okapiHeaders,
Handler<AsyncResult<Response>> asyncResultHandler, Context vertxContext) {
pieceUpdateFlowManager.updatePiecesStatuses(pieceBatchStatusCollection.getPieceIds(), pieceBatchStatusCollection.getReceivingStatus(), new RequestContext(vertxContext, okapiHeaders))
var pieceIds = pieceBatchStatusCollection.getPieceIds();
var receivingStatus = pieceBatchStatusCollection.getReceivingStatus();
var claimingInterval = pieceBatchStatusCollection.getClaimingInterval();
pieceUpdateFlowManager.updatePiecesStatuses(pieceIds, receivingStatus, claimingInterval, null, null, new RequestContext(vertxContext, okapiHeaders))
.onSuccess(v -> asyncResultHandler.handle(succeededFuture(buildNoContentResponse())))
.onFailure(t -> handleErrorResponse(asyncResultHandler, t));
}
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/org/folio/service/pieces/PieceUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.util.Optional;
import java.util.stream.Collectors;

import org.folio.models.pieces.PieceBatchStatusUpdateHolder;
import org.folio.orders.utils.PoLineCommonUtil;
import org.folio.rest.jaxrs.model.CompositePoLine;
import org.folio.rest.jaxrs.model.Eresource;
Expand Down Expand Up @@ -82,4 +83,16 @@ public static boolean updatePieceStatus(Piece piece, Piece.ReceivingStatus oldSt
return isStatusChanged;
}

public static boolean updatePieceStatus(Piece piece, PieceBatchStatusUpdateHolder holder) {
var isStatusChanged = !piece.getReceivingStatus().equals(holder.getReceivingStatus());
if (isStatusChanged) {
piece.setStatusUpdatedDate(new Date());
}
piece.setReceivingStatus(holder.getReceivingStatus());
piece.setClaimingInterval(holder.getClaimingInterval());
piece.setInternalNote(holder.getInternalNote());
piece.setExternalNote(holder.getExternalNote());
return isStatusChanged;
}

}
Loading

0 comments on commit 8ab6e5d

Please sign in to comment.