refactor
This commit is contained in:
parent
81f55b7b61
commit
cf91cc228d
3 changed files with 106 additions and 4 deletions
|
@ -51,6 +51,7 @@
|
|||
<Compile Include="ViesQueryValidator.cs" />
|
||||
<Compile Include="ViesResponseView.cs" />
|
||||
<Compile Include="ViesResponseParser.cs" />
|
||||
<Compile Include="ViesVatInfoMapper.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="LICENSE" />
|
||||
|
@ -59,5 +60,11 @@
|
|||
<ItemGroup>
|
||||
<Content Include=".gitignore" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\fcs-common\FCS.Lib.Common.csproj">
|
||||
<Project>{3E5FA1AB-44D2-4CBC-B6D7-80B74CA9B265}</Project>
|
||||
<Name>FCS.Lib.Common</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
|
@ -23,9 +23,6 @@
|
|||
// </copyright>
|
||||
// <summary></summary>
|
||||
// ***********************************************************************
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
@ -34,7 +31,7 @@ namespace FCS.Lib.Vies
|
|||
{
|
||||
public class ViesHttpRequest
|
||||
{
|
||||
//"http://ec.europa.eu/taxation_customs/vies/services/checkVatService"
|
||||
// "http://ec.europa.eu/taxation_customs/vies/services/checkVatService"
|
||||
public async Task<ViesResponseView> GetResponseAsync(string endpoint, string countryCode, string vatNumber, string userAgent)
|
||||
{
|
||||
var xml = new StringBuilder();
|
||||
|
|
98
ViesVatInfoMapper.cs
Normal file
98
ViesVatInfoMapper.cs
Normal file
|
@ -0,0 +1,98 @@
|
|||
// ***********************************************************************
|
||||
// Assembly : FCS.Lib.Virk
|
||||
// Author : FH
|
||||
// Created : 02-21-2022
|
||||
//
|
||||
// Last Modified By : FH
|
||||
// Last Modified On : 02-24-2022
|
||||
// ***********************************************************************
|
||||
// <copyright file="VrCvrMapper.cs" company="FCS">
|
||||
// Copyright (C) 2022 FCS Frede's Computer Services.
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the Affero GNU General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// Affero GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the Affero GNU General Public License
|
||||
// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
|
||||
// </copyright>
|
||||
// <summary></summary>
|
||||
// ***********************************************************************
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using FCS.Lib.Common;
|
||||
|
||||
namespace FCS.Lib.Vies
|
||||
{
|
||||
public class ViesVatInfoMapper
|
||||
{
|
||||
public VatInfoDto MapViesToCrm(ViesEntityModel viesEntity)
|
||||
{
|
||||
var addressBlock = viesEntity.Address.Split('\n');
|
||||
string coName;
|
||||
string address;
|
||||
string zip;
|
||||
string city;
|
||||
var i = 1;
|
||||
if (viesEntity.CountryCode == "SE" && addressBlock.Length > 0)
|
||||
{
|
||||
if (addressBlock.Length > 1)
|
||||
{
|
||||
coName = addressBlock[i];
|
||||
i++;
|
||||
}
|
||||
address = addressBlock[i];
|
||||
i++;
|
||||
zip = addressBlock[i].Substring(0, 6).Replace(" ", "");
|
||||
city = addressBlock[i].Substring(7).Trim();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (addressBlock.Length > 1)
|
||||
{
|
||||
coName = addressBlock[i];
|
||||
i++;
|
||||
}
|
||||
address = addressBlock[i];
|
||||
i++;
|
||||
zip = addressBlock[i].Substring(0, 5).Replace(" ", "");
|
||||
city = addressBlock[i].Substring(5).Trim();
|
||||
}
|
||||
var c = new VatInfoDto
|
||||
{
|
||||
Name = viesEntity.Name,
|
||||
Address = address,
|
||||
VatNumber = viesEntity.VatNumber,
|
||||
City = city,
|
||||
ZipCode = zip,
|
||||
RequestDate = viesEntity.RequestDate
|
||||
};
|
||||
c.States.Add(new VatState
|
||||
{
|
||||
State = viesEntity.Valid ? "NORMAL" : "LUKKET",
|
||||
LastUpdate = viesEntity.RequestDate,
|
||||
TimeFrame = new TimeFrame
|
||||
{
|
||||
EndDate = "NA",
|
||||
StartDate = "NA"
|
||||
}
|
||||
});
|
||||
c.LifeCycles.Add(new LifeCycle
|
||||
{
|
||||
LastUpdate = viesEntity.RequestDate,
|
||||
TimeFrame = new TimeFrame
|
||||
{
|
||||
StartDate = "NN",
|
||||
EndDate = "NN"
|
||||
}
|
||||
});
|
||||
return c;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue