Skip to content
This repository was archived by the owner on Apr 12, 2021. It is now read-only.

Commit e93e117

Browse files
authored
Merge pull request #244 from MJMortimer/f/PayrollUpdates
Payroll updates
2 parents 6d19236 + fa24b1c commit e93e117

18 files changed

+115
-21
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using System.Linq;
2+
using NUnit.Framework;
3+
using Xero.Api.Infrastructure.Exceptions;
4+
using Xero.Api.Payroll.Australia.Model;
5+
6+
namespace PayrollTests.AU.Integration.ValidationErrors
7+
{
8+
public class AUPayrollValidationErrors : ApiWrapperTest
9+
{
10+
[Test]
11+
public void Validation_errors_are_returned_from_the_AU_payroll_api()
12+
{
13+
var employee = new Employee() {FirstName = "Jimmy"};
14+
15+
try
16+
{
17+
Api.Employees.Create(employee);
18+
}
19+
catch (ValidationException e)
20+
{
21+
Assert.True(e.ValidationErrors.Any(p => p.Message == "The Last Name is required."));
22+
Assert.True(e.ValidationErrors.Any(p => p.Message == "The Home Address is required."));
23+
return;
24+
}
25+
26+
throw new AssertionException("Expected validation errors");
27+
}
28+
}
29+
}

PayrollTests.AU/PayrollTests.AU.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
<Compile Include="Integration\TimeSheets\Create.cs" />
7070
<Compile Include="Integration\TimeSheets\Find.cs" />
7171
<Compile Include="Integration\TimeSheets\TimesheetTest.cs" />
72+
<Compile Include="Integration\ValidationErrors\AUPayrollValidationErrors.cs" />
7273
<Compile Include="Properties\AssemblyInfo.cs" />
7374
</ItemGroup>
7475
<ItemGroup>

Xero.Api.Example.MVC/Web.config

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@
5959
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
6060
<bindingRedirect oldVersion="4.0.0.0-4.0.0.1" newVersion="4.0.0.1" />
6161
</dependentAssembly>
62+
<dependentAssembly>
63+
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
64+
<bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
65+
</dependentAssembly>
6266
</assemblyBinding>
6367
</runtime>
6468
<entityFramework>

Xero.Api.Example.MVC/Xero.Api.Example.MVC.csproj

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020
<IISExpressAnonymousAuthentication />
2121
<IISExpressWindowsAuthentication />
2222
<IISExpressUseClassicPipelineMode />
23-
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">.\</SolutionDir> <TargetFrameworkProfile />
23+
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">.\</SolutionDir>
24+
<TargetFrameworkProfile />
25+
<UseGlobalApplicationHostFile />
2426
</PropertyGroup>
2527
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
2628
<DebugSymbols>true</DebugSymbols>
@@ -45,8 +47,8 @@
4547
<HintPath>..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath>
4648
<Private>True</Private>
4749
</Reference>
48-
<Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
49-
<HintPath>..\packages\Newtonsoft.Json.4.5.6\lib\net40\Newtonsoft.Json.dll</HintPath>
50+
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
51+
<HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net40\Newtonsoft.Json.dll</HintPath>
5052
<Private>True</Private>
5153
</Reference>
5254
<Reference Include="System" />

Xero.Api.Example.MVC/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@
88
<package id="Microsoft.AspNet.WebPages" version="2.0.20710.0" targetFramework="net40" />
99
<package id="Microsoft.Net.Http" version="2.0.20710.0" targetFramework="net40" />
1010
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net40" />
11-
<package id="Newtonsoft.Json" version="4.5.6" targetFramework="net40" />
11+
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net40" />
1212
</packages>

Xero.Api/Infrastructure/Http/XeroHttpClient.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
using System.Collections.Specialized;
44
using System.Linq;
55
using System.Net;
6+
using Newtonsoft.Json.Linq;
67
using Xero.Api.Common;
78
using Xero.Api.Infrastructure.Exceptions;
89
using Xero.Api.Infrastructure.Interfaces;
10+
using Xero.Api.Infrastructure.Model;
911
using Xero.Api.Infrastructure.RateLimiter;
1012

1113
namespace Xero.Api.Infrastructure.Http
@@ -109,6 +111,16 @@ internal void HandleErrors(Response response)
109111
throw new ValidationException(data);
110112
}
111113

114+
//CHeck for inline errors
115+
var jsonObject = JObject.Parse(response.Body);
116+
var inlineValidationErrors = jsonObject.SelectTokens("$..ValidationErrors..Message").Select(p => new ValidationError { Message = p.ToString() }).ToList();
117+
118+
if (inlineValidationErrors.Any())
119+
{
120+
data.Elements = new List<DataContractBase> { new DataContractBase {ValidationErrors = inlineValidationErrors } };
121+
throw new ValidationException(data);
122+
}
123+
112124
throw new BadRequestException(data);
113125
}
114126

Xero.Api/Payroll/Australia/Model/DeductionLine.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class DeductionLine
1414
public decimal? Amount { get; set; }
1515

1616
[DataMember(EmitDefaultValue = false)]
17-
public DeductionCalculationType CalculationType { get; set; }
17+
public DeductionCalculationType? CalculationType { get; set; }
1818

1919
[DataMember(EmitDefaultValue = false)]
2020
public decimal NumberOfUnits { get; set; }

Xero.Api/Payroll/Australia/Model/EarningsLine.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ public class EarningsLine
2929
public decimal? NumberOfUnits { get; set; }
3030

3131
[DataMember(EmitDefaultValue = false)]
32-
public EarningsRateCalculationType EarningsRateCalculation { get; set; }
32+
public EarningsRateCalculationType? CalculationType { get; set; }
3333
}
3434
}

Xero.Api/Payroll/Australia/Model/LeaveLine.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public class LeaveLine
1111
public Guid LeaveTypeId { get; set; }
1212

1313
[DataMember(EmitDefaultValue = false)]
14-
public decimal NumberOfUnits { get; set; }
14+
public decimal? NumberOfUnits { get; set; }
1515

1616
[DataMember(EmitDefaultValue = false)]
1717
public decimal AnnualNumberOfUnits { get; set; }

Xero.Api/Payroll/Australia/Model/Payslip.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public class Payslip : PayNotice
2424
public decimal Wages { get; set; }
2525

2626
[DataMember]
27-
public List<EarningsLine> EarningsLines { get; set; }
27+
public List<PayslipEarningsLine> EarningsLines { get; set; }
2828

2929
[DataMember]
3030
public List<DeductionLine> DeductionLines { get; set; }
@@ -46,5 +46,9 @@ public class Payslip : PayNotice
4646

4747
[DataMember]
4848
public List<TaxLine> TaxLines { get; set; }
49+
50+
[DataMember(EmitDefaultValue = false, Name = "PayRunID")]
51+
public Guid PayRunId { get; set; }
52+
4953
}
5054
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
6+
namespace Xero.Api.Payroll.Australia.Model
7+
{
8+
using System.Runtime.Serialization;
9+
10+
/// <summary>
11+
/// Earnings Line for a payslip
12+
/// </summary>
13+
[DataContract(Namespace = "", Name = "EarningsLine")]
14+
public class PayslipEarningsLine
15+
{
16+
[DataMember(Name = "EarningsRateID")]
17+
public Guid EarningsRateId { get; set; }
18+
19+
[DataMember()]
20+
public decimal? RatePerUnit { get; set; }
21+
22+
[DataMember()]
23+
public decimal? NumberOfUnits { get; set; }
24+
25+
[DataMember(EmitDefaultValue = true)]
26+
public decimal? FixedAmount { get; set; }
27+
}
28+
}

Xero.Api/Payroll/Australia/Model/SuperLine.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ public class SuperLine
1111
public Guid SuperMembershipId { get; set; }
1212

1313
[DataMember(EmitDefaultValue = false)]
14-
public SuperannuationCalculationType CalculationType { get; set; }
14+
public SuperannuationCalculationType? CalculationType { get; set; }
1515

1616
[DataMember(EmitDefaultValue = false)]
17-
public SuperannuationContributionType ContributionType { get; set; }
17+
public SuperannuationContributionType? ContributionType { get; set; }
1818

1919
[DataMember(EmitDefaultValue = false)]
2020
public int ExpenseAccountCode { get; set; }

Xero.Api/Payroll/Australia/Model/SuperannuationLine.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ namespace Xero.Api.Payroll.Australia.Model
77
[DataContract(Namespace = "")]
88
public class SuperannuationLine
99
{
10-
[DataMember(Name = "SuperMembershipID")]
10+
[DataMember(Name = "SuperMembershipID", EmitDefaultValue = false)]
1111
public Guid SuperMembershipId { get; set; }
1212

1313
[DataMember]
14-
public SuperannuationContributionType ContributionType { get; set; }
14+
public SuperannuationContributionType? ContributionType { get; set; }
1515

1616
[DataMember]
17-
public SuperannuationCalculationType CalculationType { get; set; }
17+
public SuperannuationCalculationType? CalculationType { get; set; }
1818

1919
[DataMember]
2020
public decimal MinimumMonthlyEarnings { get; set; }

Xero.Api/Payroll/Australia/Model/TaxDeclaration.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ public class TaxDeclaration : HasUpdatedDate
2424
public bool AustralianResidentForTaxPurposes { get; set; }
2525

2626
[DataMember(EmitDefaultValue = false)]
27-
public bool TaxFreeThresholdClaimed { get; set; }
27+
public bool? TaxFreeThresholdClaimed { get; set; }
2828

2929
[DataMember(Name = "HasHELPDebt", EmitDefaultValue = false)]
3030
public bool HasHigherEducationLoanProgramDebt { get; set; }
3131

3232
[DataMember(Name = "HasSFSSDebt", EmitDefaultValue = false)]
3333
public bool HasStudentFinancialSupplementSchemeDebt { get; set; }
34-
34+
3535
[DataMember(Name = "HasTSLDebt", EmitDefaultValue = false)]
3636
public bool HasTradeSupportLoan { get; set; }
3737

@@ -51,5 +51,9 @@ public class TaxDeclaration : HasUpdatedDate
5151

5252
[DataMember(EmitDefaultValue = false)]
5353
public decimal? UpwardVariationTaxWithholdingAmount { get; set; }
54+
55+
56+
[DataMember(Name = "TFNExemptionType", EmitDefaultValue = false)]
57+
public TaxFileNumberExemptionType? TaxFileNumberExemption { get; set; }
5458
}
5559
}

Xero.Api/Payroll/Australia/Model/Types/EarningsType.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,15 @@ namespace Xero.Api.Payroll.Australia.Model.Types
55
[DataContract(Namespace = "")]
66
public enum EarningsType
77
{
8+
[EnumMember(Value = "FIXED")]
9+
Fixed,
810
[EnumMember(Value = "ORDINARYTIMEEARNINGS")]
911
OrdinaryTimeEarnings,
1012
[EnumMember(Value = "OVERTIMEEARNINGS")]
1113
OverTimeEarnings,
1214
[EnumMember(Value = "ALLOWANCE")]
1315
Allowance,
14-
[EnumMember(Value = "COMMISSION")]
15-
Commission,
16-
[EnumMember(Value = "BONUS")]
17-
Bonus,
18-
[EnumMember(Value = "BACKPAY")]
19-
BackPay
16+
[EnumMember(Value = "LUMPSUMD")]
17+
LumpSumD
2018
}
2119
}

Xero.Api/Payroll/Australia/Model/Types/SuperannuationCalculationType.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ namespace Xero.Api.Payroll.Australia.Model.Types
55
[DataContract(Namespace = "")]
66
public enum SuperannuationCalculationType
77
{
8+
[EnumMember(Value = "STATUTORY")]
9+
Statutory,
810
[EnumMember(Value = "FIXEDAMOUNT")]
911
FixedAmount,
1012
[EnumMember(Value = "PERCENTAGEOFEARNINGS")]

Xero.Api/Xero.Api.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@
3333
<WarningLevel>4</WarningLevel>
3434
</PropertyGroup>
3535
<ItemGroup>
36+
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
37+
<HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net40\Newtonsoft.Json.dll</HintPath>
38+
<Private>True</Private>
39+
</Reference>
3640
<Reference Include="System" />
3741
<Reference Include="System.Core" />
3842
<Reference Include="System.Data.Linq" />
@@ -258,6 +262,7 @@
258262
<Compile Include="Payroll\America\Response\TimesheetsResponse.cs" />
259263
<Compile Include="Payroll\Australia\Endpoints\TimesheetsEndpoint.cs" />
260264
<Compile Include="Payroll\Australia\Model\LeaveBalance.cs" />
265+
<Compile Include="Payroll\Australia\Model\PayslipEarningsLine.cs" />
261266
<Compile Include="Payroll\Australia\Model\Settings.cs" />
262267
<Compile Include="Payroll\Australia\Model\Timesheet.cs" />
263268
<Compile Include="Payroll\Australia\Model\TimesheetLine.cs" />
@@ -554,6 +559,7 @@
554559
<Compile Include="Infrastructure\ThirdParty\ServiceStack.Text\XmlSerializer.cs" />
555560
</ItemGroup>
556561
<ItemGroup>
562+
<None Include="packages.config" />
557563
<None Include="README.md" />
558564
</ItemGroup>
559565
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

Xero.Api/packages.config

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<packages>
3+
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net40-client" />
4+
</packages>

0 commit comments

Comments
 (0)