use of org.kuali.kfs.integration.cg.ContractsAndGrantsBillingAwardAccount in project cu-kfs by CU-CommunityApps.
the class ContractsGrantsInvoiceCreateDocumentServiceImpl method createInvoicesByContractControlAccounts.
/**
* Generates and saves Contracts & Grants Invoice Documents based on the given award's contract control accounts
*
* @param awd the award with contract control accounts to build Contracts & Grants Invoice Documents from
* @param errorMessages a holder for error messages
* @param creationProcessType invoice document creation process type
* @param accountDetails letter of credit details if we're creating via loc
* @param locCreationType letter of credit creation type if we're creating via loc
*/
protected void createInvoicesByContractControlAccounts(ContractsAndGrantsBillingAward awd, List<ErrorMessage> errorMessages, ContractsAndGrantsInvoiceDocumentCreationProcessType creationProcessType, List<ContractsGrantsLetterOfCreditReviewDetail> accountDetails, String locCreationType) {
List<ContractsAndGrantsBillingAwardAccount> tmpAcctList = new ArrayList<>();
List<Account> controlAccounts = getContractsGrantsInvoiceDocumentService().getContractControlAccounts(awd);
List<Account> controlAccountsTemp = getContractsGrantsInvoiceDocumentService().getContractControlAccounts(awd);
// to check if the number of contract control accounts is same as the number of accounts
if (controlAccounts == null || (controlAccounts.size() != awd.getActiveAwardAccounts().size())) {
final ErrorMessage errorMessage = new ErrorMessage(ArKeyConstants.ContractsGrantsInvoiceCreateDocumentConstants.NO_CONTROL_ACCOUNT, awd.getProposalNumber());
errorMessages.add(errorMessage);
} else {
Set<Account> controlAccountSet = new HashSet<>();
for (int i = 0; i < controlAccountsTemp.size(); i++) {
if (ObjectUtils.isNotNull(controlAccountsTemp.get(i))) {
for (int j = i + 1; j < controlAccounts.size(); j++) {
if (controlAccountsTemp.get(i).equals(controlAccounts.get(j))) {
controlAccounts.set(j, null);
}
}
} else {
break;
}
}
for (Account ctrlAcct : controlAccounts) {
if (ObjectUtils.isNotNull(ctrlAcct)) {
controlAccountSet.add(ctrlAcct);
}
}
if (controlAccountSet.size() != 0) {
for (Account controlAccount : controlAccountSet) {
Account tmpCtrlAcct;
tmpAcctList.clear();
for (ContractsAndGrantsBillingAwardAccount awardAccount : awd.getActiveAwardAccounts()) {
if (!awardAccount.isFinalBilledIndicator()) {
tmpCtrlAcct = awardAccount.getAccount().getContractControlAccount();
if (tmpCtrlAcct.getChartOfAccountsCode().equals(controlAccount.getChartOfAccountsCode()) && tmpCtrlAcct.getAccountNumber().equals(controlAccount.getAccountNumber())) {
tmpAcctList.add(awardAccount);
}
}
}
// To get valid award accounts of amounts > zero$ and pass it to the create invoices method
if (!getValidAwardAccounts(tmpAcctList, awd, creationProcessType).containsAll(tmpAcctList)) {
final ErrorMessage errorMessage = new ErrorMessage(ArKeyConstants.ContractsGrantsInvoiceCreateDocumentConstants.CONTROL_ACCOUNT_NON_BILLABLE, controlAccount.getAccountNumber(), awd.getProposalNumber());
errorMessages.add(errorMessage);
}
/**
* FINP-5295 changes.
*/
generateAndSaveContractsAndGrantsInvoiceDocument(awd, getValidAwardAccounts(tmpAcctList, awd, creationProcessType), errorMessages, creationProcessType, accountDetails, locCreationType);
}
} else {
final ErrorMessage errorMessage = new ErrorMessage(ArKeyConstants.ContractsGrantsInvoiceCreateDocumentConstants.BILL_BY_CONTRACT_LACKS_CONTROL_ACCOUNT, awd.getProposalNumber());
errorMessages.add(errorMessage);
}
}
}
use of org.kuali.kfs.integration.cg.ContractsAndGrantsBillingAwardAccount in project cu-kfs by CU-CommunityApps.
the class ContractsGrantsInvoiceCreateDocumentServiceImpl method getValidAwardAccounts.
/**
* @param awardAccounts
* @param creationProcessType invoice document creation process type
* @return the valid award accounts based on evaluation of billing frequency and invoice document status
*/
protected List<ContractsAndGrantsBillingAwardAccount> getValidAwardAccounts(List<ContractsAndGrantsBillingAwardAccount> awardAccounts, ContractsAndGrantsBillingAward award, ContractsAndGrantsInvoiceDocumentCreationProcessType creationProcessType) {
if (!ArConstants.BillingFrequencyValues.isMilestone(award) && !ArConstants.BillingFrequencyValues.isPredeterminedBilling(award)) {
List<ContractsAndGrantsBillingAwardAccount> validAwardAccounts = new ArrayList<>();
Set<Account> invalidAccounts = harvestAccountsFromContractsGrantsInvoices(getInProgressInvoicesForAward(award));
for (ContractsAndGrantsBillingAwardAccount awardAccount : awardAccounts) {
if (!invalidAccounts.contains(awardAccount.getAccount())) {
boolean checkGracePeriod = ContractsAndGrantsInvoiceDocumentCreationProcessType.MANUAL != creationProcessType;
/*
* CU Customization (KFSPTS-23675):
* Include creationProcessType in the method call.
*/
if (verifyBillingFrequencyService.validateBillingFrequency(award, awardAccount, checkGracePeriod, creationProcessType)) {
validAwardAccounts.add(awardAccount);
}
}
}
return validAwardAccounts;
} else {
return awardAccounts;
}
}
use of org.kuali.kfs.integration.cg.ContractsAndGrantsBillingAwardAccount in project cu-kfs by CU-CommunityApps.
the class ContractsGrantsInvoiceCreateDocumentServiceImpl method createInvoicesByAccounts.
/**
* Generates and saves Contracts & Grants Invoice Documents based on the award accounts of the passed in award
*
* @param award the award to build Contracts & Grants Invoice Documents from the award accounts on
* @param errorMessages a holder for error messages
* @param creationProcessType invoice document creation process type
* @param accountDetails letter of credit details if we're creating via loc
* @param locCreationType letter of credit creation type if we're creating via loc
*/
protected void createInvoicesByAccounts(ContractsAndGrantsBillingAward award, List<ErrorMessage> errorMessages, ContractsAndGrantsInvoiceDocumentCreationProcessType creationProcessType, List<ContractsGrantsLetterOfCreditReviewDetail> accountDetails, String locCreationType) {
List<ContractsAndGrantsBillingAwardAccount> tmpAcctList = new ArrayList<>();
for (ContractsAndGrantsBillingAwardAccount awardAccount : award.getActiveAwardAccounts()) {
if (!awardAccount.isFinalBilledIndicator()) {
tmpAcctList.clear();
tmpAcctList.add(awardAccount);
final List<ContractsAndGrantsBillingAwardAccount> validAwardAccounts = getValidAwardAccounts(tmpAcctList, award, creationProcessType);
if (validAwardAccounts.containsAll(tmpAcctList) && contractsGrantsBillingAwardVerificationService.isAwardAccountValidToInvoiceBasedOnSchedule(awardAccount)) {
/**
* FINP-5295 changes.
*/
generateAndSaveContractsAndGrantsInvoiceDocument(award, validAwardAccounts, errorMessages, creationProcessType, accountDetails, locCreationType);
} else {
final ErrorMessage errorMessage = new ErrorMessage(ArKeyConstants.ContractsGrantsInvoiceCreateDocumentConstants.NON_BILLABLE, awardAccount.getAccountNumber(), award.getProposalNumber());
errorMessages.add(errorMessage);
}
}
}
}
Aggregations