use of org.kuali.kfs.module.ar.businessobject.InvoiceAccountDetail in project cu-kfs by CU-CommunityApps.
the class CuContractsGrantsInvoiceDocumentServiceImpl method createSourceAccountingLinesByContractControlAccount.
/*
* CUMod: KFSPTS-14929
*/
@Override
protected CustomerInvoiceDetail createSourceAccountingLinesByContractControlAccount(ContractsGrantsInvoiceDocument contractsGrantsInvoiceDocument) {
String coaCode = null;
String accountNumber = null;
SubFundGroup subFundGroup = null;
List<InvoiceAccountDetail> accountDetails = contractsGrantsInvoiceDocument.getAccountDetails();
if (CollectionUtils.isNotEmpty(accountDetails)) {
Account contractControlAccount = determineContractControlAccount(accountDetails.get(0));
if (ObjectUtils.isNotNull(contractControlAccount)) {
coaCode = contractControlAccount.getChartOfAccountsCode();
accountNumber = contractControlAccount.getAccountNumber();
subFundGroup = contractControlAccount.getSubFundGroup();
if (ObjectUtils.isNull(subFundGroup)) {
contractControlAccount.refreshReferenceObject(KFSPropertyConstants.SUB_FUND_GROUP);
subFundGroup = contractControlAccount.getSubFundGroup();
}
}
}
return createSourceAccountingLine(contractsGrantsInvoiceDocument.getDocumentNumber(), coaCode, accountNumber, subFundGroup, getTotalAmountForInvoice(contractsGrantsInvoiceDocument), 1);
}
use of org.kuali.kfs.module.ar.businessobject.InvoiceAccountDetail in project cu-kfs by CU-CommunityApps.
the class CuContractsGrantsInvoiceDocumentServiceImpl method findPurchaseOrderNumberForInvoiceOptionAccount.
protected String findPurchaseOrderNumberForInvoiceOptionAccount(ContractsGrantsInvoiceDocument document) {
String purchaseOrderNumber = StringUtils.EMPTY;
List<InvoiceAccountDetail> invoiceAccountDetails = document.getAccountDetails();
if (CollectionUtils.isNotEmpty(invoiceAccountDetails)) {
Account invoiceAccount = invoiceAccountDetails.get(0).getAccount();
AwardAccountExtendedAttribute awardAccountExtension = findAwardAccountExtendedAttribute(invoiceAccountDetails.get(0).getProposalNumber(), invoiceAccount.getChartOfAccountsCode(), invoiceAccount.getAccountNumber());
if (ObjectUtils.isNotNull(awardAccountExtension)) {
purchaseOrderNumber = awardAccountExtension.getAccountPurchaseOrderNumber();
}
}
return purchaseOrderNumber;
}
use of org.kuali.kfs.module.ar.businessobject.InvoiceAccountDetail in project cu-kfs by CU-CommunityApps.
the class CuContractsGrantsInvoiceDocumentServiceImpl method findPurchaseOrderNumberForInvoiceOptionContractControlAndScheduled.
protected String findPurchaseOrderNumberForInvoiceOptionContractControlAndScheduled(ContractsGrantsInvoiceDocument document) {
String purchaseOrderNumber = StringUtils.EMPTY;
List<InvoiceAccountDetail> invoiceAccountDetails = document.getAccountDetails();
if (CollectionUtils.isNotEmpty(invoiceAccountDetails)) {
Account contractControlAccount = determineContractControlAccount(invoiceAccountDetails.get(0));
if (ObjectUtils.isNotNull(contractControlAccount)) {
AwardAccountExtendedAttribute awardAccountExtension = findAwardAccountExtendedAttribute(invoiceAccountDetails.get(0).getProposalNumber(), contractControlAccount.getChartOfAccountsCode(), contractControlAccount.getAccountNumber());
if (ObjectUtils.isNotNull(awardAccountExtension)) {
purchaseOrderNumber = awardAccountExtension.getAccountPurchaseOrderNumber();
}
}
}
return purchaseOrderNumber;
}
use of org.kuali.kfs.module.ar.businessobject.InvoiceAccountDetail in project cu-kfs by CU-CommunityApps.
the class ContractsGrantsInvoiceDocumentServiceImpl method assignCurrentExpenditureToNonExistingAccountObjectCode.
protected void assignCurrentExpenditureToNonExistingAccountObjectCode(ContractsGrantsInvoiceDocument contractsGrantsInvoiceDocument, ContractsGrantsInvoiceDetail invoiceDetail) {
String categoryCode = invoiceDetail.getCategoryCode();
if (StringUtils.isBlank(categoryCode)) {
throw new IllegalArgumentException("Category Code can not be null during recalculation of account object code for Contracts & Grants Invoice Document.");
}
// get the category that matches this category code.
final CostCategory category = businessObjectService.findBySinglePrimaryKey(CostCategory.class, categoryCode);
// got the category now.
if (!ObjectUtils.isNull(category)) {
final KualiDecimal oneCent = new KualiDecimal(0.01);
int size = contractsGrantsInvoiceDocument.getAccountDetails().size();
KualiDecimal amount = new KualiDecimal(invoiceDetail.getInvoiceAmount().bigDecimalValue().divide(new BigDecimal(size), 2, RoundingMode.HALF_UP));
KualiDecimal remainder = invoiceDetail.getInvoiceAmount().subtract(amount.multiply(new KualiDecimal(size)));
for (InvoiceAccountDetail invoiceAccountDetail : contractsGrantsInvoiceDocument.getAccountDetails()) {
InvoiceDetailAccountObjectCode invoiceDetailAccountObjectCode = new InvoiceDetailAccountObjectCode();
invoiceDetailAccountObjectCode.setDocumentNumber(contractsGrantsInvoiceDocument.getDocumentNumber());
invoiceDetailAccountObjectCode.setProposalNumber(contractsGrantsInvoiceDocument.getInvoiceGeneralDetail().getProposalNumber());
invoiceDetailAccountObjectCode.setCategoryCode(categoryCode);
invoiceDetailAccountObjectCode.setAccountNumber(invoiceAccountDetail.getAccountNumber());
invoiceDetailAccountObjectCode.setChartOfAccountsCode(invoiceAccountDetail.getChartOfAccountsCode());
// it's 0.00 that's why we are in this section to begin with.
invoiceDetailAccountObjectCode.setCumulativeExpenditures(KualiDecimal.ZERO);
// this is also 0.00 because it has never been billed before
invoiceDetailAccountObjectCode.setTotalBilled(KualiDecimal.ZERO);
final ObjectCodeCurrent objectCode = getCostCategoryService().findObjectCodeForChartAndCategory(invoiceAccountDetail.getChartOfAccountsCode(), categoryCode);
if (!ObjectUtils.isNull(objectCode)) {
invoiceDetailAccountObjectCode.setFinancialObjectCode(objectCode.getFinancialObjectCode());
}
// tack on or remove one penny until the remainder is 0 - take a penny, leave a penny!
if (remainder.isGreaterThan(KualiDecimal.ZERO)) {
amount = amount.add(oneCent);
remainder = remainder.subtract(oneCent);
} else if (remainder.isLessThan(KualiDecimal.ZERO)) {
amount = amount.subtract(oneCent);
remainder = remainder.add(oneCent);
}
invoiceDetailAccountObjectCode.setCurrentExpenditures(amount);
List<InvoiceDetailAccountObjectCode> invoiceDetailAccountObjectCodes = contractsGrantsInvoiceDocument.getInvoiceDetailAccountObjectCodes();
if (invoiceDetailAccountObjectCodes.contains(invoiceDetailAccountObjectCode)) {
// update existing code
InvoiceDetailAccountObjectCode original = invoiceDetailAccountObjectCodes.get(invoiceDetailAccountObjectCodes.indexOf(invoiceDetailAccountObjectCode));
original.setCurrentExpenditures(amount);
original.setCategoryCode(categoryCode);
} else {
// add this single account object code item to the list in the Map
contractsGrantsInvoiceDocument.getInvoiceDetailAccountObjectCodes().add(invoiceDetailAccountObjectCode);
}
}
} else {
LOG.error("Category Code cannot be found from the category list during recalculation of account object " + "code for Contracts & Grants Invoice Document.");
}
}
use of org.kuali.kfs.module.ar.businessobject.InvoiceAccountDetail in project cu-kfs by CU-CommunityApps.
the class ContractsGrantsInvoiceDocumentServiceImpl method createSourceAccountingLinesByContractControlAccount.
/**
* Creates source accounting lines using the contract control account to populate
*
* @param contractsGrantsInvoiceDocument the Contracts & Grants Invoice to add lines to
*/
protected CustomerInvoiceDetail createSourceAccountingLinesByContractControlAccount(ContractsGrantsInvoiceDocument contractsGrantsInvoiceDocument) {
String coaCode = null;
String accountNumber = null;
SubFundGroup subFundGroup = null;
List<InvoiceAccountDetail> accountDetails = contractsGrantsInvoiceDocument.getAccountDetails();
if (CollectionUtils.isNotEmpty(accountDetails)) {
InvoiceAccountDetail invoiceAccountDetail = accountDetails.get(0);
Account account = invoiceAccountDetail.getAccount();
if (ObjectUtils.isNull(account)) {
invoiceAccountDetail.refreshReferenceObject(KFSPropertyConstants.ACCOUNT);
account = invoiceAccountDetail.getAccount();
}
if (ObjectUtils.isNotNull(account)) {
Account contractControlAccount = account.getContractControlAccount();
if (ObjectUtils.isNotNull(contractControlAccount)) {
coaCode = contractControlAccount.getChartOfAccountsCode();
accountNumber = contractControlAccount.getAccountNumber();
subFundGroup = contractControlAccount.getSubFundGroup();
}
}
}
return createSourceAccountingLine(contractsGrantsInvoiceDocument.getDocumentNumber(), coaCode, accountNumber, subFundGroup, getTotalAmountForInvoice(contractsGrantsInvoiceDocument), 1);
}
Aggregations