Source:
private Date determineLastBilledDateByInvoicingOption(List<ContractsAndGrantsBillingAwardAccount> awardAccounts, String invoicingOptionCode, Date awardLastBilledDate) { Date computedLastBilledDate = null; if (StringUtils.equalsIgnoreCase(CuArConstants.AwardInvoicingOptionCodeToName.INV_ACCOUNT.getCode(), invoicingOptionCode) || StringUtils.equalsIgnoreCase(CuArConstants.AwardInvoicingOptionCodeToName.INV_CONTRACT_CONTROL_ACCOUNT.getCode(), invoicingOptionCode)) { ContractsAndGrantsBillingAwardAccount accountToUse = null; for (ContractsAndGrantsBillingAwardAccount awardAccount : awardAccounts) { if (ObjectUtils.isNotNull(accountToUse)) { if (isNotExpenditureAccount(awardAccount) && ObjectUtils.isNotNull(awardAccount.getCurrentLastBilledDate()) && ObjectUtils.isNotNull(accountToUse.getCurrentLastBilledDate()) && awardAccount.getCurrentLastBilledDate().after(accountToUse.getCurrentLastBilledDate())) { accountToUse = awardAccount; } } else if (isNotExpenditureAccount(awardAccount)) { accountToUse = awardAccount; } } if (ObjectUtils.isNotNull(accountToUse)) { computedLastBilledDate = accountToUse.getCurrentLastBilledDate(); } else { LOG.error("determineLastBilledDateByInvoicingOption: NO award accounts passed to method when award had invoice option of Account or Contract Control Account. lastBilledDate being returned as computedLastBilledDate =" + computedLastBilledDate); } } else if (StringUtils.equalsIgnoreCase(CuArConstants.AwardInvoicingOptionCodeToName.INV_AWARD.getCode(), invoicingOptionCode) || StringUtils.equalsIgnoreCase(CuArConstants.AwardInvoicingOptionCodeToName.INV_SCHEDULE.getCode(), invoicingOptionCode)) { computedLastBilledDate = awardLastBilledDate; } return computedLastBilledDate; }

Target:
private Date determineLastBilledDateByInvoicingOption(List<ContractsAndGrantsBillingAwardAccount> awardAccounts, String invoicingOptionCode, Date awardLastBilledDate) { Date computedLastBilledDate = null; if (StringUtils.equalsIgnoreCase(CuArConstants.AwardInvoicingOptionCodeToName.INV_ACCOUNT.getCode(), invoicingOptionCode) || StringUtils.equalsIgnoreCase(CuArConstants.AwardInvoicingOptionCodeToName.INV_CONTRACT_CONTROL_ACCOUNT.getCode(), invoicingOptionCode)) { ContractsAndGrantsBillingAwardAccount accountToUse = null; for (ContractsAndGrantsBillingAwardAccount awardAccount : awardAccounts) { if (ObjectUtils.isNotNull(accountToUse)) { if (isNotExpenditureAccount(awardAccount) && ObjectUtils.isNotNull(awardAccount.getCurrentLastBilledDate()) && ObjectUtils.isNotNull(accountToUse.getCurrentLastBilledDate()) && awardAccount.getCurrentLastBilledDate().after(accountToUse.getCurrentLastBilledDate())) { accountToUse = awardAccount; } } else if (isNotExpenditureAccount(awardAccount)) { accountToUse = awardAccount; } } if (ObjectUtils.isNotNull(accountToUse)) { computedLastBilledDate = accountToUse.getCurrentLastBilledDate(); } else { LOG.error("determineLastBilledDateByInvoicingOption: Either NO award accounts OR NO NON-Expenditure award accounts passed to method when award had invoice option of Account or Contract Control Account. lastBilledDate being returned as computedLastBilledDate =" + computedLastBilledDate); } } else if (StringUtils.equalsIgnoreCase(CuArConstants.AwardInvoicingOptionCodeToName.INV_AWARD.getCode(), invoicingOptionCode) || StringUtils.equalsIgnoreCase(CuArConstants.AwardInvoicingOptionCodeToName.INV_SCHEDULE.getCode(), invoicingOptionCode)) { computedLastBilledDate = awardLastBilledDate; } return computedLastBilledDate; }