Search in sources :

Example 6 with ParameterService

use of org.kuali.kfs.coreservice.framework.parameter.ParameterService 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 7 with ParameterService

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

the class CuPurchasingAccountsPayableModuleServiceImpl method handlePurchasingBatchCancels.

/**
 * @see org.kuali.kfs.integration.pdp.service.PurchasingAccountsPayableModuleService#handlePurchasingBatchCancels(java.lang.String)
 */
public void handlePurchasingBatchCancels(String documentNumber, String documentTypeCode, boolean primaryCancel, boolean disbursedPayment, boolean crCancel) {
    ParameterService parameterService = SpringContext.getBean(ParameterService.class);
    PaymentRequestService paymentRequestService = SpringContext.getBean(PaymentRequestService.class);
    CreditMemoService creditMemoService = SpringContext.getBean(CreditMemoService.class);
    String preqCancelNote = parameterService.getParameterValueAsString(PaymentRequestDocument.class, PurapParameterConstants.PURAP_PDP_PREQ_CANCEL_NOTE);
    String preqResetNote = parameterService.getParameterValueAsString(PaymentRequestDocument.class, PurapParameterConstants.PURAP_PDP_PREQ_RESET_NOTE);
    String cmCancelNote = parameterService.getParameterValueAsString(VendorCreditMemoDocument.class, PurapParameterConstants.PURAP_PDP_CM_CANCEL_NOTE);
    String cmResetNote = parameterService.getParameterValueAsString(VendorCreditMemoDocument.class, PurapParameterConstants.PURAP_PDP_CM_RESET_NOTE);
    if (PurapConstants.PurapDocTypeCodes.PAYMENT_REQUEST_DOCUMENT.equals(documentTypeCode)) {
        PaymentRequestDocument pr = paymentRequestService.getPaymentRequestByDocumentNumber(documentNumber);
        if (pr != null) {
            if (disbursedPayment || primaryCancel || crCancel) {
                if (!crCancel) {
                    paymentRequestService.cancelExtractedPaymentRequest(pr, preqCancelNote);
                }
            } else {
                paymentRequestService.resetExtractedPaymentRequest(pr, preqResetNote);
            }
        } else {
            LOG.error("processPdpCancels() DOES NOT EXIST, CANNOT PROCESS - Payment Request with doc type of " + documentTypeCode + " with id " + documentNumber);
        }
    } else if (PurapConstants.PurapDocTypeCodes.CREDIT_MEMO_DOCUMENT.equals(documentTypeCode)) {
        VendorCreditMemoDocument cm = creditMemoService.getCreditMemoByDocumentNumber(documentNumber);
        if (cm != null) {
            if (disbursedPayment || primaryCancel || crCancel) {
                if (!crCancel) {
                    creditMemoService.cancelExtractedCreditMemo(cm, cmCancelNote);
                }
            } else {
                creditMemoService.resetExtractedCreditMemo(cm, cmResetNote);
            }
        } else {
            LOG.error("processPdpCancels() DOES NOT EXIST, CANNOT PROCESS - Credit Memo with doc type of " + documentTypeCode + " with id " + documentNumber);
        }
    }
}
Also used : VendorCreditMemoDocument(org.kuali.kfs.module.purap.document.VendorCreditMemoDocument) ParameterService(org.kuali.kfs.coreservice.framework.parameter.ParameterService) PaymentRequestService(org.kuali.kfs.module.purap.document.service.PaymentRequestService) PaymentRequestDocument(org.kuali.kfs.module.purap.document.PaymentRequestDocument) CreditMemoService(org.kuali.kfs.module.purap.document.service.CreditMemoService)

Example 8 with ParameterService

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

the class ProcurementCardErrorEmailServiceImplTest method setUp.

@Before
public void setUp() throws Exception {
    procurementCardErrorEmailService = new ProcurementCardErrorEmailServiceImpl();
    EmailServiceImpl emailService = new EmailServiceImpl();
    ParameterService parameterService = new MockParameterServiceImpl();
    emailService.setParameterService(parameterService);
    procurementCardErrorEmailService.setEmailService(emailService);
    procurementCardErrorEmailService.setParameterService(parameterService);
}
Also used : EmailServiceImpl(org.kuali.kfs.sys.service.impl.EmailServiceImpl) ParameterService(org.kuali.kfs.coreservice.framework.parameter.ParameterService) MockParameterServiceImpl(edu.cornell.kfs.sys.service.mock.MockParameterServiceImpl) Before(org.junit.Before)

Example 9 with ParameterService

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

the class DocumentType1099BoxServiceImplTest method setupMockParameterServiceForMappings.

protected void setupMockParameterServiceForMappings(String... mappings) {
    Collection<String> mappingsCollection = Arrays.asList(mappings);
    ParameterService parameterService = EasyMock.createMock(ParameterServiceImpl.class);
    EasyMock.expect(parameterService.getParameterValuesAsString(CUTaxConstants.TAX_NAMESPACE, CUTaxConstants.TAX_1099_PARM_DETAIL, CUTaxConstants.Tax1099ParameterNames.DOCUMENT_TYPE_TO_TAX_BOX)).andStubReturn(mappingsCollection);
    EasyMock.replay(parameterService);
    documentType1099BoxService.setParameterService(parameterService);
}
Also used : ParameterService(org.kuali.kfs.coreservice.framework.parameter.ParameterService)

Example 10 with ParameterService

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

the class CuBankServiceImplTest method testGetDefaultBankByDocType_valid.

/*
     * test document type that has bank code set up in parameter
     */
public void testGetDefaultBankByDocType_valid() {
    parameterService = SpringContext.getBean(ParameterService.class);
    bankCodesMap = parameterService.getParameterValueAsString(Bank.class, KFSParameterKeyConstants.DEFAULT_BANK_BY_DOCUMENT_TYPE);
    if (StringUtils.isNotBlank(bankCodesMap)) {
        for (String docTypeBankCode : bankCodesMap.split(";")) {
            String[] docTypeBankCodePair = docTypeBankCode.split("=");
            Bank bank = cUBankService.getDefaultBankByDocType(docTypeBankCodePair[0]);
            assertTrue("should get valid bank code for " + docTypeBankCodePair[0], StringUtils.equals(docTypeBankCodePair[1], bank.getBankCode()));
        }
    }
}
Also used : Bank(org.kuali.kfs.sys.businessobject.Bank) ParameterService(org.kuali.kfs.coreservice.framework.parameter.ParameterService)

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