Credit Optimisation

This automation ensures that funds are always available in the right accounts at the right time - helping corporate customers cover upcoming expenses, avoid overdrafts, and maintain optimal liquidity without manual intervention.

Continuously track an account for surplus cash beyond regular business needs. When surplus funds are available, automatically apply extra payments towards any credit account. Turn spare cash into smart repayments - no effort required.

Download

trigger = "time";

var savingsAccount = ${savingsAccount:type=AccountInfo, required=true, label="Savings Account", linked=true};

var minAmount = ${minimumAccountBalance:type=decimal, required=true, label="Minimum Account Balance"};

var maxAmount = ${maximumAccountBalance:type=decimal, required=true, label="Maximum Account Balance"};

var bankAccount = getAutomationOwnerAccountInfo();
var bankAccountBalance = getBalance(bankAccount);
var bankAccountBalanceAmount = bankAccountBalance.availableBalance;

if (bankAccountBalanceAmount.compareTo(minAmount) > 0) {
    def transferAmount = bankAccountBalanceAmount.subtract(minAmount);
    if (transferAmount.compareTo(maxAmount) > 0) {
        transferAmount = maxAmount;
    }
    var transferFromCurrentToSaving = PaymentInfo.builder()
            .payer(bankAccount)
            .payee(savingsAccount)
            .amount(AmountInfo.builder()
                    .currency(Currency.GBP)
                    .amount(transferAmount)
                    .build())
            .reason("Cash-flow management")
            .build();
    var payment = createPayment("502652ac-8643-40ee-8275-fd89d449e88f", transferFromCurrentToSaving);
    logMessage("Cash-flow management completed successfully with amount" + transferAmount + "with payment ID: " + payment.paymentId);
} else {
    logMessage("Cash-flow management: the balance (" + bankAccountBalanceAmount + ") doesn't meet the threshold (" + minAmount + ")");
}