Search in sources :

Example 6 with CuPaymentRequestDocument

use of edu.cornell.kfs.module.purap.document.CuPaymentRequestDocument in project cu-kfs by CU-CommunityApps.

the class CuPaymentRequestServiceImplTest method testAmountAnalysisForQuantityOrderBelowLimit.

public void testAmountAnalysisForQuantityOrderBelowLimit() throws Exception {
    CuPaymentRequestDocument paymentRequestDocument = createPaymentRequestForTestingPOAmountLimit(PurchaseOrderFixture.PO_NON_B2B_OPEN_WITH_QTY_ITEM_BELOW_5K);
    assertTrue("Payment should have passed the within-amount-limit check, due to quantity-based order with amount below the threshold", ((CuPaymentRequestService) paymentRequestService).purchaseOrderForPaymentRequestIsWithinAutoApproveAmountLimit(paymentRequestDocument));
}
Also used : CuPaymentRequestDocument(edu.cornell.kfs.module.purap.document.CuPaymentRequestDocument)

Example 7 with CuPaymentRequestDocument

use of edu.cornell.kfs.module.purap.document.CuPaymentRequestDocument in project cu-kfs by CU-CommunityApps.

the class CuPaymentRequestServiceImplTest method testAmountAnalysisForQuantityOrderAtLimit.

public void testAmountAnalysisForQuantityOrderAtLimit() throws Exception {
    CuPaymentRequestDocument paymentRequestDocument = createPaymentRequestForTestingPOAmountLimit(PurchaseOrderFixture.PO_NON_B2B_OPEN_WITH_QTY_ITEM_AT_5K);
    assertFalse("Payment should have failed the within-amount-limit check, due to quantity-based order with amount equal to the threshold", ((CuPaymentRequestService) paymentRequestService).purchaseOrderForPaymentRequestIsWithinAutoApproveAmountLimit(paymentRequestDocument));
}
Also used : CuPaymentRequestDocument(edu.cornell.kfs.module.purap.document.CuPaymentRequestDocument)

Example 8 with CuPaymentRequestDocument

use of edu.cornell.kfs.module.purap.document.CuPaymentRequestDocument in project cu-kfs by CU-CommunityApps.

the class CuPaymentRequestServiceImplTest method testAmountAnalysisForNonQuantityOrderAboveLimit.

public void testAmountAnalysisForNonQuantityOrderAboveLimit() throws Exception {
    CuPaymentRequestDocument paymentRequestDocument = createPaymentRequestForTestingPOAmountLimit(PurchaseOrderFixture.PO_NON_B2B_OPEN_WITH_NON_QTY_ITEM_ABOVE_5K);
    assertFalse("Payment should have failed the within-amount-limit check, due to non-quantity order with amount above the threshold", ((CuPaymentRequestService) paymentRequestService).purchaseOrderForPaymentRequestIsWithinAutoApproveAmountLimit(paymentRequestDocument));
}
Also used : CuPaymentRequestDocument(edu.cornell.kfs.module.purap.document.CuPaymentRequestDocument)

Example 9 with CuPaymentRequestDocument

use of edu.cornell.kfs.module.purap.document.CuPaymentRequestDocument in project cu-kfs by CU-CommunityApps.

the class CuPaymentRequestServiceImplTest method testChangeVendor.

public void testChangeVendor() throws Exception {
    changeCurrentUser(UserNameFixture.ccs1);
    PurchaseOrderDocument po = PurchaseOrderFixture.PO_NON_B2B_OPEN.createPurchaseOrderdDocument(SpringContext.getBean(DocumentService.class));
    po.setVendorShippingPaymentTermsCode("AL");
    po.setVendorPaymentTermsCode("00N30");
    po.refreshNonUpdateableReferences();
    changeCurrentUser(UserNameFixture.mo14);
    CuPaymentRequestDocument paymentRequestDocument = (CuPaymentRequestDocument) PaymentRequestFixture.PAYMENT_REQ_DOC.createPaymentRequestDocument(po.getPurapDocumentIdentifier());
    paymentRequestDocument.initiateDocument();
    paymentRequestDocument.populatePaymentRequestFromPurchaseOrder(po);
    paymentRequestDocument.prepareForSave();
    AccountingDocumentTestUtils.saveDocument(paymentRequestDocument, SpringContext.getBean(DocumentService.class));
    paymentRequestService.changeVendor(paymentRequestDocument, 5314, 0);
    assertEquals("P", paymentRequestDocument.getPaymentMethodCode());
}
Also used : CuPaymentRequestDocument(edu.cornell.kfs.module.purap.document.CuPaymentRequestDocument) PurchaseOrderDocument(org.kuali.kfs.module.purap.document.PurchaseOrderDocument) DocumentService(org.kuali.kfs.krad.service.DocumentService)

Example 10 with CuPaymentRequestDocument

use of edu.cornell.kfs.module.purap.document.CuPaymentRequestDocument 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

CuPaymentRequestDocument (edu.cornell.kfs.module.purap.document.CuPaymentRequestDocument)23 DocumentService (org.kuali.kfs.krad.service.DocumentService)7 PurchaseOrderDocument (org.kuali.kfs.module.purap.document.PurchaseOrderDocument)7 PaymentRequestDocument (org.kuali.kfs.module.purap.document.PaymentRequestDocument)6 KualiDecimal (org.kuali.rice.core.api.util.type.KualiDecimal)5 PaymentRequestItem (org.kuali.kfs.module.purap.businessobject.PaymentRequestItem)4 HashMap (java.util.HashMap)3 PaymentRequestWireTransfer (edu.cornell.kfs.module.purap.businessobject.PaymentRequestWireTransfer)2 ArrayList (java.util.ArrayList)2 MessageMap (org.kuali.kfs.krad.util.MessageMap)2 PurchaseOrderItem (org.kuali.kfs.module.purap.businessobject.PurchaseOrderItem)2 Bank (org.kuali.kfs.sys.businessobject.Bank)2 GeneralLedgerPendingEntry (org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntry)2 CUPaymentMethodGeneralLedgerPendingEntryService (edu.cornell.kfs.fp.service.CUPaymentMethodGeneralLedgerPendingEntryService)1 CuPaymentRequestItemExtension (edu.cornell.kfs.module.purap.businessobject.CuPaymentRequestItemExtension)1 CuVendorCreditMemoDocument (edu.cornell.kfs.module.purap.document.CuVendorCreditMemoDocument)1 CUBankService (edu.cornell.kfs.sys.service.CUBankService)1 VendorDetailExtension (edu.cornell.kfs.vnd.businessobject.VendorDetailExtension)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1