001    /*
002     * Copyright 2011 The Kuali Foundation.
003     * 
004     * Licensed under the Educational Community License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     * 
008     * http://www.opensource.org/licenses/ecl2.php
009     * 
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    package org.kuali.kfs.module.ar.document.validation.impl;
017    
018    import java.sql.Date;
019    import java.sql.Timestamp;
020    import java.util.Calendar;
021    
022    import org.apache.commons.lang.StringUtils;
023    import org.apache.commons.lang.time.DateUtils;
024    import org.apache.log4j.Logger;
025    import org.kuali.kfs.module.ar.ArKeyConstants;
026    import org.kuali.kfs.module.ar.ArPropertyConstants;
027    import org.kuali.kfs.module.ar.businessobject.Customer;
028    import org.kuali.kfs.module.ar.businessobject.CustomerAddress;
029    import org.kuali.kfs.module.ar.document.service.CustomerService;
030    import org.kuali.kfs.sys.KFSConstants;
031    import org.kuali.kfs.sys.context.SpringContext;
032    import org.kuali.rice.kns.bo.PersistableBusinessObject;
033    import org.kuali.rice.kns.document.MaintenanceDocument;
034    import org.kuali.rice.kns.maintenance.rules.MaintenanceDocumentRuleBase;
035    import org.kuali.rice.kns.service.DateTimeService;
036    import org.kuali.rice.kns.service.ParameterService;
037    import org.kuali.rice.kns.util.GlobalVariables;
038    import org.kuali.rice.kns.util.KNSConstants;
039    import org.kuali.rice.kns.util.MessageMap;
040    import org.kuali.rice.kns.util.ObjectUtils;
041    
042    public class CustomerRule extends MaintenanceDocumentRuleBase {
043        protected static Logger LOG = org.apache.log4j.Logger.getLogger(CustomerRule.class);
044        protected Customer oldCustomer;
045        protected Customer newCustomer;
046        protected DateTimeService dateTimeService = SpringContext.getBean(DateTimeService.class);
047    
048        /**
049         * This method initializes the old and new customer
050         * 
051         * @param document
052         */
053        protected void initializeAttributes(MaintenanceDocument document) {
054            if (newCustomer == null) {
055                newCustomer = (Customer) document.getNewMaintainableObject().getBusinessObject();
056            }
057            if (oldCustomer == null) {
058                oldCustomer = (Customer) document.getOldMaintainableObject().getBusinessObject();
059            }
060        }
061    
062        /**
063         * @see org.kuali.rice.kns.maintenance.rules.MaintenanceDocumentRuleBase#processCustomRouteDocumentBusinessRules(org.kuali.rice.kns.document.MaintenanceDocument)
064         */
065        @Override
066        protected boolean processCustomRouteDocumentBusinessRules(MaintenanceDocument document) {
067    
068            boolean isValid = true;
069            isValid &= super.processCustomRouteDocumentBusinessRules(document);
070            MessageMap errorMap = GlobalVariables.getMessageMap();
071            isValid &= errorMap.isEmpty();
072            if (isValid) {
073                initializeAttributes(document);
074                isValid &= checkCustomerHasAddress(newCustomer);
075    
076                if (isValid) {
077                    isValid &= validateAddresses(newCustomer);
078                }
079    
080                if (isValid) {
081                    isValid &= checkAddresses(newCustomer);
082                }
083    
084                if (isValid) {
085                    isValid &= checkTaxNumber(newCustomer);
086                }
087    
088                if (isValid) {
089                    isValid &= checkNameIsValidLength(newCustomer.getCustomerName());
090                }
091    
092                // TODO This should probably be done in a BO 'before insert' hook, rather than in the business rule validation,
093                // unless there's some reason not clear why it needs to happen here.
094                if (isValid && document.isNew() && StringUtils.isBlank(newCustomer.getCustomerNumber())) {
095                    isValid &= setCustomerNumber();
096                }
097            }
098    
099            return isValid;
100        }
101    
102        /**
103         * This method sets the new customer number
104         * 
105         * @return Returns true if the customer number is set successfully, false otherwise.
106         */
107        protected boolean setCustomerNumber() {
108            // TODO This should probably be done in a BO 'before insert' hook, rather than in the business rule validation,
109            // unless there's some reason not clear why it needs to happen here.
110            boolean success = true;
111            try {
112                String customerNumber = SpringContext.getBean(CustomerService.class).getNextCustomerNumber(newCustomer);
113                newCustomer.setCustomerNumber(customerNumber);
114                if (oldCustomer != null) {
115                    oldCustomer.setCustomerNumber(customerNumber);
116                }
117            }
118            catch (StringIndexOutOfBoundsException sibe) {
119                // It is expected that if a StringIndexOutOfBoundsException occurs, it is due to the customer name being less than three
120                // characters
121                GlobalVariables.getMessageMap().putError(KFSConstants.MAINTENANCE_NEW_MAINTAINABLE + ArPropertyConstants.CustomerFields.CUSTOMER_NAME, ArKeyConstants.CustomerConstants.ERROR_CUSTOMER_NAME_LESS_THAN_THREE_CHARACTERS);
122                success = false;
123            }
124            return success;
125        }
126    
127        /**
128         * This method checks if the new customer has at least one address
129         * 
130         * @param newCustomer the new customer
131         * @return true is the new customer has at least one address, false otherwise
132         */
133        public boolean checkCustomerHasAddress(Customer newCustomer) {
134            boolean success = true;
135            if (newCustomer.getCustomerAddresses().isEmpty()) {
136                success = false;
137                GlobalVariables.getMessageMap().putError(KFSConstants.MAINTENANCE_NEW_MAINTAINABLE + ArPropertyConstants.CustomerFields.CUSTOMER_TAB_ADDRESSES, ArKeyConstants.CustomerConstants.ERROR_AT_LEAST_ONE_ADDRESS);
138            }
139            return success;
140    
141        }
142    
143        /**
144         * @see org.kuali.rice.kns.maintenance.rules.MaintenanceDocumentRuleBase#processCustomAddCollectionLineBusinessRules(org.kuali.rice.kns.document.MaintenanceDocument,
145         *      java.lang.String, org.kuali.rice.kns.bo.PersistableBusinessObject)
146         */
147        @Override
148        public boolean processCustomAddCollectionLineBusinessRules(MaintenanceDocument document, String collectionName, PersistableBusinessObject line) {
149            boolean isValid = true;
150            isValid &= super.processCustomAddCollectionLineBusinessRules(document, collectionName, line);
151            MessageMap errorMap = GlobalVariables.getMessageMap();
152            isValid &= errorMap.isEmpty();
153    
154            if (collectionName.equals(ArPropertyConstants.CustomerFields.CUSTOMER_TAB_ADDRESSES)) {
155                CustomerAddress customerAddress = (CustomerAddress) line;
156    
157                if (isValid) {
158                    isValid &= checkAddressIsValid(customerAddress);
159                    isValid &= validateEndDateForNewAddressLine(customerAddress.getCustomerAddressEndDate());
160                }
161    
162                if (isValid) {
163                    Customer customer = (Customer) document.getNewMaintainableObject().getBusinessObject();
164                    if (customerAddress.getCustomerAddressTypeCode().equalsIgnoreCase(ArKeyConstants.CustomerConstants.CUSTOMER_ADDRESS_TYPE_CODE_PRIMARY)) {
165    
166                        for (int i = 0; i < customer.getCustomerAddresses().size(); i++) {
167                            if (customer.getCustomerAddresses().get(i).getCustomerAddressTypeCode().equalsIgnoreCase(ArKeyConstants.CustomerConstants.CUSTOMER_ADDRESS_TYPE_CODE_PRIMARY)) {
168                                customer.getCustomerAddresses().get(i).setCustomerAddressTypeCode(ArKeyConstants.CustomerConstants.CUSTOMER_ADDRESS_TYPE_CODE_ALTERNATE);
169                                // OK
170                                // break;
171                            }
172                        }
173                    }
174                    // if new address is not Primary, check if there is an active primary address for this customer. If not, make a new
175                    // address primary
176                    else {
177                        boolean isActivePrimaryAddress = false;
178                        Date endDate;
179    
180                        for (int i = 0; i < customer.getCustomerAddresses().size(); i++) {
181                            if (customer.getCustomerAddresses().get(i).getCustomerAddressTypeCode().equalsIgnoreCase(ArKeyConstants.CustomerConstants.CUSTOMER_ADDRESS_TYPE_CODE_PRIMARY)) {
182                                endDate = customer.getCustomerAddresses().get(i).getCustomerAddressEndDate();
183                                // check if endDate qualifies this customer address as inactive (if endDate is a passed date or present
184                                // date)
185                                if (!checkEndDateIsValid(endDate, false))
186                                    customer.getCustomerAddresses().get(i).setCustomerAddressTypeCode(ArKeyConstants.CustomerConstants.CUSTOMER_ADDRESS_TYPE_CODE_ALTERNATE);
187                                else
188                                    isActivePrimaryAddress = true;
189                            }
190                        }
191                        if (!isActivePrimaryAddress)
192                            customerAddress.setCustomerAddressTypeCode(ArKeyConstants.CustomerConstants.CUSTOMER_ADDRESS_TYPE_CODE_PRIMARY);
193                    }
194                }
195            }
196    
197            return isValid;
198    
199        }
200    
201        /**
202         * This method checks if customer end date is valid: 1. if a new address is being added, customer end date must be a future date
203         * 2. if inactivating an address, customer end date must be current or future date
204         * 
205         * @param endDate
206         * @param canBeTodaysDateFlag
207         * @return True if endDate is valid.
208         */
209        public boolean checkEndDateIsValid(Date endDate, boolean canBeTodaysDateFlag) {
210            boolean isValid = true;
211    
212            if (ObjectUtils.isNull(endDate))
213                return isValid;
214    
215            Timestamp today = dateTimeService.getCurrentTimestamp();
216            today.setTime(DateUtils.truncate(today, Calendar.DAY_OF_MONTH).getTime());
217    
218            // end date must be todays date or future date
219            if (canBeTodaysDateFlag) {
220                if (endDate.before(today)) {
221                    isValid = false;
222                }
223            } // end date must be a future date
224            else {
225                if (!endDate.after(today)) {
226                    isValid = false;
227                }
228            }
229    
230            return isValid;
231        }
232    
233        public boolean validateEndDateForNewAddressLine(Date endDate) {
234            boolean isValid = checkEndDateIsValid(endDate, false);
235            if (!isValid) {
236                String propertyName = ArPropertyConstants.CustomerFields.CUSTOMER_TAB_ADDRESSES_ADD_NEW_ADDRESS + "." + ArPropertyConstants.CustomerFields.CUSTOMER_ADDRESS_END_DATE;
237                putFieldError(propertyName, ArKeyConstants.CustomerConstants.ERROR_CUSTOMER_ADDRESS_END_DATE_MUST_BE_FUTURE_DATE);
238            }
239    
240            return isValid;
241        }
242    
243        public boolean validateEndDateForExistingCustomerAddress(Date newEndDate, int ind) {
244            boolean isValid = checkEndDateIsValid(newEndDate, true);
245    
246            // valid end date for an existing customer address;
247            // 1. blank <=> no date entered
248            // 2. todays date -> makes address inactive
249            // 3. future date
250            // 4. if end date is a passed date AND it hasn't been updated <=> oldEndDate = newEndDate
251            // 
252            // invalid end date for an existing customer address
253            // 1. if end date is a passed date AND it has been updated <=> oldEndDate != newEndDate
254            if (!isValid) {
255                Date oldEndDate = oldCustomer.getCustomerAddresses().get(ind).getCustomerAddressEndDate();
256                // passed end date has been entered
257                if (ObjectUtils.isNull(oldEndDate) || ObjectUtils.isNotNull(oldEndDate) && !oldEndDate.toString().equals(newEndDate.toString())) {
258                    String propertyName = ArPropertyConstants.CustomerFields.CUSTOMER_TAB_ADDRESSES + "[" + ind + "]." + ArPropertyConstants.CustomerFields.CUSTOMER_ADDRESS_END_DATE;
259                    putFieldError(propertyName, ArKeyConstants.CustomerConstants.ERROR_CUSTOMER_ADDRESS_END_DATE_MUST_BE_CURRENT_OR_FUTURE_DATE);
260                }
261                else {
262                    isValid = true;
263                }
264            }
265            return isValid;
266        }
267    
268        /**
269         * This method checks if the customer name entered is greater than or equal to three (3) characters long. This rule was
270         * implemented to ensure that there are three characters available from the name to be used as a the customer code.
271         * 
272         * @param customerName The name of the customer.
273         * @return True if the name is greater than or equal to 3 characters long.
274         */
275        public boolean checkNameIsValidLength(String customerName) {
276            boolean success = true;
277            if (customerName.length() < 3) {
278                success = false;
279                GlobalVariables.getMessageMap().putError(KFSConstants.MAINTENANCE_NEW_MAINTAINABLE + ArPropertyConstants.CustomerFields.CUSTOMER_NAME, ArKeyConstants.CustomerConstants.ERROR_CUSTOMER_NAME_LESS_THAN_THREE_CHARACTERS);
280            }
281    
282            if (customerName.indexOf(' ') > -1 && customerName.indexOf(' ') < 3) {
283                success = false;
284                GlobalVariables.getMessageMap().putError(KFSConstants.MAINTENANCE_NEW_MAINTAINABLE + ArPropertyConstants.CustomerFields.CUSTOMER_NAME, ArKeyConstants.CustomerConstants.ERROR_CUSTOMER_NAME_NO_SPACES_IN_FIRST_THREE_CHARACTERS);
285            }
286            return success;
287        }
288    
289        /**
290         * This method checks if the address is valid
291         * 
292         * @param customerAddress
293         * @return true if valid, false otherwise
294         */
295        public boolean checkAddressIsValid(CustomerAddress customerAddress, int ind) {
296            boolean isValid = true;
297            String propertyName = ArPropertyConstants.CustomerFields.CUSTOMER_TAB_ADDRESSES + "[" + ind + "].";
298    
299            if (ArKeyConstants.CustomerConstants.CUSTOMER_ADDRESS_TYPE_CODE_US.equalsIgnoreCase(customerAddress.getCustomerCountryCode())) {
300    
301                if (customerAddress.getCustomerZipCode() == null || "".equalsIgnoreCase(customerAddress.getCustomerZipCode())) {
302                    isValid = false;
303                    putFieldError(propertyName + ArPropertyConstants.CustomerFields.CUSTOMER_ADDRESS_ZIP_CODE, ArKeyConstants.CustomerConstants.ERROR_CUSTOMER_ADDRESS_ZIP_CODE_REQUIRED_WHEN_COUNTTRY_US);
304                }
305                if (customerAddress.getCustomerStateCode() == null || "".equalsIgnoreCase(customerAddress.getCustomerStateCode())) {
306                    isValid = false;
307                    putFieldError(propertyName + ArPropertyConstants.CustomerFields.CUSTOMER_ADDRESS_STATE_CODE, ArKeyConstants.CustomerConstants.ERROR_CUSTOMER_ADDRESS_STATE_CODE_REQUIRED_WHEN_COUNTTRY_US);
308                }
309            }
310            else {
311                if (customerAddress.getCustomerInternationalMailCode() == null || "".equalsIgnoreCase(customerAddress.getCustomerInternationalMailCode())) {
312                    isValid = false;
313                    // GlobalVariables.getMessageMap().putError(ArPropertyConstants.CustomerFields.CUSTOMER_ADDRESS_INTERNATIONAL_MAIL_CODE,
314                    // ArKeyConstants.CustomerConstants.ERROR_CUSTOMER_ADDRESS_INTERNATIONAL_MAIL_CODE_REQUIRED_WHEN_COUNTTRY_NON_US);
315                    putFieldError(propertyName + ArPropertyConstants.CustomerFields.CUSTOMER_ADDRESS_INTERNATIONAL_MAIL_CODE, ArKeyConstants.CustomerConstants.ERROR_CUSTOMER_ADDRESS_INTERNATIONAL_MAIL_CODE_REQUIRED_WHEN_COUNTTRY_NON_US);
316                }
317                if (customerAddress.getCustomerAddressInternationalProvinceName() == null || "".equalsIgnoreCase(customerAddress.getCustomerAddressInternationalProvinceName())) {
318                    isValid = false;
319                    // GlobalVariables.getMessageMap().putError(ArPropertyConstants.CustomerFields.CUSTOMER_ADDRESS_INTERNATIONAL_PROVINCE_NAME,
320                    // ArKeyConstants.CustomerConstants.ERROR_CUSTOMER_ADDRESS_INTERNATIONAL_PROVINCE_NAME_REQUIRED_WHEN_COUNTTRY_NON_US);
321                    putFieldError(propertyName + ArPropertyConstants.CustomerFields.CUSTOMER_ADDRESS_INTERNATIONAL_PROVINCE_NAME, ArKeyConstants.CustomerConstants.ERROR_CUSTOMER_ADDRESS_INTERNATIONAL_PROVINCE_NAME_REQUIRED_WHEN_COUNTTRY_NON_US);
322                }
323            }
324            return isValid;
325        }
326    
327        public boolean checkAddressIsValid(CustomerAddress customerAddress) {
328            boolean isValid = true;
329    
330            if (ArKeyConstants.CustomerConstants.CUSTOMER_ADDRESS_TYPE_CODE_US.equalsIgnoreCase(customerAddress.getCustomerCountryCode())) {
331    
332                if (customerAddress.getCustomerZipCode() == null || "".equalsIgnoreCase(customerAddress.getCustomerZipCode())) {
333                    isValid = false;
334                    GlobalVariables.getMessageMap().putError(ArPropertyConstants.CustomerFields.CUSTOMER_ADDRESS_ZIP_CODE, ArKeyConstants.CustomerConstants.ERROR_CUSTOMER_ADDRESS_ZIP_CODE_REQUIRED_WHEN_COUNTTRY_US);
335                }
336                if (customerAddress.getCustomerStateCode() == null || "".equalsIgnoreCase(customerAddress.getCustomerStateCode())) {
337                    isValid = false;
338                    GlobalVariables.getMessageMap().putError(ArPropertyConstants.CustomerFields.CUSTOMER_ADDRESS_STATE_CODE, ArKeyConstants.CustomerConstants.ERROR_CUSTOMER_ADDRESS_STATE_CODE_REQUIRED_WHEN_COUNTTRY_US);
339                }
340            }
341            else {
342                if (customerAddress.getCustomerInternationalMailCode() == null || "".equalsIgnoreCase(customerAddress.getCustomerInternationalMailCode())) {
343                    isValid = false;
344                    GlobalVariables.getMessageMap().putError(ArPropertyConstants.CustomerFields.CUSTOMER_ADDRESS_INTERNATIONAL_MAIL_CODE, ArKeyConstants.CustomerConstants.ERROR_CUSTOMER_ADDRESS_INTERNATIONAL_MAIL_CODE_REQUIRED_WHEN_COUNTTRY_NON_US);
345                }
346                if (customerAddress.getCustomerAddressInternationalProvinceName() == null || "".equalsIgnoreCase(customerAddress.getCustomerAddressInternationalProvinceName())) {
347                    isValid = false;
348                    GlobalVariables.getMessageMap().putError(ArPropertyConstants.CustomerFields.CUSTOMER_ADDRESS_INTERNATIONAL_PROVINCE_NAME, ArKeyConstants.CustomerConstants.ERROR_CUSTOMER_ADDRESS_INTERNATIONAL_PROVINCE_NAME_REQUIRED_WHEN_COUNTTRY_NON_US);
349                }
350            }
351            return isValid;
352        }
353    
354        /**
355         * This method checks if the customer addresses are valid: has one and only one primary address
356         * 
357         * @param customer
358         * @return true if valid, false otherwise
359         */
360        public boolean checkAddresses(Customer customer) {
361            boolean isValid = true;
362            boolean hasPrimaryAddress = false;
363            for (CustomerAddress customerAddress : customer.getCustomerAddresses()) {
364                if (customerAddress.getCustomerAddressTypeCode().equalsIgnoreCase(ArKeyConstants.CustomerConstants.CUSTOMER_ADDRESS_TYPE_CODE_PRIMARY)) {
365                    if (hasPrimaryAddress) {
366                        isValid = false;
367                        GlobalVariables.getMessageMap().putError(KFSConstants.MAINTENANCE_NEW_MAINTAINABLE + ArPropertyConstants.CustomerFields.CUSTOMER_TAB_ADDRESSES, ArKeyConstants.CustomerConstants.ERROR_ONLY_ONE_PRIMARY_ADDRESS);
368                    }
369                    else {
370                        hasPrimaryAddress = true;
371                    }
372                }
373            }
374    
375            // customer must have at least one primary address
376            if (!hasPrimaryAddress) {
377                isValid = false;
378                GlobalVariables.getMessageMap().putError(KFSConstants.MAINTENANCE_NEW_MAINTAINABLE + ArPropertyConstants.CustomerFields.CUSTOMER_TAB_ADDRESSES, ArKeyConstants.CustomerConstants.ERROR_ONLY_ONE_PRIMARY_ADDRESS);
379            }
380            return isValid;
381        }
382    
383        public boolean validateAddresses(Customer customer) {
384            boolean isValid = true;
385            int i = 0;
386            // this block is to validate email addresses
387            for (CustomerAddress customerAddress : customer.getCustomerAddresses()) {
388                if (ObjectUtils.isNotNull(customerAddress.getCustomerEmailAddress())) {
389                    String errorPath = KNSConstants.MAINTENANCE_NEW_MAINTAINABLE + ArPropertyConstants.CustomerFields.CUSTOMER_TAB_ADDRESSES + "[" + i + "]";
390                    GlobalVariables.getMessageMap().addToErrorPath(errorPath);
391    
392                    this.getDictionaryValidationService().validateBusinessObject(customerAddress);
393                    GlobalVariables.getMessageMap().removeFromErrorPath(errorPath);
394                }
395                i++;
396            }
397            i = 0;
398            for (CustomerAddress customerAddress : customer.getCustomerAddresses()) {
399                isValid &= checkAddressIsValid(customerAddress, i);
400                isValid &= validateEndDateForExistingCustomerAddress(customerAddress.getCustomerAddressEndDate(), i);
401                i++;
402            }
403            if (GlobalVariables.getMessageMap().getErrorCount() > 0)
404                isValid = false;
405    
406            if (isValid) {
407                i = 0;
408                for (CustomerAddress customerAddress : customer.getCustomerAddresses()) {
409                    if (customerAddress.getCustomerAddressTypeCode().equalsIgnoreCase(ArKeyConstants.CustomerConstants.CUSTOMER_ADDRESS_TYPE_CODE_PRIMARY) && ObjectUtils.isNotNull(customerAddress.getCustomerAddressEndDate()))
410                        isValid &= checkIfPrimaryAddressActive(customerAddress.getCustomerAddressEndDate(), i);
411                    i++;
412                }
413            }
414    
415            return isValid;
416        }
417    
418        public boolean checkIfPrimaryAddressActive(Date newEndDate, int ind) {
419            // if here -> this is a Primary Address, customer end date is not null
420            boolean isActiveAddressFlag = checkEndDateIsValid(newEndDate, false);
421    
422            if (!isActiveAddressFlag) {
423                String propertyName = ArPropertyConstants.CustomerFields.CUSTOMER_TAB_ADDRESSES + "[" + ind + "]." + ArPropertyConstants.CustomerFields.CUSTOMER_ADDRESS_END_DATE;
424                putFieldError(propertyName, ArKeyConstants.CustomerConstants.ERROR_CUSTOMER_PRIMARY_ADDRESS_MUST_HAVE_FUTURE_END_DATE);
425            }
426    
427            return isActiveAddressFlag;
428        }
429    
430        /**
431         * This method checks if tax number is entered when tax number is required
432         * 
433         * @param customer
434         * @return true if tax number is required and tax number is entered or if tax number is not required, false if tax number
435         *         required and tax number not entered
436         */
437        public boolean checkTaxNumber(Customer customer) {
438            boolean isValid = true;
439            if (isTaxNumberRequired()) {
440                boolean noTaxNumber = (customer.getCustomerTaxNbr() == null || customer.getCustomerTaxNbr().equalsIgnoreCase(""));
441                if (noTaxNumber) {
442                    isValid = false;
443                    GlobalVariables.getMessageMap().putError(KFSConstants.MAINTENANCE_NEW_MAINTAINABLE + ArPropertyConstants.CustomerFields.CUSTOMER_SOCIAL_SECURITY_NUMBER, ArKeyConstants.CustomerConstants.ERROR_TAX_NUMBER_IS_REQUIRED);
444                }
445            }
446            return isValid;
447        }
448    
449        /**
450         * This method checks if tax number is required
451         * 
452         * @return true if tax number is required, false otherwise
453         */
454        public boolean isTaxNumberRequired() {
455            boolean paramExists = SpringContext.getBean(ParameterService.class).parameterExists(Customer.class, KFSConstants.CustomerParameter.TAX_NUMBER_REQUIRED_IND);
456            if (paramExists) {
457                return SpringContext.getBean(ParameterService.class).getIndicatorParameter(Customer.class, KFSConstants.CustomerParameter.TAX_NUMBER_REQUIRED_IND);
458            }
459            else
460                return false;
461        }
462    
463    }