za.co.bayport.rules.PolicyRules.java Source code

Java tutorial

Introduction

Here is the source code for za.co.bayport.rules.PolicyRules.java

Source

package za.co.bayport.rules;

import java.util.Collections;
import java.util.Date;
import java.util.List;

import org.joda.time.DateMidnight;
import org.joda.time.DateTime;
import org.joda.time.Years;

import za.co.bayport.schema.exceptions.ServiceException;
import za.co.bayport.commons.utils.ValidationUtils;
import za.co.bayport.schema.EWageFrequency;

public class PolicyRules {

    /**
     * 
     * @param code
     *            : Error Code
     * @param fieldName
     *            : Field Name
     * @param fieldValue
     *            : Field Value, String or an Object except Integer
     * @throws ServiceException
     *             : Standard Bayport's ServiceException
     */
    private static ServiceException checkIsNullOrEmpty(String code, String description, String message,
            Object fieldValue) {
        if (ValidationUtils.isNullOrEmpty(fieldValue))
            return new ServiceException(code, description, message);
        return null;
    }

    /**
     * 
     * @param code
     *            : Error Code
     * @param fieldName
     *            : Field Name
     * @param fieldValue
     *            : Integer Field Value
     * @throws ServiceException
     *             : Standard Bayport's ServiceException
     */
    private static ServiceException checkIsNullOrZero(String code, String description, String message,
            Integer fieldValue) {
        if (ValidationUtils.isNullOrZero(fieldValue))
            return new ServiceException(code, description, message);
        return null;
    }

    /**
     * Checks Applicant's Citizenship<br/>
     * <br/>
     * 
     * @param source
     *            : List of countries
     * @param val
     *            : Country of Citizenship
     * 
     * @throws ServiceException
     *             : Would throw ServiceException containing &lt;errorCode&gt;, &lt;fieldName&gt; and &lt;fieldValue&gt; if: <li>
     *             &lt;source&gt; is empty or null</li> <li>&lt;val&gt; is empty or null</li> <li>
     *             &lt;source&gt; does not contain &lt;val&gt;</li> <br/>
     * <br/>
     *             <b>Suggestion:</b> Applicant must be a South African citizen.
     */
    public static ServiceException checkCitizenship(List<String> source, String val) {

        ServiceException ServiceException = checkIsNullOrEmpty("RUL001", "CITIZENSHIP", "Source Is Null Or Empty",
                source);

        if (ServiceException == null)
            ServiceException = checkIsNullOrEmpty("RUL001", "CITIZENSHIP", "Value Is Null Or Empty", val);

        if (ServiceException == null)
            if (!source.contains(val))
                ServiceException = new ServiceException("POL001", "CITIZENSHIP",
                        "Applicant must be a South African citizen");

        return ServiceException;
    }

    /**
     * Checks Applicant's Age Limit<br/>
     * <br/>
     * 
     * @param minVal
     *            : Applicant's Minimum Age
     * @param maxVal
     *            : Applicant's Maximum Age
     * @param val
     *            : Applicant's age
     * @throws ServiceException
     *             : Would throw ServiceException containing &lt;errorCode&gt;, &lt;fieldName&gt; and &lt;fieldValue&gt; if: <li>
     *             &lt;minVal&gt; is zero or null</li><li>&lt;maxVal&gt; is zero or null</li> <li>&lt;val&gt; is zero or null</li> <li>if &lt;val&gt; is less
     *             than &lt;minVal&gt; or greater than &lt;maxVal&gt;<br/>
     *             <br/>
     *             <b>Suggestion:</b> Applicant must be 18 years of age or older but not older than 63 years of age. Unless: The employer can provide
     *             confirmation in writing that the applicant will be employed after reaching 63 to a maximum of 65 years of age
     */
    public static ServiceException checkAgeLimit(Integer minVal, Integer maxVal, Date dob) {

        ServiceException ServiceException = checkIsNullOrZero("RUL002", "AGE", "Minimum Age: Is Null Or Zero",
                minVal);
        if (ServiceException == null)
            ServiceException = checkIsNullOrZero("RUL002", "AGE", "Maximum Age: Is Null Or Zero", maxVal);

        if (ServiceException == null)
            ServiceException = checkIsNullOrEmpty("RUL001", "AGE", "Date of Birth Is Null or Empty", dob);

        if (ServiceException == null) {
            DateMidnight birthdate = new DateMidnight(dob);
            DateTime now = new DateTime();
            Years age = Years.yearsBetween(birthdate, now);
            int val = age.getYears();
            if (val < minVal || val > maxVal)
                ServiceException = new ServiceException("POL002", "AGE",
                        "Applicant must be 18 years of age or older but not older than 63 years of age. Unless: The employer can provide confirmation in writing that the applicant will be employed after reaching 63 to a maximum of 65 years of age");
        }
        return ServiceException;
    }

    /**
     * Checks term of the Credit Product with Applicant's Retirement Age
     * 
     * @param source
     *            : Applicant's Retirement Age
     * @param val
     *            : Expiry Date of all Credit Products
     * @throws ServiceException
     *             : Would throw ServiceException containing &lt;errorCode&gt;, &lt;fieldName&gt; and &lt;fieldValue&gt; if: <li>
     *             &lt;source&gt; is empty or null</li><li>&lt;val&gt; is empty or null</li> <li>if &lt;val&gt; is six months after than &lt;source&gt;<br/>
     *             <br/>
     *             <b>Suggestion:</b> The term of the Credit Product must Expire 6 (six) month's before the applicant's retirement date
     */
    @SuppressWarnings("deprecation")
    public static ServiceException checkCreditProductDate(Date source, List<Date> val) {
        ServiceException ServiceException = checkIsNullOrEmpty("RUL001", "CREDIT_PRODUCT_DATE", "Is Null Or Empty",
                source);
        if (ServiceException == null)
            ServiceException = checkIsNullOrEmpty("RUL001", "CREDIT_PRODUCT_DATE", "Is Null Or Empty", val);
        if (ServiceException == null) {
            Date sixMonthBeforeRetirementDate = source;
            sixMonthBeforeRetirementDate.setMonth(-6);
            for (Date productExpireDate : val) {
                if (productExpireDate != null) {
                    if (productExpireDate.after(sixMonthBeforeRetirementDate))
                        ServiceException = new ServiceException("POL003", "CREDIT_PRODUCT_DATE",
                                "The term of the Credit Product must Expire 6 (six) month's before the applicant's retirement date");
                }
            }
        }
        return ServiceException;
    }

    /**
     * Checks Valid Employment Type of an Applicant
     * 
     * @param source
     *            : All Excepted Employment Types
     * @param val
     *            : Applicant's Employment Type @ : Would throw ServiceException containing &lt;errorCode&gt;, &lt;fieldName&gt; and &lt;fieldValue&gt; if: <li>
     *            &lt;source&gt; is empty or null</li><li>&lt;val&gt; is empty or null</li> <li>if &lt;val&gt; is not found in &lt;source&gt; <br/>
     *            <br/>
     *            <b>Suggestion:</b> Applicant Must be Permanently Employed
     */
    public static ServiceException checkEmploymentType(List<String> source, String val) {
        ServiceException ServiceException = checkIsNullOrEmpty("RUL001", "Employment Type Source",
                "Is Null Or Empty", source);
        if (ServiceException == null)
            ServiceException = checkIsNullOrEmpty("RUL001", "Employment Type Value", "Is Null Or Empty", val);
        if (ServiceException == null)
            if (!source.contains(val))
                ServiceException = new ServiceException("POL004", "Employment Type",
                        "Applicant Must be Permanently Employed");
        return ServiceException;
    }

    /**
     * Checks Acceptable Employment Duration of an Applicant
     * 
     * @param val
     *            : Date of an Employment @ : Would throw ServiceException containing &lt;errorCode&gt;, &lt;fieldName&gt; and &lt;fieldValue&gt; if: <li>
     *            &lt;val&gt; is empty or null</li> <li>if &lt;val&gt; is less than six months<br/>
     *            <br/>
     *            <b>Suggestion:</b> The applicant must have been employed by his/her current employer for minimum period of (6) months as at the date of
     *            application
     */
    public static ServiceException checkEmploymentDuration(Date val) {
        ServiceException ServiceException = checkIsNullOrEmpty("RUL001", "EMPLOYMENT_DURATION", "Is Null Or Empty",
                val);
        DateTime empDate = new DateTime(val);
        if (ServiceException == null) {
            DateTime sixMonthsBeforeDate = new DateTime(new Date());
            sixMonthsBeforeDate = sixMonthsBeforeDate.plusMonths(-6);
            if (empDate.isAfter(sixMonthsBeforeDate))
                ServiceException = new ServiceException("POL005", "EMPLOYMENT_DURATION",
                        "The applicant must have been employed by his/her current employer for minimum period of (6) months as at the date of application");
        }
        return ServiceException;
    }

    /**
     * 
     * @param source
     *            : List of Acceptable telephonic sources
     * @param val
     *            : List of Telephonic Sources provided by Applicant @ : Would throw ServiceException containing &lt;errorCode&gt;, &lt;fieldName&gt; and
     *            &lt;fieldValue&gt; if: <li>
     *            &lt;source&gt; is empty or null</li><li>&lt;val&gt; is empty or null</li><li>&lt;val&gt; is not avaiblabe in &lt;source&gt; <br/>
     *            <b>Suggestion:</b> Only telephone numbers obtained from selected electronic resources will be used to do confirmations.
     */
    public static ServiceException checkTelephonicConfirmationSources(List<String> source, List<String> val) {
        ServiceException ServiceException = checkIsNullOrEmpty("RUL001", "TELEPHONIC_CONVERSATION",
                "Is Null Or Empty", source);
        if (ServiceException == null)
            ServiceException = checkIsNullOrEmpty("RUL001", "TELEPHONIC_CONVERSATION", "Is Null Or Empty", val);
        if (ServiceException == null) {
            for (String value : val) {
                if (!source.contains(value))
                    ServiceException = new ServiceException("POL006", "TELEPHONIC_CONVERSATION",
                            "Only telephone numbers obtained from selected electronic resources will be used to do confirmations");
            }
        }
        return ServiceException;
    }

    /**
     * Checks for Disciplinary<br/>
     * <br/>
     * 
     * @param isDisciplinary
     *            : Is Applicant's identified / going through disciplinary process @ : Would throw ServiceException containing &lt;errorCode&gt;,
     *            &lt;fieldName&gt; and &lt;fieldValue&gt; if: <li>
     *            &lt;isDisciplinary&gt; is empty or null</li> <li>
     *            &lt;isDisciplinary&gt; is true</li><br/>
     * <br/>
     *            <b>Suggestion:</b> Applicants that are confirmed as currently going through or identified to be in a disciplinary process are declined for
     *            credit.
     */
    public static ServiceException checkDisciplinary(Boolean isDisciplinary) {
        ServiceException ServiceException = checkIsNullOrEmpty("RUL001", "DISCIPLINARY", "Is Null Or Empty",
                isDisciplinary);
        if (ServiceException == null)
            if (isDisciplinary)
                ServiceException = new ServiceException("POL044", "DISCIPLINARY",
                        "Applicants that are confirmed as currently going through or identified to be in a disciplinary process are declined for credit");
        return ServiceException;
    }

    /**
     * Checks Employment's Landline Number
     * 
     * @param isLandline
     *            : Wheter Employer has lanline number or not @ : Would throw ServiceException containing &lt;errorCode&gt;, &lt;fieldName&gt; and
     *            &lt;fieldValue&gt; if: <li>
     *            &lt;isLandline&gt; is empty or null</li> <li>
     *            &lt;isLandline&gt; is false</li><br/>
     * <br/>
     *            <b>Suggestion:</b> Only landline numbers are accepted for employment confirmation.
     */
    public static ServiceException checkEmploymentLandline(String landlineNumber) {
        return checkIsNullOrEmpty("RUL001", "LANDLINE_SOURCES", "Is Null Or Empty", landlineNumber);
    }

    /**
     * Checks No - Work, No - Pay value
     * 
     * @param source
     *            : Should contains value like "No Work", "No Pay"
     * @param val
     *            : Should be null / "" / "No Work" / "No Pay"
     * @throws ServiceException
     *             : Would throw ServiceException containing &lt;errorCode&gt;, &lt;fieldName&gt; and &lt;fieldValue&gt; if: <li>
     *             &lt;source&gt; is empty or null</li><li>&lt;val&gt; is empty or null</li> <li>
     *             &lt;source&gt; contains &lt;val&gt;</li><br/>
     * <br/>
     *             <b>Suggestion:</b> Applications that have been confirmed and identified as no work no pay employees.
     */
    public static ServiceException checkIsNoWorkNoPay(List<String> source, String val) {
        ServiceException ServiceException = null;
        if (ServiceException == null)
            if (source.contains(val))
                ServiceException = new ServiceException("POL008", "NO_WORK-NO_PAY",
                        "Applications that have been confirmed and identified as no work no pay employees");
        return ServiceException;
    }

    /**
     * Checks Irregular Pay Date
     * 
     * @param val
     *            : Should contain a list of Salary / Pay Date
     * @param payType
     *            : Salary / Pay Type i.e. MONTHLY, WEEKLY, FORTNIGHTLY
     * @throws ServiceException
     *             : Would throw ServiceException containing &lt;errorCode&gt;, &lt;fieldName&gt; and &lt;fieldValue&gt; if: <li>
     *             &lt;val&gt; is empty or null</li><li>&lt;payType&gt; is empty or null</li> <li>
     *             &lt;val&gt; is not regular</li><br/>
     * <br/>
     *             <b>Suggestion:</b> Irregular pay dates (paydays).
     */
    @SuppressWarnings("deprecation")
    public static ServiceException checkIrregularPayDates(List<Date> val, EWageFrequency frequency) {
        ServiceException ServiceException = checkIsNullOrEmpty("PAY_DATES", "Irregular Pay Dates",
                "Is Null Or Empty", val);

        if (ServiceException == null) {
            Collections.sort(val);

            if (frequency == EWageFrequency.MONTHLY) {
                int lastMonth = -1;
                int currentMonth = -1;
                int tmpCurrentMonth = -1;
                for (Date payDate : val) {
                    currentMonth = payDate.getMonth();
                    if (currentMonth != -1) {
                        tmpCurrentMonth = currentMonth;
                        if (currentMonth == 0) {
                            tmpCurrentMonth = 12;
                        }
                        if (lastMonth != (tmpCurrentMonth - 1)) {
                            ServiceException = new ServiceException("POL009", "PAY_DATES",
                                    "Irregular pay dates (paydays)");
                        }
                    }
                    lastMonth = currentMonth;
                }
            } else {
                Date lastPayDate = null;
                int MAX_DAYS = 0;
                if (frequency == EWageFrequency.WEEKLY) {
                    MAX_DAYS = 7;
                } else if (frequency == EWageFrequency.FORTNIGHTLY) {
                    MAX_DAYS = 15;
                }
                for (Date payDate : val) {
                    if (lastPayDate != null) {
                        long pdt = payDate.getTime();
                        long lpdt = lastPayDate.getTime();
                        int days = Integer.parseInt("" + ((pdt - lpdt) / (1000 * 60 * 60 * 24)));
                        if (days > MAX_DAYS)
                            ServiceException = new ServiceException("POL009", "PAY_DATES",
                                    "Irregular pay dates (paydays)");
                    }
                    lastPayDate = payDate;
                }
            }
        }
        return ServiceException;
    }

    /**
     * Checks BFS Approved Financial Institutions for Applicant's Bank Account
     * 
     * @param source
     *            : List of BFS Approved Financial Institutions
     * @param val
     *            : List of Applicant's Financial Institutions
     * @throws ServiceException
     *             : Would throw ServiceException containing &lt;errorCode&gt;, &lt;fieldName&gt; and &lt;fieldValue&gt; if: <li>
     *             &lt;source&gt; is empty or null</li><li>&lt;val&gt; is empty or null</li> <li>
     *             &lt;source&gt; does not contain &lt;val&gt;</li><br/>
     * <br/>
     *             <b>Suggestion:</b> The applicant must have a bank account with a BFS approved financial institution.
     */

    public static ServiceException checkBFSApprovedFinancialInstitutions(List<String> source, String val) {
        ServiceException ServiceException = checkIsNullOrEmpty("RUL001", "FINANCIAL_INSTITUTIONS",
                "Is Null Or Empty", source);
        if (ServiceException == null)
            ServiceException = checkIsNullOrEmpty("RUL001", "FINANCIAL_INSTITUTIONS", "Is Null Or Empty", val);

        if (ServiceException == null) {
            if (!source.contains(val))
                ServiceException = new ServiceException("POL010", "FINANCIAL_INSTITUTIONS",
                        "The applicant must have a bank account with a BFS approved financial institution");
        }
        return ServiceException;
    }

    /**
     * Checks Required Supporting Documents
     * 
     * @param source
     *            : List of all required documents
     * @param val
     *            : List of Documents provided by applicant @ : Would throw ServiceException containing &lt;errorCode&gt;, &lt;fieldName&gt; and
     *            &lt;fieldValue&gt; if: <li>
     *            &lt;source&gt; is empty or null</li><li>&lt;val&gt; is empty or null</li> <li>
     *            &lt;source&gt; does not contain &lt;val&gt;</li><br/>
     * <br/>
     *            <b>Suggestion:</b> Applicant must present all the required supporting documentation.
     */
    public static ServiceException checkRequiredSupportingDocuments(List<String> source, List<String> val) {
        ServiceException ServiceException = checkIsNullOrEmpty("RUL001", "DOCUMENTS", "Is Null Or Empty", source);
        if (ServiceException == null)
            ServiceException = checkIsNullOrEmpty("RUL001", "DOCUMENTS", "Is Null Or Empty", val);
        if (ServiceException == null) {
            for (String value : val) {
                if (!source.contains(value))
                    ServiceException = new ServiceException("POL011", "DOCUMENTS",
                            "Applicant must present all the required supporting documentation");
            }
        }
        return ServiceException;

    }

    /**
     * 
     * @param val
     *            : List of Payslips Date @ : Would throw ServiceException containing &lt;errorCode&gt;, &lt;fieldName&gt; and &lt;fieldValue&gt; if: <li>
     *            &lt;val&gt; is empty or null</li> <li>
     *            &lt;val&gt; is more than 31 days old</li><br/>
     * <br/>
     *            <b>Suggestion:</b> All payslips submitted must not be older than 31 days from the date of application.
     */
    public static ServiceException checkPayslipsDate(List<Date> val) {
        ServiceException ServiceException = checkIsNullOrEmpty("RUL001", "Payslip Date", "Is Null Or Empty", val);
        if (ServiceException == null) {
            for (Date payDate : val) {
                long pdt = payDate.getTime();
                long currentt = new Date().getTime();
                int days = Integer.parseInt("" + ((currentt - pdt) / (1000 * 60 * 60 * 24)));
                if (days > 31)
                    ServiceException = new ServiceException("POL012", "Payslip Date",
                            "All payslips submitted must not be older than 31 days from the date of application");
            }
        }
        return ServiceException;
    }

    /**
     * Checks Payslips should carry an official company stamp
     * 
     * @param source
     *            : List of all sources of Payslip which requires HR Stamp
     * @param val
     *            : Whether Payslip source belongs to the list
     * @param isPaySlipsCarryStamp
     *            : Whether All PaySlips Carry HR Stamp @ : Would throw ServiceException containing &lt;errorCode&gt;, &lt;fieldName&gt; and &lt;fieldValue&gt;
     *            if: <li>
     *            &lt;source&gt; is empty or null</li> <li>
     *            &lt;val&gt; is empty or null</li> <li>
     *            &lt;isPaySlipsCarryStamp&gt; is empty or null</li><li>
     *            &lt;val&gt; is in source list and &lt;isPaySlipsCarryStamp&gt; is false</li><br/>
     * <br/>
     *            <b>Suggestion:</b> Internet/intranet payslips, pay packets and envelopes are accepted provided they carry an official company stamp, which is
     *            approved by the applicants HR department.
     */
    public static ServiceException checkPayslipCarryStamp(List<String> source, String val,
            Boolean isPaySlipsCarryStamp) {
        ServiceException ServiceException = checkIsNullOrEmpty("RUL001", "Payslip Carry Official Stamp",
                "Is Null Or Empty", source);
        if (ServiceException == null)
            ServiceException = checkIsNullOrEmpty("RUL001", "Payslip Carry Official Stamp", "Is Null Or Empty",
                    val);
        if (ServiceException == null) {
            if (source.contains(val) && isPaySlipsCarryStamp == false) {
                checkIsNullOrEmpty("RUL001", "Payslip Carry Official Stamp", "Is Null Or Empty",
                        isPaySlipsCarryStamp);
                ServiceException = new ServiceException("POL013", "Payslip Carry Official Stamp",
                        "Internet/intranet payslips, pay packets and envelopes are accepted provided they carry an official company stamp, which is approved by the applicants HR department");
            }
        }
        return ServiceException;
    }

    /**
     * Checks Inconsistent Salary Dates
     * 
     * @param val
     *            : List of Salary Dates @ : Would throw ServiceException containing &lt;errorCode&gt;, &lt;fieldName&gt; and &lt;fieldValue&gt; if: <br/>
     *            <li>
     *            &lt;val&gt; is empty or null</li> <li>
     *            &lt;val&gt; size is less than 3.</li> <li>latest &lt;val&gt; is older than 31 days.</li> <b>Suggestion:</b> For applicants that have
     *            inconsistent recurring income (i.e. Commission, incentives, overtime etc.) the latest 3 payslips are required with the latest being no older
     *            than 31 days from the date of application
     */
    public static ServiceException checkPayslipsForInconsistentIncome(List<Date> val) {
        ServiceException ServiceException = checkIsNullOrEmpty("RUL001", "Payslip For Inconsistent Income",
                "Is Null Or Empty", val);
        if (ServiceException == null)
            if (val.size() < 3)
                ServiceException = new ServiceException("POL014", "Payslip For Inconsistent Income",
                        "For applicants that have inconsistent recurring income (i.e. Commission, incentives, overtime etc.) the latest 3 payslips are required with the latest being no older than 31 days from the date of application");
        if (ServiceException == null) {
            Collections.sort(val);
            Date lastPayslipDate = val.get(val.size() - 1);
            long pdt = lastPayslipDate.getTime();
            long currentt = new Date().getTime();
            int days = Integer.parseInt("" + ((currentt - pdt) / (1000 * 60 * 60 * 24)));
            if (days > 31)
                ServiceException = new ServiceException("POL014", "Payslip For Inconsistent Income",
                        "For applicants that have inconsistent recurring income (i.e. Commission, incentives, overtime etc.) the latest 3 payslips are required with the latest being no older than 31 days from the date of application");
        }
        return ServiceException;
    }

    /**
     * Checks validity of Pasylips of Persal Applicant
     * 
     * @param val
     *            : List Salary Dates @ : Would throw ServiceException containing &lt;errorCode&gt;, &lt;fieldName&gt; and &lt;fieldValue&gt; if: <br/>
     *            <li>&lt;val&gt; is empty or null</li> <li>&lt;val&gt; is less than 2</li> <li>latest &lt;val&gt; is older than 2 months</li>
     *            <b>Suggestion:</b> Persal applicants will be allowed to submit a pay-slip no older than 2 calendar months from application, as long as the
     *            most recent salary deposit is reflected on the bank statement. (Exception is that for Persal employees, BFS will accept the latest stamped
     *            original printout together with an original payslip not older than 90 days.)
     */
    public static ServiceException checkPayslipsOfPersalApplicant(List<Date> val) {
        ServiceException ServiceException = checkIsNullOrEmpty("RUL001", "Payslip Of Persal Applicant",
                "Is Null Or Empty", val);
        if (ServiceException == null) {
            Collections.sort(val);
            Date lastPayslipDate = val.get(val.size() - 1);
            long pdt = lastPayslipDate.getTime();
            long currentt = new Date().getTime();
            int days = Integer.parseInt("" + ((currentt - pdt) / (1000 * 60 * 60 * 24)));
            if (days > 62)
                ServiceException = new ServiceException("POL015", "Payslip Of Persal Applicant",
                        "Persal applicants will be allowed to submit a pay-slip no older than 2 calendar months from application, as long as the most recent salary deposit is reflected on the bank statement. (Exception is that for Persal employees, BFS will accept the latest stamped original printout together with an original payslip not older than 90 days.)");
        }
        return ServiceException;
    }

    /**
     * Checks all valid South African Documents
     * 
     * @param source
     *            : List of all south african documents
     * @param val
     *            : Provided list of South african documents by Applicant @ : Would throw ServiceException containing &lt;errorCode&gt;, &lt;fieldName&gt; and
     *            &lt;fieldValue&gt; if: <br/>
     *            <li>&lt;source&gt; is null or empty</li> <li>&lt;val&gt; is null or empty</li> <li>&lt;source&gt; doues not contain &lt;val&gt;</li>
     *            <b>Suggestion:</b> South African ID Documents
     */
    public static ServiceException checkSouthAfricanIDDocuments(List<String> source, List<String> val) {
        ServiceException ServiceException = checkIsNullOrEmpty("RUL001", "South African ID Documents",
                "Is Null Or Empty", source);
        if (ServiceException == null)
            ServiceException = checkIsNullOrEmpty("RUL001", "South African ID Documents", "Is Null Or Empty", val);
        if (ServiceException == null) {
            for (String value : val) {
                if (!source.contains(value))
                    ServiceException = new ServiceException("POL016", "South African ID Documents",
                            "South African ID Documents");
            }
        }
        return ServiceException;
    }

    /**
     * Checks / Confirms Visually the identity of an applicant
     * 
     * @param isIdentityConfirmed
     *            : Provide whether BFS Representative has visually confirmed the identity or not @ : Would throw ServiceException containing &lt;errorCode&gt;,
     *            &lt;fieldName&gt; and &lt;fieldValue&gt; if: <br/>
     *            <li>&lt;isIdentityConfirmed&gt; is emty or null</li> <li>
     *            &lt;isIdentityConfirmed&gt; is false</li> <b>Suggestion:</b> The Bayport representative will be required to visually confirm the identity of
     *            the applicant.
     */
    public static ServiceException checkVisuallyConfirmedIdentity(Boolean isIdentityConfirmed) {
        ServiceException ServiceException = checkIsNullOrEmpty("RUL001", "Visually Confirmed Identity",
                "Is Null Or Empty", isIdentityConfirmed);
        if (ServiceException == null)
            if (isIdentityConfirmed == false)
                ServiceException = new ServiceException("POL017", "Visually Confirmed Identity",
                        "The Bayport representative will be required to visually confirm the identity of the applicant.");
        return ServiceException;
    }

    /**
     * Checks Applicant is South African Burger / Citizen
     * 
     * @param source
     *            : List contains data like "SA Burger","SA Citizen"
     * @param val
     *            : Applicant' Status whether "SA Burger" so forth. @ : Would throw ServiceException containing &lt;errorCode&gt;, &lt;fieldName&gt; and
     *            &lt;fieldValue&gt; if: <br/>
     *            <li>&lt;source&gt; is null or empty</li> <li>&lt;val&gt; is null or empty</li> <li>&lt;source&gt; does not contain &lt;val&gt;</li>
     *            <b>Suggestion:</b> Only documents that indicate S.A Burger / S.A Citizen will be accepted.
     */
    public static ServiceException checkIsSABurgerOrCitizen(List<String> source, String val) {
        ServiceException ServiceException = checkIsNullOrEmpty("RUL001", "S.A. Burger / S.A. Citizen",
                "Is Null Or Empty", source);
        if (ServiceException == null)
            ServiceException = checkIsNullOrEmpty("RUL001", "S.A. Burger / S.A. Citizen", "Is Null Or Empty", val);
        if (ServiceException == null)
            if (!source.contains(val))
                ServiceException = new ServiceException("POL018", "S.A. Burger / S.A. Citizen",
                        "Only documents that indicate S.A Burger / S.A Citizen will be accepted.");
        return ServiceException;
    }

    /**
     * @param isTemporaryId
     *            : true if Temporary ID
     * @param expireDate
     *            : Expire Date of Temporary ID
     * @param isCertified
     *            : true if Temporary ID is certified
     * @param isHomeAffairsStamp
     *            : true if Temporary ID carries home affairs stamp. @ : Would throw ServiceException containing &lt;errorCode&gt;, &lt;fieldName&gt; and
     *            &lt;fieldValue&gt; if: <br/>
     * 
     *            <li>&lt;isTemporaryId&gt; is empty or null</li> <li>
     *            &lt;isTemporaryId&gt; is true and &lt;expireDate&gt; is empty or null</li> <li>&lt;isTemporaryId&gt; is true and &lt;isCertified&gt; is empty
     *            or null</li> <li>
     *            &lt;isTemporaryId&gt; is true and &lt;isHomeAffairsStamp&gt; is empty or null</li> <li>&lt;isTemporaryId&gt; is true and &lt;expireDate&gt; is
     *            before currentDate or &lt;isCertified&gt; is false or &lt;isHomeAffairsStamp&gt; is false</li> <b>Suggestion:</b> A certified temporary ID
     *            will be accepted if the validity date has not expired and it has a valid Home Affairs stamp
     */
    public static ServiceException checkValidityOfTemporaryID(Boolean isTemporaryId, Date expireDate,
            Boolean isCertified, Boolean isHomeAffairsStamp) {
        ServiceException ServiceException = checkIsNullOrEmpty("RUL001", "Temporary ID Validity",
                "Is Null Or Empty", isTemporaryId);
        if (ServiceException == null) {
            if (isTemporaryId) {
                checkIsNullOrEmpty("RUL001", "Temporary ID Validity", "Is Null Or Empty", expireDate);
                checkIsNullOrEmpty("RUL001", "Temporary ID Validity", "Is Null Or Empty", isCertified);
                checkIsNullOrEmpty("RUL001", "Temporary ID Validity", "Is Null Or Empty", isHomeAffairsStamp);
                if (expireDate.before(new Date()))
                    ServiceException = new ServiceException("POL019", "Temporary ID Validity",
                            "A certified temporary ID will be accepted if the validity date has not expired and it has a valid Home Affairs stamp");
                if (isCertified == false)
                    ServiceException = new ServiceException("POL019", "Temporary ID Validity",
                            "A certified temporary ID will be accepted if the validity date has not expired and it has a valid Home Affairs stamp");
                if (isHomeAffairsStamp == false)
                    ServiceException = new ServiceException("POL019", "Temporary ID Validity",
                            "A certified temporary ID will be accepted if the validity date has not expired and it has a valid Home Affairs stamp");
            }
        }
        return ServiceException;
    }

    /**
     * Checks Documents which are not accepted
     * 
     * @param source
     *            : List of not acceptable documents
     * @param val
     *            : Applicant's provided documents @ : Would throw ServiceException containing &lt;errorCode&gt;, &lt;fieldName&gt; and &lt;fieldValue&gt; if: <br/>
     *            <li>&lt;source&gt; is empty or null</li> <li>&lt;val&gt; is empty or null</li> <li>&lt;source&gt; contains &lt;val&gt;</li> <b>Suggestion:</b>
     *            Drivers' licenses or passports will not be accepted.
     */
    public static ServiceException checkIsLicenseOrPassport(List<String> source, List<String> val) {
        ServiceException ServiceException = checkIsNullOrEmpty("RUL001", "License or Passport", "Is Null Or Empty",
                source);
        if (ServiceException == null)
            ServiceException = checkIsNullOrEmpty("RUL001", "License or Passport", "Is Null Or Empty", val);
        if (ServiceException == null) {
            for (String value : val) {
                if (source.contains(value))
                    ServiceException = new ServiceException("POL020", "License or Passport",
                            "Drivers' licenses or passports will not be accepted.");
            }
        }
        return ServiceException;
    }

    /**
     * Check photocopies have been made of documents
     * 
     * @param source
     *            : List of all documents to be photocopied
     * @param val
     *            : List of documents photocopied @ : Would throw ServiceException containing &lt;errorCode&gt;, &lt;fieldName&gt; and &lt;fieldValue&gt; if: <br/>
     *            <li>&lt;source&gt; is empty or null</li> <li>&lt;val&gt; is empty or null</li> <li>&lt;source&gt; does not contain &lt;val&gt;</li>
     *            <b>Suggestion:</b> Once the documentation has been verified and found to be original and accurate a copy needs to be made.
     */
    public static ServiceException checkCopiesHaveBeenMade(List<String> source, List<String> val) {
        ServiceException ServiceException = checkIsNullOrEmpty("RUL001", "Copies of Documents", "Is Null Or Empty",
                source);
        if (ServiceException == null)
            ServiceException = checkIsNullOrEmpty("RUL001", "Copies of Documents", "Is Null Or Empty", val);
        if (ServiceException == null) {
            for (String value : val) {
                if (!source.contains(value))
                    ServiceException = new ServiceException("POL022", "Copies of Documents",
                            "Once the documentation has been verified and found to be original and accurate a copy needs to be made.");
            }
        }
        return ServiceException;
    }

    /**
     * Checks Bank Statements from Approved Financial Institutions for Retails
     * 
     * @param source
     *            : List of approved financial institutions for retails for bank statements
     * @param val
     *            : List of financial institutions of which bank statements have been provided @ : Would throw ServiceException containing &lt;errorCode&gt;,
     *            &lt;fieldName&gt; and &lt;fieldValue&gt; if: <br/>
     *            : Would throw ServiceException containing &lt;errorCode&gt;, &lt;fieldName&gt; and &lt;fieldValue&gt; if: <br/>
     *            <li>&lt;source&gt; is empty or null</li> <li>&lt;val&gt; is empty or null</li> <li>&lt;source&gt; does not contain &lt;val&gt;</li>
     *            <b>Suggestion:</b> Statements from only the following institutions will be accepted for Retail business. e.g. ABSA, FNB, SBSA, Nedcor,
     *            Capitec, TEBA, Mercantile Bank
     */
    public static ServiceException checkStatementsFromFinancialInstitutionsForRetail(List<String> source,
            List<String> val) {
        ServiceException ServiceException = checkIsNullOrEmpty("RUL001", "Bank Statements - Retail",
                "Is Null Or Empty", source);
        if (ServiceException == null)
            ServiceException = checkIsNullOrEmpty("RUL001", "Bank Statements - Retail", "Is Null Or Empty", val);
        if (ServiceException == null) {
            for (String value : val) {
                if (!source.contains(value))
                    ServiceException = new ServiceException("POL023", "Bank Statements - Retail",
                            "Statements from only the following institutions will be accepted for Retail business");
            }
        }
        return ServiceException;
    }

    /**
     * Checks Bank Statements from Approved Financial Institutions for Business
     * 
     * @param source
     *            : List of approved financial institutions for business for bank statements
     * @param val
     *            : List of financial institutions of which bank statements have been provided @ : Would throw ServiceException containing &lt;errorCode&gt;,
     *            &lt;fieldName&gt; and &lt;fieldValue&gt; if: <br/>
     *            <li>&lt;source&gt; is empty or null</li> <li>&lt;val&gt; is empty or null</li> <li>&lt;source&gt; does not contain &lt;val&gt;</li>
     *            <b>Suggestion:</b> Statements from only the following institutions will be accepted for Payroll business. e.g ABSA, FNB, SBSA, Nedcor,
     *            Capitec, Postbank, TEBA, Mercantile Bank
     */
    public static ServiceException checkStatementsFromFinancialInstitutionsForBusiness(List<String> source,
            List<String> val) {
        ServiceException ServiceException = checkIsNullOrEmpty("RUL001", "Bank Statements - Business",
                "Is Null Or Empty", source);
        if (ServiceException == null)
            ServiceException = checkIsNullOrEmpty("RUL001", "Bank Statements - Business", "Is Null Or Empty", val);
        if (ServiceException == null) {
            for (String value : val) {
                if (!source.contains(value))
                    ServiceException = new ServiceException("POL024", "Bank Statements - Business",
                            "Statements from only the following institutions will be accepted for Payroll business");
            }
        }
        return ServiceException;
    }

    /**
     * Checks required numbers of salaries in bank statement
     * 
     * @param numberOfSalariesRefletecdInBankStatement
     *            : Number of Salaries reflected in bank statements :
     * @param payType
     *            : Salary pay type (MONTHLY, WEEKLY) @ : Would throw ServiceException containing &lt;errorCode&gt;, &lt;fieldName&gt; and &lt;fieldValue&gt;
     *            if: <br/>
     *            <li>&lt;numberOfSalariesRefletecdInBankStatement&gt; is null or zero</li> <li>&lt;payType&gt; is null or empty</li> <li>
     *            &lt;payType&gt; is MONTHLY and &lt;numberOfSalariesRefletecdInBankStatement&gt; is less than 2</li> <li>&lt;payType&gt; is WEEKLY and
     *            &lt;numberOfSalariesRefletecdInBankStatement&gt; is less than 4</li> <b>Suggestion:</b> All statements need to reflect the (2) most recent
     *            salary deposits for a monthly applicant or the (4) most recent wage deposits for a weekly paid applicant
     */
    public static ServiceException checkStatementsReflectSalaryDeposits(
            Integer numberOfSalariesRefletecdInBankStatement, String payType) {
        ServiceException ServiceException = checkIsNullOrZero("RUL001", "Statements Reflect Salary Deposits",
                "Is Null Or Empty", numberOfSalariesRefletecdInBankStatement);
        if (ServiceException == null)
            ServiceException = checkIsNullOrEmpty("RUL001", "Statements Reflect Salary Deposits",
                    "Is Null Or Empty", payType);
        if (ServiceException == null)
            if (payType.equals("MONTHLY") && numberOfSalariesRefletecdInBankStatement < 2)
                ServiceException = new ServiceException("POL025", "Statements Reflect Salary Deposits",
                        "All statements need to reflect the (2) most recent salary deposits for a monthly applicant or the (4) most recent wage deposits for a weekly paid applicant");
        if (ServiceException == null)
            if (payType.equals("WEEKLY") && numberOfSalariesRefletecdInBankStatement < 4)
                ServiceException = new ServiceException("POL025", "Statements Reflect Salary Deposits",
                        "All statements need to reflect the (2) most recent salary deposits for a monthly applicant or the (4) most recent wage deposits for a weekly paid applicant");
        return ServiceException;
    }

    /**
     * Checks if Bank account is Joint account
     * 
     * @param isJointBankAccount
     *            : true is bank account is joint account @ : : Would throw ServiceException containing &lt;errorCode&gt;, &lt;fieldName&gt; and
     *            &lt;fieldValue&gt; if: <br/>
     *            <li>&lt;isJointBankAccount&gt; is null or empty</li> <li>
     *            &lt;isJointBankAccount&gt; is true</li> <b>Suggestion:</b> A joint Bank Account will not be accepted
     */
    public static ServiceException checkJointBankAccount(Boolean isJointBankAccount) {
        ServiceException ServiceException = checkIsNullOrEmpty("RUL001", "Joint Bank Account", "Is Null Or Empty",
                isJointBankAccount);
        if (ServiceException == null)
            if (isJointBankAccount)
                ServiceException = new ServiceException("POL026", "Joint Bank Account",
                        "A joint Bank Account will not be accepted");
        return ServiceException;
    }

    /**
     * Checks Name on Disbursement account and Debit Order account
     * 
     * @param nameOnDisbursementBankAccount
     *            : Name on Bank Account for Disbursement
     * @param nameOnDebitOrderAccount
     *            : Name on Bank Account for Debit Orders @ : Would throw ServiceException containing &lt;errorCode&gt;, &lt;fieldName&gt; and
     *            &lt;fieldValue&gt; if: <br/>
     *            <li>&lt;nameOnDisbursementBankAccount&gt; is null or empty</li> <li>&lt;nameOnDebitOrderAccount&gt; is null or empty</li> <li>
     *            &lt;nameOnDisbursementBankAccount&gt; does not match &lt;nameOnDebitOrderAccount&gt;</li> <b>Suggestion:</b> The Bank Account for disbursement
     *            and debit orders must be in the name of the applicant
     */
    public static ServiceException checkAccountHolderName(String nameOnDisbursementBankAccount,
            String nameOnDebitOrderAccount) {
        ServiceException ServiceException = checkIsNullOrEmpty("RUL001", "Account Holder Name", "Is Null Or Empty",
                nameOnDisbursementBankAccount);
        if (ServiceException == null)
            ServiceException = checkIsNullOrEmpty("RUL001", "Account Holder Name", "Is Null Or Empty",
                    nameOnDebitOrderAccount);
        if (ServiceException == null)
            if (!nameOnDisbursementBankAccount.equalsIgnoreCase(nameOnDebitOrderAccount))
                ServiceException = new ServiceException("POL027", "ACCOUNT_HOLDER",
                        "The Bank Account for disbursement and debit orders must be in the name of the applicant");
        return ServiceException;
    }

    /**
     * Check number of salary deposits dates for payroll applicant
     * 
     * @param val
     *            : List of Salary Deposit Dates @ : Would throw ServiceException containing &lt;errorCode&gt;, &lt;fieldName&gt; and &lt;fieldValue&gt; if: <br/>
     *            <li>&lt;val&gt; is null or empty</li> <li>&lt;val&gt; is older than 31 days; <b>Suggestion:</b> Only one recent salary deposit is required for
     *            a payroll applicant
     */
    public static ServiceException checkSalaryDepositForPayrollApplicant(List<Date> val) {
        ServiceException ServiceException = checkIsNullOrEmpty("RUL001", "Salary Deposit For Payroll Applicant",
                "Is Null Or Empty", val);
        if (ServiceException == null)
            if (val.size() < 1)
                ServiceException = new ServiceException("POL028", "Salary Deposit For Payroll Applicant",
                        "Only one recent salary deposit is required for a payroll applicant");
        if (ServiceException == null) {
            Collections.sort(val);
            Date lastPayslipDate = val.get(val.size() - 1);
            long pdt = lastPayslipDate.getTime();
            long currentt = new Date().getTime();
            int days = Integer.parseInt("" + ((currentt - pdt) / (1000 * 60 * 60 * 24)));
            if (days > 31)
                ServiceException = new ServiceException("POL028", "Salary Deposit For Payroll Applicant",
                        "Only one recent salary deposit is required for a payroll applicant");
        }
        return ServiceException;
    }

    /**
     * 
     * @param source
     * @param val
     *            @ : Would throw ServiceException containing &lt;errorCode&gt;, &lt;fieldName&gt; and &lt;fieldValue&gt; if: <br/>
     *            <b>Suggestion:</b> All statements must be printed on branded bank stationery, Where the stationery is not branded an original and dated bank
     *            stamp must be present.
     */
    public static ServiceException checkStatementsPrinting(List<String> source, List<String> val) {
        ServiceException ServiceException = checkIsNullOrEmpty("RUL001", "Statements Printed On",
                "Is Null Or Empty", source);
        if (ServiceException == null)
            ServiceException = checkIsNullOrEmpty("RUL001", "Statements Printed On", "Is Null Or Empty", val);
        if (ServiceException == null) {
            for (String value : val) {
                if (!source.contains(value))
                    ServiceException = new ServiceException("POL029", "Statements Printed On",
                            "All statements must be printed on branded bank stationery, Where the stationery is not branded an original and dated bank stamp must be present.");
            }
        }
        return ServiceException;
    }

    /**
     * 
     * @param nameVisibility
     * @param surnameVisibility
     *            @ : Would throw ServiceException containing &lt;errorCode&gt;, &lt;fieldName&gt; and &lt;fieldValue&gt; if: <br/>
     *            <li>&lt;nameVisibility&gt; is empty or null</li> <li>
     *            &lt;surnameVisibility&gt; is empty or null<li> <li>
     *            &lt;nameVisibility&gt; is false or &lt;surnameVisibility&gt; is false</li> <b>Suggestion:</b> The applicant's surname and account number must
     *            be clearly visible on the supplied bank statement. Where the surname does not reflect, a cross-reference of information needs to be done with
     *            the applicant's payslip to ensure that the bank statement is accurate
     */
    public static ServiceException checkNameSurnameVisibility(Boolean nameVisibility, Boolean surnameVisibility) {
        ServiceException ServiceException = checkIsNullOrEmpty("RUL001", "Name and Surname Visibility",
                "Is Null Or Empty", nameVisibility);
        if (ServiceException == null)
            ServiceException = checkIsNullOrEmpty("RUL001", "Name and Surname Visibility", "Is Null Or Empty",
                    surnameVisibility);
        if (ServiceException == null)
            if (nameVisibility == false)
                ServiceException = new ServiceException("POL030", "Name and Surname Visibility",
                        "The applicant's surname and account number must be clearly visible on the supplied bank statement. Where the surname does not reflect, a cross-reference of information needs to be done with the applicant's payslip to ensure that the bank statement is accurate");
        if (ServiceException == null)
            if (surnameVisibility == false)
                ServiceException = new ServiceException("POL030", "Name and Surname Visibility",
                        "The applicant's surname and account number must be clearly visible on the supplied bank statement. Where the surname does not reflect, a cross-reference of information needs to be done with the applicant's payslip to ensure that the bank statement is accurate");
        return ServiceException;
    }

    /**
     * Checks valid deposit mode of salary
     * 
     * @param source
     *            : List of all acceptable salary deposit mode
     * @param val
     *            : List of all modes of applicant' salary deposit @ : Would throw ServiceException containing &lt;errorCode&gt;, &lt;fieldName&gt; and
     *            &lt;fieldValue&gt; if: <br/>
     *            <li>&lt;source&gt; is null or empty.</li> <li>&lt;val&gt; is null or empty.</li> <li>&lt;source&gt; does not contain &lt;val&gt;.</li>
     *            <b>Suggestion:</b>The deposit must be an EFT or direct deposit by the employer. Cash and cheque deposits will not be considered a salary
     *            payment
     */
    public static ServiceException checkSalaryDeposit(List<String> source, List<String> val) {
        ServiceException ServiceException = checkIsNullOrEmpty("RUL001", "Salary Deposit", "Is Null Or Empty",
                source);
        if (ServiceException == null)
            ServiceException = checkIsNullOrEmpty("RUL001", "Salary Deposit", "Is Null Or Empty", val);
        if (ServiceException == null) {
            for (String value : val) {
                if (!source.contains(value))
                    ServiceException = new ServiceException("POL031", "Salary Deposit",
                            "The deposit must be an EFT or direct deposit by the employer. Cash and cheque deposits will not be considered a salary payment");
            }
        }
        return ServiceException;
    }

    /**
     * Checks Account type of an applicant.
     * 
     * @param source
     *            : List of all acceptable bank account types
     * @param val
     *            : List of applicant's bank account types @ : Would throw ServiceException containing &lt;errorCode&gt;, &lt;fieldName&gt; and
     *            &lt;fieldValue&gt; if: <br/>
     *            <li>&lt;source&gt; is null or empty.</li> <li>&lt;val&gt; is null or empty.</li> <li>&lt;source&gt; does not contain &lt;val&gt;.</li>
     *            <b>Suggestion:</b> Only cheque, savings and transmission accounts will be considered as valid accounts by BFS.
     */
    public static ServiceException checkValidAccount(List<String> source, List<String> val) {
        ServiceException ServiceException = checkIsNullOrEmpty("RUL001", "Valid Accounts", "Is Null Or Empty",
                source);
        if (ServiceException == null)
            ServiceException = checkIsNullOrEmpty("RUL001", "Valid Accounts", "Is Null Or Empty", val);
        if (ServiceException == null) {
            for (String value : val) {
                if (!source.contains(value))
                    ServiceException = new ServiceException("POL032", "Valid Accounts",
                            "Only cheque, savings and transmission accounts will be considered as valid accounts by BFS.");
            }
        }
        return ServiceException;
    }

    /**
     * Checks Documents for existing clients
     * 
     * @param source
     *            : List of all required documents for existing client.
     * @param val
     *            : List of documents provided by an applicant @ : Would throw ServiceException containing &lt;errorCode&gt;, &lt;fieldName&gt; and
     *            &lt;fieldValue&gt; if: <br/>
     *            <li>&lt;source&gt; is null or empty.</li> <li>&lt;val&gt; is null or empty.</li> <li>&lt;source&gt; does not contain &lt;val&gt;.</li>
     *            <b>Suggestion:</b> Bayport Financial Services does not require the above supporting documentation when a credit transaction is concluded with
     *            an existing applicant
     */
    public static ServiceException checkDocumentsForExistingClient(List<String> source, List<String> val) {
        ServiceException ServiceException = checkIsNullOrEmpty("RUL001", "Documents For Existing Client",
                "Is Null Or Empty", source);
        if (ServiceException == null)
            ServiceException = checkIsNullOrEmpty("RUL001", "Documents For Existing Client", "Is Null Or Empty",
                    val);
        if (ServiceException == null) {
            for (String value : val) {
                if (!source.contains(value))
                    ServiceException = new ServiceException("POL033", "Documents For Existing Client",
                            "Bayport Financial Services does not require the above supporting documentation when a credit transaction is concluded with an existing applicant");
            }
        }
        return ServiceException;
    }

    /**
     * Checks debit order facility for Mzanzi Accounts
     * 
     * @param isMzanziAccount
     *            : True if applicant's account is Mzanzi Account
     * @param debitOrderFacility
     *            : True if account has debit order facility @ : Would throw ServiceException containing &lt;errorCode&gt;, &lt;fieldName&gt; and
     *            &lt;fieldValue&gt; if: <br/>
     *            <li>&lt;isMzanziAccount&gt; is null or empty.</li> <li>
     *            &lt;debitOrderFacility&gt; is null or empty.</li> <li>
     *            &lt;isMzanziAccount&gt; is true and &lt;debitOrderFacility&gt; is false.</li> <b>Suggestion:</b> Mzanzi account holders will not be eligible
     *            unless the account has a Debit Order facility
     */
    public static ServiceException checkDebitOrderFacilityForMzanziAccounts(Boolean isMzanziAccount,
            Boolean debitOrderFacility) {
        ServiceException ServiceException = checkIsNullOrEmpty("RUL001", "Debit Order Facility For Mzanzi Accounts",
                "Is Null Or Empty", isMzanziAccount);
        if (ServiceException == null)
            ServiceException = checkIsNullOrEmpty("RUL001", "Debit Order Facility For Mzanzi Accounts",
                    "Is Null Or Empty", debitOrderFacility);
        if (ServiceException == null)
            if (isMzanziAccount && debitOrderFacility == false)
                ServiceException = new ServiceException("POL034", "Debit Order Facility For Mzanzi Accounts",
                        "Mzanzi account holders will not be eligible unless the account has a Debit Order facility");
        return ServiceException;
    }

    /**
     * Chekcs NAEDO compliant accounts
     * 
     * @param isRetail
     *            : True if retail agreements
     * @param isNAEDOCompliant
     *            : True if NAEDO Compliant @ : Would throw ServiceException containing &lt;errorCode&gt;, &lt;fieldName&gt; and &lt;fieldValue&gt; if: <br/>
     *            <li>&lt;isRetail&gt; is null or empty.</li> <li>
     *            &lt;isNAEDOCompliant&gt; is null or empty.</li> <li>
     *            &lt;isRetail&gt; is true and &lt;isNAEDOCompliant&gt; is false.</li> <b>Suggestion:</b> Only NAEDO compliant bank accounts will be accepted on
     *            retail agreements
     */
    public static ServiceException checkNAEDOCompliant(Boolean isRetail, Boolean isNAEDOCompliant) {
        ServiceException ServiceException = checkIsNullOrEmpty("RUL001", "NAEDO Compliant Accounts",
                "Is Null Or Empty", isRetail);
        if (ServiceException == null)
            ServiceException = checkIsNullOrEmpty("RUL001", "NAEDO Compliant Accounts", "Is Null Or Empty",
                    isNAEDOCompliant);
        if (ServiceException == null)
            if (isRetail && isNAEDOCompliant == false)
                ServiceException = new ServiceException("POL035", "NAEDO Compliant Accounts",
                        "Only NAEDO compliant bank accounts will be accepted on retail agreements");
        return ServiceException;
    }

    /**
     * Checks Completion of application form.
     * 
     * @param : True if Application Form is Completed. @ : Would throw ServiceException containing &lt;errorCode&gt;, &lt;fieldName&gt; and &lt;fieldValue&gt;
     *        if: <br/>
     *        <li>&lt;isApplicationFormCompleted&gt; is null or empty.</li> <li>
     *        &lt;isApplicationFormCompleted&gt; is false.</li> <b>Suggestion:</b> The applicant must complete the application form.
     */
    public static ServiceException checkApplicantionForm(Boolean isApplicationFormCompleted) {
        ServiceException ServiceException = checkIsNullOrEmpty("RUL001", "Application Form", "Is Null Or Empty",
                isApplicationFormCompleted);
        if (ServiceException == null)
            if (isApplicationFormCompleted == false)
                ServiceException = new ServiceException("POL036", "Application Form",
                        "The applicant must complete the application form");
        return ServiceException;
    }

    /**
     * Checks Signature on application form.
     * 
     * @param isSignatureCompleted
     *            : True if signature is on all areas indicated on the contract. @ : Would throw ServiceException containing &lt;errorCode&gt;,
     *            &lt;fieldName&gt; and &lt;fieldValue&gt; if: <br/>
     *            <li>&lt;isSignatureCompleted&gt; is null or empty</li> <li>
     *            &lt;isSignatureCompleted&gt; is false</li> <b>Suggestion:</b> The applicant must sign all areas indicated on the contract
     */
    public static ServiceException checkSignature(Boolean isSignatureCompleted) {
        ServiceException ServiceException = checkIsNullOrEmpty("RUL001", "Application Form Signature",
                "Is Null Or Empty", isSignatureCompleted);
        if (ServiceException == null)
            if (isSignatureCompleted == false)
                ServiceException = new ServiceException("POL037", "Application Form Signature",
                        "The applicant must sign all areas indicated on the contract");
        return ServiceException;
    }

    /**
     * Checks Signature if applicant is Common law spouse.
     * 
     * @param isCommonLawSpouse
     *            : True if common law spouse
     * @param isSpouseSignatureCompleted
     *            : True if spouse signature completed @ : Would throw ServiceException containing &lt;errorCode&gt;, &lt;fieldName&gt; and &lt;fieldValue&gt;
     *            if: <br/>
     *            <li>&lt;isCommonLawSpouse&gt; is null or empty.</li> <li>
     *            &lt;isCommonLawSpouse&gt; is true and &lt;isSpouseSignatureCompleted&gt; is null or empty. or &lt;isSpouseSignatureCompleted&gt; is false.</li>
     *            <b>Suggestion:</b> Where the applicant has a Common Law spouse, Bayport will require spousal consent in the form of a signature on the
     *            application form
     */
    public static ServiceException checkSpouseSignature(Boolean isCommonLawSpouse,
            Boolean isSpouseSignatureCompleted) {
        ServiceException ServiceException = checkIsNullOrEmpty("RUL001", "Spouse Signature", "Is Null Or Empty",
                isCommonLawSpouse);
        if (ServiceException == null)
            if (isCommonLawSpouse == true) {
                ServiceException = checkIsNullOrEmpty("RUL001", "Spouse Signature", "Is Null Or Empty",
                        isSpouseSignatureCompleted);
                if (ServiceException == null)
                    if (isSpouseSignatureCompleted == false)
                        ServiceException = new ServiceException("POL038", "Spouse Signature",
                                "Where the applicant has a Common Law spouse, Bayport will require spousal consent in the form of a signature on the application form");
            }
        return ServiceException;
    }

    /**
     * Checks Left Tumb Print if Applicant is Illiterate
     * 
     * @param isIllitrate
     *            : True if applicant is Illiterate
     * @param isLeftThumbImpression
     *            : True if Left Thumb impression has been taken. @ : Would throw ServiceException containing &lt;errorCode&gt;, &lt;fieldName&gt; and
     *            &lt;fieldValue&gt; if: <br/>
     *            <li>&lt;isIllitrate&gt; is null or empty.</li> <li>
     *            &lt;isIllitrate&gt; is true and &lt;isLeftThumbImpression&gt; is null or empty. or &lt;isLeftThumbImpression&gt; is false.</li>
     *            <b>Suggestion:</b> An illiterate applicant (an applicant who cannot read or write) must indicate their approval and acceptance of the original
     *            application form / agreement by signing a clear and legible left thumb print
     */
    public static ServiceException checkSignatureOfIlliterate(Boolean isIllitrate, Boolean isLeftThumbImpression) {
        ServiceException ServiceException = checkIsNullOrEmpty("RUL001", "Left Thumb Print", "Is Null Or Empty",
                isIllitrate);
        if (ServiceException == null)
            if (isIllitrate == true) {
                ServiceException = checkIsNullOrEmpty("RUL001", "Left Thumb Print", "Is Null Or Empty",
                        isLeftThumbImpression);
                if (ServiceException == null)
                    if (isLeftThumbImpression == false)
                        ServiceException = new ServiceException("POL039", "Left Thumb Print",
                                "An illiterate applicant (an applicant who cannot read or write) must indicate their approval and acceptance of the original application form / agreement by signing a clear and legible left thumb print");
            }
        return ServiceException;
    }

    /**
     * Checks: Proper steps has been taken if applicant is visually impaired
     * 
     * @param isVisuallyImpaired
     *            : True if applicant is visually impaired
     * @param isReadAndWitness
     *            : True if Bayport Employee has read out the details @ : Would throw ServiceException containing &lt;errorCode&gt;, &lt;fieldName&gt; and
     *            &lt;fieldValue&gt; if: <br/>
     *            <li>&lt;isVisuallyImpaired&gt; is null or empty.</li> <li>
     *            &lt;isVisuallyImpaired&gt; is true and &lt;isReadAndWitness&gt; is null or empty. or &lt;isReadAndWitness&gt; is false.</li> <b>Suggestion:
     *            </b>A visually impaired applicant will be assisted by a Bayport Employee who will read out the details to the applicant in full, where after
     *            the applicant will sign the application form with another witness nominated by the applicant
     */
    public static ServiceException checkApplicationForVisullayImpaired(Boolean isVisuallyImpaired,
            Boolean isReadAndWitness) {
        ServiceException ServiceException = checkIsNullOrEmpty("RUL001", "Visullay Impaired", "Is Null Or Empty",
                isVisuallyImpaired);
        if (ServiceException == null)
            if (isVisuallyImpaired == true) {
                ServiceException = checkIsNullOrEmpty("RUL001", "Visullay Impaired", "Is Null Or Empty",
                        isReadAndWitness);
                if (ServiceException == null)
                    if (isReadAndWitness == false)
                        ServiceException = new ServiceException("POL040", "Visullay Impaired",
                                "A visually impaired applicant will be assisted by a Bayport Employee who will read out the details to the applicant in full, where after the applicant will sign the application form with another witness nominated by the applicant");
            }
        return ServiceException;
    }

    /**
     * Checks: Proper steps has been taken if applicant is Auditory impaired
     * 
     * @param isAuditoryImpaired
     *            : True if applicant is Auditory impaired
     * @param isReadAndWitness
     *            : True Applicant has read the application form in full and indicated their acceptance. @ : Would throw ServiceException containing
     *            &lt;errorCode&gt;, &lt;fieldName&gt; and &lt;fieldValue&gt; if: <br/>
     *            <li>&lt;isAuditoryImpaired&gt; is null or empty.</li> <li>
     *            &lt;isAuditoryImpaired&gt; is true and &lt;isReadAndWitness&gt; is null or empty. or &lt;isReadAndWitness&gt; is false.</li> <b>Suggestion:
     *            </b>An auditory impaired applicant must read the application form in full and indicate their acceptance of the original application
     *            form/agreement by means of a signature
     */
    public static ServiceException checkApplicationForAuditoryImpaired(Boolean isAuditoryImpaired,
            Boolean isReadAndWitness) {
        ServiceException ServiceException = checkIsNullOrEmpty("RUL001", "Auditory Impaired", "Is Null Or Empty",
                isAuditoryImpaired);
        if (ServiceException == null)
            if (isAuditoryImpaired == true) {
                ServiceException = checkIsNullOrEmpty("RUL001", "Auditory Impaired", "Is Null Or Empty",
                        isReadAndWitness);
                if (ServiceException == null)
                    if (isReadAndWitness == false)
                        ServiceException = new ServiceException("POL041", "Auditory Impaired",
                                "An auditory impaired applicant must read the application form in full and indicate their acceptance of the original application form/agreement by means of a signature");
            }
        return ServiceException;
    }

    /**
     * Checks Bayport Representative Signed as a Witness
     * 
     * @param isBayportRepesentativeSignAsWitness
     *            : True if Bayport Representative Signed as a Witness @ : Would throw ServiceException containing &lt;errorCode&gt;, &lt;fieldName&gt; and
     *            &lt;fieldValue&gt; if: <br/>
     *            <li>&lt;isBayportRepesentativeSignAsWitness&gt; is null or empty</li> <li>&lt;isBayportRepesentativeSignAsWitness&gt; is false</li>
     *            <b>Suggestion: </b>A Bayport representative must sign as a witness to the above
     */
    public static ServiceException checkWitnessFromBayport(Boolean isBayportRepesentativeSignAsWitness) {
        ServiceException ServiceException = checkIsNullOrEmpty("RUL001", "Witness From Bayport", "Is Null Or Empty",
                isBayportRepesentativeSignAsWitness);
        if (ServiceException == null)
            if (isBayportRepesentativeSignAsWitness == false)
                ServiceException = new ServiceException("POL042", "Witness From Bayport",
                        "A Bayport representative must sign as a witness to the above");
        return ServiceException;
    }

    /**
     * Checks signature near to alterations
     * 
     * @param isAlterations
     *            : True is application form has alterations
     * @param isSignature
     *            : True if alterations has been signed @ : Would throw ServiceException containing &lt;errorCode&gt;, &lt;fieldName&gt; and &lt;fieldValue&gt;
     *            if: <br/>
     *            <li>&lt;isAlterations&gt; is null or empty.</li> <li>
     *            &lt;isAlterations&gt; is true and &lt;isSignature&gt; is null or empty. or &lt;isSignature&gt; is false.</li> <b>Suggestion: </b>Any
     *            alteration/s needs to be signed by the applicant
     */
    public static ServiceException checkAlterationsSignature(boolean isAlterations, boolean isSignature) {
        ServiceException ServiceException = checkIsNullOrEmpty("RUL001", "Alterations Signature",
                "Is Null Or Empty", isAlterations);
        if (ServiceException == null)
            if (isAlterations == true) {
                ServiceException = checkIsNullOrEmpty("RUL001", "Alterations Signature", "Is Null Or Empty",
                        isSignature);
                if (ServiceException == null)
                    if (isSignature == false)
                        ServiceException = new ServiceException("POL043", "Alterations Signature",
                                "Any alteration/s needs to be signed by the applicant");
            }
        return ServiceException;
    }
}