Search in sources :

Example 11 with AccountingDocument

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

the class KualiAccountingDocumentActionBase method execute.

/**
 * Adds check for accountingLine updates, generates and dispatches any events caused by such updates
 *
 * @see org.apache.struts.action.Action#execute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm,
 *      javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
 */
@Override
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    KualiAccountingDocumentFormBase transForm = (KualiAccountingDocumentFormBase) form;
    // handle changes to accountingLines
    if (transForm.hasDocumentId()) {
        AccountingDocument financialDocument = (AccountingDocument) transForm.getDocument();
        processAccountingLines(financialDocument, transForm, KFSConstants.SOURCE);
        processAccountingLines(financialDocument, transForm, KFSConstants.TARGET);
    }
    // This is after a potential handleUpdate(), to display automatically cleared overrides following a route or save.
    processAccountingLineOverrides(transForm);
    // proceed as usual
    ActionForward result = super.execute(mapping, form, request, response);
    return result;
}
Also used : AccountingDocument(org.kuali.kfs.sys.document.AccountingDocument) ActionForward(org.apache.struts.action.ActionForward) AccountingLineOverride(org.kuali.kfs.sys.businessobject.AccountingLineOverride)

Example 12 with AccountingDocument

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

the class KualiAccountingDocumentActionBase method deleteTargetLine.

/**
 * This method will remove a TargetAccountingLine 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 deleteTargetLine(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_TARGET_ACCT_LINE_PROPERTY_NAME + "[" + deleteIndex + "]";
    boolean rulePassed = SpringContext.getBean(KualiRuleService.class).applyRules(new DeleteAccountingLineEvent(errorPath, financialDocumentForm.getDocument(), ((AccountingDocument) financialDocumentForm.getDocument()).getTargetAccountingLine(deleteIndex), false));
    // if the rule evaluation passed, let's delete it
    if (rulePassed) {
        deleteAccountingLine(false, financialDocumentForm, deleteIndex);
    } else {
        String[] errorParams = new String[] { "target", 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 13 with AccountingDocument

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

the class KualiAccountingDocumentActionBase method insertTargetLine.

/**
 * This method will add a TargetAccountingLine to a FinancialDocument. This assumes that the user presses the add button for a
 * specific accounting line on the document and that the document is represented by a FinancialDocumentFormBase. It first
 * validates the line for data integrity and then checks appropriate business rules.
 *
 * @param mapping
 * @param form
 * @param request
 * @param response
 * @return ActionForward
 * @throws Exception
 */
public ActionForward insertTargetLine(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    KualiAccountingDocumentFormBase financialDocumentForm = (KualiAccountingDocumentFormBase) form;
    TargetAccountingLine line = financialDocumentForm.getNewTargetLine();
    // populate chartOfAccountsCode from account number if accounts cant cross chart and Javascript is turned off
    // SpringContext.getBean(AccountService.class).populateAccountingLineChartIfNeeded(line);
    boolean rulePassed = true;
    // 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, false, true, 0);
    // check any business rules
    rulePassed &= SpringContext.getBean(KualiRuleService.class).applyRules(new AddAccountingLineEvent(KFSConstants.NEW_TARGET_ACCT_LINE_PROPERTY_NAME, financialDocumentForm.getDocument(), line));
    // if the rule evaluation passed, let's add it
    if (rulePassed) {
        // add accountingLine
        SpringContext.getBean(PersistenceService.class).refreshAllNonUpdatingReferences(line);
        insertAccountingLine(false, financialDocumentForm, line);
        // clear the used newTargetLine
        financialDocumentForm.setNewTargetLine(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) TargetAccountingLine(org.kuali.kfs.sys.businessobject.TargetAccountingLine) AccountingDocument(org.kuali.kfs.sys.document.AccountingDocument)

Example 14 with AccountingDocument

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

the class CuAdvanceDepositDocumentPresentationController method getEditModes.

@Override
public Set<String> getEditModes(Document document) {
    Set<String> editModes = super.getEditModes(document);
    if (document instanceof AmountTotaling) {
        editModes.add(KFSConstants.AMOUNT_TOTALING_EDITING_MODE);
    }
    editModes.add(KFSConstants.BANK_ENTRY_VIEWABLE_EDITING_MODE);
    AccountingDocument accountingDocument = (AccountingDocument) document;
    WorkflowDocument workflowDocument = accountingDocument.getDocumentHeader().getWorkflowDocument();
    if (workflowDocument.isInitiated() || workflowDocument.isSaved()) {
        editModes.add(CUKFSAuthorizationConstants.AdvanceDepositEditMode.EDITABLE_ADVANCE_DEPOSITS);
    }
    return editModes;
}
Also used : WorkflowDocument(org.kuali.rice.kew.api.WorkflowDocument) AccountingDocument(org.kuali.kfs.sys.document.AccountingDocument) AmountTotaling(org.kuali.kfs.sys.document.AmountTotaling)

Example 15 with AccountingDocument

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

the class CapitalAssetInformationActionBase method copy.

/**
 * Overridden to guarantee that form of copied document is set to whatever the entry mode of the document is
 *
 * @see org.kuali.rice.kns.web.struts.action.KualiTransactionalDocumentActionBase#copy(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
 */
@Override
public ActionForward copy(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    CapitalAccountingLinesFormBase capitalAccountingLinesFormBase = (CapitalAccountingLinesFormBase) form;
    ;
    CapitalAccountingLinesDocumentBase caldb = (CapitalAccountingLinesDocumentBase) capitalAccountingLinesFormBase.getFinancialDocument();
    List<CapitalAccountingLines> capitalAccountingLines = caldb.getCapitalAccountingLines();
    List<CapitalAccountingLines> copiedCapitalAccountingLines = new ArrayList<>();
    for (CapitalAccountingLines capitalAccountingLine : capitalAccountingLines) {
        copiedCapitalAccountingLines.add(capitalAccountingLine);
    }
    capitalAccountingLines.clear();
    ActionForward forward = super.copy(mapping, form, request, response);
    caldb.setCapitalAccountingLines(copiedCapitalAccountingLines);
    // if the copied document has capital asset collection, remove the collection
    KualiAccountingDocumentFormBase kualiAccountingDocumentFormBase = (KualiAccountingDocumentFormBase) form;
    AccountingDocument document = kualiAccountingDocumentFormBase.getFinancialDocument();
    if (document instanceof CapitalAssetEditable) {
        CapitalAssetEditable capitalAssetEditable = (CapitalAssetEditable) document;
        List<CapitalAssetInformation> capitalAssets = capitalAssetEditable.getCapitalAssetInformation();
        for (CapitalAssetInformation capitalAsset : capitalAssets) {
            Long capitalAssetNumber = capitalAsset.getCapitalAssetNumber();
            resetCapitalAssetInfo(capitalAsset);
            // because resetCapitalAssetInfo cleared the value.
            if (KFSConstants.CapitalAssets.CAPITAL_ASSET_MODIFY_ACTION_INDICATOR.equalsIgnoreCase(capitalAsset.getCapitalAssetActionIndicator())) {
                capitalAsset.setCapitalAssetNumber(capitalAssetNumber);
            }
            capitalAsset.setCapitalAssetProcessedIndicator(false);
        }
    }
    // setup the initial next sequence number column..
    KualiDocumentFormBase kualiDocumentFormBase = (KualiDocumentFormBase) form;
    setupIntialNextCapitalAssetLineNumber(kualiDocumentFormBase);
    checkCapitalAccountingLinesSelected(capitalAccountingLinesFormBase);
    return forward;
}
Also used : CapitalAssetInformation(org.kuali.kfs.fp.businessobject.CapitalAssetInformation) ArrayList(java.util.ArrayList) CapitalAccountingLinesDocumentBase(org.kuali.kfs.fp.document.CapitalAccountingLinesDocumentBase) ActionForward(org.apache.struts.action.ActionForward) CapitalAssetEditable(org.kuali.kfs.fp.document.CapitalAssetEditable) CapitalAccountingLines(org.kuali.kfs.fp.businessobject.CapitalAccountingLines) KualiDocumentFormBase(org.kuali.kfs.kns.web.struts.form.KualiDocumentFormBase) AccountingDocument(org.kuali.kfs.sys.document.AccountingDocument) KualiAccountingDocumentFormBase(org.kuali.kfs.sys.web.struts.KualiAccountingDocumentFormBase)

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