Search in sources :

Example 11 with ObjectCode

use of org.kuali.kfs.coa.businessobject.ObjectCode in project cu-kfs by CU-CommunityApps.

the class AmazonWebServicesBillingServiceImpl method updateTransactionDTOObjectCodes.

private void updateTransactionDTOObjectCodes(AmazonBillingDistributionOfIncomeTransactionDTO transactionDTO, AmazonBillingCostCenterDTO costCenterDTO) {
    if (StringUtils.isNotBlank(costCenterDTO.getObjectCode())) {
        ObjectCode objectCode = getObjectCodeService().getByPrimaryIdForCurrentYear(transactionDTO.getChartCode(), costCenterDTO.getObjectCode());
        if (ObjectUtils.isNotNull(objectCode)) {
            transactionDTO.setObjectCodeNumber(objectCode.getFinancialObjectCode());
            if (StringUtils.isNotBlank(costCenterDTO.getSubObjectCode())) {
                SubObjectCode subObjectCode = getSubObjectCodeService().getByPrimaryIdForCurrentYear(transactionDTO.getChartCode(), transactionDTO.getAccountNumber(), objectCode.getFinancialObjectCode(), costCenterDTO.getSubObjectCode());
                if (ObjectUtils.isNotNull(subObjectCode)) {
                    transactionDTO.setSubObjectCodeNumber(subObjectCode.getFinancialSubObjectCode());
                } else {
                    LOG.info("updateTransactionDTOObjectCodes() Invalid Sub Object Code.");
                    transactionDTO.setTransactionInputError(true);
                }
            }
        } else {
            LOG.info("updateTransactionDTOObjectCodes() Invalid Object Code.");
            transactionDTO.setTransactionInputError(true);
        }
    } else {
        transactionDTO.setObjectCodeNumber(getTransactionObjectCode());
    }
}
Also used : SubObjectCode(org.kuali.kfs.coa.businessobject.SubObjectCode) ObjectCode(org.kuali.kfs.coa.businessobject.ObjectCode) SubObjectCode(org.kuali.kfs.coa.businessobject.SubObjectCode)

Example 12 with ObjectCode

use of org.kuali.kfs.coa.businessobject.ObjectCode in project cu-kfs by CU-CommunityApps.

the class CUPaymentMethodGeneralLedgerPendingEntryServiceImpl method generateFeeAssessmentEntries.

/**
 * Generates the GL entries to charge the department for the foreign draft and credit the Wire Charge
 * Fee Account as specified by system parameters.
 *
 * @param document Document into which to add the generated GL Entries.
 */
protected boolean generateFeeAssessmentEntries(PaymentMethod pm, AccountingDocument document, GeneralLedgerPendingEntry templatePendingEntry, GeneralLedgerPendingEntrySequenceHelper sequenceHelper, boolean reverseEntries) {
    LOG.debug("generateForeignDraftChargeEntries started");
    PaymentMethodChart pmc = pm.getPaymentMethodChartInfo(templatePendingEntry.getChartOfAccountsCode(), new java.sql.Date(document.getDocumentHeader().getWorkflowDocument().getDateCreated().getMillis()));
    if (pmc == null) {
        LOG.warn("No Applicable PaymentMethodChart found for chart: " + templatePendingEntry.getChartOfAccountsCode() + " and date: " + document.getDocumentHeader().getWorkflowDocument().getDateCreated());
        return false;
    }
    // Get all the parameters which control these entries
    String feeIncomeChartCode = pmc.getFeeIncomeChartOfAccountsCode();
    String feeIncomeAccountNumber = pmc.getFeeIncomeAccountNumber();
    String feeExpenseObjectCode = pmc.getFeeExpenseFinancialObjectCode();
    String feeIncomeObjectCode = pmc.getFeeIncomeFinancialObjectCode();
    KualiDecimal feeAmount = pmc.getFeeAmount();
    // skip creation if the fee has been set to zero
    if (!KualiDecimal.ZERO.equals(feeAmount)) {
        // grab the explicit entry for the first accounting line and adjust for the foreign draft fee
        GeneralLedgerPendingEntry chargeEntry = new GeneralLedgerPendingEntry(document.getGeneralLedgerPendingEntry(0));
        chargeEntry.setTransactionLedgerEntrySequenceNumber(sequenceHelper.getSequenceCounter());
        // change the object code (expense to the department)
        chargeEntry.setFinancialObjectCode(feeExpenseObjectCode);
        chargeEntry.setFinancialSubObjectCode(GENERAL_LEDGER_PENDING_ENTRY_CODE.getBlankFinancialSubObjectCode());
        chargeEntry.setTransactionLedgerEntryDescription(StringUtils.left("Automatic debit for " + pm.getPaymentMethodName() + " fee", 40));
        chargeEntry.setFinancialBalanceTypeCode(KFSConstants.BALANCE_TYPE_ACTUAL);
        // retrieve object type
        ObjectCode objectCode = getObjectCodeService().getByPrimaryIdForCurrentYear(chargeEntry.getChartOfAccountsCode(), chargeEntry.getFinancialObjectCode());
        if (objectCode == null) {
            LOG.fatal("Specified offset object code: " + chargeEntry.getChartOfAccountsCode() + "-" + chargeEntry.getFinancialObjectCode() + " does not exist - failed to generate foreign draft fee entries", new RuntimeException());
            return false;
        }
        chargeEntry.setFinancialObjectTypeCode(objectCode.getFinancialObjectTypeCode());
        // Set the amount from the parameter
        chargeEntry.setTransactionLedgerEntryAmount(feeAmount);
        chargeEntry.setTransactionDebitCreditCode(reverseEntries ? GL_CREDIT_CODE : GL_DEBIT_CODE);
        document.addPendingEntry(chargeEntry);
        sequenceHelper.increment();
        // handle the offset entry
        GeneralLedgerPendingEntry offsetEntry = new GeneralLedgerPendingEntry(chargeEntry);
        getGeneralLedgerPendingEntryService().populateOffsetGeneralLedgerPendingEntry(document.getPostingYear(), chargeEntry, sequenceHelper, offsetEntry);
        document.addPendingEntry(offsetEntry);
        sequenceHelper.increment();
        // Now, create the income entry in the AP Foreign draft fee account
        GeneralLedgerPendingEntry feeIncomeEntry = new GeneralLedgerPendingEntry(document.getGeneralLedgerPendingEntry(0));
        feeIncomeEntry.setTransactionLedgerEntrySequenceNumber(sequenceHelper.getSequenceCounter());
        feeIncomeEntry.setChartOfAccountsCode(feeIncomeChartCode);
        feeIncomeEntry.setAccountNumber(feeIncomeAccountNumber);
        feeIncomeEntry.setFinancialObjectCode(feeIncomeObjectCode);
        feeIncomeEntry.setFinancialSubObjectCode(GENERAL_LEDGER_PENDING_ENTRY_CODE.getBlankFinancialSubObjectCode());
        feeIncomeEntry.setSubAccountNumber(GENERAL_LEDGER_PENDING_ENTRY_CODE.getBlankSubAccountNumber());
        feeIncomeEntry.setProjectCode(GENERAL_LEDGER_PENDING_ENTRY_CODE.getBlankProjectCode());
        // retrieve object type
        objectCode = getObjectCodeService().getByPrimaryIdForCurrentYear(feeIncomeChartCode, feeIncomeObjectCode);
        if (objectCode == null) {
            LOG.fatal("Specified income object code: " + feeIncomeChartCode + "-" + feeIncomeObjectCode + " does not exist - failed to generate foreign draft income entries", new RuntimeException());
            return false;
        }
        feeIncomeEntry.setFinancialObjectTypeCode(objectCode.getFinancialObjectTypeCode());
        feeIncomeEntry.setTransactionLedgerEntryAmount(feeAmount);
        feeIncomeEntry.setTransactionDebitCreditCode(KFSConstants.GL_CREDIT_CODE);
        feeIncomeEntry.setFinancialBalanceTypeCode(KFSConstants.BALANCE_TYPE_ACTUAL);
        document.addPendingEntry(feeIncomeEntry);
        sequenceHelper.increment();
        // create the offset entry
        offsetEntry = new GeneralLedgerPendingEntry(feeIncomeEntry);
        getGeneralLedgerPendingEntryService().populateOffsetGeneralLedgerPendingEntry(document.getPostingYear(), feeIncomeEntry, sequenceHelper, offsetEntry);
        document.addPendingEntry(offsetEntry);
        sequenceHelper.increment();
    }
    return true;
}
Also used : PaymentMethodChart(edu.cornell.kfs.fp.businessobject.PaymentMethodChart) GeneralLedgerPendingEntry(org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntry) KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal) ObjectCode(org.kuali.kfs.coa.businessobject.ObjectCode)

Example 13 with ObjectCode

use of org.kuali.kfs.coa.businessobject.ObjectCode in project cu-kfs by CU-CommunityApps.

the class YearEndGeneralLedgerPendingEntriesServiceImpl method generateBBCashOffset.

/**
 * Generates the BB cash offset.
 *
 * @param document
 * @param accountingLine
 * @param sequenceNumber
 * @param documentTypeCode
 * @param fiscalYear
 * @return the generated glpe
 */
public GeneralLedgerPendingEntry generateBBCashOffset(AccountingDocumentBase document, AccountingLine accountingLine, Integer sequenceNumber, String documentTypeCode, Integer fiscalYear) {
    Integer closingFiscalYear = new Integer(getParameterService().getParameterValueAsString(KfsParameterConstants.GENERAL_LEDGER_BATCH.class, GeneralLedgerConstants.ANNUAL_CLOSING_FISCAL_YEAR_PARM));
    String currentDocumentTypeName = document.getFinancialSystemDocumentHeader().getWorkflowDocument().getDocumentTypeName();
    OffsetDefinition cashOffsetDefinition = offsetDefinitionService.getByPrimaryId(fiscalYear, accountingLine.getChartOfAccountsCode(), documentTypeCode, KFSConstants.BALANCE_TYPE_ACTUAL);
    ObjectCode cashObjectCode = cashOffsetDefinition.getFinancialObject();
    String cashOffsetObjectCode = cashOffsetDefinition.getFinancialObjectCode();
    String debitCreditCode = null;
    GeneralLedgerPendingEntry offsetEntry = new GeneralLedgerPendingEntry();
    offsetEntry.setUniversityFiscalYear(fiscalYear + 1);
    offsetEntry.setChartOfAccountsCode(accountingLine.getChartOfAccountsCode());
    offsetEntry.setAccountNumber(accountingLine.getAccountNumber());
    offsetEntry.setSubAccountNumber(StringUtils.isBlank(accountingLine.getSubAccountNumber()) ? KFSConstants.getDashSubAccountNumber() : accountingLine.getSubAccountNumber());
    offsetEntry.setFinancialObjectCode(cashOffsetObjectCode);
    offsetEntry.setFinancialSubObjectCode(StringUtils.isBlank(accountingLine.getFinancialSubObjectCode()) ? KFSConstants.getDashFinancialSubObjectCode() : accountingLine.getFinancialSubObjectCode());
    offsetEntry.setFinancialBalanceTypeCode(KFSConstants.BALANCE_TYPE_ACTUAL);
    offsetEntry.setFinancialObjectTypeCode(cashObjectCode.getFinancialObjectTypeCode());
    offsetEntry.setUniversityFiscalPeriodCode(KFSConstants.PERIOD_CODE_BEGINNING_BALANCE);
    offsetEntry.setFinancialDocumentTypeCode(currentDocumentTypeName);
    offsetEntry.setFinancialSystemOriginationCode(homeOriginationService.getHomeOrigination().getFinSystemHomeOriginationCode());
    offsetEntry.setDocumentNumber(document.getDocumentNumber());
    offsetEntry.setTransactionLedgerEntrySequenceNumber(new Integer(sequenceNumber.intValue()));
    offsetEntry.setTransactionLedgerEntryDescription("BEG BAL BROUGHT FORWARD FROM " + closingFiscalYear);
    offsetEntry.setTransactionLedgerEntryAmount(accountingLine.getAmount());
    offsetEntry.setTransactionDebitCreditCode(debitCreditCode);
    Timestamp transactionTimestamp = new Timestamp(dateTimeService.getCurrentDate().getTime());
    offsetEntry.setTransactionDate(new java.sql.Date(transactionTimestamp.getTime()));
    offsetEntry.setTransactionEntryProcessedTs(transactionTimestamp);
    offsetEntry.setOrganizationDocumentNumber(null);
    offsetEntry.setProjectCode(StringUtils.isBlank(accountingLine.getProjectCode()) ? KFSConstants.getDashProjectCode() : accountingLine.getProjectCode());
    offsetEntry.setOrganizationReferenceId(accountingLine.getOrganizationReferenceId());
    offsetEntry.setReferenceFinancialDocumentTypeCode(null);
    offsetEntry.setReferenceFinancialSystemOriginationCode(null);
    offsetEntry.setReferenceFinancialDocumentNumber(null);
    offsetEntry.setFinancialDocumentReversalDate(null);
    offsetEntry.setTransactionEncumbranceUpdateCode(null);
    if (accountingLine.getAmount().isNegative()) {
        offsetEntry.setTransactionDebitCreditCode(KFSConstants.GL_CREDIT_CODE);
    } else {
        offsetEntry.setTransactionDebitCreditCode(KFSConstants.GL_DEBIT_CODE);
    }
    if (accountingLine.getAmount().isNegative()) {
        offsetEntry.setTransactionLedgerEntryAmount(accountingLine.getAmount().negated());
    }
    return offsetEntry;
}
Also used : GeneralLedgerPendingEntry(org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntry) OffsetDefinition(org.kuali.kfs.coa.businessobject.OffsetDefinition) ObjectCode(org.kuali.kfs.coa.businessobject.ObjectCode) Timestamp(java.sql.Timestamp)

Example 14 with ObjectCode

use of org.kuali.kfs.coa.businessobject.ObjectCode in project cu-kfs by CU-CommunityApps.

the class MockObjectCodeService method getByPrimaryIdForCurrentYear.

@Override
public ObjectCode getByPrimaryIdForCurrentYear(String chartOfAccountsCode, String financialObjectCode) {
    ObjectCode objectCode = null;
    if (ConcurAccountValidationTestConstants.VALID_CHART.equalsIgnoreCase(chartOfAccountsCode) && ConcurAccountValidationTestConstants.VALID_OBJ_CD.equalsIgnoreCase(financialObjectCode)) {
        objectCode = createObjectCode(chartOfAccountsCode, financialObjectCode);
        objectCode.setActive(true);
    }
    if (ConcurAccountValidationTestConstants.VALID_CHART.equalsIgnoreCase(chartOfAccountsCode) && ConcurAccountValidationTestConstants.INACTIVE_OBJ_CD.equalsIgnoreCase(financialObjectCode)) {
        objectCode = createObjectCode(chartOfAccountsCode, financialObjectCode);
        objectCode.setActive(false);
    }
    return objectCode;
}
Also used : ObjectCode(org.kuali.kfs.coa.businessobject.ObjectCode)

Example 15 with ObjectCode

use of org.kuali.kfs.coa.businessobject.ObjectCode in project cu-kfs by CU-CommunityApps.

the class AwsAccountingXmlDocumentAccountingLineServiceImplTest method createMockObjectCode.

private static ObjectCode createMockObjectCode(ObjectCodeFixture objectCodeFixture) {
    ObjectCode objectCode = mock(ObjectCode.class);
    when(objectCode.isActive()).thenReturn(objectCodeFixture.active);
    return objectCode;
}
Also used : ObjectCode(org.kuali.kfs.coa.businessobject.ObjectCode) SubObjectCode(org.kuali.kfs.coa.businessobject.SubObjectCode)

Aggregations

ObjectCode (org.kuali.kfs.coa.businessobject.ObjectCode)20 SubObjectCode (org.kuali.kfs.coa.businessobject.SubObjectCode)7 OriginEntryFull (org.kuali.kfs.gl.businessobject.OriginEntryFull)4 ObjectCodeService (org.kuali.kfs.coa.service.ObjectCodeService)3 FatalErrorException (org.kuali.kfs.gl.batch.service.impl.exception.FatalErrorException)3 GeneralLedgerPendingEntry (org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntry)3 KualiDecimal (org.kuali.rice.core.api.util.type.KualiDecimal)3 PaymentMethodChart (edu.cornell.kfs.fp.businessobject.PaymentMethodChart)2 HashMap (java.util.HashMap)2 ObjectType (org.kuali.kfs.coa.businessobject.ObjectType)2 SubObjectCodeService (org.kuali.kfs.coa.service.SubObjectCodeService)2 ContractGrantReportingCode (edu.cornell.kfs.coa.businessobject.ContractGrantReportingCode)1 ObjectCodeExtendedAttribute (edu.cornell.kfs.coa.businessobject.ObjectCodeExtendedAttribute)1 ReversionCategory (edu.cornell.kfs.coa.businessobject.ReversionCategory)1 ReversionCategoryInfo (edu.cornell.kfs.coa.businessobject.ReversionCategoryInfo)1 ReversionUnitOfWorkCategoryAmount (edu.cornell.kfs.gl.businessobject.ReversionUnitOfWorkCategoryAmount)1 IOException (java.io.IOException)1 BigDecimal (java.math.BigDecimal)1 Date (java.sql.Date)1 Timestamp (java.sql.Timestamp)1