예제 #1
0
        internal static List <string> ValidateEachRow(this ImportFileDetail importFileDetail)
        {
            List <string> errorDetails = new List <string>();

            errorDetails.Add(importFileDetail.ValidateFirstName());
            errorDetails.Add(importFileDetail.ValidateLastName());
            errorDetails.Add(importFileDetail.ValidateAnnualIncome());
            errorDetails.Add(importFileDetail.ValidateSuperRate());
            errorDetails.Add(importFileDetail.ValidateMonthStarting());
            return(errorDetails.Where(errDetail => !string.IsNullOrEmpty(errDetail)).ToList());
        }
예제 #2
0
        internal static string ValidateAnnualIncome(this ImportFileDetail importFileDetail)
        {
            decimal annualIncome;
            string  errorMessage = string.Empty;

            if (decimal.TryParse(importFileDetail.AnnualIncomeString.Replace(",", string.Empty).Replace("$", string.Empty),
                                 out annualIncome))
            {
                importFileDetail.AnnualIncome = annualIncome;
            }
            else
            {
                importFileDetail.IsValid = false;
                errorMessage             = @"Value for Annual Income is not a valid decimal";
            }
            return(errorMessage);
        }
예제 #3
0
        internal static string ValidateMonthStarting(this ImportFileDetail importFileDetail)
        {
            bool   isValidMonthStarting = false;
            string errorMessage         = string.Empty;
            string tempMonthStarting    = importFileDetail.MonthStarting.Replace(" ", String.Empty).Trim().ToLower();

            foreach (MonthlyRange monthlyRange in Enum.GetValues(typeof(MonthlyRange)))
            {
                if (GetEnumDescription(monthlyRange) == tempMonthStarting)
                {
                    isValidMonthStarting = true;
                    break;
                }
            }

            if (!isValidMonthStarting)
            {
                importFileDetail.IsValid = false;
                errorMessage             = @"Value for Month Starting is not valid";
            }
            return(errorMessage);
        }
예제 #4
0
        internal static string ValidateSuperRate(this ImportFileDetail importFileDetail)
        {
            decimal superRate;
            string  errorMessage = string.Empty;
            // Remove % character from super rate input
            string tempSuperRate = importFileDetail.SuperRateString.Replace("%", string.Empty);

            if (decimal.TryParse(tempSuperRate, out superRate))
            {
                importFileDetail.SuperRate = superRate;

                if (importFileDetail.SuperRate < 0 || importFileDetail.SuperRate > 50)
                {
                    errorMessage = @"Value for Super Rate must be between 0 and 50%";
                }
            }
            else
            {
                importFileDetail.IsValid = false;
                errorMessage             = @"Value for Super Rate is not a valid decimal";
            }
            return(errorMessage);
        }
예제 #5
0
 internal static string ValidateLastName(this ImportFileDetail importFileDetail)
 {
     return(string.IsNullOrEmpty(importFileDetail.LastName) ? @"Value for Last Name cannot be blank" : string.Empty);
 }
예제 #6
0
 public static string FormatPayslipOutput(this ImportFileDetail importFileDetail)
 {
     return(importFileDetail.FirstName + " " + importFileDetail.LastName + ',' + importFileDetail.MonthStarting + "," +
            importFileDetail.GrossMonthlyIncome.ToString() + "," + importFileDetail.IncomeTax.ToString() + "," +
            importFileDetail.NetIncome.ToString() + "," + importFileDetail.SuperDeduction.ToString());
 }
예제 #7
0
 internal static void CalculateSuperDeduction(this ImportFileDetail importFileDetail)
 {
     importFileDetail.SuperDeduction = decimal.Round((importFileDetail.GrossMonthlyIncome * (importFileDetail.SuperRate / 100)), 0);
 }
예제 #8
0
 internal static void CalculateNetIncome(this ImportFileDetail importFileDetail)
 {
     importFileDetail.NetIncome = decimal.Round((importFileDetail.GrossMonthlyIncome - importFileDetail.IncomeTax), 0);
 }
예제 #9
0
 internal static void CalculateIncomeTax(this ImportFileDetail importFileDetail, IncomeTaxDetail incomeTaxDetail)
 {
     importFileDetail.IncomeTax = decimal.Round(((incomeTaxDetail.TaxOnIncome
                                                  + (importFileDetail.AnnualIncome - (incomeTaxDetail.LowerLimit - 1)) * incomeTaxDetail.TaxPerDollar) / 12), 0);
 }
예제 #10
0
 internal static void CalculateGrossMonthlyIncome(this ImportFileDetail importFileDetail)
 {
     importFileDetail.GrossMonthlyIncome = decimal.Round((importFileDetail.AnnualIncome / 12), 0);
 }