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);
}
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);
}
Aggregations