Search in sources :

Example 1 with AttributeSecurity

use of org.kuali.kfs.krad.datadictionary.AttributeSecurity in project cu-kfs by CU-CommunityApps.

the class PendingTransactionServiceImpl 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>();
    for (PaymentDetail paymentDetail : paymentGroup.getPaymentDetails()) {
        accountListings.addAll(paymentDetail.getAccountDetail());
    }
    BusinessObjectEntry businessObjectEntry = dataDictionaryService.getDataDictionary().getBusinessObjectEntry(PaymentDetail.class.getName());
    AttributeDefinition attributeDefinition = businessObjectEntry.getAttributeDefinition("paymentGroup.payeeName");
    AttributeSecurity originalPayeeNameAttributeSecurity = attributeDefinition.getAttributeSecurity();
    String maskLiteral = ((MaskFormatterLiteral) originalPayeeNameAttributeSecurity.getMaskFormatter()).getLiteral();
    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(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());
        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();
        if (researchParticipantPaymentValidationService.isResearchParticipantPayment(customerProfile)) {
            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 : 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)

Example 2 with AttributeSecurity

use of org.kuali.kfs.krad.datadictionary.AttributeSecurity in project cu-kfs by CU-CommunityApps.

the class PayeeACHAccount method toString.

/**
 * KFSCNTRB-1682: Some of the fields contain confidential information
 *
 * @see org.kuali.rice.krad.bo.BusinessObjectBase#toString()
 */
@Override
public String toString() {
    class PayeeACHAccountToStringBuilder extends ReflectionToStringBuilder {

        private PayeeACHAccountToStringBuilder(Object object) {
            super(object);
        }

        @Override
        public boolean accept(Field field) {
            if (BusinessObject.class.isAssignableFrom(field.getType())) {
                return false;
            }
            DataDictionaryService dataDictionaryService = SpringContext.getBean(DataDictionaryService.class);
            AttributeSecurity attributeSecurity = dataDictionaryService.getAttributeSecurity(PayeeACHAccount.class.getName(), field.getName());
            if ((ObjectUtils.isNotNull(attributeSecurity) && (attributeSecurity.isHide() || attributeSecurity.isMask() || attributeSecurity.isPartialMask()))) {
                return false;
            }
            return super.accept(field);
        }
    }
    ;
    ReflectionToStringBuilder toStringBuilder = new PayeeACHAccountToStringBuilder(this);
    return toStringBuilder.toString();
}
Also used : Field(java.lang.reflect.Field) BusinessObject(org.kuali.rice.krad.bo.BusinessObject) ReflectionToStringBuilder(org.apache.commons.lang.builder.ReflectionToStringBuilder) DataDictionaryService(org.kuali.kfs.krad.service.DataDictionaryService) AttributeSecurity(org.kuali.kfs.krad.datadictionary.AttributeSecurity)

Example 3 with AttributeSecurity

use of org.kuali.kfs.krad.datadictionary.AttributeSecurity in project cu-kfs by CU-CommunityApps.

the class WebUtils method getPartiallyMaskedValue.

public static String getPartiallyMaskedValue(String className, String fieldName, Object formObject, String propertyName) {
    String displayMaskValue = null;
    Object propertyValue = ObjectUtils.getPropertyValue(formObject, propertyName);
    DataDictionaryEntryBase entry = (DataDictionaryEntryBase) KRADServiceLocatorWeb.getDataDictionaryService().getDataDictionary().getDictionaryObjectEntry(className);
    AttributeDefinition a = entry.getAttributeDefinition(fieldName);
    AttributeSecurity attributeSecurity = a.getAttributeSecurity();
    if (attributeSecurity != null && attributeSecurity.isPartialMask()) {
        MaskFormatter partialMaskFormatter = attributeSecurity.getPartialMaskFormatter();
        displayMaskValue = partialMaskFormatter.maskValue(propertyValue);
    }
    return displayMaskValue;
}
Also used : DataDictionaryEntryBase(org.kuali.kfs.krad.datadictionary.DataDictionaryEntryBase) AttributeDefinition(org.kuali.kfs.krad.datadictionary.AttributeDefinition) MaskFormatter(org.kuali.kfs.krad.datadictionary.mask.MaskFormatter) AttributeSecurity(org.kuali.kfs.krad.datadictionary.AttributeSecurity)

Example 4 with AttributeSecurity

use of org.kuali.kfs.krad.datadictionary.AttributeSecurity in project cu-kfs by CU-CommunityApps.

the class WebUtils method getFullyMaskedValue.

public static String getFullyMaskedValue(String className, String fieldName, Object formObject, String propertyName) {
    String displayMaskValue = null;
    Object propertyValue = ObjectUtils.getPropertyValue(formObject, propertyName);
    DataDictionaryEntryBase entry = (DataDictionaryEntryBase) KRADServiceLocatorWeb.getDataDictionaryService().getDataDictionary().getDictionaryObjectEntry(className);
    AttributeDefinition a = entry.getAttributeDefinition(fieldName);
    AttributeSecurity attributeSecurity = a.getAttributeSecurity();
    if (attributeSecurity != null && attributeSecurity.isMask()) {
        MaskFormatter maskFormatter = attributeSecurity.getMaskFormatter();
        displayMaskValue = maskFormatter.maskValue(propertyValue);
    }
    return displayMaskValue;
}
Also used : DataDictionaryEntryBase(org.kuali.kfs.krad.datadictionary.DataDictionaryEntryBase) AttributeDefinition(org.kuali.kfs.krad.datadictionary.AttributeDefinition) MaskFormatter(org.kuali.kfs.krad.datadictionary.mask.MaskFormatter) AttributeSecurity(org.kuali.kfs.krad.datadictionary.AttributeSecurity)

Example 5 with AttributeSecurity

use of org.kuali.kfs.krad.datadictionary.AttributeSecurity in project cu-kfs by CU-CommunityApps.

the class PayeeACHAccountExtractServiceImpl method getResolvedEmailBody.

/**
 * Helper method for replacing "[propertyName]"-style placeholders in the email body
 * with actual property values from the given Payee ACH Account, in addition to
 * replacing literal "\n" with newline characters accordingly. Potentially sensitive
 * placeholders will be replaced with empty text except for the bank name.
 * Placeholders referencing properties with value finders will print the matching key/value
 * label instead. Any placeholders that could not be resolved successfully will be replaced
 * with empty text.
 */
@SuppressWarnings("deprecation")
protected String getResolvedEmailBody(PayeeACHAccount achAccount, String emailBody) {
    Pattern placeholderPattern = Pattern.compile("\\[([^\\]]+)\\]");
    Matcher emailMatcher = placeholderPattern.matcher(emailBody.replace("\\n", "\n"));
    // Use a StringBuffer here, due to the Matcher class not supporting StringBuilder for appending operations.
    StringBuffer resolvedEmailBody = new StringBuffer(emailBody.length());
    // Replace all placeholders one by one. The pattern has a single group in it to help with retrieving just the property name and not the brackets.
    while (emailMatcher.find()) {
        String propertyName = emailMatcher.group(1);
        AttributeDefinition attDefinition = dataDictionaryService.getAttributeDefinition(PayeeACHAccount.class.getName(), propertyName);
        String replacement;
        // Make sure property exists in data dictionary and is either not potentially sensitive or is the safe-to-use bank name property.
        if (attDefinition != null) {
            AttributeSecurity attSecurity = attDefinition.getAttributeSecurity();
            if (attSecurity != null && (attSecurity.isHide() || attSecurity.isMask() || attSecurity.isPartialMask()) && !CUPdpConstants.PAYEE_ACH_ACCOUNT_EXTRACT_BANK_NAME_PROPERTY.equals(propertyName)) {
                // Replace potentially-sensitive placeholders with an empty string.
                replacement = KFSConstants.EMPTY_STRING;
            } else {
                // Replace the placeholder with the property value, or with an empty string if null or invalid.
                try {
                    Object propertyValue = ObjectPropertyUtils.getPropertyValue(achAccount, propertyName);
                    replacement = ObjectUtils.isNotNull(propertyValue) ? propertyValue.toString() : KFSConstants.EMPTY_STRING;
                    // If a values finder is defined, use the label from the matching key/value pair instead.
                    if (attDefinition.getControl() != null && StringUtils.isNotBlank(attDefinition.getControl().getValuesFinderClass())) {
                        KeyValuesFinder valuesFinder = (KeyValuesFinder) Class.forName(attDefinition.getControl().getValuesFinderClass()).newInstance();
                        String key = replacement;
                        replacement = valuesFinder.getKeyLabel(key);
                        // If the key is in the label, then remove it from the label.
                        if (attDefinition.getControl().getIncludeKeyInLabel() != null && attDefinition.getControl().getIncludeKeyInLabel().booleanValue()) {
                            // Check for key-and-dash or key-in-parentheses, and remove them if found.
                            // (Former can come from BO values finders, latter is only for custom values finders that append the keys as such.)
                            String keyAndDashPrefix = key + " - ";
                            String keyInParenSuffix = " (" + key + ")";
                            replacement = replacement.startsWith(keyAndDashPrefix) ? StringUtils.substringAfter(replacement, keyAndDashPrefix) : (replacement.endsWith(keyInParenSuffix) ? StringUtils.substringBeforeLast(replacement, keyInParenSuffix) : replacement);
                        }
                    }
                    // Because of the way that Matcher.appendReplacement() works, escape the special replacement characters accordingly.
                    if (replacement.indexOf('\\') != -1) {
                        replacement = replacement.replace("\\", "\\\\");
                    }
                    if (replacement.indexOf('$') != -1) {
                        replacement = replacement.replace("$", "\\$");
                    }
                } catch (ClassNotFoundException | IllegalAccessException | InstantiationException | RuntimeException e) {
                    replacement = KFSConstants.EMPTY_STRING;
                }
            }
        } else {
            // Replace non-data-dictionary-defined property placeholders with an empty string.
            replacement = KFSConstants.EMPTY_STRING;
        }
        emailMatcher.appendReplacement(resolvedEmailBody, replacement);
    }
    emailMatcher.appendTail(resolvedEmailBody);
    return resolvedEmailBody.toString();
}
Also used : Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher) PayeeACHAccount(org.kuali.kfs.pdp.businessobject.PayeeACHAccount) KeyValuesFinder(org.kuali.kfs.krad.keyvalues.KeyValuesFinder) AttributeDefinition(org.kuali.kfs.krad.datadictionary.AttributeDefinition) AttributeSecurity(org.kuali.kfs.krad.datadictionary.AttributeSecurity)

Aggregations

AttributeSecurity (org.kuali.kfs.krad.datadictionary.AttributeSecurity)7 AttributeDefinition (org.kuali.kfs.krad.datadictionary.AttributeDefinition)6 MaskFormatterLiteral (org.kuali.kfs.krad.datadictionary.mask.MaskFormatterLiteral)3 Date (java.sql.Date)2 ArrayList (java.util.ArrayList)2 AccountingPeriod (org.kuali.kfs.coa.businessobject.AccountingPeriod)2 OffsetDefinition (org.kuali.kfs.coa.businessobject.OffsetDefinition)2 OffsetDefinitionService (org.kuali.kfs.coa.service.OffsetDefinitionService)2 BusinessObjectEntry (org.kuali.kfs.krad.datadictionary.BusinessObjectEntry)2 DataDictionaryEntryBase (org.kuali.kfs.krad.datadictionary.DataDictionaryEntryBase)2 MaskFormatter (org.kuali.kfs.krad.datadictionary.mask.MaskFormatter)2 CustomerProfile (org.kuali.kfs.pdp.businessobject.CustomerProfile)2 GlPendingTransaction (org.kuali.kfs.pdp.businessobject.GlPendingTransaction)2 PaymentAccountDetail (org.kuali.kfs.pdp.businessobject.PaymentAccountDetail)2 PaymentDetail (org.kuali.kfs.pdp.businessobject.PaymentDetail)2 GeneralLedgerPendingEntrySequenceHelper (org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntrySequenceHelper)2 FlexibleOffsetAccountService (org.kuali.kfs.sys.service.FlexibleOffsetAccountService)2 KualiInteger (org.kuali.rice.core.api.util.type.KualiInteger)2 Field (java.lang.reflect.Field)1 Matcher (java.util.regex.Matcher)1