Search in sources :

Example 1 with LaborExpenseTransferDocumentBase

use of org.kuali.kfs.module.ld.document.LaborExpenseTransferDocumentBase in project cu-kfs by CU-CommunityApps.

the class LaborExpenseTransferAccountTypesValidation method validate.

/**
 * Validates before the document routes
 * @see org.kuali.kfs.validation.Validation#validate(java.lang.Object[])
 */
@SuppressWarnings("unchecked")
public boolean validate(AttributedDocumentEvent event) {
    boolean isValid = true;
    if (getParameterService().getParameterValueAsBoolean(LaborConstants.LABOR_MODULE_CODE, ParameterConstants.DOCUMENT_COMPONENT, LdParameterConstants.VALIDATE_TRANSFER_ACCOUNT_TYPES_IND) && !hasExceptionPermission()) {
        Document documentForValidation = getDocumentForValidation();
        LaborExpenseTransferDocumentBase expenseTransferDocument = (LaborExpenseTransferDocumentBase) documentForValidation;
        List<AccountingLine> sourceLines = (List<AccountingLine>) expenseTransferDocument.getSourceAccountingLines();
        List<AccountingLine> targetLines = (List<AccountingLine>) expenseTransferDocument.getTargetAccountingLines();
        setInvalidTransferAccountTypesMap();
        if (CollectionUtils.isNotEmpty(sourceLines) && CollectionUtils.isNotEmpty(targetLines) && invalidTransferAccountTypesMap.size() > 0) {
            if (isInvalidTransferBetweenAccountTypes(sourceLines, targetLines)) {
                GlobalVariables.getMessageMap().putError(KFSPropertyConstants.SOURCE_ACCOUNTING_LINES, CuLaborKeyConstants.INVALID_ACCOUNTTRANSFER_ERROR);
                isValid = false;
            }
        }
    }
    return isValid;
}
Also used : AccountingLine(org.kuali.kfs.sys.businessobject.AccountingLine) LaborExpenseTransferDocumentBase(org.kuali.kfs.module.ld.document.LaborExpenseTransferDocumentBase) List(java.util.List) Document(org.kuali.kfs.krad.document.Document)

Example 2 with LaborExpenseTransferDocumentBase

use of org.kuali.kfs.module.ld.document.LaborExpenseTransferDocumentBase in project cu-kfs by CU-CommunityApps.

the class SalaryExpenseTransferAccountingLinesNotEmpty method hasEmptyAccountingLines.

@SuppressWarnings("unchecked")
protected boolean hasEmptyAccountingLines(AccountingDocument accountingDocument) {
    LaborExpenseTransferDocumentBase expenseTransferDocument = (LaborExpenseTransferDocumentBase) accountingDocument;
    List<ExpenseTransferSourceAccountingLine> sourceAccountingLines = expenseTransferDocument.getSourceAccountingLines();
    List<ExpenseTransferTargetAccountingLine> targetAccountingLines = expenseTransferDocument.getTargetAccountingLines();
    // If the lines are emoty the validation results should be false
    boolean sourceAccountingLinesValidationResult = !sourceAccountingLines.isEmpty();
    boolean targetAccountingLinesValidationResult = !targetAccountingLines.isEmpty();
    if (!sourceAccountingLinesValidationResult) {
        GlobalVariables.getMessageMap().putError(KFSPropertyConstants.SOURCE_ACCOUNTING_LINES, CuLaborKeyConstants.ERROR_ACCOUNTING_LINE_EMPTY);
    }
    if (!targetAccountingLinesValidationResult) {
        GlobalVariables.getMessageMap().putError(KFSPropertyConstants.TARGET_ACCOUNTING_LINES, CuLaborKeyConstants.ERROR_ACCOUNTING_LINE_EMPTY);
    }
    return sourceAccountingLinesValidationResult && targetAccountingLinesValidationResult;
}
Also used : ExpenseTransferSourceAccountingLine(org.kuali.kfs.module.ld.businessobject.ExpenseTransferSourceAccountingLine) LaborExpenseTransferDocumentBase(org.kuali.kfs.module.ld.document.LaborExpenseTransferDocumentBase) ExpenseTransferTargetAccountingLine(org.kuali.kfs.module.ld.businessobject.ExpenseTransferTargetAccountingLine)

Aggregations

LaborExpenseTransferDocumentBase (org.kuali.kfs.module.ld.document.LaborExpenseTransferDocumentBase)2 List (java.util.List)1 Document (org.kuali.kfs.krad.document.Document)1 ExpenseTransferSourceAccountingLine (org.kuali.kfs.module.ld.businessobject.ExpenseTransferSourceAccountingLine)1 ExpenseTransferTargetAccountingLine (org.kuali.kfs.module.ld.businessobject.ExpenseTransferTargetAccountingLine)1 AccountingLine (org.kuali.kfs.sys.businessobject.AccountingLine)1