...
This commit is contained in:
@@ -23,6 +23,7 @@
|
|||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
|
<PackageReference Include="TaxCollectData.Library" Version="0.0.15" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@@ -67,5 +67,23 @@ namespace Back.Controllers
|
|||||||
|
|
||||||
return Ok(await _servTaxPayer.PreparationInvoiceBeforeSending(item, result));
|
return Ok(await _servTaxPayer.PreparationInvoiceBeforeSending(item, result));
|
||||||
}
|
}
|
||||||
|
[HttpPost("CheckAuth")]
|
||||||
|
public async Task<ActionResult<string>> CheckAuth([FromBody] CheckAuthDTO item)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (item == null)
|
||||||
|
return BadRequest("مدل صحیح نمی باشد");
|
||||||
|
|
||||||
|
using (ActionTaxPayer action = new ActionTaxPayer(item.UniqueMemory, item.PrivateKey))
|
||||||
|
{
|
||||||
|
if (action.login())
|
||||||
|
return Ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return BadRequest();
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
85
Back/Services/ActionTaxPayer.cs
Normal file
85
Back/Services/ActionTaxPayer.cs
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
using Back.Common;
|
||||||
|
using TaxCollectData.Library.Business;
|
||||||
|
using TaxCollectData.Library.Dto.Config;
|
||||||
|
using TaxCollectData.Library.Dto.Content;
|
||||||
|
using TaxCollectData.Library.Dto.Properties;
|
||||||
|
using TaxCollectData.Library.Dto.Transfer;
|
||||||
|
using TaxCollectData.Library.Enums;
|
||||||
|
|
||||||
|
namespace Back.Services
|
||||||
|
{
|
||||||
|
public class ActionTaxPayer : IDisposable
|
||||||
|
{
|
||||||
|
private string _UniqueMemory;
|
||||||
|
public ActionTaxPayer(string UniqueMemory, string PrivateKey)
|
||||||
|
{
|
||||||
|
#region TokenTax
|
||||||
|
if (!string.IsNullOrEmpty(UniqueMemory) && !string.IsNullOrEmpty(PrivateKey))
|
||||||
|
{
|
||||||
|
_UniqueMemory = UniqueMemory;
|
||||||
|
|
||||||
|
TaxApiService.Instance.Init(UniqueMemory,
|
||||||
|
new SignatoryConfig(PrivateKey, null),
|
||||||
|
new NormalProperties(ClientType.SELF_TSP), "https://tp.tax.gov.ir/req/api/");
|
||||||
|
TaxApiService.Instance.TaxApis.GetServerInformation();
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
public string GenerateTaxid(string FactorNo, string InvoiceDate)
|
||||||
|
{
|
||||||
|
return TaxApiService.Instance.TaxIdGenerator.GenerateTaxId(_UniqueMemory,
|
||||||
|
Convert.ToInt64(FactorNo), InvoiceDate.ToMiladi());
|
||||||
|
}
|
||||||
|
|
||||||
|
public InquiryResultModel GetResultByUid(string uid)
|
||||||
|
{
|
||||||
|
if (!login())
|
||||||
|
return null;
|
||||||
|
var uidAndFiscalId = new UidAndFiscalId(uid, _UniqueMemory);
|
||||||
|
var inquiryResultModels = TaxApiService.Instance.TaxApis.InquiryByUidAndFiscalId(new() { uidAndFiscalId });
|
||||||
|
if (inquiryResultModels.Count > 0)
|
||||||
|
return inquiryResultModels[0];
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
public TaxCollectData.Library.Dto.HttpResponse<AsyncResponseModel> SendInvoice(InvoiceHeaderDto header, List<InvoiceBodyDto> InvoiceBody, PaymentDto payment)
|
||||||
|
{
|
||||||
|
if (!login())
|
||||||
|
return null;
|
||||||
|
return TaxApiService.Instance.TaxApis.SendInvoices(new List<InvoiceDto>()
|
||||||
|
{
|
||||||
|
new InvoiceDto()
|
||||||
|
{
|
||||||
|
Header =header,Body =InvoiceBody,Payments = new() {payment}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
, null);
|
||||||
|
}
|
||||||
|
public EconomicCodeModel? GetEconomicCodeInformation(string Item)
|
||||||
|
{
|
||||||
|
return TaxApiService.Instance.TaxApis.GetEconomicCodeInformation(Item);
|
||||||
|
}
|
||||||
|
//-------------------internal
|
||||||
|
public bool login()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (TaxApiService.Instance.TaxApis.GetToken() is null)
|
||||||
|
{
|
||||||
|
if(TaxApiService.Instance.TaxApis.RequestToken()==null)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -251,5 +251,7 @@ namespace Back.Services
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
14
Shared/DTOs/CheckAuthDTO.cs
Normal file
14
Shared/DTOs/CheckAuthDTO.cs
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Shared.DTOs
|
||||||
|
{
|
||||||
|
public class CheckAuthDTO
|
||||||
|
{
|
||||||
|
public string UniqueMemory { get; set; }
|
||||||
|
public string PrivateKey { get; set; }
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user