Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 15 of 15

Thread: payroll-retrobaseSalary issue

  1. #1
    Junior Member
    Join Date
    Jul 2013
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default payroll-retrobaseSalary issue

    I am having a doubt about how to fix and what could be the code to generate a retroActive salary case in payroll generation.Upto last year(2013) it was working fine.Now it is 2014 and i am stuck as i am new to java.

    The system is computing every value in yearly basis,but the inputs are in monthly basis.


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    6,329
    My Mood
    Mellow
    Thanks
    253
    Thanked 781 Times in 766 Posts

    Default Re: payroll-retrobaseSalary issue

    Show the code, especially the part that generates the "retroActive salary case," and explain the problem better. Is the salary computed from a start date to an end date, and now you have to update the computation for crossing a year boundary?

  3. #3
    Junior Member
    Join Date
    Jul 2013
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: payroll-retrobaseSalary issue

    This is the code for checking whether the employee is retro or not? please check
    public static boolean isRetroActive(Calendar currDate, Date hireDate, int finStartMonth) {
    Calendar hireDtCal = Calendar.getInstance();
    hireDtCal.setTime(hireDate);
    // Zero out the hour, minute, second, and millisecond
    hireDtCal.set(Calendar.HOUR_OF_DAY, 0);
    hireDtCal.set(Calendar.MINUTE, 0);
    hireDtCal.set(Calendar.SECOND, 0);
    hireDtCal.set(Calendar.MILLISECOND, 0);

    int currMonth = currDate.get(Calendar.MONTH);
    int currYear = currDate.get(Calendar.YEAR);
    int currDay = currDate.get(Calendar.DAY_OF_MONTH);
    int hireDay = hireDtCal.get(Calendar.DAY_OF_MONTH);
    int hireMonth = hireDtCal.get(Calendar.MONTH);
    int hireYear = hireDtCal.get(Calendar.YEAR);

    if(currYear == hireYear && currMonth == hireMonth + 1 && hireDay >= currDay) {
    return true;
    }
    else if(finStartMonth != 1 && currYear == hireYear + 1 && currMonth == 0 && hireDay >= currDay){
    return true;
    }

    return false;
    }

    --- Update ---

    The payroll is executed for every month on 15th ,if an employee join on 16-31 of a month then it is retroactive .

    --- Update ---

    i need some help cause i am not having much time to fix this code.Anyone please help?

  4. #4
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    6,329
    My Mood
    Mellow
    Thanks
    253
    Thanked 781 Times in 766 Posts

    Default Re: payroll-retrobaseSalary issue

    Welcome to the Forum! Please read this topic to learn how to post your code correctly along with other useful info for newcomers.

  5. #5
    Junior Member
    Join Date
    Jul 2013
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: payroll-retrobaseSalary issue

    This is the code for checking whether the employee is retro or not? please check
     
    public static boolean isRetroActive(Calendar currDate, Date hireDate, int finStartMonth) {
    Calendar hireDtCal = Calendar.getInstance();
    hireDtCal.setTime(hireDate);
    // Zero out the hour, minute, second, and millisecond
    hireDtCal.set(Calendar.HOUR_OF_DAY, 0);
    hireDtCal.set(Calendar.MINUTE, 0);
    hireDtCal.set(Calendar.SECOND, 0);
    hireDtCal.set(Calendar.MILLISECOND, 0);
     
    int currMonth = currDate.get(Calendar.MONTH);
    int currYear = currDate.get(Calendar.YEAR);
    int currDay = currDate.get(Calendar.DAY_OF_MONTH);
    int hireDay = hireDtCal.get(Calendar.DAY_OF_MONTH);
    int hireMonth = hireDtCal.get(Calendar.MONTH);
    int hireYear = hireDtCal.get(Calendar.YEAR);
     
    if(currYear == hireYear && currMonth == hireMonth + 1 && hireDay >= currDay) {
    return true;
    }
    else if(finStartMonth != 1 && currYear == hireYear + 1 && currMonth == 0 && hireDay >= currDay){
    return true;
    }
     
    return false;
    }
     
    --- Update ---
    The payroll is executed for every month on 15th ,if an employee join on 16-31 of a month then it is retroactive .

    --- Update ---

    i need some help cause i am not having much time to fix this code.Anyone please help?

  6. #6
    Member
    Join Date
    Oct 2013
    Location
    United Kingdom
    Posts
    62
    Thanks
    1
    Thanked 4 Times in 4 Posts

    Default Re: payroll-retrobaseSalary issue

    Hi, We have almost understood the logic. But could you give an example to explain what exactly the program should do?
    What value does finStartMonth holds?
    If the logic is simple i.e. "joining date 1-15 is non-retroactive and joining date 16-31 is retroactive", then why is current date details are stored and how the comparision is performed in your code.
    Thanks and regards,
    Sambit Swain

  7. #7
    Junior Member
    Join Date
    Jul 2013
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: payroll-retrobaseSalary issue

    Thank you Sambit for your reply,let me explain i have not created this project ,i need to rectify the code only.'finstartMonth' means starting month.In JAVA,'0' stands for january. Here is the code where calculation is executed.
    package com.openhr.taxengine;
     
    import java.util.ArrayList;
    import java.util.Calendar;
    import java.util.Date;
    import java.util.HashMap;
    import java.util.List;
    import java.util.Map;
     
    import com.openhr.common.PayhumConstants;
    import com.openhr.company.Company;
    import com.openhr.data.Benefit;
    import com.openhr.data.Branch;
    import com.openhr.data.ConfigData;
    import com.openhr.data.EmpBankAccount;
    import com.openhr.data.EmpPayrollMap;
    import com.openhr.data.Employee;
    import com.openhr.data.EmployeeBonus;
    import com.openhr.data.EmployeePayroll;
    import com.openhr.data.Payroll;
    import com.openhr.data.PayrollDate;
    import com.openhr.data.TypesData;
    import com.openhr.factories.BenefitFactory;
    import com.openhr.factories.ConfigDataFactory;
    import com.openhr.factories.EmpBankAccountFactory;
    import com.openhr.factories.EmpPayTaxFactroy;
    import com.openhr.factories.PayrollFactory;
    import com.util.payhumpackages.PayhumUtil;
     
    public class TaxEngine {
    	private Company comp;
    	private Branch branch;
    	private List<Employee> activeEmpList;
    	private List<Employee> inActiveEmpList;
     
    	private Map<Employee, EmployeePayroll> testMap;
     
    	private Double prevNetPay = 0D;
    	private Double prevTaxAmt = 0D;
    	private Double prevEmprSS = 0D;
     
    	public TaxEngine(Company company, Branch branch, List<Employee> activeList, List<Employee> inactiveList) {
    		this.comp = company;
    		this.branch = branch;
    		this.activeEmpList = activeList;
    		this.inActiveEmpList = inactiveList;
     
    		if(System.getProperty("DRYRUN") != null 
    		&& System.getProperty("DRYRUN").equalsIgnoreCase("true")) {
    			testMap = new HashMap<Employee, EmployeePayroll>();
    		}
    	}
     
    	public List<EmployeePayroll> execute(Payroll payroll, boolean adhoc) throws Exception {
    		/*
    		 * for each emp
    		> Resident type factory.getSourceofIncomeObj(type)
    		> obj.calculate(emp)
    		> Resident type factory.getExcemptionObj(type)
    		> obj.calculate(emp)
    			> EmployeeExemptionFactory.get
    		> Resident type factory.getTaxRatesCalculator(type)
    			> Calculator.execute(emp);
    		 */
    		Calendar toBeProcessedFor = Calendar.getInstance();
    		toBeProcessedFor.setTime(payroll.getPayDateId().getRunDateofDateObject());
     
    		List<EmployeePayroll> retList = new ArrayList<EmployeePayroll>();
    		List<PayrollDate> payrollDates = PayrollFactory.findPayrollDateByBranch(branch.getId());
    		List<Payroll> payRuns = PayrollFactory.findAllPayrollRuns();
     
    		for (Employee emp : activeEmpList) {
    			System.out.println("Processing for employee - " + emp.getId());
     
    			IncomeCalculator incomeCalc = ResidentTypeFactory.getIncomeCalculator(emp);
     
    			// Get the annual income of the person, which involves his AGP + other incomes
    			EmployeePayroll empPayroll = incomeCalc.calculate(emp, toBeProcessedFor, true, comp.getFinStartMonth());
     
    			prevNetPay = empPayroll.getNetPay();
    			prevEmprSS = empPayroll.getEmployerSS();
    			prevTaxAmt = empPayroll.getTaxAmount();			
     
    			// Calculate the Exemptions
    			ExemptionCalculator exmpCalc = ResidentTypeFactory.getExemptionCalculator(emp);
    			exmpCalc.calculate(emp, empPayroll, comp.getFinStartMonth(), toBeProcessedFor, true);
     
    			// Calculate the deductions
    			DeductionCalculator deducCalc = ResidentTypeFactory.getDeductionCalculator(emp);
    			deducCalc.calculate(emp, empPayroll, toBeProcessedFor, comp.getFinStartMonth(), true);
     
    			// Finally calculate the tax to be paid
    			TaxCalculator taxCalc = ResidentTypeFactory.getTaxCalculator(emp);
    			Double lastPercentage = taxCalc.calculate(emp, empPayroll);
     
    			// Process if the tax is to be paid by employer.
    			processTaxPaidByEmployer(empPayroll, lastPercentage);
     
    			// Here if the employees (resident and non-res foreigner) are not subject to withhold tax then
    			// consider it.
    			Double income = empPayroll.getTotalIncome();
    			Double empeSS = 0D;
     
    			List<DeductionsDone> deductionsList = empPayroll.getDeductionsDone();
    			for(DeductionsDone dd: deductionsList) {
    				if(dd.getType().getName().equalsIgnoreCase(PayhumConstants.EMPLOYEE_SOCIAL_SECURITY)) {
    					empeSS = dd.getAmount();
    					break;
    				}
    			}
     
    			if(empPayroll.getWithholdTax().compareTo(1) == 0) {
    				if(emp.getPayAccomAmt() != null && emp.getPayAccomAmt().equalsIgnoreCase("true")) {
    					empPayroll.setNetPay(income - empPayroll.getTaxAmount() - empPayroll.getEmployerSS() - empeSS);
    				} else {
    					empPayroll.setNetPay(income - empPayroll.getTaxAmount() - empPayroll.getEmployerSS() - empeSS - empPayroll.getAccomodationAmount());
    				}
    			} else {
    				if(emp.getPayAccomAmt() != null && emp.getPayAccomAmt().equalsIgnoreCase("true")) {
    					// Else keep the Net pay as taxable Income and let Employee pay the tax and we just tell the amount.
    					empPayroll.setNetPay(income - empPayroll.getEmployerSS() - empeSS);
    				} else {
    					empPayroll.setNetPay(income - empPayroll.getEmployerSS() - empeSS - empPayroll.getAccomodationAmount());
    				}
    			}
     
    			// Update on the split per month/week/biweekly
    			computeDetailsPerPayPeriod(empPayroll, toBeProcessedFor, payroll, adhoc,
    					payrollDates, payRuns, comp.getFinStartMonth());
     
    			if(System.getProperty("DRYRUN") != null 
    			&& System.getProperty("DRYRUN").equalsIgnoreCase("true")) {
    				testMap.put(emp,  empPayroll);
    			} else {
    				// Update the payroll details into the repos.
    				boolean success = EmpPayTaxFactroy.update(empPayroll); 
    				if( success ) {
    					retList.add(empPayroll);
    				} else {
    					throw new Exception("Failed to process payroll for emp - " + emp.getId());
    				}
    			}
    		}
     
    		// Process the inactive or terminated employees in this month\
    		for(Employee emp: inActiveEmpList) {
    			System.out.println("Processing for inactive employee - " + emp.getId());
    			IncomeCalculator incomeCalc = ResidentTypeFactory.getIncomeCalculator(emp);
     
    			// Get the annual income of the person, which involves his AGP + other incomes
    			EmployeePayroll empPayroll = incomeCalc.calculate(emp, toBeProcessedFor, false, comp.getFinStartMonth());
     
    			// Calculate the Exemptions
    			ExemptionCalculator exmpCalc = ResidentTypeFactory.getExemptionCalculator(emp);
    			exmpCalc.calculate(emp, empPayroll, comp.getFinStartMonth(), toBeProcessedFor, false);
     
    			// Calculate the deductions
    			DeductionCalculator deducCalc = ResidentTypeFactory.getDeductionCalculator(emp);
    			deducCalc.calculate(emp, empPayroll, toBeProcessedFor, comp.getFinStartMonth(), false);
     
    			// Finally calculate the tax to be paid
    			TaxCalculator taxCalc = ResidentTypeFactory.getTaxCalculator(emp);
    			Double lastPercentage = taxCalc.calculate(emp, empPayroll);
     
    			// Process if the tax is to be paid by employer.
    			processTaxPaidByEmployer(empPayroll, lastPercentage);
     
    			Double income = empPayroll.getTotalIncome();
    			Double empeSS = 0D;
     
    			List<DeductionsDone> deductionsList = empPayroll.getDeductionsDone();
    			for(DeductionsDone dd: deductionsList) {
    				if(dd.getType().getName().equalsIgnoreCase(PayhumConstants.EMPLOYEE_SOCIAL_SECURITY)) {
    					empeSS = dd.getAmount();
    					break;
    				}
    			}
     
    			// Here if the employees (resident and non-res foreigner) are not subject to withhold tax then
    			// consider it.
    			if(empPayroll.getWithholdTax().compareTo(1) == 0) {
    				if(emp.getPayAccomAmt() != null && emp.getPayAccomAmt().equalsIgnoreCase("true")) {
    					empPayroll.setNetPay(income - empPayroll.getTaxAmount() - empPayroll.getEmployerSS() - empeSS);
    				} else {
    					empPayroll.setNetPay(income - empPayroll.getTaxAmount() - empPayroll.getEmployerSS() - empeSS - empPayroll.getAccomodationAmount());
    				}
    			} else {
    				if(emp.getPayAccomAmt() != null && emp.getPayAccomAmt().equalsIgnoreCase("true")) {
    					// Else keep the Net pay as taxable Income and let Employee pay the tax and we just tell the amount.
    					empPayroll.setNetPay(income - empPayroll.getEmployerSS() - empeSS);
    				} else {
    					empPayroll.setNetPay(income - empPayroll.getEmployerSS() - empeSS - empPayroll.getAccomodationAmount());
    				}
    			}
     
    			computeDetailsPerPayPeriodForInactive(empPayroll, toBeProcessedFor, payroll, payrollDates, payRuns, comp.getFinStartMonth());
     
    			if(System.getProperty("DRYRUN") != null 
    			&& System.getProperty("DRYRUN").equalsIgnoreCase("true")) {
    				testMap.put(emp,  empPayroll);
    			} else {
    				// Update the payroll details into the repos.
    				boolean success = EmpPayTaxFactroy.update(empPayroll); 
    				if( success ) {
    					retList.add(empPayroll);
    				} else {
    					throw new Exception("Failed to process payroll for emp - " + emp.getId());
    				}
    			}
    		}
     
    		return retList;
    	}
     
    	private void processTaxPaidByEmployer(EmployeePayroll empPayroll, 
    											Double ratePercentage) {
    		Integer taxPaidByEmployer = empPayroll.getTaxPaidByEmployer();
     
    		if(taxPaidByEmployer != null && taxPaidByEmployer.compareTo(1) == 0) {
    			// Tax is paid by Employer so process it.
    			Double taxRate = ratePercentage / 100;
     
    			Double taxAmount = empPayroll.getTaxAmount();
     
    			Double amt1 = taxAmount * taxRate;
    			amt1 += (amt1 * taxRate) / (1 - taxRate);
    			amt1 += taxAmount;
     
    			empPayroll.setTaxAmount(amt1);
     
    			Double totalAmt = empPayroll.getTotalIncome();
    			Double taxableAmt = empPayroll.getTaxableIncome();
     
    			empPayroll.setTotalIncome(totalAmt + amt1);
    			empPayroll.setTaxableIncome(taxableAmt + amt1);
    		}
    	}
     
    	private void computeDetailsPerPayPeriod(EmployeePayroll empPayroll,
    			Calendar toBeProcessedFor, Payroll payroll, boolean adhoc,
    			List<PayrollDate> payrollDates, List<Payroll> payRuns, int finStartMonth) throws Exception {
    		boolean isRetroEmp = PayhumUtil.isRetroActive(toBeProcessedFor, empPayroll.getEmployeeId().getHiredate(), finStartMonth,
    				empPayroll.getEmployeeId().getDeptId().getBranchId().getId());
     
    		Integer divNo = payrollDates.size();
    		int remainingPaycycles = PayhumUtil.remainingPaycycles(payrollDates, payRuns);
    		Double proRate = 1D;
    		Double divNoWithProrate = 1D;
    		Date hireDate = empPayroll.getEmployeeId().getHiredate();
    		Calendar hireDtCal = Calendar.getInstance();
    		hireDtCal.setTime(hireDate);
    	    // Zero out the hour, minute, second, and millisecond
    		hireDtCal.set(Calendar.HOUR_OF_DAY, 0);
    		hireDtCal.set(Calendar.MINUTE, 0);
    		hireDtCal.set(Calendar.SECOND, 0);
    		hireDtCal.set(Calendar.MILLISECOND, 0);
     
    		int currMonth = toBeProcessedFor.get(Calendar.MONTH);
    		int hireMonth = hireDtCal.get(Calendar.MONTH);
    		int hireYear = hireDtCal.get(Calendar.YEAR);
    		int currYear = toBeProcessedFor.get(Calendar.YEAR);
     
    		if(currYear == hireYear && currMonth == hireMonth) {
    			int hireDay = hireDtCal.get(Calendar.DAY_OF_MONTH);
     
    			int diffDays = 1;
    			if(hireDay < 31) {
    				diffDays = 31 - hireDay;
    			}
     
    			proRate = diffDays / 30D;
    			divNoWithProrate = (remainingPaycycles - 1) + proRate;
    		} else {
    			// no change in div no
    			divNoWithProrate = new Double(divNo);
    		}
     
    		if(adhoc) {
    			EmployeeBonus latestBonus = getLatestBonus(empPayroll, toBeProcessedFor);
    			if(latestBonus != null && prevNetPay != 0D) {
    				Double diffNetPay = empPayroll.getNetPay() - prevNetPay;
    				Double diffTaxAmt = empPayroll.getTaxAmount() - prevTaxAmt;
    				Double diffEmpSS = empPayroll.getEmployerSS() - prevEmprSS;
     
    				empPayroll.setPaidNetPay(empPayroll.getPaidNetPay() + diffNetPay);
    				empPayroll.setPaidTaxAmt(empPayroll.getPaidTaxAmt() + diffTaxAmt);
    				empPayroll.setPaidEmprSS(empPayroll.getPaidEmprSS() + diffEmpSS);
     
    				// Save to emp_payroll_map table.
    				EmpBankAccount empBankAcct = EmpBankAccountFactory.findByEmployeeId(empPayroll.getEmployeeId().getId());
    				EmpPayrollMap empPayMap = new EmpPayrollMap();
    				empPayMap.setEmppayId(empPayroll);
    				empPayMap.setNetPay(diffNetPay);
    				empPayMap.setTaxAmount(diffTaxAmt);
    				empPayMap.setEmprSocialSec(diffEmpSS);
    				empPayMap.setPayrollId(payroll);
     
    				if(empBankAcct != null) {
    					empPayMap.setMode(1);
    				}
     
    				if(System.getProperty("DRYRUN") == null 
    				|| ! System.getProperty("DRYRUN").equalsIgnoreCase("true")) {
    					PayrollFactory.insertEmpPayrollMap(empPayMap);
    				}
    			} else {
    				// this emp has no bonus, so no changes.
    			}
    		} else {
    			Double totalTaxAmt = empPayroll.getTaxAmount();
    			Double totalNeyPay = empPayroll.getNetPay();
    			Double totalEmprSS = empPayroll.getEmployerSS();
    			Double totalEmpeSS = 0D;
    			Double totalTaxableAmt = empPayroll.getTaxableIncome();
    			Double totalAccomAmt = empPayroll.getAccomodationAmount();
    			Double totalBasicAllow = 0D;
    		    Double totalAllowance=0D;
    			// get employee contribution of SS
    			List<DeductionsDone> deductionsList = empPayroll.getDeductionsDone();
     
    			for(DeductionsDone dd: deductionsList) {
    				if(dd.getType().getName().equalsIgnoreCase(PayhumConstants.EMPLOYEE_SOCIAL_SECURITY)) {
    					totalEmpeSS += dd.getAmount();
    					break;
    				}
    			}
     
    			List<ExemptionsDone> exemptionsList = empPayroll.getExemptionsDone();
     
    			for(ExemptionsDone ed: exemptionsList) {
    				if(ed.getType().getName().equalsIgnoreCase(PayhumConstants.BASIC_ALLOWANCE)) {
    					totalBasicAllow += ed.getAmount();
    					break;
    				}
    			}
    			List<Benefit>benefits=BenefitFactory.findByEmpId(empPayroll.getEmployeeId());
    			for(Benefit b:benefits)
    			{
    				if(b.getTypeId().getName().equalsIgnoreCase(PayhumConstants.ALLOWANCE))
    				{
    					totalAllowance+=b.getAmount();
    				}
    			}
     
    			TypesData currency = empPayroll.getEmployeeId().getCurrency();
    			Double currencyCoverVal = 1D;
     
    			if(currency.getName().equalsIgnoreCase(PayhumConstants.CURRENCY_USD)) {
    				ConfigData currencyConver = ConfigDataFactory.findByName(PayhumConstants.USD_MMK_CONVER);
    				currencyCoverVal = Double.valueOf(currencyConver.getConfigValue());
    			} else if(currency.getName().equalsIgnoreCase(PayhumConstants.CURRENCY_EURO)) {
    				ConfigData currencyConver = ConfigDataFactory.findByName(PayhumConstants.EURO_MMK_CONVER);
    				currencyCoverVal = Double.valueOf(currencyConver.getConfigValue());
    			} else if(currency.getName().equalsIgnoreCase(PayhumConstants.CURRENCY_POUND)) {
    				ConfigData currencyConver = ConfigDataFactory.findByName(PayhumConstants.POUND_MMK_CONVER);
    				currencyCoverVal = Double.valueOf(currencyConver.getConfigValue());
    			}
     
    			Double newOvertimeAmt = empPayroll.getNewOvertimeAmt();
    			Double newOtherIncome = empPayroll.getNewOtherIncome();
    			Double pendingNeyPay = totalNeyPay - empPayroll.getPaidNetPay() - newOtherIncome - newOvertimeAmt;
    			Double pendingTaxAmt = totalTaxAmt - empPayroll.getPaidTaxAmt();
    			Double pendingEmprSS = totalEmprSS - empPayroll.getPaidEmprSS();
    			Double pendingEmpeSS = totalEmpeSS - empPayroll.getPaidEmpeSS();
    			Double pendingTaxableAmt = totalTaxableAmt - empPayroll.getPaidTaxableAmt();
    			Double pendingAccomAmt = totalAccomAmt - empPayroll.getPaidAccomAmt();
    			Double pendingBasicAllow = totalBasicAllow - empPayroll.getPaidBasicAllow();
    			Double pendingAllowance=totalAllowance-empPayroll.getPaidAllowance();
    			Double thisMonthPaidNetPay = 0D;
    			Double thisMonthPaidTaxAmt = 0D;
    			Double thisMonthPaidEmpeSS = 0D;
    			Double thisMonthPaidEmprSS = 0D;
    			Double thisMonthPaidTaxableAmt = 0D;
    			Double thisMonthPaidAccomAmt = 0D;
    			Double thisMonthPaidBasicAllow = 0D;
    			Double thisMonthPaidAllowance=0D;
    			if(currYear == hireYear && currMonth == hireMonth) {
    				int hireDay = hireDtCal.get(Calendar.DAY_OF_MONTH);
     
    				int diffDays = 1;
    				if(hireDay < 31) {
    					diffDays = 31 - hireDay;
    				}
     
    				Double divideBy = (remainingPaycycles - 1) + diffDays / 30D;
    				thisMonthPaidNetPay = ((pendingNeyPay / divideBy) / 30 ) * diffDays + newOvertimeAmt + newOtherIncome;
    				thisMonthPaidTaxAmt = ((pendingTaxAmt / divideBy) / 30 ) * diffDays;
    				thisMonthPaidTaxableAmt = ((pendingTaxableAmt / divideBy) / 30 ) * diffDays;
    				thisMonthPaidAccomAmt = ((pendingAccomAmt / divideBy) / 30 ) * diffDays;
    				thisMonthPaidBasicAllow = ((pendingBasicAllow / divideBy) / 30 ) * diffDays;
    				thisMonthPaidEmpeSS = totalEmpeSS / remainingPaycycles;
    				thisMonthPaidEmprSS = totalEmprSS / remainingPaycycles;
    				thisMonthPaidAllowance=totalAllowance/remainingPaycycles;
     
    				Double extraEmpeSS = (((thisMonthPaidEmpeSS / divideBy) / 30 ) * (30 - diffDays)) * (remainingPaycycles - 1);
    				thisMonthPaidNetPay = thisMonthPaidNetPay - extraEmpeSS;
     
    				empPayroll.setPaidNetPay(empPayroll.getPaidNetPay() + thisMonthPaidNetPay );
    				empPayroll.setPaidTaxAmt(empPayroll.getPaidTaxAmt() + thisMonthPaidTaxAmt);
    				empPayroll.setPaidEmpeSS(thisMonthPaidEmpeSS);
    				empPayroll.setPaidEmprSS(thisMonthPaidEmprSS);
    				empPayroll.setPaidTaxableAmt(thisMonthPaidTaxableAmt);
    				empPayroll.setPaidAccomAmt(thisMonthPaidAccomAmt);
    				empPayroll.setPaidBasicAllow(thisMonthPaidBasicAllow);
    				empPayroll.setPaidAllowance(thisMonthPaidAllowance);
    			} else if(isRetroEmp) {
    				thisMonthPaidNetPay = (pendingNeyPay - empPayroll.getRetroBaseSal() + pendingEmpeSS) / remainingPaycycles + newOvertimeAmt + newOtherIncome
    						+ empPayroll.getRetroBaseSal();
    				thisMonthPaidTaxAmt = pendingTaxAmt / remainingPaycycles;
    				thisMonthPaidEmpeSS = pendingEmpeSS / (remainingPaycycles + 1);
    				thisMonthPaidEmprSS = pendingEmprSS / (remainingPaycycles + 1);
    				thisMonthPaidEmpeSS=pendingEmpeSS/remainingPaycycles;
    				thisMonthPaidEmprSS=pendingEmprSS/remainingPaycycles;
    				thisMonthPaidTaxableAmt = pendingTaxableAmt / remainingPaycycles;
    				thisMonthPaidAccomAmt = pendingAccomAmt / remainingPaycycles;
    				thisMonthPaidBasicAllow = pendingBasicAllow / remainingPaycycles;
    			    thisMonthPaidAllowance=pendingAllowance/remainingPaycycles;		
    				// If retro lets get 2 months SS
    				thisMonthPaidEmpeSS = thisMonthPaidEmpeSS * 2;
    				thisMonthPaidEmprSS = thisMonthPaidEmprSS * 2;
    				thisMonthPaidNetPay = thisMonthPaidNetPay - thisMonthPaidEmpeSS;
     
    				empPayroll.setPaidNetPay(empPayroll.getPaidNetPay() + thisMonthPaidNetPay);
    				empPayroll.setPaidTaxAmt(empPayroll.getPaidTaxAmt() + thisMonthPaidTaxAmt);
    				empPayroll.setPaidEmpeSS(empPayroll.getPaidEmpeSS() + thisMonthPaidEmpeSS);
    				empPayroll.setPaidEmprSS(empPayroll.getPaidEmprSS() + thisMonthPaidEmprSS);
     
    				empPayroll.setPaidTaxableAmt(empPayroll.getPaidTaxableAmt() + thisMonthPaidTaxableAmt);
    				empPayroll.setPaidAccomAmt(empPayroll.getPaidAccomAmt() + thisMonthPaidAccomAmt);
    				empPayroll.setPaidBasicAllow(empPayroll.getPaidBasicAllow() + thisMonthPaidBasicAllow);
    				empPayroll.setPaidAllowance(thisMonthPaidAllowance+empPayroll.getPaidAllowance());
    			} else {
    				thisMonthPaidNetPay = pendingNeyPay / remainingPaycycles + newOvertimeAmt + newOtherIncome;
    				thisMonthPaidTaxAmt = pendingTaxAmt / remainingPaycycles;
    				thisMonthPaidEmpeSS = pendingEmpeSS / remainingPaycycles;
    				thisMonthPaidEmprSS = pendingEmprSS / remainingPaycycles;
    				thisMonthPaidTaxableAmt = pendingTaxableAmt / remainingPaycycles;
    				thisMonthPaidAccomAmt = pendingAccomAmt / remainingPaycycles;
    				thisMonthPaidBasicAllow = pendingBasicAllow / remainingPaycycles;
    				thisMonthPaidAllowance=pendingAllowance/remainingPaycycles;
    				// Now if the employee is USD, then his number for SS should be 5 and 3 only.
    				if(currency.getName().equalsIgnoreCase(PayhumConstants.CURRENCY_USD)) {
    					Double valForEmprSS = 5D;
    					Double valForEmpeSS = 3D;
     
    					Double currValForEmprSS = thisMonthPaidEmprSS / currencyCoverVal;
    					Double currValForEmpeSS = thisMonthPaidEmpeSS / currencyCoverVal;
     
    					Double diffForEmprSS = currValForEmprSS - valForEmprSS;
    					Double diffForEmpeSS = currValForEmpeSS - valForEmpeSS;
     
    					thisMonthPaidNetPay += diffForEmprSS * currencyCoverVal;
    					thisMonthPaidNetPay += diffForEmpeSS * currencyCoverVal;
     
    					thisMonthPaidEmpeSS = valForEmpeSS * currencyCoverVal;
    					thisMonthPaidEmprSS = valForEmprSS * currencyCoverVal;
    				} 
     
    				empPayroll.setPaidNetPay(empPayroll.getPaidNetPay() + thisMonthPaidNetPay);
    				empPayroll.setPaidTaxAmt(empPayroll.getPaidTaxAmt() + thisMonthPaidTaxAmt);
    				empPayroll.setPaidEmpeSS(empPayroll.getPaidEmpeSS() + thisMonthPaidEmpeSS);
    				empPayroll.setPaidEmprSS(empPayroll.getPaidEmprSS() + thisMonthPaidEmprSS);
    				empPayroll.setPaidTaxableAmt(empPayroll.getPaidTaxableAmt() + thisMonthPaidTaxableAmt);
    				empPayroll.setPaidAccomAmt(empPayroll.getPaidAccomAmt() + thisMonthPaidAccomAmt);
    				empPayroll.setPaidBasicAllow(empPayroll.getPaidBasicAllow() + thisMonthPaidBasicAllow);
    				empPayroll.setPaidAllowance(empPayroll.getPaidAllowance()+thisMonthPaidAllowance);
    			}
     
    			// Save to emp_payroll_map table.
    			EmpBankAccount empBankAcct = EmpBankAccountFactory.findByEmployeeId(empPayroll.getEmployeeId().getId());
    			EmpPayrollMap empPayMap = new EmpPayrollMap();
    			empPayMap.setEmppayId(empPayroll);
    			empPayMap.setNetPay(thisMonthPaidNetPay);
    			empPayMap.setTaxAmount(thisMonthPaidTaxAmt);
    			empPayMap.setTaxableAmt(thisMonthPaidTaxableAmt);
    			empPayMap.setEmpeSocialSec(thisMonthPaidEmpeSS);
    			empPayMap.setEmprSocialSec(thisMonthPaidEmprSS);
    			empPayMap.setAccomAmt(thisMonthPaidAccomAmt);
    			empPayMap.setBasicAllow(thisMonthPaidBasicAllow);
    			empPayMap.setAllowance(thisMonthPaidAllowance);
     
    			empPayMap.setOvertimeAmt(newOvertimeAmt);
    			empPayroll.clearNewOvertimeAmt();
     
    			empPayMap.setOtherIncome(newOtherIncome);
    			empPayroll.clearNewOtherIncome();
     
    			if(isRetroEmp) {
    				empPayMap.setRetroBaseSal(empPayroll.getRetroBaseSal());
    			} else {
    				empPayMap.setRetroBaseSal(0D);
    			}
     
     
    			Double baseSalforMonth = empPayroll.getBaseSalary() - empPayroll.getPaidBaseSalary();
    			baseSalforMonth = baseSalforMonth / remainingPaycycles;
    			if(proRate.compareTo(1D) == 0) {
    				empPayMap.setBaseSalary(baseSalforMonth);
    				empPayroll.addPaidBaseSalary(baseSalforMonth);
    			} else {
    				empPayMap.setBaseSalary((empPayroll.getBaseSalary() / divNoWithProrate) * proRate);
    				empPayroll.addPaidBaseSalary((empPayroll.getBaseSalary() / divNoWithProrate) * proRate);
    			}
     
    			empPayMap.setBonus(empPayroll.getNewBonus());
    			empPayroll.clearNewBonus();
     
    			empPayMap.setCurrencyConverRate(currencyCoverVal);
     
    			ConfigData salPayDate = ConfigDataFactory.findByName(PayhumConstants.SAL_PAY_DATE);
    			empPayMap.setSalPayDate(Integer.parseInt(salPayDate.getConfigValue()));
     
    			empPayMap.setPayrollId(payroll);
     
    			if(empBankAcct != null) {
    				empPayMap.setMode(1);
    			} else {
    				empPayMap.setMode(0);
    			}
     
    			if(System.getProperty("DRYRUN") == null 
    			|| ! System.getProperty("DRYRUN").equalsIgnoreCase("true")) {
    				PayrollFactory.insertEmpPayrollMap(empPayMap);
    			}
    		}
    	}
     
    	private void computeDetailsPerPayPeriodForInactive(EmployeePayroll empPayroll,
    			Calendar toBeProcessedFor, Payroll payroll,
    			List<PayrollDate> payrollDates, List<Payroll> payRuns, int finStartMonth) throws Exception {
    		boolean isRetroEmp = PayhumUtil.isRetroActive(toBeProcessedFor, empPayroll.getEmployeeId().getHiredate(), finStartMonth,empPayroll.getEmployeeId().getDeptId().getBranchId().getId());
     
    		Integer divNo = 1;
    		Double proRate = 1D;
    		Double divNoWithProrate = 1D;
    		Date hireDate = empPayroll.getEmployeeId().getHiredate();
    		Date lastDate = empPayroll.getEmployeeId().getInactiveDate();
     
    		Calendar hireDtCal = Calendar.getInstance();
    		hireDtCal.setTime(hireDate);
    	    // Zero out the hour, minute, second, and millisecond
    		hireDtCal.set(Calendar.HOUR_OF_DAY, 0);
    		hireDtCal.set(Calendar.MINUTE, 0);
    		hireDtCal.set(Calendar.SECOND, 0);
    		hireDtCal.set(Calendar.MILLISECOND, 0);
     
    		Calendar lastDtCal = Calendar.getInstance();
    		lastDtCal.setTime(lastDate);
    	    // Zero out the hour, minute, second, and millisecond
    		lastDtCal.set(Calendar.HOUR_OF_DAY, 0);
    		lastDtCal.set(Calendar.MINUTE, 0);
    		lastDtCal.set(Calendar.SECOND, 0);
    		lastDtCal.set(Calendar.MILLISECOND, 0);
     
    		int currMonth = toBeProcessedFor.get(Calendar.MONTH);
    		int hireMonth = hireDtCal.get(Calendar.MONTH);
    		int hireYear = hireDtCal.get(Calendar.YEAR);
    		int currYear = toBeProcessedFor.get(Calendar.YEAR);
    		int lastMonth = lastDtCal.get(Calendar.MONTH);
    		int lastYear = lastDtCal.get(Calendar.YEAR);
    		int lastDay = lastDtCal.get(Calendar.DAY_OF_MONTH);
     
    		if(currYear == hireYear && currMonth == hireMonth) {
    			int hireDay = hireDtCal.get(Calendar.DAY_OF_MONTH);
     
    			int diffDays = 1;
    			if(hireDay < 31) {
    				diffDays = lastDay + 1 - hireDay;
    			}
     
    			proRate = diffDays / (double)lastDay;
    			divNoWithProrate = divNo + proRate;
    		} else {
    			// no change in div no
    			divNoWithProrate = new Double(divNo);
    		}
     
    		Double totalTaxAmt = empPayroll.getTaxAmount();
    		Double totalNeyPay = empPayroll.getNetPay();
    		Double totalEmprSS = empPayroll.getEmployerSS();
    		Double totalEmpeSS = 0D;
    		Double totalTaxableAmt = empPayroll.getTaxableIncome();
    		Double totalAccomAmt = empPayroll.getAccomodationAmount();
    		Double totalBasicAllow = 0D;
     
    		// get employee contribution of SS
    		List<DeductionsDone> deductionsList = empPayroll.getDeductionsDone();
     
    		for(DeductionsDone dd: deductionsList) {
    			if(dd.getType().getName().equalsIgnoreCase(PayhumConstants.EMPLOYEE_SOCIAL_SECURITY)) {
    				totalEmpeSS += dd.getAmount();
    				break;
    			}
    		}
     
    		List<ExemptionsDone> exemptionsList = empPayroll.getExemptionsDone();
     
    		for(ExemptionsDone ed: exemptionsList) {
    			if(ed.getType().getName().equalsIgnoreCase(PayhumConstants.BASIC_ALLOWANCE)) {
    				totalBasicAllow += ed.getAmount();
    				break;
    			}
    		}
     
    		int remainingPaycycles = 1;
     
    		TypesData currency = empPayroll.getEmployeeId().getCurrency();
    		Double currencyCoverVal = 1D;
     
    		if(currency.getName().equalsIgnoreCase(PayhumConstants.CURRENCY_USD)) {
    			ConfigData currencyConver = ConfigDataFactory.findByName(PayhumConstants.USD_MMK_CONVER);
    			currencyCoverVal = Double.valueOf(currencyConver.getConfigValue());
    		} else if(currency.getName().equalsIgnoreCase(PayhumConstants.CURRENCY_EURO)) {
    			ConfigData currencyConver = ConfigDataFactory.findByName(PayhumConstants.EURO_MMK_CONVER);
    			currencyCoverVal = Double.valueOf(currencyConver.getConfigValue());
    		} else if(currency.getName().equalsIgnoreCase(PayhumConstants.CURRENCY_POUND)) {
    			ConfigData currencyConver = ConfigDataFactory.findByName(PayhumConstants.POUND_MMK_CONVER);
    			currencyCoverVal = Double.valueOf(currencyConver.getConfigValue());
    		}
     
    		Double newOvertimeAmt = empPayroll.getNewOvertimeAmt();
    		Double newOtherIncome = empPayroll.getNewOtherIncome();
    		Double pendingNeyPay = totalNeyPay - empPayroll.getPaidNetPay() - newOtherIncome - newOvertimeAmt;
    		Double pendingTaxAmt = totalTaxAmt - empPayroll.getPaidTaxAmt();
    		Double pendingEmprSS = totalEmprSS - empPayroll.getPaidEmprSS();
    		Double pendingEmpeSS = totalEmpeSS - empPayroll.getPaidEmpeSS();
    		Double pendingTaxableAmt = totalTaxableAmt - empPayroll.getPaidTaxableAmt();
    		Double pendingAccomAmt = totalAccomAmt - empPayroll.getPaidAccomAmt();
    		Double pendingBasicAllow = totalBasicAllow - empPayroll.getPaidBasicAllow();
     
    		Double thisMonthPaidNetPay = 0D;
    		Double thisMonthPaidTaxAmt = 0D;
    		Double thisMonthPaidEmpeSS = 0D;
    		Double thisMonthPaidEmprSS = 0D;
    		Double thisMonthPaidTaxableAmt = 0D;
    		Double thisMonthPaidAccomAmt = 0D;
    		Double thisMonthPaidBasicAllow = 0D;
    		if(currYear == hireYear && currMonth == hireMonth) {
    			int hireDay = hireDtCal.get(Calendar.DAY_OF_MONTH);
     
    			int diffDays = 1;
    			if(hireDay < 31) {
    				diffDays = lastDay + 1 - hireDay;
    			}
     
    			Double divideBy = (remainingPaycycles - 1) + diffDays / (double) lastDay;
    			thisMonthPaidNetPay = ((pendingNeyPay / divideBy) / 30 ) * diffDays + newOvertimeAmt + newOtherIncome;
    			thisMonthPaidTaxAmt = ((pendingTaxAmt / divideBy) / 30 ) * diffDays;
    			thisMonthPaidTaxableAmt = ((pendingTaxableAmt/ divideBy) / 30 ) * diffDays;
    			thisMonthPaidEmpeSS = totalEmpeSS / remainingPaycycles;
    			thisMonthPaidEmprSS = totalEmprSS / remainingPaycycles;
    			thisMonthPaidAccomAmt = ((pendingAccomAmt / divideBy) / 30 ) * diffDays;
    			thisMonthPaidBasicAllow = ((pendingBasicAllow / divideBy) / 30 ) * diffDays;
     
    			empPayroll.setPaidNetPay(empPayroll.getPaidNetPay() + thisMonthPaidNetPay );
    			empPayroll.setPaidTaxAmt(empPayroll.getPaidTaxAmt() + thisMonthPaidTaxAmt);
    			empPayroll.setPaidEmpeSS(thisMonthPaidEmpeSS);
    			empPayroll.setPaidEmprSS(thisMonthPaidEmprSS);
    			empPayroll.setPaidTaxableAmt(empPayroll.getPaidTaxableAmt() + thisMonthPaidTaxableAmt);
    			empPayroll.setPaidAccomAmt(thisMonthPaidAccomAmt);
    			empPayroll.setPaidBasicAllow(thisMonthPaidBasicAllow);
    		} else if(isRetroEmp) {
    			thisMonthPaidNetPay = pendingNeyPay / remainingPaycycles + newOvertimeAmt + newOtherIncome;
    			thisMonthPaidTaxAmt = pendingTaxAmt / remainingPaycycles;
    			thisMonthPaidTaxableAmt = pendingTaxableAmt / remainingPaycycles;
    			thisMonthPaidEmpeSS = pendingEmpeSS / (remainingPaycycles + 1);
    			thisMonthPaidEmprSS = pendingEmprSS / (remainingPaycycles + 1);
    			thisMonthPaidAccomAmt = pendingAccomAmt / remainingPaycycles;
    			thisMonthPaidBasicAllow = pendingBasicAllow / remainingPaycycles;
     
    			// If retro lets get 2 months SS
    			thisMonthPaidEmpeSS = thisMonthPaidEmpeSS * 2;
    			thisMonthPaidEmprSS = thisMonthPaidEmprSS * 2;
     
    			empPayroll.setPaidNetPay(empPayroll.getPaidNetPay() + thisMonthPaidNetPay);
    			empPayroll.setPaidTaxAmt(empPayroll.getPaidTaxAmt() + thisMonthPaidTaxAmt);
    			empPayroll.setPaidEmpeSS(empPayroll.getPaidEmpeSS() + thisMonthPaidEmpeSS);
    			empPayroll.setPaidEmprSS(empPayroll.getPaidEmprSS() + thisMonthPaidEmprSS);
    			empPayroll.setPaidTaxableAmt(empPayroll.getPaidTaxableAmt() + thisMonthPaidTaxableAmt);
    			empPayroll.setPaidAccomAmt(empPayroll.getPaidAccomAmt() + thisMonthPaidAccomAmt);
    			empPayroll.setPaidBasicAllow(empPayroll.getPaidBasicAllow() + thisMonthPaidBasicAllow);
    		} else {
    			thisMonthPaidNetPay = pendingNeyPay / remainingPaycycles + newOvertimeAmt + newOtherIncome;
    			thisMonthPaidTaxAmt = pendingTaxAmt / remainingPaycycles;
    			thisMonthPaidTaxableAmt = pendingTaxableAmt / remainingPaycycles;
    			thisMonthPaidEmpeSS = pendingEmpeSS / remainingPaycycles;
    			thisMonthPaidEmprSS = pendingEmprSS / remainingPaycycles;
    			thisMonthPaidAccomAmt = pendingAccomAmt / remainingPaycycles;
    			thisMonthPaidBasicAllow = pendingBasicAllow / remainingPaycycles;
     
    			// Now if the employee is USD, then his number for SS should be 5 and 3 only.
    			if(currency.getName().equalsIgnoreCase(PayhumConstants.CURRENCY_USD)) {
    				Double valForEmprSS = 5D;
    				Double valForEmpeSS = 3D;
     
    				Double currValForEmprSS = thisMonthPaidEmprSS / currencyCoverVal;
    				Double currValForEmpeSS = thisMonthPaidEmpeSS / currencyCoverVal;
     
    				Double diffForEmprSS = currValForEmprSS - valForEmprSS;
    				Double diffForEmpeSS = currValForEmpeSS - valForEmpeSS;
     
    				thisMonthPaidNetPay += diffForEmprSS * currencyCoverVal;
    				thisMonthPaidNetPay += diffForEmpeSS * currencyCoverVal;
     
    				thisMonthPaidEmpeSS = valForEmpeSS * currencyCoverVal;
    				thisMonthPaidEmprSS = valForEmprSS * currencyCoverVal;
    			} 
     
    			empPayroll.setPaidNetPay(empPayroll.getPaidNetPay() + thisMonthPaidNetPay);
    			empPayroll.setPaidTaxAmt(empPayroll.getPaidTaxAmt() + thisMonthPaidTaxAmt);
    			empPayroll.setPaidEmpeSS(empPayroll.getPaidEmpeSS() + thisMonthPaidEmpeSS);
    			empPayroll.setPaidEmprSS(empPayroll.getPaidEmprSS() + thisMonthPaidEmprSS);
    			empPayroll.setPaidTaxableAmt(empPayroll.getPaidTaxableAmt() + thisMonthPaidTaxableAmt);
    			empPayroll.setPaidAccomAmt(empPayroll.getPaidAccomAmt() + thisMonthPaidAccomAmt);
    			empPayroll.setPaidBasicAllow(empPayroll.getPaidBasicAllow() + thisMonthPaidBasicAllow);
    		}
     
    		// Save to emp_payroll_map table.
    		EmpBankAccount empBankAcct = EmpBankAccountFactory.findByEmployeeId(empPayroll.getEmployeeId().getId());
    		EmpPayrollMap empPayMap = new EmpPayrollMap();
    		empPayMap.setEmppayId(empPayroll);
    		empPayMap.setNetPay(thisMonthPaidNetPay);
    		empPayMap.setTaxAmount(thisMonthPaidTaxAmt);
    		empPayMap.setTaxableAmt(thisMonthPaidTaxableAmt);
    		empPayMap.setEmpeSocialSec(thisMonthPaidEmpeSS);
    		empPayMap.setEmprSocialSec(thisMonthPaidEmprSS);
    		empPayMap.setAccomAmt(thisMonthPaidAccomAmt);
    		empPayMap.setBasicAllow(thisMonthPaidBasicAllow);
     
    		empPayMap.setOvertimeAmt(newOvertimeAmt);
    		empPayroll.clearNewOvertimeAmt();
     
    		empPayMap.setOtherIncome(newOtherIncome);
    		empPayroll.clearNewOtherIncome();
     
    		if(isRetroEmp) {
    			empPayMap.setRetroBaseSal(empPayroll.getRetroBaseSal());
    		} else {
    			empPayMap.setRetroBaseSal(0D);
    		}
     
    		Double baseSalforMonth = empPayroll.getBaseSalary() - empPayroll.getPaidBaseSalary();
    		if(proRate.compareTo(1D) == 0) {
    			empPayMap.setBaseSalary(baseSalforMonth);
    			empPayroll.addPaidBaseSalary(baseSalforMonth);
    		} else {
    			empPayMap.setBaseSalary((empPayroll.getBaseSalary() / divNoWithProrate) * proRate);
    			empPayroll.addPaidBaseSalary((empPayroll.getBaseSalary() / divNoWithProrate) * proRate);
    		}
     
    		empPayMap.setBonus(empPayroll.getNewBonus());
    		empPayroll.clearNewBonus();
     
    		empPayMap.setCurrencyConverRate(currencyCoverVal);
     
    		ConfigData salPayDate = ConfigDataFactory.findByName(PayhumConstants.SAL_PAY_DATE);
    		empPayMap.setSalPayDate(Integer.parseInt(salPayDate.getConfigValue()));
     
    		empPayMap.setPayrollId(payroll);
     
    		if(empBankAcct != null) {
    			empPayMap.setMode(1);
    		} else {
    			empPayMap.setMode(0);
    		}
     
    		if(System.getProperty("DRYRUN") == null 
    		|| ! System.getProperty("DRYRUN").equalsIgnoreCase("true")) {
    			PayrollFactory.insertEmpPayrollMap(empPayMap);
    		}
    	}
     
    	public Map<Employee, EmployeePayroll> testExecute(Payroll payroll) throws Exception {
    		execute(payroll, false);
    		return testMap;
    	}
     
    	public static EmployeeBonus getLatestBonus(EmployeePayroll empPayroll,
    			Calendar currDtCal) {
    		List<EmployeeBonus> empBonusList = EmpPayTaxFactroy.findEmpBonus(empPayroll.getEmployeeId());
    		EmployeeBonus latestEmpBonus = null;
     
    		currDtCal.set(Calendar.HOUR_OF_DAY, 0);
    	    currDtCal.set(Calendar.MINUTE, 0);
    	    currDtCal.set(Calendar.SECOND, 0);
    	    currDtCal.set(Calendar.MILLISECOND, 0);
    	    currDtCal.set(Calendar.DAY_OF_MONTH, 1);
     
    	    for(EmployeeBonus empBonus : empBonusList) {
    			Date effectiveDate = empBonus.getGivendate();
     
    		    Calendar effDtCal = Calendar.getInstance();
    		    effDtCal.setTime(effectiveDate);
    		    // Zero out the hour, minute, second, and millisecond
    		    effDtCal.set(Calendar.HOUR_OF_DAY, 0);
    		    effDtCal.set(Calendar.MINUTE, 0);
    		    effDtCal.set(Calendar.SECOND, 0);
    		    effDtCal.set(Calendar.MILLISECOND, 0);
    		    effDtCal.set(Calendar.DAY_OF_MONTH, 1);
     
    		    if(currDtCal.equals(effDtCal)) {
    		    	// its effective from current month, so lets update the base salary
    		    	latestEmpBonus = empBonus;
    		    	break;
    		    }
    		}
     
    	    return latestEmpBonus;
    	}
    }


    --- Update ---

    The code might be little long.Here i have included the 'isRetro' condition.please check.
     else if(isRetroEmp) {
    				thisMonthPaidNetPay = (pendingNeyPay - empPayroll.getRetroBaseSal() + pendingEmpeSS) / remainingPaycycles + newOvertimeAmt + newOtherIncome
    						+ empPayroll.getRetroBaseSal();
    				thisMonthPaidTaxAmt = pendingTaxAmt / remainingPaycycles;
    				thisMonthPaidEmpeSS = pendingEmpeSS / (remainingPaycycles + 1);
    				thisMonthPaidEmprSS = pendingEmprSS / (remainingPaycycles + 1);
    				thisMonthPaidEmpeSS=pendingEmpeSS/remainingPaycycles;
    				thisMonthPaidEmprSS=pendingEmprSS/remainingPaycycles;
    				thisMonthPaidTaxableAmt = pendingTaxableAmt / remainingPaycycles;
    				thisMonthPaidAccomAmt = pendingAccomAmt / remainingPaycycles;
    				thisMonthPaidBasicAllow = pendingBasicAllow / remainingPaycycles;
    			    thisMonthPaidAllowance=pendingAllowance/remainingPaycycles;		
    				// If retro lets get 2 months SS
    				thisMonthPaidEmpeSS = thisMonthPaidEmpeSS * 2;
    				thisMonthPaidEmprSS = thisMonthPaidEmprSS * 2;
    				thisMonthPaidNetPay = thisMonthPaidNetPay - thisMonthPaidEmpeSS;
     
    				empPayroll.setPaidNetPay(empPayroll.getPaidNetPay() + thisMonthPaidNetPay);
    				empPayroll.setPaidTaxAmt(empPayroll.getPaidTaxAmt() + thisMonthPaidTaxAmt);
    				empPayroll.setPaidEmpeSS(empPayroll.getPaidEmpeSS() + thisMonthPaidEmpeSS);
    				empPayroll.setPaidEmprSS(empPayroll.getPaidEmprSS() + thisMonthPaidEmprSS);
     
    				empPayroll.setPaidTaxableAmt(empPayroll.getPaidTaxableAmt() + thisMonthPaidTaxableAmt);
    				empPayroll.setPaidAccomAmt(empPayroll.getPaidAccomAmt() + thisMonthPaidAccomAmt);
    				empPayroll.setPaidBasicAllow(empPayroll.getPaidBasicAllow() + thisMonthPaidBasicAllow);
    				empPayroll.setPaidAllowance(thisMonthPaidAllowance+empPayroll.getPaidAllowance());

  8. #8
    Member
    Join Date
    Oct 2013
    Location
    United Kingdom
    Posts
    62
    Thanks
    1
    Thanked 4 Times in 4 Posts

    Default Re: payroll-retrobaseSalary issue

    There are lots of java programs involved. If you are using an IDE, can you please run this application in debug mode and check where is the value getting modified. If the issue is only in 2014 and it worked fine in 2013 then there might be a flag incorrectly set. Can you change your system date to March, 2014 and see if the same issue appears?

    Please can you post the method defination of isRetroActive(..some parameters...)?
    Thanks and regards,
    Sambit Swain

  9. #9
    Junior Member
    Join Date
    Jul 2013
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: payroll-retrobaseSalary issue

    Ok no issue,
    here these are the methods involved in brief,it might be little long please don't mind
    package com.util.payhumpackages;
     
    import java.text.DecimalFormat;
    import java.text.SimpleDateFormat;
    import java.util.Calendar;
    import java.util.Date;
    import java.util.List;
     
    import com.openhr.data.Payroll;
    import com.openhr.data.PayrollDate;
    import com.openhr.factories.PayrollFactory;
     
    public class PayhumUtil {
     
    	static SimpleDateFormat dateformat = new SimpleDateFormat("dd/MM/yy");// 22/12/13
     
    	static SimpleDateFormat formatter = new SimpleDateFormat("dd-MMMM-yyyy");// //
    																				// 29-June-2002
     
    	static SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("dd-MM-yyyy");// 02-11-2012
     
    	static DecimalFormat decmalfrmt = new DecimalFormat("###.00");
     
    	// String s="E1_JohnSo_29_07_13";
     
    	// public enum
    	// Months{1(JANUARY),2(FEBRUARY),3(MARCH),4(APRIL),(5(MAY,6(JUNE),7(JULY),8(AUGUST),9(SEPTEMBER),10(OCTOBER),11(NOVEMBER),12(DECEMBER)};
     
    	public static String getDateFormatFullNum(Date d) {
     
    		String format = DATE_FORMAT.format(d);
     
    		return format;
    	}
     
    	public static String decimalFormat(double d) {
    		if(d == 0D) {
    			return "0.00";
    		}
     
    		return decmalfrmt.format(d);
     
    	}
     
    	public static Date getDateAfterBefore(Date d) {
     
    		// String format=DATE_FORMAT.format(d);
     
    		Calendar cal = Calendar.getInstance();
     
    		cal.setTime(d);
    		cal.add(Calendar.DATE, -7);
    		return cal.getTime();
    	}
     
    	public static Integer getNumberDays(Date dd) {
     
    		Calendar calendar = Calendar.getInstance();
    		calendar.setTime(dd);
     
    		return calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
    	}
     
    	public static String getDateFormatNum(Date d) {
     
    		String format = dateformat.format(d);
     
    		return format;
    	}
     
    	public static Integer parseInt(String sint) {
    		return Integer.valueOf(sint);
    	}
     
    	public static String getDateFormatString(Date d) {
     
    		String format = formatter.format(d);
     
    		return format;
    	}
     
    	public static String getNumberSpaces(int a) {
    		StringBuilder sb = new StringBuilder();
    		for (int i = 0; i < a; i++) {
    			sb.append(" ");
     
    		}
     
    		return sb.toString();
    	}
     
    	public static String[] splitString(String s, int limit, String regex) {
     
    		String spltit[] = s.split(regex, limit);
     
    		return spltit;
     
    	}
     
    	public static int remainingPaycycles(List<PayrollDate> payDates,
    			List<Payroll> payRuns) {
    		// default starts with 1 as the current date is being processed, but its
    		// already recorded as processed
    		int unprocessedDates = 1;
     
    		for (PayrollDate payDate : payDates) {
    			boolean processed = false;
    			for (Payroll run : payRuns) {
    				if (run.getPayDateId().getId().compareTo(payDate.getId()) == 0
    						&& run.getBranchId().getId().compareTo(payDate.getBranchId().getId()) == 0) {
    					processed = true;
    					break;
    				}
    			}
     
    			if (!processed) {
    				unprocessedDates++;
    			}
     
    		}
     
    		return unprocessedDates;
    	}
     
    	public static int remainingMonths(Calendar currDate, int finStartMonth) {
    		int retVal = 0;
     
    		// Get the remaining months in the year.
    		int currentMonth = currDate.get(Calendar.MONTH) + 1;
     
    		// Default is Jan to Dec
    		if(finStartMonth < 1)
    			finStartMonth = 1;
     
    		if(currentMonth > finStartMonth) {
    			retVal = 12 - currentMonth + 1;
    			retVal += finStartMonth - 1;
    		} else if(currentMonth == finStartMonth ) {
    			// Start of the financial year, so 12 months is left
    			retVal = 12;	
    		} else {
    			// current month is less than fin start month
    			retVal = finStartMonth - currentMonth;
    		}
     
    		return retVal;
    	}
     
    	public static boolean isRetroActive(Calendar currDate, Date hireDate, int finStartMonth, Integer branchId) {
    		Calendar hireDtCal = Calendar.getInstance();
    		hireDtCal.setTime(hireDate);
    	    // Zero out the hour, minute, second, and millisecond
    		hireDtCal.set(Calendar.HOUR_OF_DAY, 0);
    		hireDtCal.set(Calendar.MINUTE, 0);
    		hireDtCal.set(Calendar.SECOND, 0);
    		hireDtCal.set(Calendar.MILLISECOND, 0);
     
    		int currMonth = currDate.get(Calendar.MONTH);
    		int currYear = currDate.get(Calendar.YEAR);
    		int currDay = currDate.get(Calendar.DAY_OF_MONTH);
    		int hireDay = hireDtCal.get(Calendar.DAY_OF_MONTH);
    		int hireMonth = hireDtCal.get(Calendar.MONTH);
    		int hireYear = hireDtCal.get(Calendar.YEAR);
    		int runDay = 0;
     
    		try {
    			List<Payroll> payroll=PayrollFactory.findAllPayrollRunsPerBranch(branchId);
     
    			for(Payroll p:payroll){
    				Date runDate = p.getRunOnDate();
    				Calendar runCal = Calendar.getInstance();
    				runCal.setTime(runDate);
     
     
    				int runMonth = runCal.get(Calendar.MONTH);
     
    				if(currMonth == 0 && runMonth == 11) {
    					runDay = runCal.get(Calendar.DAY_OF_MONTH);
    					break;
    				}
    				else if(runMonth == currMonth - 1) {
    					runDay = runCal.get(Calendar.DAY_OF_MONTH);
    					break;
    				}
    			}
    		} catch (Exception e) {
    			// TODO Auto-generated catch block
    			e.printStackTrace();
    		}
     
     
     
    		if(currYear == hireYear && currMonth == hireMonth + 1 && hireDay >= runDay) {
    			return true;
    		}
    		else if(finStartMonth != 1 &&  currYear == hireYear + 1 && currMonth == 0 && hireDay >= currDay){
    			return true;
    		}
     
    		return false;
    	}
     
    }

  10. #10
    Member
    Join Date
    Oct 2013
    Location
    United Kingdom
    Posts
    62
    Thanks
    1
    Thanked 4 Times in 4 Posts

    Default Re: payroll-retrobaseSalary issue

    Please can you give me the value of 'hireYear' and 'currYear'. I guess both are different if program executed in 2014.
    Thanks and regards,
    Sambit Swain

  11. #11
    Junior Member
    Join Date
    Jul 2013
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: payroll-retrobaseSalary issue

    Say example emp#1 hired on 23rd december 2013,currentYear-2014,january
    Payroll execution date is 15th of every month.After 15th if they join it will be considered as retro.

  12. #12
    Member
    Join Date
    Oct 2013
    Location
    United Kingdom
    Posts
    62
    Thanks
    1
    Thanked 4 Times in 4 Posts

    Default Re: payroll-retrobaseSalary issue

    For emp#1 if hired is 23rd december 2013, then emp#1 is retro. Now your method isRetroActive() is returning false. This means if statements are holding false conditions. Only scenario left out would be finStartMonth is 1. Have you tried debugging the code or putting System.out.println() to check what exactly the values are?
    Thanks and regards,
    Sambit Swain

  13. #13
    Member
    Join Date
    Oct 2013
    Location
    United Kingdom
    Posts
    62
    Thanks
    1
    Thanked 4 Times in 4 Posts

    Default Re: payroll-retrobaseSalary issue

    In the method isRetroActive(), please can you put System.out.println() and check for the values of variables which is causeing the return value false. Keep doing the same and you will come to know what is the incorrect assigning which is causing the problem in 2014.
    Thanks and regards,
    Sambit Swain

  14. #14
    Junior Member
    Join Date
    Jul 2013
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: payroll-retrobaseSalary issue

    Ok.Let me check and get back to you people.

    --- Update ---

    ok.I think the 'retroActive' method is checking whether the employee is working extra or not?
    Returning false means if the condition is not right,then it is not retro?Please check.

  15. #15
    Junior Member
    Join Date
    Jul 2013
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: payroll-retrobaseSalary issue

    Thanks for discussing this issue has been solved.

Similar Threads

  1. Someone who can help me with my PAYROLL PROGRAM
    By driczdc in forum What's Wrong With My Code?
    Replies: 2
    Last Post: August 5th, 2013, 06:02 AM
  2. employe payroll
    By daim9996 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: April 18th, 2013, 09:35 AM
  3. Payroll Program Only Returning Value Of 0
    By starterkit123 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: February 16th, 2013, 10:17 AM
  4. [SOLVED] Please help me with this payroll program
    By Leprechaun_hunter in forum What's Wrong With My Code?
    Replies: 2
    Last Post: April 14th, 2011, 07:47 PM
  5. Payroll
    By Kesh486 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: September 6th, 2010, 07:48 PM