Search in sources :

Example 1 with RefundAndCancelAccountCommand

use of org.folio.circulation.services.support.RefundAndCancelAccountCommand in project mod-circulation by folio-org.

the class FeeFineFacade method cancelAccountIfNeeded.

CompletableFuture<Result<AccountActionResponse>> cancelAccountIfNeeded(RefundAndCancelAccountCommand command, User user) {
    final Account account = command.getAccount();
    if (!account.getRemaining().hasAmount()) {
        log.info("Nothing to cancel for account {}", account.getId());
        return ofAsync(() -> null);
    }
    log.info("Initiating cancel for account {}", account.getId());
    final CancelAccountCommand cancelCommand = CancelAccountCommand.builder().accountId(account.getId()).currentServicePointId(command.getServicePointId()).cancellationReason(command.getCancelReason()).userName(user.getPersonalName()).build();
    return feeFineService.cancelAccount(cancelCommand);
}
Also used : StoredAccount(org.folio.circulation.domain.representations.StoredAccount) Account(org.folio.circulation.domain.Account) CancelAccountCommand(org.folio.circulation.services.feefine.CancelAccountCommand) RefundAndCancelAccountCommand(org.folio.circulation.services.support.RefundAndCancelAccountCommand)

Example 2 with RefundAndCancelAccountCommand

use of org.folio.circulation.services.support.RefundAndCancelAccountCommand in project mod-circulation by folio-org.

the class FeeFineFacadeTest method refundCommand.

private RefundAndCancelAccountCommand refundCommand() {
    final JsonObject account = new JsonObject().put("feeFineType", "Lost item fee").put("amount", 50.0).put("remaining", 0.0).put("id", UUID.randomUUID().toString());
    final FeeFineAction paidAction = FeeFineAction.from(new JsonObject().put("typeAction", "Paid fully").put("amountAction", 50.0));
    return new RefundAndCancelAccountCommand(Account.from(account).withFeeFineActions(singletonList(paidAction)), "user-id", "sp-id", LOST_ITEM_FOUND, CANCELLED_ITEM_RETURNED);
}
Also used : FeeFineAction(org.folio.circulation.domain.FeeFineAction) JsonObject(io.vertx.core.json.JsonObject) RefundAndCancelAccountCommand(org.folio.circulation.services.support.RefundAndCancelAccountCommand)

Aggregations

RefundAndCancelAccountCommand (org.folio.circulation.services.support.RefundAndCancelAccountCommand)2 JsonObject (io.vertx.core.json.JsonObject)1 Account (org.folio.circulation.domain.Account)1 FeeFineAction (org.folio.circulation.domain.FeeFineAction)1 StoredAccount (org.folio.circulation.domain.representations.StoredAccount)1 CancelAccountCommand (org.folio.circulation.services.feefine.CancelAccountCommand)1