C# Comparing two lists to check if Payroll Process was done correctly (Validation)
<p>Im am learning C# and am making a Payroll Add-On for SAP Business One.</p>

<p>I have completed the payroll process that calculates netpay, gross pay, PAYE, earnings, deductions etc. These calculations for each employee are entered into a temporary process data table.</p>

<p>I now want to do a monthly rollover (close the current month). To do so, I have to do some validation to make sure that the calculations were done correctly before removing contents from the temp process data table to a permanent one.</p>

<p>I want to do this by comparing two lists. </p>

<p>The 1st is drawn from Employee Master Data in SAP and it contains employee IDs, names, telephones, salary units etc. I have selected employeeIDs only.</p>

<p>The 2nd is drawn from Process_Data_Temp and it contains employee IDs, net pay (U_PD_code = SYS001) etc.</p>

<p>I want to match this list by making sure that all the empIDs in 1st are contained in the 2nd (exactly) and that the net pay in the 2nd list is not null ie (U_PD_code where == SYS001 is not null or empty) etc. .</p>

<p>I want to do three comparisons based on salary unit ie. Monthly = M, SemiMonthly =S and Weekly = W.
Right now I'm interested in Monthly.</p>

<p>The field salary unit is in Employee master data but not in the process data temp table so I'm not sure how I will get distinct empIDs that are on monthly pay in the temp table in order to do the comparison. I am comparing monthly employees first.</p>

<p><strong>Process_Data_Temp fields</strong></p>

<pre><code>Code Name, U_Tax_year, U_Employee_ID, U_Process_month, U_PD_code U_Amount, U_Balance, 

U_Employer_cont_amnt
</code></pre>

<p>How does one do this?</p>

<p><strong>My Code So Far</strong></p>

<pre><code>private void DoMonthEndRollover()
{
// Get service instances needed            
var getAllEmployees = Program.Kernel.Get&lt;IEmployeeService&gt;().GetAllEmployees().Where(x =&gt; x.salaryUnit.ToString() == "M");
var tempProcessData = Program.Kernel.Get&lt;IProcessDataTempService&gt;().GetAllProcessDataTemps();

// Get all employee IDs from first list
var employeeIdList = (from el in getAllEmployees select el.empID).Distinct();

// Get information from second list
var tempList = (from tl in tempProcessData orderby tl.U_Employee_ID select tl).Distinct(); ......not finished

// Check if all Employee IDs have net pay (Contained in Process Data Temporary table)

}
</code></pre>

<p>NB: The Process Data Temporary table contains calculations of all employees whether monthly, semimonthly or weekly.</p>

<p>I hope I am clear enough</p>
