Search in sources :

Example 1 with FeefineActionsBuilder

use of api.support.builders.FeefineActionsBuilder in project mod-circulation by folio-org.

the class FeeFineAccountFixture method pay.

public void pay(String accountId, double amount) {
    final UUID accountUuid = UUID.fromString(accountId);
    final JsonObject account = accountsClient.getById(accountUuid).getJson();
    final double remaining = account.getDouble("remaining") - amount;
    final String actionType = remaining == 0 ? "Paid fully" : "Paid partially";
    final String accountStatus = remaining == 0 ? "Closed" : "Open";
    accountActionsClient.create(new FeefineActionsBuilder().forAccount(accountUuid).withBalance(remaining).withActionAmount(amount).withPaymentMethod("Cash").withActionType(actionType).createdAt("Circ Desk 1"));
    accountsClient.replace(accountUuid, account.copy().put("remaining", remaining).put("status", new JsonObject().put("name", accountStatus)).put("paymentStatus", new JsonObject().put("name", actionType)));
}
Also used : FeefineActionsBuilder(api.support.builders.FeefineActionsBuilder) JsonObject(io.vertx.core.json.JsonObject) UUID(java.util.UUID)

Example 2 with FeefineActionsBuilder

use of api.support.builders.FeefineActionsBuilder in project mod-circulation by folio-org.

the class FeeFineAccountFixture method createManualFeeForLoan.

public IndividualResource createManualFeeForLoan(IndividualResource loan, double amount) {
    final IndividualResource account = accountsClient.create(new AccountBuilder().withLoan(loan).withAmount(amount).withRemainingFeeFine(amount).feeFineStatusOpen().manualFeeFine());
    accountActionsClient.create(new FeefineActionsBuilder().forAccount(account.getId()).withBalance(amount).withActionAmount(amount).withActionType("Manual fee fine").createdAt("Circ Desk 1"));
    return account;
}
Also used : FeefineActionsBuilder(api.support.builders.FeefineActionsBuilder) AccountBuilder(api.support.builders.AccountBuilder) IndividualResource(api.support.http.IndividualResource)

Example 3 with FeefineActionsBuilder

use of api.support.builders.FeefineActionsBuilder in project mod-circulation by folio-org.

the class LoanAnonymizationTests method createClosedAccountWithFeeFines.

void createClosedAccountWithFeeFines(IndividualResource loanResource, ZonedDateTime closedDate) {
    IndividualResource account = accountsClient.create(new AccountBuilder().withLoan(loanResource).feeFineStatusClosed().withRemainingFeeFine(0));
    FeefineActionsBuilder builder = new FeefineActionsBuilder().forAccount(account.getId()).withBalance(0).withDate(closedDate);
    FeefineActionsBuilder builder1 = new FeefineActionsBuilder().forAccount(account.getId()).withBalance(0).withDate(closedDate.minusDays(1));
    feeFineActionsClient.create(builder);
    feeFineActionsClient.create(builder1);
}
Also used : FeefineActionsBuilder(api.support.builders.FeefineActionsBuilder) AccountBuilder(api.support.builders.AccountBuilder) IndividualResource(api.support.http.IndividualResource)

Example 4 with FeefineActionsBuilder

use of api.support.builders.FeefineActionsBuilder in project mod-circulation by folio-org.

the class LoanAnonymizationTests method createOpenAccountWithFeeFines.

void createOpenAccountWithFeeFines(IndividualResource loanResource) {
    IndividualResource account = accountsClient.create(new AccountBuilder().feeFineStatusOpen().withLoan(loanResource).feeFineStatusOpen().withRemainingFeeFine(150));
    FeefineActionsBuilder builder = new FeefineActionsBuilder().forAccount(account.getId()).withBalance(150).withDate(null);
    feeFineActionsClient.create(builder);
}
Also used : FeefineActionsBuilder(api.support.builders.FeefineActionsBuilder) AccountBuilder(api.support.builders.AccountBuilder) IndividualResource(api.support.http.IndividualResource)

Example 5 with FeefineActionsBuilder

use of api.support.builders.FeefineActionsBuilder in project mod-circulation by folio-org.

the class FeeFineAccountFixture method transfer.

public void transfer(String accountId, double amount) {
    final UUID accountUuid = UUID.fromString(accountId);
    final JsonObject account = accountsClient.getById(accountUuid).getJson();
    final double remaining = account.getDouble("remaining") - amount;
    final String actionType = remaining == 0 ? "Transferred fully" : "Transferred partially";
    final String accountStatus = remaining == 0 ? "Closed" : "Open";
    accountActionsClient.create(new FeefineActionsBuilder().forAccount(accountUuid).withBalance(remaining).withActionAmount(amount).withPaymentMethod("Bursar").withActionType(actionType).createdAt("Circ Desk 1"));
    accountsClient.replace(accountUuid, account.copy().put("remaining", remaining).put("status", new JsonObject().put("name", accountStatus)).put("paymentStatus", new JsonObject().put("name", actionType)));
}
Also used : FeefineActionsBuilder(api.support.builders.FeefineActionsBuilder) JsonObject(io.vertx.core.json.JsonObject) UUID(java.util.UUID)

Aggregations

FeefineActionsBuilder (api.support.builders.FeefineActionsBuilder)5 AccountBuilder (api.support.builders.AccountBuilder)3 IndividualResource (api.support.http.IndividualResource)3 JsonObject (io.vertx.core.json.JsonObject)2 UUID (java.util.UUID)2