use of org.kuali.kfs.module.ar.document.ContractsGrantsInvoiceDocument in project cu-kfs by CU-CommunityApps.
the class ContractsGrantsInvoiceCreateDocumentServiceImpl method generateAndSaveContractsAndGrantsInvoiceDocument.
/**
* FINP-5295 This method was modified for the backport.
*
* Generates and then saves a Contracts & Grants Invoice Document
*
* @param awd the award for the document
* @param validAwardAccounts the award accounts which should appear on the document
* @param errorMessages a List of error messages, to be appended to if there are errors in document generation
* @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 generateAndSaveContractsAndGrantsInvoiceDocument(ContractsAndGrantsBillingAward awd, List<ContractsAndGrantsBillingAwardAccount> validAwardAccounts, List<ErrorMessage> errorMessages, ContractsAndGrantsInvoiceDocumentCreationProcessType creationProcessType, List<ContractsGrantsLetterOfCreditReviewDetail> accountDetails, String locCreationType) {
ChartOrgHolder chartOrgHolder = financialSystemUserService.getPrimaryOrganization(awd.getAwardPrimaryFundManager().getFundManager().getPrincipalId(), KFSConstants.OptionalModuleNamespaces.ACCOUNTS_RECEIVABLE);
/*
* CU Customization (KFSPTS-23675):
* Include creationProcessType in the method call.
*/
ContractsGrantsInvoiceDocument cgInvoiceDocument = createCGInvoiceDocumentByAwardInfo(awd, validAwardAccounts, chartOrgHolder.getChartOfAccountsCode(), chartOrgHolder.getOrganizationCode(), errorMessages, accountDetails, locCreationType, creationProcessType);
if (ObjectUtils.isNotNull(cgInvoiceDocument)) {
if (cgInvoiceDocument.getTotalInvoiceAmount().isPositive() || getContractsGrantsInvoiceDocumentService().getInvoiceMilestoneTotal(cgInvoiceDocument).isPositive() || getContractsGrantsInvoiceDocumentService().getBillAmountTotal(cgInvoiceDocument).isPositive() || (ArConstants.BillingFrequencyValues.isTimeBased(awd) && ContractsAndGrantsInvoiceDocumentCreationProcessType.MANUAL.equals(creationProcessType))) {
try {
documentService.saveDocument(cgInvoiceDocument, DocumentSystemSaveEvent.class);
} catch (WorkflowException ex) {
LOG.error("Error creating cgin documents: " + ex.getMessage(), ex);
throw new RuntimeException("Error creating cgin documents: " + ex.getMessage(), ex);
}
} else {
ErrorMessage errorMessage;
List<InvoiceAccountDetail> invoiceAccounts = cgInvoiceDocument.getAccountDetails();
if (!invoiceAccounts.isEmpty()) {
errorMessage = new ErrorMessage(ArKeyConstants.ContractsGrantsInvoiceCreateDocumentConstants.NON_BILLABLE, invoiceAccounts.get(0).getAccountNumber(), awd.getProposalNumber());
} else {
errorMessage = new ErrorMessage(ArKeyConstants.ContractsGrantsInvoiceCreateDocumentConstants.NON_BILLABLE, null, awd.getProposalNumber());
}
errorMessages.add(errorMessage);
}
}
}
use of org.kuali.kfs.module.ar.document.ContractsGrantsInvoiceDocument in project cu-kfs by CU-CommunityApps.
the class CuTotalAmountBilledToDateExceedsTotalBudgetSuspensionCategoryTest method prepareContractsGrantsInvoiceDocument.
private void prepareContractsGrantsInvoiceDocument(KualiDecimal totalAmountBilledToDate, KualiDecimal budgetTotal) {
PowerMockito.suppress(PowerMockito.constructor(DocumentBase.class));
contractsGrantsInvoiceDocument = PowerMockito.spy(new ContractsGrantsInvoiceDocument());
Award award = new Award();
AwardExtendedAttribute attribute = new AwardExtendedAttribute();
attribute.setBudgetTotalAmount(budgetTotal);
award.setExtension(attribute);
InvoiceGeneralDetail invoiceGeneralDetail = Mockito.mock(InvoiceGeneralDetail.class);
Mockito.when(invoiceGeneralDetail.getTotalAmountBilledToDate()).thenReturn(totalAmountBilledToDate);
Mockito.when(invoiceGeneralDetail.getAward()).thenReturn(award);
contractsGrantsInvoiceDocument.setInvoiceGeneralDetail(invoiceGeneralDetail);
}
use of org.kuali.kfs.module.ar.document.ContractsGrantsInvoiceDocument in project cu-kfs by CU-CommunityApps.
the class AutoApproveDisabledSuspensionCategoryTest method prepareContractsGrantsInvoiceDocument.
private void prepareContractsGrantsInvoiceDocument(boolean autoApproveIndicator, String autoApproveReason) {
PowerMockito.suppress(PowerMockito.constructor(DocumentBase.class));
contractsGrantsInvoiceDocument = PowerMockito.spy(new ContractsGrantsInvoiceDocument());
Award award = new Award();
award.setAutoApproveIndicator(autoApproveIndicator);
AwardExtendedAttribute attribute = new AwardExtendedAttribute();
attribute.setAutoApproveReason(autoApproveReason);
award.setExtension(attribute);
InvoiceGeneralDetail invoiceGeneralDetail = Mockito.mock(InvoiceGeneralDetail.class);
Mockito.when(invoiceGeneralDetail.getAward()).thenReturn(award);
contractsGrantsInvoiceDocument.setInvoiceGeneralDetail(invoiceGeneralDetail);
}
use of org.kuali.kfs.module.ar.document.ContractsGrantsInvoiceDocument in project cu-kfs by CU-CommunityApps.
the class CuContractsGrantsInvoiceDocumentServiceImpl method getInstitutionTemplateParameters.
protected Map<String, String> getInstitutionTemplateParameters(ContractsGrantsInvoiceDocument document) {
Map<String, Object> localParameterMap = new HashMap<String, Object>();
if (document.getInvoiceGeneralDetail().isFinalBillIndicator()) {
localParameterMap.put(CuArPropertyConstants.ContractsAndGrantsBillingAwardFields.FINAL_BILL, CUKFSConstants.CAPITAL_X);
localParameterMap.put(CuArPropertyConstants.ContractsAndGrantsBillingAwardFields.PARTIAL_BILL, StringUtils.EMPTY);
} else {
localParameterMap.put(CuArPropertyConstants.ContractsAndGrantsBillingAwardFields.FINAL_BILL, StringUtils.EMPTY);
localParameterMap.put(CuArPropertyConstants.ContractsAndGrantsBillingAwardFields.PARTIAL_BILL, CUKFSConstants.CAPITAL_X);
}
ContractsGrantsInvoiceDetail totalCostInvoiceDetail = document.getTotalCostInvoiceDetail();
if (ObjectUtils.isNotNull(totalCostInvoiceDetail)) {
localParameterMap.put(CuArPropertyConstants.ContractsAndGrantsBillingAwardFields.TOTAL_PROGRAM_OUTLAYS_TO_DATE, totalCostInvoiceDetail.getTotalAmountBilledToDate().add(document.getInvoiceGeneralDetail().getCostShareAmount()));
}
setAwardExtendedAttributeValuesInParameterMap(document, localParameterMap);
setPurchaseOrderNumberFieldInParameterMap(document, localParameterMap);
if (!localParameterMap.isEmpty()) {
LOG.debug("getInstitutionTemplateParameters, there were local parameters, these will be in the returned map.");
}
return localParameterMap.keySet().stream().collect(Collectors.toMap(key -> key, key -> stringifyValue(localParameterMap.get(key)), (a, b) -> b));
}
use of org.kuali.kfs.module.ar.document.ContractsGrantsInvoiceDocument in project cu-kfs by CU-CommunityApps.
the class CuContractsGrantsInvoiceDocumentAction method findAwardBudgetTotal.
private KualiDecimal findAwardBudgetTotal(ContractsGrantsInvoiceDocumentForm contractsGrantsInvoiceDocumentForm) {
ContractsGrantsInvoiceDocument contractsGrantsInvoiceDocument = contractsGrantsInvoiceDocumentForm.getContractsGrantsInvoiceDocument();
Award award = (Award) contractsGrantsInvoiceDocument.getInvoiceGeneralDetail().getAward();
AwardExtendedAttribute awardExtension = (AwardExtendedAttribute) award.getExtension();
KualiDecimal budgetTotalAmount = null;
if (ObjectUtils.isNotNull(awardExtension)) {
budgetTotalAmount = awardExtension.getBudgetTotalAmount();
} else {
LOG.error("findAwardBudgetTotal, there is no award extension object on award " + award.getProposalNumber());
}
return budgetTotalAmount;
}
Aggregations