ekioISpro

Untitled

May 7th, 2020
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.29 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using WNPayroll.TaxCalcs;
  4. using WNPayroll.Zenith.Models.Data.Payroll;
  5. using Xunit;
  6. using Zenith.Business.Engine;
  7. using Zenith.Models.Data.Payroll.PayData;
  8. using SubTaxType = WNPayroll.Zenith.Models.Data.Enums.SubTaxType;
  9.  
  10. namespace Zenith.UnitTests.Test_Cases
  11. {
  12.     public class FUTATests
  13.     {
  14.         private readonly PayrollEngineV2 Engine = new PayrollEngineV2();
  15.         private ZenithPayrollData PD = new ZenithPayrollData();
  16.  
  17.         private readonly Boolean W42020Tests = false;
  18.         private readonly States StateTested = States.CA;
  19.  
  20.         /*  Monthly = 1
  21.          *  Semi-weekly = 2   */
  22.         private readonly short Default_FederalTaxDueFrequency = 1;
  23.  
  24.         [Fact]
  25.         public void P53()
  26.         {
  27.             PD = TestDefaults.ResetPayrollData(StateTested);
  28.  
  29.             PD.Employees[0].PayDataRecords[0] = TestDefaults.DefaultRecord(25, 40);
  30.  
  31.             //  CA State
  32.             PD.Employees[0].StateTaxes.Add(new EmployeeStateTax()
  33.             {
  34.                 TaxID = 2,
  35.                 State = StateTested,
  36.                 CompanyTaxDueFrequency = Default_FederalTaxDueFrequency
  37.             });
  38.  
  39.             //  Allowances and filing status are stored in Parameters in EmployeeStateTax class so we have to add them here outside
  40.             //  Parameters is a list of decimals (later cast into their appropriate types, sensitive to list index)
  41.  
  42.             /*  Filing Status: SingleOrMarriedMultipleIncomes = 1, MarriedOneIncome = 2, HeadOfHousehold = 4  */
  43.             PD.Employees[0].StateTaxes[0].Parameters.Add(1);
  44.             /*  Allowances  */
  45.             PD.Employees[0].StateTaxes[0].Parameters.Add(0);
  46.             /*  Additional allowances   */
  47.             PD.Employees[0].StateTaxes[0].Parameters.Add(0);
  48.             /*  Additional withholding  */
  49.             PD.Employees[0].StateTaxes[0].Parameters.Add(0);
  50.             /*  Exempt from State tax: false=0, true=1  */
  51.             PD.Employees[0].StateTaxes[0].Parameters.Add(0);
  52.  
  53.             //  Federal
  54.             PD.Employees[0].FederalTaxes[0] = new EmployeeFederalTax()
  55.             {
  56.                 TaxID = 1,
  57.                 FilingStatus = (short)FederalTaxCalcs.FilingStatus.Single,
  58.                 Allowances = 0,
  59.                 SubTaxType = SubTaxType.FederalTax,
  60.  
  61.                 CompanyTaxDueFrequency = Default_FederalTaxDueFrequency,
  62.                 SUTAState = StateTested,
  63.                 IsW42020OrLater = W42020Tests,
  64.             };
  65.  
  66.             //  FUTA
  67.             //  Note the index number. If we left it at 0, it'd just overwrite the previous Federal tax object.
  68.             PD.Employees[0].FederalTaxes.Add(new EmployeeFederalTax()
  69.             {
  70.                 TaxID = 3,
  71.                 FilingStatus = (short)FederalTaxCalcs.FilingStatus.Single,
  72.                 Allowances = 0,
  73.                 SubTaxType = SubTaxType.FUTA,
  74.  
  75.                 CompanyTaxDueFrequency = Default_FederalTaxDueFrequency,
  76.                 SUTAState = StateTested,
  77.                 IsW42020OrLater = W42020Tests,
  78.             });
  79.  
  80.             var results = Engine.Process(PD);
  81.  
  82.             Assert.Equal(1000m, results.First().GrossPay, 0);
  83.             Assert.Equal(6m, results.First().PayrollTaxes.Find(x => x.TaxID == 3).CompanyAmount, 0);
  84.         }
  85.     }
  86. }
Add Comment
Please, Sign In to add comment