Cash-Flow 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.

Automatically detect surplus cash above a certain threshold. Transfer surplus into high-interest savings or investment accounts. Trigger cash movement based on account balance thresholds.

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 + ")");
}