use of org.kuali.kfs.module.ar.businessobject.CustomerInvoiceDetail in project cu-kfs by CU-CommunityApps.
the class ContractsGrantsInvoiceDocumentServiceImpl method createSourceAccountingLine.
protected CustomerInvoiceDetail createSourceAccountingLine(String docNum, String coaCode, String acctNum, SubFundGroup subFundGroup, KualiDecimal totalAmount, Integer seqNum) {
CustomerInvoiceDetail cid = new CustomerInvoiceDetail();
cid.setDocumentNumber(docNum);
cid.setAccountNumber(acctNum);
cid.setChartOfAccountsCode(coaCode);
ContractsGrantsInvoiceObjectCode cgbiObjectCode = contractGrantsInvoiceObjectCodeForSubFundGroup(subFundGroup, coaCode);
if (cgbiObjectCode != null) {
cid.setFinancialObjectCode(cgbiObjectCode.getIncomeFinancialObjectCode());
// To get AR Object codes for the GLPEs .... as it is not being called implicitly.
cid.setAccountsReceivableObjectCode(cgbiObjectCode.getReceivableFinancialObjectCode());
}
cid.setSequenceNumber(seqNum);
cid.setInvoiceItemQuantity(BigDecimal.ONE);
cid.setInvoiceItemUnitOfMeasureCode(ArConstants.CUSTOMER_INVOICE_DETAIL_UOM_DEFAULT);
cid.setInvoiceItemUnitPrice(totalAmount);
cid.setAmount(totalAmount);
if (totalAmount.isNegative()) {
cid.setInvoiceItemDiscountLineNumber(seqNum);
}
return cid;
}
use of org.kuali.kfs.module.ar.businessobject.CustomerInvoiceDetail in project cu-kfs by CU-CommunityApps.
the class ContractsGrantsInvoiceDocumentServiceImpl method createSourceAccountingLinesByAward.
/**
* Generates the source accounting lines for a Contracts & Grants Invoice from the award accounts associated with
* an award (in the form of the pre-generated invoice account details)
*
* @param contractsGrantsInvoiceDocument the Contracts & Grants Invoice to create invoice details for
* @return a List of generated accounting lines
*/
protected List<CustomerInvoiceDetail> createSourceAccountingLinesByAward(ContractsGrantsInvoiceDocument contractsGrantsInvoiceDocument) {
List<CustomerInvoiceDetail> awardAccountingLines = new ArrayList<>();
if (!CollectionUtils.isEmpty(contractsGrantsInvoiceDocument.getAccountDetails())) {
final Map<String, KualiDecimal> accountExpenditureAmounts = getCategoryExpenditureAmountsForInvoiceAccountDetail(contractsGrantsInvoiceDocument);
final Map<String, KualiDecimal> accountTotalBilledAmounts = getCategoryTotalBilledAmountsForInvoiceAccountDetail(contractsGrantsInvoiceDocument);
for (InvoiceAccountDetail invAcctD : contractsGrantsInvoiceDocument.getAccountDetails()) {
final String proposalNumber = invAcctD.getProposalNumber();
final String chartOfAccountsCode = invAcctD.getChartOfAccountsCode();
final String accountNumber = invAcctD.getAccountNumber();
if (invAcctD.getAccount() == null) {
invAcctD.refreshReferenceObject(KFSPropertyConstants.ACCOUNT);
}
final SubFundGroup subFundGroup = invAcctD.getAccount().getSubFundGroup();
final Integer sequenceNumber = contractsGrantsInvoiceDocument.getAccountDetails().indexOf(invAcctD) + 1;
final String accountKey = StringUtils.join(new String[] { chartOfAccountsCode, accountNumber }, "-");
KualiDecimal totalAmount = accountExpenditureAmounts.getOrDefault(accountKey, KualiDecimal.ZERO);
if (invAcctD.getTotalPreviouslyBilled().isZero()) {
KualiDecimal previouslyBilledAmount = getPredeterminedBillingBilledToDateAmount(proposalNumber, chartOfAccountsCode, accountNumber);
previouslyBilledAmount = previouslyBilledAmount.add(getMilestonesBilledToDateAmount(proposalNumber, chartOfAccountsCode, accountNumber));
KualiDecimal totalBilledAmount = accountTotalBilledAmounts.getOrDefault(accountKey, KualiDecimal.ZERO);
previouslyBilledAmount = previouslyBilledAmount.subtract(totalBilledAmount);
if (previouslyBilledAmount.isGreaterThan(KualiDecimal.ZERO)) {
totalAmount = totalAmount.subtract(previouslyBilledAmount);
}
}
CustomerInvoiceDetail cide = createSourceAccountingLine(contractsGrantsInvoiceDocument.getDocumentNumber(), chartOfAccountsCode, accountNumber, subFundGroup, totalAmount, sequenceNumber);
awardAccountingLines.add(cide);
}
}
return awardAccountingLines;
}
use of org.kuali.kfs.module.ar.businessobject.CustomerInvoiceDetail in project cu-kfs by CU-CommunityApps.
the class CustomerInvoiceDetailServiceImpl method getCustomerInvoiceDetailFromOrganizationAccountingDefault.
@Override
public CustomerInvoiceDetail getCustomerInvoiceDetailFromOrganizationAccountingDefault(Integer universityFiscalYear, String chartOfAccountsCode, String organizationCode) {
CustomerInvoiceDetail customerInvoiceDetail = new CustomerInvoiceDetail();
Map<String, Object> criteria = new HashMap<>();
criteria.put("universityFiscalYear", universityFiscalYear);
criteria.put("chartOfAccountsCode", chartOfAccountsCode);
criteria.put("organizationCode", organizationCode);
OrganizationAccountingDefault organizationAccountingDefault = businessObjectService.findByPrimaryKey(OrganizationAccountingDefault.class, criteria);
if (ObjectUtils.isNotNull(organizationAccountingDefault)) {
customerInvoiceDetail.setChartOfAccountsCode(organizationAccountingDefault.getDefaultInvoiceChartOfAccountsCode());
customerInvoiceDetail.setAccountNumber(organizationAccountingDefault.getDefaultInvoiceAccountNumber());
customerInvoiceDetail.setSubAccountNumber(organizationAccountingDefault.getDefaultInvoiceSubAccountNumber());
customerInvoiceDetail.setFinancialObjectCode(organizationAccountingDefault.getDefaultInvoiceFinancialObjectCode());
customerInvoiceDetail.setFinancialSubObjectCode(organizationAccountingDefault.getDefaultInvoiceFinancialSubObjectCode());
customerInvoiceDetail.setProjectCode(organizationAccountingDefault.getDefaultInvoiceProjectCode());
customerInvoiceDetail.setOrganizationReferenceId(organizationAccountingDefault.getDefaultInvoiceOrganizationReferenceIdentifier());
}
customerInvoiceDetail.setInvoiceItemTaxAmount(new KualiDecimal(0.00));
customerInvoiceDetail.setInvoiceItemQuantity(new BigDecimal(1));
customerInvoiceDetail.setInvoiceItemUnitOfMeasureCode(ArConstants.CUSTOMER_INVOICE_DETAIL_UOM_DEFAULT);
customerInvoiceDetail.setTaxableIndicator(false);
return customerInvoiceDetail;
}
use of org.kuali.kfs.module.ar.businessobject.CustomerInvoiceDetail in project cu-kfs by CU-CommunityApps.
the class CustomerInvoiceDetailServiceImpl method getCustomerInvoiceDetailFromCustomerInvoiceItemCode.
@Override
public CustomerInvoiceDetail getCustomerInvoiceDetailFromCustomerInvoiceItemCode(String invoiceItemCode, String chartOfAccountsCode, String organizationCode) {
Map<String, String> criteria = new HashMap<>();
criteria.put("invoiceItemCode", invoiceItemCode);
criteria.put("chartOfAccountsCode", chartOfAccountsCode);
criteria.put("organizationCode", organizationCode);
CustomerInvoiceItemCode customerInvoiceItemCode = businessObjectService.findByPrimaryKey(CustomerInvoiceItemCode.class, criteria);
CustomerInvoiceDetail customerInvoiceDetail = null;
if (ObjectUtils.isNotNull(customerInvoiceItemCode)) {
customerInvoiceDetail = new CustomerInvoiceDetail();
customerInvoiceDetail.setChartOfAccountsCode(customerInvoiceItemCode.getDefaultInvoiceChartOfAccountsCode());
customerInvoiceDetail.setAccountNumber(customerInvoiceItemCode.getDefaultInvoiceAccountNumber());
customerInvoiceDetail.setSubAccountNumber(customerInvoiceItemCode.getDefaultInvoiceSubAccountNumber());
customerInvoiceDetail.setFinancialObjectCode(customerInvoiceItemCode.getDefaultInvoiceFinancialObjectCode());
customerInvoiceDetail.setFinancialSubObjectCode(customerInvoiceItemCode.getDefaultInvoiceFinancialSubObjectCode());
customerInvoiceDetail.setProjectCode(customerInvoiceItemCode.getDefaultInvoiceProjectCode());
customerInvoiceDetail.setOrganizationReferenceId(customerInvoiceItemCode.getDefaultInvoiceOrganizationReferenceIdentifier());
customerInvoiceDetail.setInvoiceItemCode(customerInvoiceItemCode.getInvoiceItemCode());
customerInvoiceDetail.setInvoiceItemDescription(customerInvoiceItemCode.getInvoiceItemDescription());
customerInvoiceDetail.setInvoiceItemUnitPrice(customerInvoiceItemCode.getItemDefaultPrice());
customerInvoiceDetail.setInvoiceItemUnitOfMeasureCode(customerInvoiceItemCode.getDefaultUnitOfMeasureCode());
customerInvoiceDetail.setInvoiceItemQuantity(customerInvoiceItemCode.getItemDefaultQuantity());
customerInvoiceDetail.setTaxableIndicator(customerInvoiceItemCode.isTaxableIndicator());
// TODO set sales tax accordingly
customerInvoiceDetail.setInvoiceItemTaxAmount(new KualiDecimal(0.00));
// set amount = unit price * quantity
customerInvoiceDetail.updateAmountBasedOnQuantityAndUnitPrice();
}
return customerInvoiceDetail;
}
use of org.kuali.kfs.module.ar.businessobject.CustomerInvoiceDetail in project cu-kfs by CU-CommunityApps.
the class CustomerInvoiceDetailServiceImpl method getDiscountCustomerInvoiceDetail.
@Override
public CustomerInvoiceDetail getDiscountCustomerInvoiceDetail(CustomerInvoiceDetail customerInvoiceDetail, Integer universityFiscalYear, String chartOfAccountsCode, String organizationCode) {
CustomerInvoiceDetail discountCustomerInvoiceDetail = (CustomerInvoiceDetail) ObjectUtils.deepCopy(customerInvoiceDetail);
discountCustomerInvoiceDetail.setInvoiceItemUnitPriceToNegative();
discountCustomerInvoiceDetail.updateAmountBasedOnQuantityAndUnitPrice();
discountCustomerInvoiceDetail.setInvoiceItemDescription(ArConstants.DISCOUNT_PREFIX + StringUtils.trimToEmpty(customerInvoiceDetail.getInvoiceItemDescription()));
Map<String, Object> criteria = new HashMap<>();
criteria.put("universityFiscalYear", universityFiscalYear);
criteria.put("processingChartOfAccountCode", chartOfAccountsCode);
criteria.put("processingOrganizationCode", organizationCode);
SystemInformation systemInformation = businessObjectService.findByPrimaryKey(SystemInformation.class, criteria);
if (ObjectUtils.isNotNull(systemInformation)) {
discountCustomerInvoiceDetail.setFinancialObjectCode(systemInformation.getDiscountObjectCode());
}
return discountCustomerInvoiceDetail;
}
Aggregations