private int getTransferNumber(final Transfer transfer) {
   final ScheduledPayment scheduledPayment = transfer.getScheduledPayment();
   int transferNumber = 0;
   for (final Transfer currentTransfer : scheduledPayment.getTransfers()) {
     transferNumber++;
     if (currentTransfer.equals(transfer)) {
       break;
     }
   }
   return transferNumber;
 }
  @Override
  protected ActionForward handleSubmit(final ActionContext context) throws Exception {
    Transfer transfer = resolveTransfer(context);

    // Validate the transaction password if needed
    if (shouldValidateTransactionPassword(context, transfer)) {
      final ScheduledPaymentForm form = context.getForm();
      context.checkTransactionPassword(form.getTransactionPassword());
    }

    // Perform the actual payment
    try {
      transfer = scheduledPaymentService.processTransfer(transfer);
    } catch (final CreditsException e) {
      return context.sendError(actionHelper.resolveErrorKey(e), actionHelper.resolveParameters(e));
    } catch (final UnexpectedEntityException e) {
      return context.sendError("payment.error.invalidTransferType");
    }
    return ActionHelper.redirectWithParam(
        context.getRequest(),
        context.getSuccessForward(),
        "paymentId",
        transfer.getScheduledPayment().getId());
  }
 private int getNumberOfTransfer(final Transfer transfer) {
   final ScheduledPayment scheduledPayment = transfer.getScheduledPayment();
   return scheduledPayment.getTransfers().size();
 }