Search in sources :

Example 16 with AccountingDocument

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

the class CreateAccountingDocumentServiceImplTest method buildExpectedDocumentsAndAppendToLists.

private void buildExpectedDocumentsAndAppendToLists(Consumer<AccountingXmlDocumentEntryFixture> fixtureListAppender, Consumer<AccountingDocument> documentListAppender, AccountingXmlDocumentEntryFixture... fixtures) {
    MutableInt idCounter = new MutableInt(DOCUMENT_NUMBER_START);
    Stream.of(fixtures).filter(this::isDocumentExpectedToReachInitiationPoint).map((fixture) -> buildDocumentIdToFixtureMapping(idCounter, fixture)).filter((mapping) -> isDocumentExpectedToPassBusinessRulesValidation(mapping.getValue())).peek((mapping) -> fixtureListAppender.accept(mapping.getValue())).map(this::buildExpectedDocument).forEach(documentListAppender);
}
Also used : CUMarshalServiceImpl(edu.cornell.kfs.sys.service.impl.CUMarshalServiceImpl) Arrays(java.util.Arrays) StringUtils(org.apache.commons.lang.StringUtils) ValidationException(org.kuali.kfs.krad.exception.ValidationException) BatchInputFileServiceImpl(org.kuali.kfs.sys.batch.service.impl.BatchInputFileServiceImpl) AdHocRoutePerson(org.kuali.kfs.krad.bo.AdHocRoutePerson) Date(java.util.Date) CreateAccountingDocumentReportService(edu.cornell.kfs.fp.batch.service.CreateAccountingDocumentReportService) BiFunction(java.util.function.BiFunction) AccountingXmlDocumentEntryFixture(edu.cornell.kfs.fp.batch.xml.fixture.AccountingXmlDocumentEntryFixture) DateTimeService(org.kuali.rice.core.api.datetime.DateTimeService) AccountingXmlDocumentListWrapperFixture(edu.cornell.kfs.fp.batch.xml.fixture.AccountingXmlDocumentListWrapperFixture) GlobalVariables(org.kuali.kfs.krad.util.GlobalVariables) CuFPConstants(edu.cornell.kfs.fp.CuFPConstants) ByteArrayInputStream(java.io.ByteArrayInputStream) CuFPKeyConstants(edu.cornell.kfs.fp.CuFPKeyConstants) WebServiceCredentialFixture(edu.cornell.kfs.sys.businessobject.fixture.WebServiceCredentialFixture) MockPersonUtil(edu.cornell.kfs.sys.util.MockPersonUtil) Map(java.util.Map) After(org.junit.After) KFSConstants(org.kuali.kfs.sys.KFSConstants) URI(java.net.URI) AttachmentService(org.kuali.kfs.krad.service.AttachmentService) FileStorageService(org.kuali.kfs.sys.service.FileStorageService) PersonService(org.kuali.rice.kim.api.identity.PersonService) MutableInt(org.apache.commons.lang.mutable.MutableInt) KRADConstants(org.kuali.kfs.krad.util.KRADConstants) Person(org.kuali.rice.kim.api.identity.Person) Note(org.kuali.kfs.krad.bo.Note) AccountingXmlDocumentDownloadAttachmentService(edu.cornell.kfs.fp.batch.service.AccountingXmlDocumentDownloadAttachmentService) GeneralLedgerConstants(org.kuali.kfs.gl.GeneralLedgerConstants) InternalBillingItem(org.kuali.kfs.fp.businessobject.InternalBillingItem) Invocation(javax.ws.rs.client.Invocation) Collectors(java.util.stream.Collectors) WebServiceCredentialService(edu.cornell.kfs.sys.service.WebServiceCredentialService) JAXBXmlBatchInputFileTypeBase(edu.cornell.kfs.sys.batch.JAXBXmlBatchInputFileTypeBase) List(java.util.List) Stream(java.util.stream.Stream) Response(javax.ws.rs.core.Response) AccountingLine(org.kuali.kfs.sys.businessobject.AccountingLine) Assert.assertFalse(org.junit.Assert.assertFalse) AccountingDocumentMapping(edu.cornell.kfs.fp.batch.xml.fixture.AccountingDocumentMapping) AccountingDocumentGenerator(edu.cornell.kfs.fp.batch.service.AccountingDocumentGenerator) UserNameFixture(org.kuali.kfs.sys.fixture.UserNameFixture) CuFPTestConstants(edu.cornell.kfs.fp.CuFPTestConstants) UserSession(org.kuali.kfs.krad.UserSession) Document(org.kuali.kfs.krad.document.Document) Client(javax.ws.rs.client.Client) SimpleDateFormat(java.text.SimpleDateFormat) HashMap(java.util.HashMap) Function(java.util.function.Function) Supplier(java.util.function.Supplier) ArrayList(java.util.ArrayList) MockObjectUtils(edu.cornell.kfs.sys.util.MockObjectUtils) DocumentService(org.kuali.kfs.krad.service.DocumentService) BiConsumer(java.util.function.BiConsumer) CreateAccountingDocumentReportItem(edu.cornell.kfs.fp.batch.CreateAccountingDocumentReportItem) MockDocumentUtils(edu.cornell.kfs.sys.util.MockDocumentUtils) Before(org.junit.Before) Attachment(org.kuali.kfs.krad.bo.Attachment) FinancialSystemDocumentHeader(org.kuali.kfs.sys.businessobject.FinancialSystemDocumentHeader) Capture(org.easymock.Capture) Assert.assertNotNull(org.junit.Assert.assertNotNull) Assert.assertTrue(org.junit.Assert.assertTrue) IOException(java.io.IOException) FileUtils(org.apache.commons.io.FileUtils) Test(org.junit.Test) AccountingDocument(org.kuali.kfs.sys.document.AccountingDocument) EasyMock(org.easymock.EasyMock) InternalBillingDocument(org.kuali.kfs.fp.document.InternalBillingDocument) AccountingXmlDocumentListWrapper(edu.cornell.kfs.fp.batch.xml.AccountingXmlDocumentListWrapper) File(java.io.File) Consumer(java.util.function.Consumer) AccountingDocumentClassMappingUtils(edu.cornell.kfs.fp.batch.xml.fixture.AccountingDocumentClassMappingUtils) AbstractMap(java.util.AbstractMap) ConfigurationService(org.kuali.rice.core.api.config.property.ConfigurationService) Assert.assertNull(org.junit.Assert.assertNull) CuFPParameterConstants(edu.cornell.kfs.fp.CuFPParameterConstants) ParameterService(org.kuali.kfs.coreservice.framework.parameter.ParameterService) FileSystemFileStorageServiceImpl(org.kuali.kfs.sys.service.impl.FileSystemFileStorageServiceImpl) WebTarget(javax.ws.rs.client.WebTarget) Assert.assertEquals(org.junit.Assert.assertEquals) InputStream(java.io.InputStream) MutableInt(org.apache.commons.lang.mutable.MutableInt)

Example 17 with AccountingDocument

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

the class CreateAccountingDocumentServiceImplTest method assertDocumentsWereCreatedAndRoutedCorrectly.

private void assertDocumentsWereCreatedAndRoutedCorrectly(AccountingXmlDocumentEntryFixture... fixtures) {
    List<AccountingXmlDocumentEntryFixture> expectedRoutableFixtures = new ArrayList<>(fixtures.length);
    List<AccountingDocument> expectedAccountingDocuments = new ArrayList<>(fixtures.length);
    buildExpectedDocumentsAndAppendToLists(expectedRoutableFixtures::add, expectedAccountingDocuments::add, fixtures);
    assertEquals("Wrong number of routed documents", expectedAccountingDocuments.size(), routedAccountingDocuments.size());
    for (int i = 0; i < expectedAccountingDocuments.size(); i++) {
        AccountingXmlDocumentEntryFixture fixture = expectedRoutableFixtures.get(i);
        Class<? extends AccountingDocument> expectedDocumentClass = AccountingDocumentClassMappingUtils.getDocumentClassByDocumentType(fixture.documentTypeCode);
        assertAccountingDocumentIsCorrect(expectedDocumentClass, expectedAccountingDocuments.get(i), routedAccountingDocuments.get(i));
    }
}
Also used : AccountingXmlDocumentEntryFixture(edu.cornell.kfs.fp.batch.xml.fixture.AccountingXmlDocumentEntryFixture) ArrayList(java.util.ArrayList) AccountingDocument(org.kuali.kfs.sys.document.AccountingDocument)

Example 18 with AccountingDocument

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

the class MockDocumentUtils method performInitializationFromSkippedConstructor.

private static void performInitializationFromSkippedConstructor(Document document) {
    document.setDocumentHeader(new FinancialSystemDocumentHeader());
    document.setAdHocRoutePersons(new ArrayList<>());
    document.setAdHocRouteWorkgroups(new ArrayList<>());
    document.setNotes(new ArrayList<>());
    if (document instanceof AccountingDocument) {
        AccountingDocument accountingDocument = (AccountingDocument) document;
        accountingDocument.setSourceAccountingLines(new ArrayList<>());
        accountingDocument.setTargetAccountingLines(new ArrayList<>());
        accountingDocument.setNextSourceLineNumber(Integer.valueOf(1));
        accountingDocument.setNextTargetLineNumber(Integer.valueOf(1));
    }
    if (document instanceof InternalBillingDocument) {
        InternalBillingDocument internalBillingDocument = (InternalBillingDocument) document;
        internalBillingDocument.setItems(new ArrayList<>());
        internalBillingDocument.setNextItemLineNumber(Integer.valueOf(1));
    }
}
Also used : FinancialSystemDocumentHeader(org.kuali.kfs.sys.businessobject.FinancialSystemDocumentHeader) AccountingDocument(org.kuali.kfs.sys.document.AccountingDocument) InternalBillingDocument(org.kuali.kfs.fp.document.InternalBillingDocument)

Example 19 with AccountingDocument

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

the class CuPreEncumbranceAction method setTabStates.

protected void setTabStates(ActionForm form) {
    KualiAccountingDocumentFormBase kualiForm = (KualiAccountingDocumentFormBase) form;
    AccountingDocument accountingDocument = kualiForm.getFinancialDocument();
    Map<String, String> tabStates = kualiForm.getTabStates();
    setAutomaticPartialDisEncumbrancesTabsOpen(accountingDocument, tabStates);
    setGeneralLedgerPendingEntriesTabOpenWhenGLPEsExist(accountingDocument, tabStates);
    kualiForm.setTabStates(tabStates);
}
Also used : AccountingDocument(org.kuali.kfs.sys.document.AccountingDocument) KualiAccountingDocumentFormBase(org.kuali.kfs.sys.web.struts.KualiAccountingDocumentFormBase)

Example 20 with AccountingDocument

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

the class KualiAccountingDocumentActionBase method handleSalesTaxRequiredAllLines.

/**
 * This method is called from the createDocument and processes through all the accouting lines and checks to see if they need
 * sales tax fields
 *
 * @param kualiDocumentFormBase
 * @param baselineSourceLines
 */
protected void handleSalesTaxRequiredAllLines(KualiDocumentFormBase kualiDocumentFormBase, List<AccountingLine> baselineAcctingLines) {
    AccountingDocument accoutingDocument = (AccountingDocument) kualiDocumentFormBase.getDocument();
    int index = 0;
    for (AccountingLine accountingLine : baselineAcctingLines) {
        boolean source = false;
        if (accountingLine.isSourceAccountingLine()) {
            source = true;
        }
        handleSalesTaxRequired(accoutingDocument, accountingLine, source, false, index);
        index++;
    }
}
Also used : SourceAccountingLine(org.kuali.kfs.sys.businessobject.SourceAccountingLine) AccountingLine(org.kuali.kfs.sys.businessobject.AccountingLine) TargetAccountingLine(org.kuali.kfs.sys.businessobject.TargetAccountingLine) AccountingDocument(org.kuali.kfs.sys.document.AccountingDocument)

Aggregations

AccountingDocument (org.kuali.kfs.sys.document.AccountingDocument)22 AccountingLine (org.kuali.kfs.sys.businessobject.AccountingLine)6 ArrayList (java.util.ArrayList)5 SourceAccountingLine (org.kuali.kfs.sys.businessobject.SourceAccountingLine)5 TargetAccountingLine (org.kuali.kfs.sys.businessobject.TargetAccountingLine)5 DocumentService (org.kuali.kfs.krad.service.DocumentService)4 WorkflowException (org.kuali.rice.kew.api.exception.WorkflowException)4 List (java.util.List)3 FinancialSystemDocumentHeader (org.kuali.kfs.sys.businessobject.FinancialSystemDocumentHeader)3 AccountingXmlDocumentEntryFixture (edu.cornell.kfs.fp.batch.xml.fixture.AccountingXmlDocumentEntryFixture)2 IOException (java.io.IOException)2 ActionForward (org.apache.struts.action.ActionForward)2 InternalBillingDocument (org.kuali.kfs.fp.document.InternalBillingDocument)2 Document (org.kuali.kfs.krad.document.Document)2 ValidationException (org.kuali.kfs.krad.exception.ValidationException)2 KualiRuleService (org.kuali.kfs.krad.service.KualiRuleService)2 PersistenceService (org.kuali.kfs.krad.service.PersistenceService)2 AmountTotaling (org.kuali.kfs.sys.document.AmountTotaling)2 AddAccountingLineEvent (org.kuali.kfs.sys.document.validation.event.AddAccountingLineEvent)2 DeleteAccountingLineEvent (org.kuali.kfs.sys.document.validation.event.DeleteAccountingLineEvent)2