Search in sources :

Example 6 with AccountingDocument

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

the class KualiAccountingDocumentActionBase method refreshSalesTaxInfo.

/**
 * This method refreshes the sales tax fields on a refresh or tab toggle so that all the information that was there before is
 * still there after a state change
 *
 * @param form
 */
protected void refreshSalesTaxInfo(ActionForm form) {
    KualiAccountingDocumentFormBase accountingForm = (KualiAccountingDocumentFormBase) form;
    AccountingDocument document = (AccountingDocument) accountingForm.getDocument();
    List sourceLines = document.getSourceAccountingLines();
    List targetLines = document.getTargetAccountingLines();
    handleSalesTaxRequiredAllLines(accountingForm, sourceLines);
    handleSalesTaxRequiredAllLines(accountingForm, targetLines);
    AccountingLine newTargetLine = accountingForm.getNewTargetLine();
    AccountingLine newSourceLine = accountingForm.getNewSourceLine();
    if (newTargetLine != null) {
        handleSalesTaxRequired(document, newTargetLine, false, true, 0);
    }
    if (newSourceLine != null) {
        handleSalesTaxRequired(document, newSourceLine, true, true, 0);
    }
}
Also used : SourceAccountingLine(org.kuali.kfs.sys.businessobject.SourceAccountingLine) AccountingLine(org.kuali.kfs.sys.businessobject.AccountingLine) TargetAccountingLine(org.kuali.kfs.sys.businessobject.TargetAccountingLine) List(java.util.List) ArrayList(java.util.ArrayList) AccountingDocument(org.kuali.kfs.sys.document.AccountingDocument)

Example 7 with AccountingDocument

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

the class KualiAccountingDocumentActionBase method processAccountingLineOverrides.

/**
 * @param transForm
 */
protected void processAccountingLineOverrides(KualiAccountingDocumentFormBase transForm) {
    processAccountingLineOverrides(transForm.getNewSourceLine());
    processAccountingLineOverrides(transForm.getNewTargetLine());
    if (transForm.hasDocumentId()) {
        AccountingDocument financialDocument = (AccountingDocument) transForm.getDocument();
        processAccountingLineOverrides(financialDocument, financialDocument.getSourceAccountingLines());
        processAccountingLineOverrides(financialDocument, financialDocument.getTargetAccountingLines());
    }
}
Also used : AccountingDocument(org.kuali.kfs.sys.document.AccountingDocument)

Example 8 with AccountingDocument

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

the class KualiAccountingDocumentActionBase method insertSourceLine.

/**
 * This action executes an insert of a SourceAccountingLine into a document only after validating the accounting line and
 * checking any appropriate business rules.
 *
 * @param mapping
 * @param form
 * @param request
 * @param response
 * @return ActionForward
 * @throws Exception
 */
public ActionForward insertSourceLine(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    KualiAccountingDocumentFormBase financialDocumentForm = (KualiAccountingDocumentFormBase) form;
    SourceAccountingLine line = financialDocumentForm.getNewSourceLine();
    // populate chartOfAccountsCode from account number if accounts cant cross chart and Javascript is turned off
    // SpringContext.getBean(AccountService.class).populateAccountingLineChartIfNeeded(line);
    boolean rulePassed = true;
    // DV acct line amount got error during form populate; should not insert this line.  KFSUPGRADE-847
    MessageMap msgMap = GlobalVariables.getMessageMap();
    if (msgMap.hasErrors() && msgMap.getErrorMessages().keySet().contains("newSourceLine.amount") && financialDocumentForm.getDocument() instanceof DisbursementVoucherDocument) {
        rulePassed = false;
    }
    // before we check the regular rules we need to check the sales tax rules
    // TODO: Refactor rules so we no longer have to call this before a copy of the
    // accountingLine
    rulePassed &= checkSalesTax((AccountingDocument) financialDocumentForm.getDocument(), line, true, true, 0);
    // check any business rules
    rulePassed &= SpringContext.getBean(KualiRuleService.class).applyRules(new AddAccountingLineEvent(KFSConstants.NEW_SOURCE_ACCT_LINE_PROPERTY_NAME, financialDocumentForm.getDocument(), line));
    if (rulePassed) {
        // add accountingLine
        SpringContext.getBean(PersistenceService.class).refreshAllNonUpdatingReferences(line);
        insertAccountingLine(true, financialDocumentForm, line);
        // clear the used newTargetLine
        financialDocumentForm.setNewSourceLine(null);
    }
    return mapping.findForward(KFSConstants.MAPPING_BASIC);
}
Also used : PersistenceService(org.kuali.kfs.krad.service.PersistenceService) AddAccountingLineEvent(org.kuali.kfs.sys.document.validation.event.AddAccountingLineEvent) SourceAccountingLine(org.kuali.kfs.sys.businessobject.SourceAccountingLine) AccountingDocument(org.kuali.kfs.sys.document.AccountingDocument) MessageMap(org.kuali.kfs.krad.util.MessageMap) DisbursementVoucherDocument(org.kuali.kfs.fp.document.DisbursementVoucherDocument)

Example 9 with AccountingDocument

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

the class KualiAccountingDocumentActionBase method deleteSourceLine.

/**
 * This method will remove a SourceAccountingLine from a FinancialDocument. This assumes that the user presses the delete button
 * for a specific accounting line on the document and that the document is represented by a FinancialDocumentFormBase.
 *
 * @param mapping
 * @param form
 * @param request
 * @param response
 * @return ActionForward
 * @throws Exception
 */
public ActionForward deleteSourceLine(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    KualiAccountingDocumentFormBase financialDocumentForm = (KualiAccountingDocumentFormBase) form;
    int deleteIndex = getLineToDelete(request);
    String errorPath = KFSConstants.DOCUMENT_PROPERTY_NAME + "." + KFSConstants.EXISTING_SOURCE_ACCT_LINE_PROPERTY_NAME + "[" + deleteIndex + "]";
    boolean rulePassed = SpringContext.getBean(KualiRuleService.class).applyRules(new DeleteAccountingLineEvent(errorPath, financialDocumentForm.getDocument(), ((AccountingDocument) financialDocumentForm.getDocument()).getSourceAccountingLine(deleteIndex), false));
    // if the rule evaluation passed, let's delete it
    if (rulePassed) {
        deleteAccountingLine(true, financialDocumentForm, deleteIndex);
    } else {
        String[] errorParams = new String[] { "source", Integer.toString(deleteIndex + 1) };
        GlobalVariables.getMessageMap().putError(errorPath, KFSKeyConstants.ERROR_ACCOUNTINGLINE_DELETERULE_INVALIDACCOUNT, errorParams);
    }
    return mapping.findForward(KFSConstants.MAPPING_BASIC);
}
Also used : KualiRuleService(org.kuali.kfs.krad.service.KualiRuleService) DeleteAccountingLineEvent(org.kuali.kfs.sys.document.validation.event.DeleteAccountingLineEvent) AccountingDocument(org.kuali.kfs.sys.document.AccountingDocument)

Example 10 with AccountingDocument

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

the class KualiAccountingDocumentActionBase method uploadAccountingLines.

/**
 * This method determines whether we are uploading source or target lines, and then calls uploadAccountingLines directly on the
 * document object. This method handles retrieving the actual upload file as an input stream into the document.
 *
 * @param isSource
 * @param form
 * @throws FileNotFoundException
 * @throws IOException
 */
protected void uploadAccountingLines(boolean isSource, ActionForm form) throws FileNotFoundException, IOException {
    KualiAccountingDocumentFormBase tmpForm = (KualiAccountingDocumentFormBase) form;
    List importedLines = null;
    AccountingDocument financialDocument = tmpForm.getFinancialDocument();
    AccountingLineParser accountingLineParser = financialDocument.getAccountingLineParser();
    // import the lines
    String errorPathPrefix = null;
    try {
        if (isSource) {
            errorPathPrefix = KFSConstants.DOCUMENT_PROPERTY_NAME + "." + KFSConstants.SOURCE_ACCOUNTING_LINE_ERRORS;
            FormFile sourceFile = tmpForm.getSourceFile();
            checkUploadFile(sourceFile);
            importedLines = accountingLineParser.importSourceAccountingLines(sourceFile.getFileName(), sourceFile.getInputStream(), financialDocument);
        } else {
            errorPathPrefix = KFSConstants.DOCUMENT_PROPERTY_NAME + "." + KFSConstants.TARGET_ACCOUNTING_LINE_ERRORS;
            FormFile targetFile = tmpForm.getTargetFile();
            checkUploadFile(targetFile);
            importedLines = accountingLineParser.importTargetAccountingLines(targetFile.getFileName(), targetFile.getInputStream(), financialDocument);
        }
    } catch (AccountingLineParserException e) {
        GlobalVariables.getMessageMap().putError(errorPathPrefix, e.getErrorKey(), e.getErrorParameters());
    }
    // add line to list for those lines which were successfully imported
    if (importedLines != null) {
        for (Iterator i = importedLines.iterator(); i.hasNext(); ) {
            AccountingLine importedLine = (AccountingLine) i.next();
            insertAccountingLine(isSource, tmpForm, importedLine);
        }
    }
}
Also used : AccountingLineParser(org.kuali.kfs.sys.businessobject.AccountingLineParser) SourceAccountingLine(org.kuali.kfs.sys.businessobject.SourceAccountingLine) AccountingLine(org.kuali.kfs.sys.businessobject.AccountingLine) TargetAccountingLine(org.kuali.kfs.sys.businessobject.TargetAccountingLine) AccountingLineParserException(org.kuali.kfs.sys.exception.AccountingLineParserException) Iterator(java.util.Iterator) List(java.util.List) ArrayList(java.util.ArrayList) AccountingDocument(org.kuali.kfs.sys.document.AccountingDocument) FormFile(org.apache.struts.upload.FormFile)

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