Search in sources :

Example 16 with ParameterService

use of org.kuali.kfs.coreservice.framework.parameter.ParameterService in project cu-kfs by CU-CommunityApps.

the class CuLaborPendingEntryConverterServiceImpl method getOffsetPendingEntries.

/**
 * convert the given document and accounting line into the benefit pending entries
 *
 * @param document the given accounting document
 * @param accountingLine the given accounting line
 * @param sequenceHelper the given sequence helper
 * @param benefitAmount the given benefit amount
 * @param fringeBenefitObjectCode the given fringe benefit object code
 * @return a set of benefit pending entries
 */
public List<LaborLedgerPendingEntry> getOffsetPendingEntries(LaborLedgerPendingEntry pendingEntry, GeneralLedgerPendingEntrySequenceHelper sequenceHelper) {
    List<LaborLedgerPendingEntry> offsetEntries = new ArrayList<LaborLedgerPendingEntry>();
    String benefitRateCategoryCode = SpringContext.getBean(LaborBenefitsCalculationService.class).getBenefitRateCategoryCode(pendingEntry.getChartOfAccountsCode(), pendingEntry.getAccountNumber(), pendingEntry.getSubAccountNumber());
    Collection<PositionObjectBenefit> positionObjectBenefits = SpringContext.getBean(LaborPositionObjectBenefitService.class).getActivePositionObjectBenefits(pendingEntry.getUniversityFiscalYear(), pendingEntry.getChartOfAccountsCode(), pendingEntry.getFinancialObjectCode());
    if (positionObjectBenefits == null || positionObjectBenefits.isEmpty()) {
        return offsetEntries;
    }
    for (PositionObjectBenefit positionObjectBenefit : positionObjectBenefits) {
        Map<String, Object> fieldValues = new HashMap<String, Object>();
        fieldValues.put(KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR, pendingEntry.getUniversityFiscalYear());
        fieldValues.put(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE, pendingEntry.getChartOfAccountsCode());
        fieldValues.put(LaborPropertyConstants.POSITION_BENEFIT_TYPE_CODE, positionObjectBenefit.getFinancialObjectBenefitsTypeCode());
        fieldValues.put(LaborPropertyConstants.LABOR_BENEFIT_RATE_CATEGORY_CODE, benefitRateCategoryCode);
        BenefitsCalculation benefitsCalculation = SpringContext.getBean(BusinessObjectService.class).findByPrimaryKey(BenefitsCalculation.class, fieldValues);
        if (ObjectUtils.isNull(benefitsCalculation)) {
            continue;
        }
        LaborLedgerPendingEntry offsetEntry = new LaborLedgerPendingEntry();
        // Copy values from pending entry
        offsetEntry.setReferenceFinancialDocumentNumber(pendingEntry.getReferenceFinancialDocumentNumber());
        offsetEntry.setReferenceFinancialDocumentTypeCode(pendingEntry.getReferenceFinancialDocumentTypeCode());
        offsetEntry.setFinancialDocumentReversalDate(pendingEntry.getFinancialDocumentReversalDate());
        offsetEntry.setFinancialBalanceTypeCode(pendingEntry.getFinancialBalanceTypeCode());
        offsetEntry.setFinancialObjectTypeCode(pendingEntry.getFinancialObjectTypeCode());
        offsetEntry.setReferenceFinancialSystemOriginationCode(pendingEntry.getReferenceFinancialSystemOriginationCode());
        offsetEntry.setOrganizationDocumentNumber(pendingEntry.getOrganizationDocumentNumber());
        offsetEntry.setTransactionDate(pendingEntry.getTransactionDate());
        offsetEntry.setTransactionDebitCreditCode(pendingEntry.getTransactionDebitCreditCode());
        offsetEntry.setTransactionEncumbranceUpdateCode(pendingEntry.getTransactionEncumbranceUpdateCode());
        offsetEntry.setPositionNumber(pendingEntry.getPositionNumber());
        offsetEntry.setTransactionPostingDate(pendingEntry.getTransactionPostingDate());
        offsetEntry.setPayPeriodEndDate(pendingEntry.getPayPeriodEndDate());
        offsetEntry.setTransactionTotalHours(pendingEntry.getTransactionTotalHours());
        offsetEntry.setPayrollEndDateFiscalYear(pendingEntry.getPayrollEndDateFiscalYear());
        offsetEntry.setPayrollEndDateFiscalPeriodCode(pendingEntry.getPayrollEndDateFiscalPeriodCode());
        offsetEntry.setEmplid(pendingEntry.getEmplid());
        offsetEntry.setEmployeeRecord(pendingEntry.getEmployeeRecord());
        offsetEntry.setEarnCode(pendingEntry.getEarnCode());
        offsetEntry.setPayGroup(pendingEntry.getPayGroup());
        offsetEntry.setSalaryAdministrationPlan(pendingEntry.getSalaryAdministrationPlan());
        offsetEntry.setGrade(pendingEntry.getGrade());
        offsetEntry.setRunIdentifier(pendingEntry.getRunIdentifier());
        offsetEntry.setLaborLedgerOriginalChartOfAccountsCode(pendingEntry.getLaborLedgerOriginalChartOfAccountsCode());
        offsetEntry.setLaborLedgerOriginalAccountNumber(pendingEntry.getLaborLedgerOriginalAccountNumber());
        offsetEntry.setLaborLedgerOriginalSubAccountNumber(pendingEntry.getLaborLedgerOriginalSubAccountNumber());
        offsetEntry.setLaborLedgerOriginalFinancialObjectCode(pendingEntry.getLaborLedgerOriginalFinancialObjectCode());
        offsetEntry.setLaborLedgerOriginalFinancialSubObjectCode(pendingEntry.getLaborLedgerOriginalFinancialSubObjectCode());
        offsetEntry.setHrmsCompany(pendingEntry.getHrmsCompany());
        offsetEntry.setSetid(pendingEntry.getSetid());
        offsetEntry.setTransactionEntryOffsetCode(pendingEntry.getTransactionEntryOffsetCode());
        offsetEntry.setPayrollEndDateFiscalPeriod(pendingEntry.getPayrollEndDateFiscalPeriod());
        // New offset values
        offsetEntry.setFinancialObjectCode(benefitsCalculation.getPositionFringeBenefitObjectCode());
        offsetEntry.setTransactionLedgerEntrySequenceNumber(getNextSequenceNumber(sequenceHelper));
        // calculate the offsetAmount amount (ledger amt * (benfit pct/100) )
        KualiDecimal fringeBenefitPercent = benefitsCalculation.getPositionFringeBenefitPercent();
        KualiDecimal offsetAmount = fringeBenefitPercent.multiply(pendingEntry.getTransactionLedgerEntryAmount()).divide(KFSConstants.ONE_HUNDRED.kualiDecimalValue());
        offsetEntry.setTransactionLedgerEntryAmount(offsetAmount.abs());
        offsetEntry.setAccountNumber(benefitsCalculation.getAccountCodeOffset());
        offsetEntry.setFinancialObjectCode(benefitsCalculation.getObjectCodeOffset());
        // Set all the fields required to process through the scrubber and poster jobs
        offsetEntry.setUniversityFiscalPeriodCode(pendingEntry.getUniversityFiscalPeriodCode());
        offsetEntry.setChartOfAccountsCode(pendingEntry.getChartOfAccountsCode());
        offsetEntry.setUniversityFiscalYear(pendingEntry.getUniversityFiscalYear());
        offsetEntry.setSubAccountNumber("-----");
        offsetEntry.setFinancialSubObjectCode("---");
        offsetEntry.setOrganizationReferenceId("");
        offsetEntry.setProjectCode("");
        offsetEntry.setTransactionLedgerEntryDescription("GENERATED BENEFIT OFFSET");
        ParameterService parameterService = SpringContext.getBean(ParameterService.class);
        String originCode = parameterService.getParameterValueAsString(LaborEnterpriseFeedStep.class, LdConstants.LABOR_BENEFIT_OFFSET_ORIGIN_CODE);
        offsetEntry.setFinancialSystemOriginationCode(originCode);
        DateTimeService dateTimeService = SpringContext.getBean(DateTimeService.class);
        offsetEntry.setDocumentNumber(dateTimeService.toString(dateTimeService.getCurrentDate(), "yyyyMMddhhmmssSSS"));
        if (pendingEntry.getTransactionDebitCreditCode().equalsIgnoreCase("D")) {
            offsetAmount = offsetAmount;
        } else {
            offsetAmount = offsetAmount.multiply(new KualiDecimal(-1));
        }
        if (offsetAmount.isGreaterThan(new KualiDecimal(0))) {
            offsetEntry.setTransactionDebitCreditCode("C");
        } else if (offsetAmount.isLessThan(new KualiDecimal(0))) {
            offsetEntry.setTransactionDebitCreditCode("D");
        }
        String offsetDocTypes = null;
        if (StringUtils.isNotEmpty(parameterService.getParameterValueAsString(LaborEnterpriseFeedStep.class, LdConstants.LABOR_BENEFIT_OFFSET_DOCTYPE))) {
            offsetDocTypes = "," + parameterService.getParameterValueAsString(LaborEnterpriseFeedStep.class, LdConstants.LABOR_BENEFIT_OFFSET_DOCTYPE).replace(";", ",").replace("|", ",") + ",";
        }
        String docTypeCode = offsetDocTypes;
        if (offsetDocTypes.contains(",")) {
            String[] splits = offsetDocTypes.split(",");
            for (String split : splits) {
                if (!StringUtils.isEmpty(split)) {
                    docTypeCode = split;
                    break;
                }
            }
        }
        offsetEntry.setFinancialDocumentTypeCode(docTypeCode);
        offsetEntries.add(offsetEntry);
    }
    return offsetEntries;
}
Also used : BenefitsCalculation(org.kuali.kfs.module.ld.businessobject.BenefitsCalculation) LaborBenefitsCalculationService(org.kuali.kfs.module.ld.service.LaborBenefitsCalculationService) HashMap(java.util.HashMap) ParameterService(org.kuali.kfs.coreservice.framework.parameter.ParameterService) LaborEnterpriseFeedStep(org.kuali.kfs.module.ld.batch.LaborEnterpriseFeedStep) ArrayList(java.util.ArrayList) PositionObjectBenefit(org.kuali.kfs.module.ld.businessobject.PositionObjectBenefit) BusinessObjectService(org.kuali.kfs.krad.service.BusinessObjectService) LaborLedgerPendingEntry(org.kuali.kfs.module.ld.businessobject.LaborLedgerPendingEntry) LaborPositionObjectBenefitService(org.kuali.kfs.module.ld.service.LaborPositionObjectBenefitService) KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal) DateTimeService(org.kuali.rice.core.api.datetime.DateTimeService)

Example 17 with ParameterService

use of org.kuali.kfs.coreservice.framework.parameter.ParameterService in project cu-kfs by CU-CommunityApps.

the class PreEncumbranceAutoDisEncumberValidation method validate.

public boolean validate(AttributedDocumentEvent event) {
    boolean success = true;
    ParameterService ps = SpringContext.getBean(ParameterService.class);
    try {
        DateFormat transactionDateFormat = new SimpleDateFormat(TRANSACTION_DATE_FORMAT_STRING);
        annualClosingDate = new Date(transactionDateFormat.parse(ps.getParameterValueAsString(KfsParameterConstants.GENERAL_LEDGER_BATCH.class, GeneralLedgerConstants.ANNUAL_CLOSING_TRANSACTION_DATE_PARM)).getTime());
        // this needs to be changed
        annualClosingDate.setYear(annualClosingDate.getYear() + 1);
        LOG.info("Annual closing Date of: " + annualClosingDate);
    } catch (ParseException e) {
        LOG.error("PreEncumbrance validation nnable to parse transaction date", e);
        throw new IllegalArgumentException("Unable to parse transaction date");
    }
    PreEncumbranceDocument ped = (PreEncumbranceDocument) getAccountingDocumentForValidation();
    Iterator<PreEncumbranceSourceAccountingLine> it = ped.getSourceAccountingLines().iterator();
    while (it.hasNext()) {
        PreEncumbranceSourceAccountingLine pesal = it.next();
        auto = true;
        if (checkMinimumRequirements(pesal) && auto) {
            success &= checkDates(pesal);
            success &= checkGenerationValidity(pesal);
        } else {
            if (auto) {
                success &= false;
            }
        }
    }
    return success;
}
Also used : ParameterService(org.kuali.kfs.coreservice.framework.parameter.ParameterService) PreEncumbranceSourceAccountingLine(edu.cornell.kfs.fp.businessobject.PreEncumbranceSourceAccountingLine) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) KfsParameterConstants(org.kuali.kfs.sys.service.impl.KfsParameterConstants) ParseException(java.text.ParseException) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.sql.Date) PreEncumbranceDocument(edu.cornell.kfs.fp.document.PreEncumbranceDocument)

Example 18 with ParameterService

use of org.kuali.kfs.coreservice.framework.parameter.ParameterService in project cu-kfs by CU-CommunityApps.

the class PurchasingCommodityCodeValidation method validateCommodityCodes.

/**
 * Validates whether the commodity code existed on the item, and if existed, whether the
 * commodity code on the item existed in the database, and if so, whether the commodity
 * code is active. Display error if any of these 3 conditions are not met.
 *
 * @param item  The PurApItem containing the commodity code to be validated.
 * @return boolean false if the validation fails and true otherwise.
 */
protected boolean validateCommodityCodes(PurApItem item, boolean commodityCodeRequired) {
    boolean valid = true;
    String identifierString = item.getItemIdentifierString();
    PurchasingItemBase purItem = (PurchasingItemBase) item;
    // check to see if item is unordered and commodity code is required, if so, assign a default commodity code and return true
    if (commodityCodeRequired && purItem.getItemTypeCode().equals("UNOR")) {
        ParameterService parameterService = SpringContext.getBean(ParameterService.class);
        String unorderedItemDefaultCommodityCode = parameterService.getParameterValueAsString(PurapConstants.PURAP_NAMESPACE, "LineItemReceiving", UNORDERED_ITEM_DEFAULT_COMMODITY_CODE);
        purItem.setPurchasingCommodityCode(unorderedItemDefaultCommodityCode);
        valid = true;
    }
    // This validation is only needed if the commodityCodeRequired system parameter is true
    if (commodityCodeRequired && StringUtils.isBlank(purItem.getPurchasingCommodityCode())) {
        // This is the case where the commodity code is required but the item does not currently contain the commodity code.
        valid = false;
        String attributeLabel = dataDictionaryService.getDataDictionary().getBusinessObjectEntry(CommodityCode.class.getName()).getAttributeDefinition(PurapPropertyConstants.ITEM_COMMODITY_CODE).getLabel();
        GlobalVariables.getMessageMap().putError(PurapPropertyConstants.ITEM_COMMODITY_CODE, KFSKeyConstants.ERROR_REQUIRED, attributeLabel + " in " + identifierString);
    } else if (StringUtils.isNotBlank(purItem.getPurchasingCommodityCode())) {
        // Find out whether the commodity code has existed in the database
        Map<String, String> fieldValues = new HashMap<String, String>();
        fieldValues.put(PurapPropertyConstants.ITEM_COMMODITY_CODE, purItem.getPurchasingCommodityCode());
        if (businessObjectService.countMatching(CommodityCode.class, fieldValues) != 1) {
            // This is the case where the commodity code on the item does not exist in the database.
            valid = false;
            GlobalVariables.getMessageMap().putError(PurapPropertyConstants.ITEM_COMMODITY_CODE, PurapKeyConstants.PUR_COMMODITY_CODE_INVALID, " in " + identifierString);
        } else {
            valid &= validateThatCommodityCodeIsActive(item);
        }
    }
    return valid;
}
Also used : ParameterService(org.kuali.kfs.coreservice.framework.parameter.ParameterService) PurchasingItemBase(org.kuali.kfs.module.purap.businessobject.PurchasingItemBase) CommodityCode(org.kuali.kfs.vnd.businessobject.CommodityCode) HashMap(java.util.HashMap) Map(java.util.Map)

Example 19 with ParameterService

use of org.kuali.kfs.coreservice.framework.parameter.ParameterService in project cu-kfs by CU-CommunityApps.

the class KualiAccountingDocumentActionBase method isSalesTaxRequired.

/**
 * This method checks to see if this doctype needs sales tax If it does then it checks to see if the account and object code
 * require sales tax If it does then it returns true. Note - this is hackish as we shouldn't have to call rules directly from
 * the action class But we need to in this instance because we are copying the lines before calling rules and need a way to
 * modify them before they go on
 *
 * @param accountingLine
 * @return true if sales tax check is needed, false otherwise
 */
protected boolean isSalesTaxRequired(AccountingDocument financialDocument, AccountingLine accountingLine) {
    boolean required = false;
    String docType = SpringContext.getBean(DataDictionaryService.class).getDocumentTypeNameByClass(financialDocument.getClass());
    // first we need to check just the doctype to see if it needs the sales tax check
    ParameterService parameterService = SpringContext.getBean(ParameterService.class);
    // apply the rule, see if it fails
    ParameterEvaluator docTypeSalesTaxCheckEvaluator = /*REFACTORME*/
    SpringContext.getBean(ParameterEvaluatorService.class).getParameterEvaluator(KfsParameterConstants.FINANCIAL_PROCESSING_DOCUMENT.class, APPLICATION_PARAMETER.DOCTYPE_SALES_TAX_CHECK, docType);
    if (docTypeSalesTaxCheckEvaluator.evaluationSucceeds()) {
        required = true;
    }
    // second we need to check the account and object code combination to see if it needs sales tax
    if (required) {
        // get the object code and account
        String objCd = accountingLine.getFinancialObjectCode();
        String account = accountingLine.getAccountNumber();
        if (!StringUtils.isEmpty(objCd) && !StringUtils.isEmpty(account)) {
            String compare = account + ":" + objCd;
            ParameterEvaluator salesTaxApplicableAcctAndObjectEvaluator = /*REFACTORME*/
            SpringContext.getBean(ParameterEvaluatorService.class).getParameterEvaluator(KfsParameterConstants.FINANCIAL_PROCESSING_DOCUMENT.class, APPLICATION_PARAMETER.SALES_TAX_APPLICABLE_ACCOUNTS_AND_OBJECT_CODES, compare);
            if (!salesTaxApplicableAcctAndObjectEvaluator.evaluationSucceeds()) {
                required = false;
            }
        } else {
            // the two fields are currently empty and we don't need to check yet
            required = false;
        }
    }
    return required;
}
Also used : ParameterService(org.kuali.kfs.coreservice.framework.parameter.ParameterService) KfsParameterConstants(org.kuali.kfs.sys.service.impl.KfsParameterConstants) ParameterEvaluator(org.kuali.rice.core.api.parameter.ParameterEvaluator) ParameterEvaluatorService(org.kuali.rice.core.api.parameter.ParameterEvaluatorService) DataDictionaryService(org.kuali.kfs.kns.service.DataDictionaryService)

Example 20 with ParameterService

use of org.kuali.kfs.coreservice.framework.parameter.ParameterService in project cu-kfs by CU-CommunityApps.

the class CuPendingTransactionServiceImpl method populatePaymentGeneralLedgerPendingEntry.

/**
 * Populates and stores a new GLPE for each account detail in the payment group.
 *
 * @param paymentGroup payment group to generate entries for
 * @param achFdocTypeCode doc type for ach disbursements
 * @param checkFdocTypeCod doc type for check disbursements
 * @param reversal boolean indicating if this is a reversal
 */
protected void populatePaymentGeneralLedgerPendingEntry(PaymentGroup paymentGroup, String achFdocTypeCode, String checkFdocTypeCod, boolean reversal) {
    List<PaymentAccountDetail> accountListings = new ArrayList<PaymentAccountDetail>();
    GeneralLedgerPendingEntrySequenceHelper sequenceHelper = new GeneralLedgerPendingEntrySequenceHelper();
    for (PaymentDetail paymentDetail : paymentGroup.getPaymentDetails()) {
        accountListings.addAll(paymentDetail.getAccountDetail());
    }
    // GeneralLedgerPendingEntrySequenceHelper sequenceHelper = new GeneralLedgerPendingEntrySequenceHelper();
    for (PaymentAccountDetail paymentAccountDetail : accountListings) {
        GlPendingTransaction glPendingTransaction = new GlPendingTransaction();
        glPendingTransaction.setSequenceNbr(new KualiInteger(sequenceHelper.getSequenceCounter()));
        if (StringUtils.isNotBlank(paymentAccountDetail.getPaymentDetail().getFinancialSystemOriginCode()) && StringUtils.isNotBlank(paymentAccountDetail.getPaymentDetail().getFinancialDocumentTypeCode())) {
            glPendingTransaction.setFdocRefTypCd(paymentAccountDetail.getPaymentDetail().getFinancialDocumentTypeCode());
            glPendingTransaction.setFsRefOriginCd(paymentAccountDetail.getPaymentDetail().getFinancialSystemOriginCode());
        } else {
            glPendingTransaction.setFdocRefTypCd(PdpConstants.PDP_FDOC_TYPE_CODE);
            glPendingTransaction.setFsRefOriginCd(PdpConstants.PDP_FDOC_ORIGIN_CODE);
        }
        glPendingTransaction.setFinancialBalanceTypeCode(org.kuali.kfs.sys.KFSConstants.BALANCE_TYPE_ACTUAL);
        Date transactionTimestamp = new Date(dateTimeService.getCurrentDate().getTime());
        glPendingTransaction.setTransactionDt(transactionTimestamp);
        AccountingPeriod fiscalPeriod = accountingPeriodService.getByDate(new java.sql.Date(transactionTimestamp.getTime()));
        glPendingTransaction.setUniversityFiscalYear(fiscalPeriod.getUniversityFiscalYear());
        glPendingTransaction.setUnivFiscalPrdCd(fiscalPeriod.getUniversityFiscalPeriodCode());
        glPendingTransaction.setAccountNumber(paymentAccountDetail.getAccountNbr());
        glPendingTransaction.setSubAccountNumber(paymentAccountDetail.getSubAccountNbr());
        glPendingTransaction.setChartOfAccountsCode(paymentAccountDetail.getFinChartCode());
        if (paymentGroup.getDisbursementType().getCode().equals(PdpConstants.DisbursementTypeCodes.ACH)) {
            glPendingTransaction.setFinancialDocumentTypeCode(achFdocTypeCode);
        } else if (paymentGroup.getDisbursementType().getCode().equals(PdpConstants.DisbursementTypeCodes.CHECK)) {
            glPendingTransaction.setFinancialDocumentTypeCode(checkFdocTypeCod);
        }
        glPendingTransaction.setFsOriginCd(PdpConstants.PDP_FDOC_ORIGIN_CODE);
        glPendingTransaction.setFdocNbr(paymentGroup.getDisbursementNbr().toString());
        // if stale
        if (StringUtils.equals(FDOC_TYP_CD_STALE_CHECK, checkFdocTypeCod)) {
            ParameterService parameterService = SpringContext.getBean(ParameterService.class);
            String clAcct = parameterService.getParameterValueAsString(CheckReconciliationImportStep.class, CRConstants.CLEARING_ACCOUNT);
            String obCode = parameterService.getParameterValueAsString(CheckReconciliationImportStep.class, CRConstants.CLEARING_OBJECT_CODE);
            String coaCode = parameterService.getParameterValueAsString(CheckReconciliationImportStep.class, CRConstants.CLEARING_COA);
            // Use clearing parameters if stale
            glPendingTransaction.setAccountNumber(clAcct);
            glPendingTransaction.setFinancialObjectCode(obCode);
            glPendingTransaction.setChartOfAccountsCode(coaCode);
            glPendingTransaction.setFinancialSubObjectCode(KFSConstants.getDashFinancialSubObjectCode());
            // KFSUPGRADE-943
            glPendingTransaction.setSubAccountNumber(KFSConstants.getDashSubAccountNumber());
        } else {
            Boolean relieveLiabilities = paymentGroup.getBatch().getCustomerProfile().getRelieveLiabilities();
            if ((relieveLiabilities != null) && (relieveLiabilities.booleanValue()) && paymentAccountDetail.getPaymentDetail().getFinancialDocumentTypeCode() != null) {
                OffsetDefinition offsetDefinition = SpringContext.getBean(OffsetDefinitionService.class).getByPrimaryId(glPendingTransaction.getUniversityFiscalYear(), glPendingTransaction.getChartOfAccountsCode(), paymentAccountDetail.getPaymentDetail().getFinancialDocumentTypeCode(), glPendingTransaction.getFinancialBalanceTypeCode());
                glPendingTransaction.setFinancialObjectCode(offsetDefinition != null ? offsetDefinition.getFinancialObjectCode() : paymentAccountDetail.getFinObjectCode());
                glPendingTransaction.setFinancialSubObjectCode(KFSConstants.getDashFinancialSubObjectCode());
            } else {
                glPendingTransaction.setFinancialObjectCode(paymentAccountDetail.getFinObjectCode());
                glPendingTransaction.setFinancialSubObjectCode(paymentAccountDetail.getFinSubObjectCode());
            }
        }
        glPendingTransaction.setProjectCd(paymentAccountDetail.getProjectCode());
        glPendingTransaction.setDebitCrdtCd(pdpUtilService.isDebit(paymentAccountDetail, reversal) ? KFSConstants.GL_DEBIT_CODE : KFSConstants.GL_CREDIT_CODE);
        glPendingTransaction.setAmount(paymentAccountDetail.getAccountNetAmount().abs());
        // Changes for Research Participant Upload
        String trnDesc = StringUtils.EMPTY;
        CustomerProfile customerProfile = paymentGroup.getBatch().getCustomerProfile();
        // KFSUPGRADE-973
        if (researchParticipantPaymentValidationService.isResearchParticipantPayment(customerProfile)) {
            BusinessObjectEntry businessObjectEntry = dataDictionaryService.getDataDictionary().getBusinessObjectEntry(PaymentDetail.class.getName());
            AttributeDefinition attributeDefinition = businessObjectEntry.getAttributeDefinition("paymentGroup.payeeName");
            AttributeSecurity originalPayeeNameAttributeSecurity = attributeDefinition.getAttributeSecurity();
            // This is a temporary work around for an issue introduced with KFSCNTRB-705.
            if (ObjectUtils.isNotNull(originalPayeeNameAttributeSecurity)) {
                String maskLiteral = ((MaskFormatterLiteral) originalPayeeNameAttributeSecurity.getMaskFormatter()).getLiteral();
                trnDesc = maskLiteral;
            }
        } else {
            String payeeName = paymentGroup.getPayeeName();
            if (StringUtils.isNotBlank(payeeName)) {
                trnDesc = payeeName.length() > 40 ? payeeName.substring(0, 40) : StringUtils.rightPad(payeeName, 40);
            }
            if (reversal) {
                String poNbr = paymentAccountDetail.getPaymentDetail().getPurchaseOrderNbr();
                if (StringUtils.isNotBlank(poNbr)) {
                    trnDesc += " " + (poNbr.length() > 9 ? poNbr.substring(0, 9) : StringUtils.rightPad(poNbr, 9));
                }
                String invoiceNbr = paymentAccountDetail.getPaymentDetail().getInvoiceNbr();
                if (StringUtils.isNotBlank(invoiceNbr)) {
                    trnDesc += " " + (invoiceNbr.length() > 14 ? invoiceNbr.substring(0, 14) : StringUtils.rightPad(invoiceNbr, 14));
                }
                if (trnDesc.length() > 40) {
                    trnDesc = trnDesc.substring(0, 40);
                }
            }
        }
        glPendingTransaction.setDescription(trnDesc);
        glPendingTransaction.setOrgDocNbr(paymentAccountDetail.getPaymentDetail().getOrganizationDocNbr());
        glPendingTransaction.setOrgReferenceId(paymentAccountDetail.getOrgReferenceId());
        glPendingTransaction.setFdocRefNbr(paymentAccountDetail.getPaymentDetail().getCustPaymentDocNbr());
        // update the offset account if necessary
        SpringContext.getBean(FlexibleOffsetAccountService.class).updateOffset(glPendingTransaction);
        this.businessObjectService.save(glPendingTransaction);
        sequenceHelper.increment();
        if (bankService.isBankSpecificationEnabled()) {
            this.populateBankOffsetEntry(paymentGroup, glPendingTransaction, sequenceHelper);
        }
    }
}
Also used : ParameterService(org.kuali.kfs.coreservice.framework.parameter.ParameterService) GlPendingTransaction(org.kuali.kfs.pdp.businessobject.GlPendingTransaction) KualiInteger(org.kuali.rice.core.api.util.type.KualiInteger) AccountingPeriod(org.kuali.kfs.coa.businessobject.AccountingPeriod) ArrayList(java.util.ArrayList) AttributeDefinition(org.kuali.kfs.krad.datadictionary.AttributeDefinition) CustomerProfile(org.kuali.kfs.pdp.businessobject.CustomerProfile) GeneralLedgerPendingEntrySequenceHelper(org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntrySequenceHelper) Date(java.sql.Date) Date(java.sql.Date) PaymentDetail(org.kuali.kfs.pdp.businessobject.PaymentDetail) BusinessObjectEntry(org.kuali.kfs.krad.datadictionary.BusinessObjectEntry) FlexibleOffsetAccountService(org.kuali.kfs.sys.service.FlexibleOffsetAccountService) OffsetDefinition(org.kuali.kfs.coa.businessobject.OffsetDefinition) OffsetDefinitionService(org.kuali.kfs.coa.service.OffsetDefinitionService) AttributeSecurity(org.kuali.kfs.krad.datadictionary.AttributeSecurity) PaymentAccountDetail(org.kuali.kfs.pdp.businessobject.PaymentAccountDetail) MaskFormatterLiteral(org.kuali.kfs.krad.datadictionary.mask.MaskFormatterLiteral)

Aggregations

ParameterService (org.kuali.kfs.coreservice.framework.parameter.ParameterService)29 ArrayList (java.util.ArrayList)9 KualiDecimal (org.kuali.rice.core.api.util.type.KualiDecimal)9 List (java.util.List)4 PurApAccountingLine (org.kuali.kfs.module.purap.businessobject.PurApAccountingLine)4 PurApItem (org.kuali.kfs.module.purap.businessobject.PurApItem)4 ParameterEvaluator (org.kuali.rice.core.api.parameter.ParameterEvaluator)4 ParameterEvaluatorService (org.kuali.rice.core.api.parameter.ParameterEvaluatorService)4 CuDisbursementVoucherPayeeDetailExtension (edu.cornell.kfs.fp.businessobject.CuDisbursementVoucherPayeeDetailExtension)3 HashMap (java.util.HashMap)3 Account (org.kuali.kfs.coa.businessobject.Account)3 DisbursementVoucherDocument (org.kuali.kfs.fp.document.DisbursementVoucherDocument)3 RequisitionDocument (org.kuali.kfs.module.purap.document.RequisitionDocument)3 KfsParameterConstants (org.kuali.kfs.sys.service.impl.KfsParameterConstants)3 EntityAddress (org.kuali.rice.kim.api.identity.address.EntityAddress)3 Date (java.sql.Date)2 ParseException (java.text.ParseException)2 Calendar (java.util.Calendar)2 BenefitsCalculation (org.kuali.kfs.module.ld.businessobject.BenefitsCalculation)2 PreEncumbranceSourceAccountingLine (edu.cornell.kfs.fp.businessobject.PreEncumbranceSourceAccountingLine)1