Search in sources :

Example 1 with GeneralLedgerPostingDocument

use of org.kuali.kfs.sys.document.GeneralLedgerPostingDocument in project cu-kfs by CU-CommunityApps.

the class FinancialSystemSearchableAttribute method extractDocumentAttributes.

@Override
public List<DocumentAttribute> extractDocumentAttributes(ExtensionDefinition extensionDefinition, DocumentWithContent documentWithContent) {
    if (LOG.isDebugEnabled()) {
        LOG.debug("extractDocumentAttributes( " + extensionDefinition + ", " + documentWithContent + " )");
    }
    List<DocumentAttribute> searchAttrValues = super.extractDocumentAttributes(extensionDefinition, documentWithContent);
    String docId = documentWithContent.getDocument().getDocumentId();
    DocumentService docService = SpringContext.getBean(DocumentService.class);
    Document doc = null;
    try {
        doc = docService.getByDocumentHeaderIdSessionless(docId);
    } catch (WorkflowException we) {
    }
    if (doc != null) {
        if (doc instanceof AmountTotaling && ((AmountTotaling) doc).getTotalDollarAmount() != null) {
            DocumentAttributeDecimal.Builder searchableAttributeValue = DocumentAttributeDecimal.Builder.create(KFSPropertyConstants.FINANCIAL_DOCUMENT_TOTAL_AMOUNT);
            searchableAttributeValue.setValue(((AmountTotaling) doc).getTotalDollarAmount().bigDecimalValue());
            searchAttrValues.add(searchableAttributeValue.build());
        }
        if (doc instanceof AccountingDocument) {
            AccountingDocument accountingDoc = (AccountingDocument) doc;
            searchAttrValues.addAll(harvestAccountingDocumentSearchableAttributes(accountingDoc));
        }
        boolean indexedLedgerDoc = false;
        if (doc instanceof LaborLedgerPostingDocumentForSearching) {
            LaborLedgerPostingDocumentForSearching LLPostingDoc = (LaborLedgerPostingDocumentForSearching) doc;
            searchAttrValues.addAll(harvestLLPDocumentSearchableAttributes(LLPostingDoc));
            indexedLedgerDoc = true;
        }
        if (doc instanceof GeneralLedgerPostingDocument && !indexedLedgerDoc) {
            GeneralLedgerPostingDocument GLPostingDoc = (GeneralLedgerPostingDocument) doc;
            searchAttrValues.addAll(harvestGLPDocumentSearchableAttributes(GLPostingDoc));
        }
        DocumentHeader docHeader = doc.getDocumentHeader();
        if (ObjectUtils.isNotNull(docHeader) && ObjectUtils.isNotNull(docHeader.getWorkflowDocument()) && CUKFSConstants.GACC_DOCUMENT_TYPE.equalsIgnoreCase(docHeader.getWorkflowDocument().getDocumentTypeName())) {
            for (AccountGlobalDetail detail : ((AccountGlobal) ((AccountGlobalMaintainableImpl) ((FinancialSystemMaintenanceDocument) doc).getNewMaintainableObject()).getBusinessObject()).getAccountGlobalDetails()) {
                if (!StringUtils.isBlank(detail.getAccountNumber())) {
                    DocumentAttributeString.Builder searchableAttributeValue = DocumentAttributeString.Builder.create(KFSPropertyConstants.ACCOUNT_NUMBER);
                    searchableAttributeValue.setValue(detail.getAccountNumber());
                    searchAttrValues.add(searchableAttributeValue.build());
                }
            }
        }
    }
    return searchAttrValues;
}
Also used : WorkflowException(org.kuali.rice.kew.api.exception.WorkflowException) DocumentAttributeDecimal(org.kuali.rice.kew.api.document.attribute.DocumentAttributeDecimal) DocumentAttributeString(org.kuali.rice.kew.api.document.attribute.DocumentAttributeString) Document(org.kuali.kfs.krad.document.Document) GeneralLedgerPostingDocument(org.kuali.kfs.sys.document.GeneralLedgerPostingDocument) FinancialSystemMaintenanceDocument(org.kuali.kfs.sys.document.FinancialSystemMaintenanceDocument) AccountingDocument(org.kuali.kfs.sys.document.AccountingDocument) DocumentHeader(org.kuali.kfs.krad.bo.DocumentHeader) FinancialSystemDocumentHeader(org.kuali.kfs.sys.businessobject.FinancialSystemDocumentHeader) DocumentService(org.kuali.kfs.krad.service.DocumentService) LaborLedgerPostingDocumentForSearching(org.kuali.kfs.integration.ld.LaborLedgerPostingDocumentForSearching) FinancialSystemMaintenanceDocument(org.kuali.kfs.sys.document.FinancialSystemMaintenanceDocument) GeneralLedgerPostingDocument(org.kuali.kfs.sys.document.GeneralLedgerPostingDocument) AccountGlobal(org.kuali.kfs.coa.businessobject.AccountGlobal) DocumentAttribute(org.kuali.rice.kew.api.document.attribute.DocumentAttribute) AccountingDocument(org.kuali.kfs.sys.document.AccountingDocument) AccountGlobalDetail(org.kuali.kfs.coa.businessobject.AccountGlobalDetail) DocumentAttributeString(org.kuali.rice.kew.api.document.attribute.DocumentAttributeString) AmountTotaling(org.kuali.kfs.sys.document.AmountTotaling)

Example 2 with GeneralLedgerPostingDocument

use of org.kuali.kfs.sys.document.GeneralLedgerPostingDocument in project cu-kfs by CU-CommunityApps.

the class CUPaymentMethodGeneralLedgerPendingEntryServiceImpl method generateFinalEntriesForPRNC.

/**
 * Creates final entries for PRNC doc: Reverse all usage 2900 object codes Replaces with 1000 offset object code Generate
 * Bank Offsets for total amounts
 *
 * @see edu.cornell.kfs.fp.service.CUPaymentMethodGeneralLedgerPendingEntryService#generateFinalEntriesForPRNC(org.kuali.kfs.module.purap.document.PaymentRequestDocument)
 */
public void generateFinalEntriesForPRNC(PaymentRequestDocument document) {
    GeneralLedgerPendingEntrySequenceHelper sequenceHelper = new GeneralLedgerPendingEntrySequenceHelper(getNextAvailableSequence(document.getDocumentNumber()));
    String documentType = CuPaymentRequestDocument.DOCUMENT_TYPE_NON_CHECK;
    if (PaymentMethod.PM_CODE_INTERNAL_BILLING.equalsIgnoreCase(((CuPaymentRequestDocument) document).getPaymentMethodCode())) {
        documentType = CuPaymentRequestDocument.DOCUMENT_TYPE_INTERNAL_BILLING;
    }
    // generate bank offset
    if (PaymentMethod.PM_CODE_FOREIGN_DRAFT.equalsIgnoreCase(((CuPaymentRequestDocument) document).getPaymentMethodCode()) || PaymentMethod.PM_CODE_WIRE.equalsIgnoreCase(((CuPaymentRequestDocument) document).getPaymentMethodCode())) {
        generateDocumentBankOffsetEntries((AccountingDocument) document, document.getBankCode(), KRADConstants.DOCUMENT_PROPERTY_NAME + "." + "bankCode", documentType, sequenceHelper, document.getTotalDollarAmount().negated());
    }
    // check for balance type Actual offset pending entries and replace the object code with chart cash object code (currently replacing object code 2900 with 1000)
    List<GeneralLedgerPendingEntry> glpes = document.getGeneralLedgerPendingEntries();
    for (GeneralLedgerPendingEntry glpe : glpes) {
        OffsetDefinition offsetDefinition = SpringContext.getBean(OffsetDefinitionService.class).getByPrimaryId(glpe.getUniversityFiscalYear(), glpe.getChartOfAccountsCode(), documentType, KFSConstants.BALANCE_TYPE_ACTUAL);
        if (glpe.getFinancialObjectCode().equalsIgnoreCase(offsetDefinition.getFinancialObjectCode())) {
            if (ObjectUtils.isNull(glpe.getChart())) {
                glpe.refreshReferenceObject(KFSPropertyConstants.CHART);
            }
            glpe.setFinancialObjectCode(glpe.getChart().getFinancialCashObjectCode());
            glpe.refreshReferenceObject(KFSPropertyConstants.FINANCIAL_OBJECT);
            glpe.setFinancialObjectTypeCode(glpe.getFinancialObject().getFinancialObjectTypeCode());
        }
    }
    // reverse 2900
    // check for posted entries and create reverse pending entries
    // get all charts on document
    List<AccountingLine> accountingLines = new ArrayList<AccountingLine>();
    if (ObjectUtils.isNotNull(document.getSourceAccountingLines())) {
        accountingLines.addAll(document.getSourceAccountingLines());
    }
    if (ObjectUtils.isNotNull(document.getTargetAccountingLines())) {
        accountingLines.addAll(document.getTargetAccountingLines());
    }
    Map<String, String> chartOffsets = new HashMap<String, String>();
    if (accountingLines.size() > 0) {
        for (AccountingLine accountingLine : accountingLines) {
            if (!chartOffsets.containsKey(accountingLine.getChartOfAccountsCode())) {
                OffsetDefinition offsetDefinition = SpringContext.getBean(OffsetDefinitionService.class).getByPrimaryId(accountingLine.getPostingYear(), accountingLine.getChartOfAccountsCode(), documentType, KFSConstants.BALANCE_TYPE_ACTUAL);
                chartOffsets.put(accountingLine.getChartOfAccountsCode(), offsetDefinition.getFinancialObjectCode());
            }
        }
    }
    for (String offsetObjectCode : chartOffsets.values()) {
        Collection<Entry> glEntries = findMatchingGLEntries(document, offsetObjectCode);
        if (glEntries != null && glEntries.size() > 0) {
            for (Entry entry : glEntries) {
                // create reversal
                GeneralLedgerPendingEntry glpe = new GeneralLedgerPendingEntry();
                boolean debit = KFSConstants.GL_CREDIT_CODE.equalsIgnoreCase(entry.getTransactionDebitCreditCode());
                glpe = getGeneralLedgerPendingEntryService().buildGeneralLedgerPendingEntry((GeneralLedgerPostingDocument) document, entry.getAccount(), entry.getFinancialObject(), entry.getSubAccountNumber(), entry.getFinancialSubObjectCode(), entry.getOrganizationReferenceId(), entry.getProjectCode(), entry.getReferenceFinancialDocumentNumber(), entry.getReferenceFinancialDocumentTypeCode(), entry.getReferenceFinancialSystemOriginationCode(), entry.getTransactionLedgerEntryDescription(), debit, entry.getTransactionLedgerEntryAmount(), sequenceHelper);
                glpe.setFinancialDocumentTypeCode(documentType);
                document.addPendingEntry(glpe);
                sequenceHelper.increment();
                // create cash entry
                GeneralLedgerPendingEntry cashGlpe = new GeneralLedgerPendingEntry();
                cashGlpe = getGeneralLedgerPendingEntryService().buildGeneralLedgerPendingEntry((GeneralLedgerPostingDocument) document, entry.getAccount(), entry.getChart().getFinancialCashObject(), entry.getSubAccountNumber(), entry.getFinancialSubObjectCode(), entry.getOrganizationReferenceId(), entry.getProjectCode(), entry.getReferenceFinancialDocumentNumber(), entry.getReferenceFinancialDocumentTypeCode(), entry.getReferenceFinancialSystemOriginationCode(), entry.getTransactionLedgerEntryDescription(), !debit, entry.getTransactionLedgerEntryAmount(), sequenceHelper);
                cashGlpe.setFinancialDocumentTypeCode(documentType);
                document.addPendingEntry(cashGlpe);
                sequenceHelper.increment();
            }
        }
    }
    if (document.getGeneralLedgerPendingEntries() != null && document.getGeneralLedgerPendingEntries().size() > 0) {
        for (GeneralLedgerPendingEntry glpe : document.getGeneralLedgerPendingEntries()) {
            glpe.setFinancialDocumentApprovedCode(KFSConstants.PENDING_ENTRY_APPROVED_STATUS_CODE.APPROVED);
        }
    }
}
Also used : AccountingLine(org.kuali.kfs.sys.businessobject.AccountingLine) GeneralLedgerPendingEntry(org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntry) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) GeneralLedgerPendingEntrySequenceHelper(org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntrySequenceHelper) GeneralLedgerPendingEntry(org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntry) Entry(org.kuali.kfs.gl.businessobject.Entry) GeneralLedgerPostingDocument(org.kuali.kfs.sys.document.GeneralLedgerPostingDocument) CuPaymentRequestDocument(edu.cornell.kfs.module.purap.document.CuPaymentRequestDocument) OffsetDefinition(org.kuali.kfs.coa.businessobject.OffsetDefinition) OffsetDefinitionService(org.kuali.kfs.coa.service.OffsetDefinitionService)

Aggregations

GeneralLedgerPostingDocument (org.kuali.kfs.sys.document.GeneralLedgerPostingDocument)2 CuPaymentRequestDocument (edu.cornell.kfs.module.purap.document.CuPaymentRequestDocument)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 AccountGlobal (org.kuali.kfs.coa.businessobject.AccountGlobal)1 AccountGlobalDetail (org.kuali.kfs.coa.businessobject.AccountGlobalDetail)1 OffsetDefinition (org.kuali.kfs.coa.businessobject.OffsetDefinition)1 OffsetDefinitionService (org.kuali.kfs.coa.service.OffsetDefinitionService)1 Entry (org.kuali.kfs.gl.businessobject.Entry)1 LaborLedgerPostingDocumentForSearching (org.kuali.kfs.integration.ld.LaborLedgerPostingDocumentForSearching)1 DocumentHeader (org.kuali.kfs.krad.bo.DocumentHeader)1 Document (org.kuali.kfs.krad.document.Document)1 DocumentService (org.kuali.kfs.krad.service.DocumentService)1 AccountingLine (org.kuali.kfs.sys.businessobject.AccountingLine)1 FinancialSystemDocumentHeader (org.kuali.kfs.sys.businessobject.FinancialSystemDocumentHeader)1 GeneralLedgerPendingEntry (org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntry)1 GeneralLedgerPendingEntrySequenceHelper (org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntrySequenceHelper)1 AccountingDocument (org.kuali.kfs.sys.document.AccountingDocument)1 AmountTotaling (org.kuali.kfs.sys.document.AmountTotaling)1 FinancialSystemMaintenanceDocument (org.kuali.kfs.sys.document.FinancialSystemMaintenanceDocument)1