Search in sources :

Example 1 with ContractsAndGrantsOrganization

use of org.kuali.kfs.integration.cg.ContractsAndGrantsOrganization in project cu-kfs by CU-CommunityApps.

the class ContractsGrantsInvoiceCreateDocumentServiceImpl method createInvoices.

/**
 * This method iterates through awards and create cgInvoice documents
 *
 * @param awards          used to create cgInvoice documents
 * @param creationProcessType  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
 * @return List of error messages (if any)
 */
protected List<ErrorMessage> createInvoices(Collection<ContractsAndGrantsBillingAward> awards, ContractsAndGrantsInvoiceDocumentCreationProcessType creationProcessType, List<ContractsGrantsLetterOfCreditReviewDetail> accountDetails, String locCreationType) {
    List<ErrorMessage> errorMessages = new ArrayList<>();
    if (ObjectUtils.isNotNull(awards) && awards.size() > 0) {
        for (ContractsAndGrantsBillingAward awd : awards) {
            String invOpt = awd.getInvoicingOptionCode();
            final ContractsAndGrantsOrganization awardOrganization = awd.getPrimaryAwardOrganization();
            if (ObjectUtils.isNull(awardOrganization)) {
                final ErrorMessage errorMessage = new ErrorMessage(ArKeyConstants.ContractsGrantsInvoiceCreateDocumentConstants.NO_ORGANIZATION_ON_AWARD, awd.getProposalNumber());
                errorMessages.add(errorMessage);
            } else {
                switch(invOpt) {
                    case ArConstants.INV_ACCOUNT:
                    case ArConstants.INV_SCHEDULE:
                        createInvoicesByAccounts(awd, errorMessages, creationProcessType, accountDetails, locCreationType);
                        break;
                    case ArConstants.INV_CONTRACT_CONTROL_ACCOUNT:
                        createInvoicesByContractControlAccounts(awd, errorMessages, creationProcessType, accountDetails, locCreationType);
                        break;
                    case ArConstants.INV_AWARD:
                        createInvoicesByAward(awd, errorMessages, creationProcessType, accountDetails, locCreationType);
                        break;
                    default:
                        break;
                }
            }
        }
    } else {
        final ErrorMessage errorMessage = new ErrorMessage(ArKeyConstants.ContractsGrantsInvoiceCreateDocumentConstants.NO_AWARD);
        errorMessages.add(errorMessage);
    }
    return errorMessages;
}
Also used : ContractsAndGrantsBillingAward(org.kuali.kfs.integration.cg.ContractsAndGrantsBillingAward) ArrayList(java.util.ArrayList) ErrorMessage(org.kuali.kfs.krad.util.ErrorMessage) ContractsGrantsInvoiceDocumentErrorMessage(org.kuali.kfs.module.ar.businessobject.ContractsGrantsInvoiceDocumentErrorMessage) ContractsAndGrantsOrganization(org.kuali.kfs.integration.cg.ContractsAndGrantsOrganization)

Aggregations

ArrayList (java.util.ArrayList)1 ContractsAndGrantsBillingAward (org.kuali.kfs.integration.cg.ContractsAndGrantsBillingAward)1 ContractsAndGrantsOrganization (org.kuali.kfs.integration.cg.ContractsAndGrantsOrganization)1 ErrorMessage (org.kuali.kfs.krad.util.ErrorMessage)1 ContractsGrantsInvoiceDocumentErrorMessage (org.kuali.kfs.module.ar.businessobject.ContractsGrantsInvoiceDocumentErrorMessage)1