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);
}
}
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());
}
}
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);
}
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);
}
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);
}
}
}
Aggregations