Search in sources :

Example 41 with KualiDecimal

use of org.kuali.rice.core.api.util.type.KualiDecimal in project cu-kfs by CU-CommunityApps.

the class YearEndGeneralLedgerPendingEntriesServiceImpl method generateGeneralForwardOriginEntry.

/**
 * Generates the general forward entry.
 *
 * @param document
 * @param postable
 * @param closingFiscalYear
 * @param sequenceNumber
 * @return the generated glpe
 */
public GeneralLedgerPendingEntry generateGeneralForwardOriginEntry(AccountingDocumentBase document, AccountingLine postable, Integer closingFiscalYear, Integer sequenceNumber) {
    SystemOptions currentYearOptions = optionsService.getCurrentYearOptions();
    String currentDocumentTypeName = document.getFinancialSystemDocumentHeader().getWorkflowDocument().getDocumentTypeName();
    GeneralLedgerPendingEntry entry = new GeneralLedgerPendingEntry();
    entry.setUniversityFiscalYear(closingFiscalYear + 1);
    entry.setChartOfAccountsCode(postable.getChartOfAccountsCode());
    entry.setAccountNumber(postable.getAccountNumber());
    entry.setSubAccountNumber(StringUtils.isBlank(postable.getSubAccountNumber()) ? KFSConstants.getDashSubAccountNumber() : postable.getSubAccountNumber());
    entry.setFinancialObjectCode(postable.getFinancialObjectCode());
    entry.setFinancialSubObjectCode(StringUtils.isBlank(postable.getFinancialSubObjectCode()) ? KFSConstants.getDashFinancialSubObjectCode() : postable.getFinancialSubObjectCode());
    entry.setFinancialBalanceTypeCode(postable.getBalanceTypeCode());
    if (currentYearOptions.getFinObjTypeExpendNotExpCode().equals(postable.getObjectCode().getFinancialObjectTypeCode())) {
        entry.setFinancialObjectTypeCode(currentYearOptions.getFinancialObjectTypeAssetsCd());
    } else {
        entry.setFinancialObjectTypeCode(postable.getObjectCode().getFinancialObjectTypeCode());
    }
    entry.setUniversityFiscalPeriodCode(KFSConstants.PERIOD_CODE_BEGINNING_BALANCE);
    entry.setFinancialDocumentTypeCode(currentDocumentTypeName);
    entry.setFinancialSystemOriginationCode(homeOriginationService.getHomeOrigination().getFinSystemHomeOriginationCode());
    entry.setDocumentNumber(new StringBuffer(KFSConstants.BALANCE_TYPE_ACTUAL).append(postable.getAccountNumber()).toString());
    entry.setTransactionLedgerEntrySequenceNumber(sequenceNumber);
    entry.setTransactionLedgerEntryDescription(new StringBuffer("BEG BAL BROUGHT FORWARD FROM ").append(closingFiscalYear).toString());
    String transactionEncumbranceUpdateCode = null;
    transactionEncumbranceUpdateCode = KFSConstants.ENCUMB_UPDT_NO_ENCUMBRANCE_CD;
    entry.setTransactionEncumbranceUpdateCode(transactionEncumbranceUpdateCode);
    KualiDecimal transactionLedgerEntryAmount = KualiDecimal.ZERO;
    transactionLedgerEntryAmount = transactionLedgerEntryAmount.add(postable.getAmount());
    entry.setTransactionDebitCreditCode(postable.getDebitCreditCode());
    Timestamp transactionTimestamp = new Timestamp(dateTimeService.getCurrentDate().getTime());
    entry.setTransactionDate(new java.sql.Date(transactionTimestamp.getTime()));
    entry.setTransactionEntryProcessedTs(transactionTimestamp);
    entry.setOrganizationDocumentNumber(null);
    entry.setProjectCode(StringUtils.isBlank(postable.getProjectCode()) ? KFSConstants.getDashProjectCode() : postable.getProjectCode());
    entry.setOrganizationReferenceId(postable.getOrganizationReferenceId());
    entry.setReferenceFinancialDocumentTypeCode(null);
    entry.setReferenceFinancialSystemOriginationCode(null);
    entry.setReferenceFinancialDocumentNumber(null);
    entry.setFinancialDocumentReversalDate(null);
    if (KFSConstants.BALANCE_TYPE_AUDIT_TRAIL.equals(entry.getFinancialBalanceTypeCode())) {
        entry.setFinancialBalanceTypeCode(KFSConstants.BALANCE_TYPE_ACTUAL);
    }
    if (transactionLedgerEntryAmount.isNegative()) {
        if (KFSConstants.BALANCE_TYPE_ACTUAL.equals(entry.getFinancialBalanceTypeCode())) {
            transactionLedgerEntryAmount = transactionLedgerEntryAmount.negated();
        }
    }
    entry.setTransactionLedgerEntryAmount(transactionLedgerEntryAmount);
    return entry;
}
Also used : GeneralLedgerPendingEntry(org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntry) KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal) SystemOptions(org.kuali.kfs.sys.businessobject.SystemOptions) Timestamp(java.sql.Timestamp)

Example 42 with KualiDecimal

use of org.kuali.rice.core.api.util.type.KualiDecimal in project cu-kfs by CU-CommunityApps.

the class PreEncumbranceDocument method processExplicitGeneralLedgerPendingEntry.

/**
 * This method processes all necessary information to build an explicit general ledger entry, and then adds that to the
 * document.
 *
 * @param accountingDocument
 * @param sequenceHelper
 * @param accountingLine
 * @param explicitEntry
 * @return boolean True if the explicit entry generation was successful, false otherwise.
 */
@Override
protected void processExplicitGeneralLedgerPendingEntry(GeneralLedgerPendingEntrySequenceHelper sequenceHelper, GeneralLedgerPendingEntrySourceDetail glpeSourceDetail, GeneralLedgerPendingEntry explicitEntry) {
    if (glpeSourceDetail instanceof PreEncumbranceSourceAccountingLine) {
        int rowId = ((AccountingLine) glpeSourceDetail).getSequenceNumber() - 1;
        PreEncumbranceSourceAccountingLine pesal = (PreEncumbranceSourceAccountingLine) glpeSourceDetail;
        if (ObjectUtils.isNotNull(pesal.getAutoDisEncumberType())) {
            if (ObjectUtils.isNull(pesal.getStartDate()) || ObjectUtils.isNull(pesal.getPartialTransactionCount()) || ObjectUtils.isNull(pesal.getPartialAmount())) {
                throw new ValidationException("Insufficient information for GLPE generation");
            }
            Date generatedEndDate = PreEncumbranceAccountingLineUtil.generateEndDate(pesal.getStartDate(), Integer.parseInt(pesal.getPartialTransactionCount()), pesal.getAutoDisEncumberType());
            pesal.setEndDate(generatedEndDate);
            TreeMap<Date, KualiDecimal> datesAndAmounts = PreEncumbranceAccountingLineUtil.generateDatesAndAmounts(pesal.getAutoDisEncumberType(), pesal.getStartDate(), pesal.getEndDate(), Integer.parseInt(pesal.getPartialTransactionCount()), pesal.getAmount(), pesal.getPartialAmount(), rowId);
            Iterator<Date> it = datesAndAmounts.keySet().iterator();
            boolean isErrorCorrection = false;
            Date today = new Date(Calendar.getInstance().getTimeInMillis());
            if (pesal.getAmount().isNegative()) {
                // we are doing error correction
                LOG.info("Error correction!");
                isErrorCorrection = true;
            }
            while (it.hasNext()) {
                Date revDate = it.next();
                if (isErrorCorrection && revDate.before(today)) {
                    break;
                }
                KualiDecimal partialAmount = datesAndAmounts.get(revDate);
                GeneralLedgerPendingEntry explicitPartialEntry = new GeneralLedgerPendingEntry();
                SpringContext.getBean(GeneralLedgerPendingEntryService.class).populateExplicitGeneralLedgerPendingEntry(this, glpeSourceDetail, sequenceHelper, explicitPartialEntry);
                explicitPartialEntry.setFinancialDocumentReversalDate(revDate);
                explicitPartialEntry.setTransactionLedgerEntryAmount(isErrorCorrection ? partialAmount.negated() : partialAmount);
                customizeExplicitGeneralLedgerPendingEntry(glpeSourceDetail, explicitPartialEntry);
                addPendingEntry(explicitPartialEntry);
                sequenceHelper.increment();
                GeneralLedgerPendingEntry offsetEntry = new GeneralLedgerPendingEntry(explicitPartialEntry);
                processOffsetGeneralLedgerPendingEntry(sequenceHelper, glpeSourceDetail, explicitPartialEntry, offsetEntry);
                sequenceHelper.increment();
            }
            // no need to do the following stuff, as we're generating a bunch of custom GL pending entries above
            return;
        }
    }
    // populate the explicit entry
    SpringContext.getBean(GeneralLedgerPendingEntryService.class).populateExplicitGeneralLedgerPendingEntry(this, glpeSourceDetail, sequenceHelper, explicitEntry);
    // hook for children documents to implement document specific GLPE field mappings
    customizeExplicitGeneralLedgerPendingEntry(glpeSourceDetail, explicitEntry);
    addPendingEntry(explicitEntry);
    sequenceHelper.increment();
    // handle the offset entry
    GeneralLedgerPendingEntry offsetEntry = new GeneralLedgerPendingEntry(explicitEntry);
    boolean success = processOffsetGeneralLedgerPendingEntry(sequenceHelper, glpeSourceDetail, explicitEntry, offsetEntry);
}
Also used : ValidationException(org.kuali.kfs.krad.exception.ValidationException) GeneralLedgerPendingEntry(org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntry) PreEncumbranceSourceAccountingLine(edu.cornell.kfs.fp.businessobject.PreEncumbranceSourceAccountingLine) GeneralLedgerPendingEntryService(org.kuali.kfs.sys.service.GeneralLedgerPendingEntryService) KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal) Date(java.sql.Date)

Example 43 with KualiDecimal

use of org.kuali.rice.core.api.util.type.KualiDecimal in project cu-kfs by CU-CommunityApps.

the class CuDisbursementVoucherDocument method populateDocumentForRouting.

@Override
public void populateDocumentForRouting() {
    CuDisbursementVoucherPayeeDetail payeeDetail = getDvPayeeDetail();
    if (payeeDetail.isVendor()) {
        payeeDetail.setDisbVchrPayeeEmployeeCode(getVendorService().isVendorInstitutionEmployee(payeeDetail.getDisbVchrVendorHeaderIdNumberAsInteger()));
        payeeDetail.setDvPayeeSubjectPaymentCode(getVendorService().isSubjectPaymentVendor(payeeDetail.getDisbVchrVendorHeaderIdNumberAsInteger()));
    } else if (payeeDetail.isEmployee() || payeeDetail.isStudent() || payeeDetail.isAlumni()) {
        // Determine if employee student or alumni is a research subject
        ParameterEvaluator researchPaymentReasonCodeEvaluator = /*REFACTORME*/
        SpringContext.getBean(ParameterEvaluatorService.class).getParameterEvaluator(DisbursementVoucherDocument.class, DisbursementVoucherConstants.RESEARCH_PAYMENT_REASONS_PARM_NM, payeeDetail.getDisbVchrPaymentReasonCode());
        if (researchPaymentReasonCodeEvaluator.evaluationSucceeds()) {
            if (getParameterService().parameterExists(DisbursementVoucherDocument.class, DisbursementVoucherConstants.RESEARCH_NON_VENDOR_PAY_LIMIT_AMOUNT_PARM_NM)) {
                String researchPayLimit = getParameterService().getParameterValueAsString(DisbursementVoucherDocument.class, DisbursementVoucherConstants.RESEARCH_NON_VENDOR_PAY_LIMIT_AMOUNT_PARM_NM);
                if (StringUtils.isNotBlank(researchPayLimit)) {
                    KualiDecimal payLimit = new KualiDecimal(researchPayLimit);
                    if (getDisbVchrCheckTotalAmount().isLessThan(payLimit)) {
                        payeeDetail.setDvPayeeSubjectPaymentCode(true);
                    }
                }
            }
        }
    }
    // Call last, serializes to XML
    super.populateDocumentForRouting();
}
Also used : CuDisbursementVoucherPayeeDetail(edu.cornell.kfs.fp.businessobject.CuDisbursementVoucherPayeeDetail) KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal) ParameterEvaluator(org.kuali.rice.core.api.parameter.ParameterEvaluator) DisbursementVoucherDocument(org.kuali.kfs.fp.document.DisbursementVoucherDocument)

Example 44 with KualiDecimal

use of org.kuali.rice.core.api.util.type.KualiDecimal in project cu-kfs by CU-CommunityApps.

the class CuDisbursementVoucherDocument method templateStudent.

/**
 * Convenience method to set dv payee detail fields based on a given student.
 *
 * @param student
 */
public void templateStudent(Person student) {
    if (student == null) {
        return;
    }
    this.getDvPayeeDetail().setDisbursementVoucherPayeeTypeCode(CuDisbursementVoucherConstants.DV_PAYEE_TYPE_STUDENT);
    this.getDvPayeeDetail().setDisbVchrPayeeIdNumber(student.getPrincipalId());
    ((CuDisbursementVoucherPayeeDetailExtension) this.getDvPayeeDetail().getExtension()).setDisbVchrPayeeIdType(CuDisbursementVoucherConstants.DV_PAYEE_ID_TYP_ENTITY);
    ((CuDisbursementVoucherPayeeDetailExtension) this.getDvPayeeDetail().getExtension()).setPayeeTypeSuffix(StringUtils.EMPTY);
    this.getDvPayeeDetail().setDisbVchrPayeePersonName(student.getNameUnmasked());
    final ParameterService parameterService = this.getParameterService();
    // Use the same parameter as for employees even though this is a student as basic intention is the same
    if (parameterService.parameterExists(DisbursementVoucherDocument.class, DisbursementVoucherDocument.USE_DEFAULT_EMPLOYEE_ADDRESS_PARAMETER_NAME) && parameterService.getParameterValueAsBoolean(DisbursementVoucherDocument.class, DisbursementVoucherDocument.USE_DEFAULT_EMPLOYEE_ADDRESS_PARAMETER_NAME)) {
        this.getDvPayeeDetail().setDisbVchrPayeeLine1Addr(student.getAddressLine1Unmasked());
        this.getDvPayeeDetail().setDisbVchrPayeeLine2Addr(student.getAddressLine2Unmasked());
        this.getDvPayeeDetail().setDisbVchrPayeeCityName(student.getAddressCityUnmasked());
        this.getDvPayeeDetail().setDisbVchrPayeeStateCode(student.getAddressStateProvinceCodeUnmasked());
        this.getDvPayeeDetail().setDisbVchrPayeeZipCode(student.getAddressPostalCodeUnmasked());
        this.getDvPayeeDetail().setDisbVchrPayeeCountryCode(student.getAddressCountryCodeUnmasked());
    } else {
        final EntityAddress address = getNonDefaultAddress(student);
        if (address != null) {
            this.getDvPayeeDetail().setDisbVchrPayeeLine1Addr(address.getLine1Unmasked());
            this.getDvPayeeDetail().setDisbVchrPayeeLine2Addr(address.getLine2Unmasked());
            this.getDvPayeeDetail().setDisbVchrPayeeCityName(address.getCityUnmasked());
            this.getDvPayeeDetail().setDisbVchrPayeeStateCode(address.getStateProvinceCodeUnmasked());
            this.getDvPayeeDetail().setDisbVchrPayeeZipCode(student.getAddressPostalCodeUnmasked());
            this.getDvPayeeDetail().setDisbVchrPayeeCountryCode(address.getCountryCodeUnmasked());
        } else {
            this.getDvPayeeDetail().setDisbVchrPayeeLine1Addr("");
            this.getDvPayeeDetail().setDisbVchrPayeeLine2Addr("");
            this.getDvPayeeDetail().setDisbVchrPayeeCityName("");
            this.getDvPayeeDetail().setDisbVchrPayeeStateCode("");
            this.getDvPayeeDetail().setDisbVchrPayeeZipCode("");
            this.getDvPayeeDetail().setDisbVchrPayeeCountryCode("");
        }
    }
    // I'm assuming that if a tax id type code other than 'TAX' is present, then the student must be foreign
    for (String externalIdentifierTypeCode : student.getExternalIdentifiers().keySet()) {
        if (KimConstants.PersonExternalIdentifierTypes.TAX.equals(externalIdentifierTypeCode)) {
            this.getDvPayeeDetail().setDisbVchrAlienPaymentCode(false);
        }
    }
    // Determine if student is a research subject
    ParameterEvaluator researchPaymentReasonCodeEvaluator = SpringContext.getBean(ParameterEvaluatorService.class).getParameterEvaluator(DisbursementVoucherDocument.class, DisbursementVoucherConstants.RESEARCH_PAYMENT_REASONS_PARM_NM);
    if (researchPaymentReasonCodeEvaluator.evaluationSucceeds()) {
        if (getParameterService().parameterExists(DisbursementVoucherDocument.class, DisbursementVoucherConstants.RESEARCH_NON_VENDOR_PAY_LIMIT_AMOUNT_PARM_NM)) {
            String researchPayLimit = getParameterService().getParameterValueAsString(DisbursementVoucherDocument.class, DisbursementVoucherConstants.RESEARCH_NON_VENDOR_PAY_LIMIT_AMOUNT_PARM_NM);
            if (StringUtils.isNotBlank(researchPayLimit)) {
                KualiDecimal payLimit = new KualiDecimal(researchPayLimit);
                if (getDisbVchrCheckTotalAmount().isLessThan(payLimit)) {
                    this.getDvPayeeDetail().setDvPayeeSubjectPaymentCode(true);
                }
            }
        }
    }
    this.disbVchrPayeeTaxControlCode = "";
    this.disbVchrPayeeW9CompleteCode = true;
}
Also used : ParameterService(org.kuali.kfs.coreservice.framework.parameter.ParameterService) CuDisbursementVoucherPayeeDetailExtension(edu.cornell.kfs.fp.businessobject.CuDisbursementVoucherPayeeDetailExtension) EntityAddress(org.kuali.rice.kim.api.identity.address.EntityAddress) KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal) ParameterEvaluator(org.kuali.rice.core.api.parameter.ParameterEvaluator) ParameterEvaluatorService(org.kuali.rice.core.api.parameter.ParameterEvaluatorService) DisbursementVoucherDocument(org.kuali.kfs.fp.document.DisbursementVoucherDocument)

Example 45 with KualiDecimal

use of org.kuali.rice.core.api.util.type.KualiDecimal in project cu-kfs by CU-CommunityApps.

the class CuDisbursementVoucherDocument method isCAndGReviewRequired.

protected boolean isCAndGReviewRequired() {
    String awardThreshold = getParameterService().getParameterValueAsString("KFS-FP", "DisbursementVoucher", DOLLAR_THRESHOLD_REQUIRING_AWARD_REVIEW);
    KualiDecimal dollarThresholdDecimal = new KualiDecimal(awardThreshold);
    if (this.disbVchrCheckTotalAmount.isGreaterEqual(dollarThresholdDecimal)) {
        return true;
    }
    List<AccountingLine> theList = (List<AccountingLine>) this.sourceAccountingLines;
    for (AccountingLine alb : theList) {
        ParameterEvaluator objectCodes = SpringContext.getBean(ParameterEvaluatorService.class).getParameterEvaluator("KFS-FP", "DisbursementVoucher", OBJECT_CODES_REQUIRING_AWARD_REVIEW, alb.getFinancialObjectCode());
        if (objectCodes.evaluationSucceeds()) {
            LOG.info("Object Code " + alb.getFinancialObjectCode() + " requires this document to undergo Award review.");
            return true;
        }
    }
    return false;
}
Also used : AccountingLine(org.kuali.kfs.sys.businessobject.AccountingLine) KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal) List(java.util.List) ArrayList(java.util.ArrayList) ParameterEvaluator(org.kuali.rice.core.api.parameter.ParameterEvaluator) ParameterEvaluatorService(org.kuali.rice.core.api.parameter.ParameterEvaluatorService)

Aggregations

KualiDecimal (org.kuali.rice.core.api.util.type.KualiDecimal)209 ArrayList (java.util.ArrayList)37 HashMap (java.util.HashMap)19 Test (org.junit.Test)19 List (java.util.List)15 SourceAccountingLine (org.kuali.kfs.sys.businessobject.SourceAccountingLine)15 CapitalAssetInformation (org.kuali.kfs.fp.businessobject.CapitalAssetInformation)14 BigDecimal (java.math.BigDecimal)13 Date (java.sql.Date)13 Iterator (java.util.Iterator)12 PurchaseOrderDocument (org.kuali.kfs.module.purap.document.PurchaseOrderDocument)12 KualiInteger (org.kuali.rice.core.api.util.type.KualiInteger)12 PaymentRequestItem (org.kuali.kfs.module.purap.businessobject.PaymentRequestItem)11 IOException (java.io.IOException)10 ParameterService (org.kuali.kfs.coreservice.framework.parameter.ParameterService)10 Map (java.util.Map)9 CapitalAccountingLines (org.kuali.kfs.fp.businessobject.CapitalAccountingLines)9 PurchaseOrderItem (org.kuali.kfs.module.purap.businessobject.PurchaseOrderItem)9 PaymentGroup (org.kuali.kfs.pdp.businessobject.PaymentGroup)9 RequisitionDocument (org.kuali.kfs.module.purap.document.RequisitionDocument)8