use of org.kuali.kfs.integration.cg.ContractsAndGrantsBillingAward in project cu-kfs by CU-CommunityApps.
the class CuAREmailServiceImpl method getSubject.
@Override
protected String getSubject(ContractsGrantsInvoiceDocument invoice) {
String grantNumber = invoice.getInvoiceGeneralDetail().getAward().getProposal().getGrantNumber();
String subject;
String message;
if (StringUtils.isBlank(grantNumber)) {
subject = kualiConfigurationService.getPropertyValueAsString(ArKeyConstants.CGINVOICE_EMAIL_SUBJECT_NO_GRANT_NUMBER);
message = MessageFormat.format(subject, invoice.getDocumentNumber(), invoice.getInvoiceGeneralDetail().getAward().getProposal().getProposalNumber());
} else {
subject = kualiConfigurationService.getPropertyValueAsString(ArKeyConstants.CGINVOICE_EMAIL_SUBJECT);
ContractsAndGrantsBillingAward award = invoice.getInvoiceGeneralDetail().getAward();
message = MessageFormat.format(subject, invoice.getDocumentNumber(), award.getProposal().getGrantNumber(), award.getProposal().getProposalNumber(), award.getAwardPrimaryProjectDirector().getProjectDirector().getName());
}
return message;
}
use of org.kuali.kfs.integration.cg.ContractsAndGrantsBillingAward in project cu-kfs by CU-CommunityApps.
the class FirstInvoiceForAwardSuspensionCategory method priorSuccessfulInvoicesExist.
protected boolean priorSuccessfulInvoicesExist(ContractsGrantsInvoiceDocument contractsGrantsInvoiceDocument) {
Map<String, String> criteria = new HashMap<>();
String proposalNumber = contractsGrantsInvoiceDocument.getInvoiceGeneralDetail().getProposalNumber();
String documentNumber = contractsGrantsInvoiceDocument.getDocumentNumber();
ContractsAndGrantsBillingAward award = contractsGrantsInvoiceDocument.getInvoiceGeneralDetail().getAward();
criteria.put(ArPropertyConstants.ContractsGrantsInvoiceDocumentFields.PROPOSAL_NUMBER, proposalNumber);
criteria.put(KFSPropertyConstants.DOCUMENT_HEADER + KFSConstants.DELIMITER + KFSPropertyConstants.WORKFLOW_DOCUMENT_STATUS_CODE, buildSuccessfulDocumentStatusesCriteria());
criteria.put(KFSPropertyConstants.DOCUMENT_NUMBER, SearchOperator.NOT.op() + documentNumber);
Map<String, String> extraCriteria = buildAdditionalCriteriaForInvoicingOption(contractsGrantsInvoiceDocument, award.getInvoicingOptionCode());
criteria.putAll(extraCriteria);
Collection<ContractsGrantsInvoiceDocument> priorInvoices = contractsGrantsInvoiceDocumentDao.getMatchingInvoicesByCollection(criteria);
return CollectionUtils.isNotEmpty(priorInvoices);
}
use of org.kuali.kfs.integration.cg.ContractsAndGrantsBillingAward in project cu-kfs by CU-CommunityApps.
the class ContractsGrantsInvoiceDocumentServiceImpl method createSourceAccountingLines.
@Override
public void createSourceAccountingLines(ContractsGrantsInvoiceDocument contractsGrantsInvoiceDocument, List<ContractsAndGrantsBillingAwardAccount> awardAccounts) {
// To check if the Source accounting lines are existing. If they are do nothing
if (CollectionUtils.isEmpty(contractsGrantsInvoiceDocument.getSourceAccountingLines())) {
ContractsAndGrantsBillingAward award = contractsGrantsInvoiceDocument.getInvoiceGeneralDetail().getAward();
if (ObjectUtils.isNotNull(award)) {
if (StringUtils.equalsIgnoreCase(award.getInvoicingOptionCode(), ArConstants.INV_ACCOUNT) || StringUtils.equalsIgnoreCase(award.getInvoicingOptionCode(), ArConstants.INV_SCHEDULE)) {
// If its bill by Account or Schedule, irrespective of it is by contract control account,
// there would be a single source accounting line with award account specified by the user.
CustomerInvoiceDetail cide = createSourceAccountingLine(contractsGrantsInvoiceDocument.getDocumentNumber(), awardAccounts.get(0).getChartOfAccountsCode(), awardAccounts.get(0).getAccountNumber(), awardAccounts.get(0).getAccount().getSubFundGroup(), getTotalAmountForInvoice(contractsGrantsInvoiceDocument), 1);
contractsGrantsInvoiceDocument.getSourceAccountingLines().add(cide);
} else if (StringUtils.equalsIgnoreCase(award.getInvoicingOptionCode(), ArConstants.INV_CONTRACT_CONTROL_ACCOUNT)) {
// by control account
// If its bill by Contract Control Account there would be a single source accounting line.
CustomerInvoiceDetail cide = createSourceAccountingLinesByContractControlAccount(contractsGrantsInvoiceDocument);
contractsGrantsInvoiceDocument.getSourceAccountingLines().add(cide);
} else {
// by award
List<CustomerInvoiceDetail> awardAccountingLines = createSourceAccountingLinesByAward(contractsGrantsInvoiceDocument);
contractsGrantsInvoiceDocument.getSourceAccountingLines().addAll(awardAccountingLines);
}
}
}
}
use of org.kuali.kfs.integration.cg.ContractsAndGrantsBillingAward in project cu-kfs by CU-CommunityApps.
the class ContractsGrantsInvoiceDocumentServiceImpl method updateLastBilledDate.
@Override
public void updateLastBilledDate(ContractsGrantsInvoiceDocument document) {
boolean isFinalBill = document.getInvoiceGeneralDetail().isFinalBillIndicator();
for (InvoiceAccountDetail id : document.getAccountDetails()) {
if (isFinalBill) {
setAwardAccountFinalBilledValueAndLastBilledDate(id, true, document.getInvoiceGeneralDetail().getProposalNumber(), document.isInvoiceReversal(), document.getInvoiceGeneralDetail().getLastBilledDate());
} else {
calculateAwardAccountLastBilledDate(id, document.isInvoiceReversal(), document.getInvoiceGeneralDetail().getLastBilledDate(), document.getInvoiceGeneralDetail().getProposalNumber());
}
}
// 2. Set last Billed to Award = least of last billed date of award account.
String proposalNumber = document.getInvoiceGeneralDetail().getProposalNumber();
Map<String, Object> map = new HashMap<>();
map.put(KFSPropertyConstants.PROPOSAL_NUMBER, proposalNumber);
ContractsAndGrantsBillingAward award = kualiModuleService.getResponsibleModuleService(ContractsAndGrantsBillingAward.class).getExternalizableBusinessObject(ContractsAndGrantsBillingAward.class, map);
if (CollectionUtils.isNotEmpty(award.getActiveAwardAccounts())) {
// To set last billed Date to award.
contractsAndGrantsModuleBillingService.setLastBilledDateToAward(proposalNumber, getLastBilledDate(award));
}
}
use of org.kuali.kfs.integration.cg.ContractsAndGrantsBillingAward in project cu-kfs by CU-CommunityApps.
the class ContractsGrantsInvoiceCreateDocumentServiceImpl method calculateTotalExpenditureAmount.
protected KualiDecimal calculateTotalExpenditureAmount(ContractsGrantsInvoiceDocument document, List<ContractsGrantsLetterOfCreditReviewDetail> locReviewDetails) {
Map<String, KualiDecimal> totalBilledByAccountNumberMap = new HashMap<>();
for (InvoiceDetailAccountObjectCode objectCode : document.getInvoiceDetailAccountObjectCodes()) {
final String key = objectCode.getChartOfAccountsCode() + "-" + objectCode.getAccountNumber();
KualiDecimal totalBilled = cleanAmount(totalBilledByAccountNumberMap.get(key));
totalBilled = totalBilled.add(objectCode.getTotalBilled());
totalBilledByAccountNumberMap.put(key, totalBilled);
}
KualiDecimal totalExpendituredAmount = KualiDecimal.ZERO;
for (InvoiceAccountDetail invAcctD : document.getAccountDetails()) {
final String chartOfAccountsCode = invAcctD.getChartOfAccountsCode();
final String accountNumber = invAcctD.getAccountNumber();
final String key = chartOfAccountsCode + "-" + accountNumber;
if (!ObjectUtils.isNull(totalBilledByAccountNumberMap.get(key))) {
invAcctD.setTotalPreviouslyBilled(totalBilledByAccountNumberMap.get(key));
} else {
invAcctD.setTotalPreviouslyBilled(KualiDecimal.ZERO);
}
if (invAcctD.getTotalPreviouslyBilled().isZero()) {
String proposalNumber = document.getInvoiceGeneralDetail().getProposalNumber();
KualiDecimal previouslyBilledAmount = KualiDecimal.ZERO;
previouslyBilledAmount = previouslyBilledAmount.add(contractsGrantsInvoiceDocumentService.getPredeterminedBillingBilledToDateAmount(proposalNumber, chartOfAccountsCode, accountNumber));
previouslyBilledAmount = previouslyBilledAmount.add(contractsGrantsInvoiceDocumentService.getMilestonesBilledToDateAmount(proposalNumber, chartOfAccountsCode, accountNumber));
invAcctD.setTotalPreviouslyBilled(previouslyBilledAmount);
}
KualiDecimal currentExpenditureAmount = invAcctD.getCumulativeExpenditures().subtract(invAcctD.getTotalPreviouslyBilled());
invAcctD.setInvoiceAmount(currentExpenditureAmount);
// overwrite account detail expenditure amount if locReview Indicator is true and award is LOC Billing
if (!ObjectUtils.isNull(document.getInvoiceGeneralDetail())) {
ContractsAndGrantsBillingAward award = document.getInvoiceGeneralDetail().getAward();
if (ObjectUtils.isNotNull(award) && ArConstants.BillingFrequencyValues.isLetterOfCredit(award) && !CollectionUtils.isEmpty(locReviewDetails)) {
for (ContractsAndGrantsBillingAwardAccount awardAccount : award.getActiveAwardAccounts()) {
final ContractsGrantsLetterOfCreditReviewDetail locReviewDetail = retrieveMatchingLetterOfCreditReviewDetail(awardAccount, locReviewDetails);
if (!ObjectUtils.isNull(locReviewDetail) && StringUtils.equals(awardAccount.getChartOfAccountsCode(), chartOfAccountsCode) && StringUtils.equals(awardAccount.getAccountNumber(), accountNumber)) {
currentExpenditureAmount = locReviewDetail.getAmountToDraw();
invAcctD.setInvoiceAmount(currentExpenditureAmount);
}
}
}
}
totalExpendituredAmount = totalExpendituredAmount.add(currentExpenditureAmount);
}
totalExpendituredAmount = totalExpendituredAmount.add(document.getInvoiceGeneralDetail().getTotalPreviouslyBilled());
return totalExpendituredAmount;
}
Aggregations