101 lines
3.7 KiB
C#
101 lines
3.7 KiB
C#
using Back.Common;
|
|
using Microsoft.IdentityModel.Tokens;
|
|
|
|
using Shared.DTOs;
|
|
|
|
|
|
namespace Back.Services
|
|
{
|
|
public class ActionTaxPayer
|
|
{
|
|
private string _UniqueMemory;
|
|
private string _PrivateKey;
|
|
private readonly servCompany _servCompany;
|
|
private readonly IConfiguration _configuration;
|
|
|
|
public ActionTaxPayer(servCompany servCompany, IConfiguration configuration)
|
|
{
|
|
_servCompany = servCompany;
|
|
_configuration = configuration;
|
|
}
|
|
|
|
public string GenerateTaxid(string FactorNo, string InvoiceDate)
|
|
{
|
|
return "testTaxid";
|
|
//return TaxApiService.Instance.TaxIdGenerator.GenerateTaxId(_UniqueMemory,
|
|
// Convert.ToInt64(FactorNo), InvoiceDate.ToMiladi());
|
|
}
|
|
//public async Task<InquiryResultModel> GetResultByUid(int CompanyID, string uid)
|
|
//{
|
|
|
|
// var uidAndFiscalId = new UidAndFiscalId(uid, _UniqueMemory);
|
|
// var inquiryResultModels = TaxApiService.Instance.TaxApis.InquiryByUidAndFiscalId(new() { uidAndFiscalId });
|
|
// if (inquiryResultModels.Count > 0)
|
|
// return inquiryResultModels[0];
|
|
// return null;
|
|
//}
|
|
//public async Task<TaxCollectData.Library.Dto.HttpResponse<AsyncResponseModel>> SendInvoice(int CompanyID,InvoiceHeaderDto header, List<InvoiceBodyDto> InvoiceBody, List<PaymentDto> payments)
|
|
//{
|
|
// return await TaxApiService.Instance.TaxApis.SendInvoicesAsync(new List<InvoiceDto>()
|
|
// {
|
|
// new()
|
|
// {
|
|
// Header =header,Body =InvoiceBody,Payments = payments
|
|
// }
|
|
// }
|
|
// , null);
|
|
//}
|
|
//public async Task<EconomicCodeModel?> GetEconomicCodeInformation(string Item)
|
|
//{
|
|
|
|
// return await TaxApiService.Instance.TaxApis.GetEconomicCodeInformationAsync(Item);
|
|
|
|
|
|
//}
|
|
//public async Task<FiscalInformationModel?> GetFiscalInformation(string Item)
|
|
//{
|
|
// return await TaxApiService.Instance.TaxApis.GetFiscalInformationAsync(Item);
|
|
//}
|
|
//-------------------internal
|
|
public async Task<bool> login(int CompanyID)
|
|
{
|
|
return false;
|
|
//try
|
|
//{
|
|
// #region TokenTax
|
|
// var resquth = await _servCompany.GetTaxAuth(CompanyID);
|
|
// if (string.IsNullOrEmpty(resquth.UniqueMemory) || string.IsNullOrEmpty(resquth.PrivateKey))
|
|
// return false;
|
|
|
|
// if (!string.IsNullOrEmpty(resquth.UniqueMemory) && !string.IsNullOrEmpty(resquth.PrivateKey))
|
|
// {
|
|
|
|
// //string taxapi = _configuration.GetSection("TaxPayerApi").Value;
|
|
// string taxapi = "https://sandboxrc.tax.gov.ir/req/api/";
|
|
// _UniqueMemory = resquth.UniqueMemory;
|
|
// _PrivateKey = resquth.PrivateKey;
|
|
// TaxApiService.Instance.Init(_UniqueMemory,
|
|
// new SignatoryConfig(_PrivateKey, null),
|
|
// new NormalProperties(ClientType.SELF_TSP), taxapi);
|
|
// await TaxApiService.Instance.TaxApis.GetServerInformationAsync();
|
|
// }
|
|
// #endregion
|
|
|
|
// if (TaxApiService.Instance.TaxApis.GetToken() is null)
|
|
// {
|
|
// if (await TaxApiService.Instance.TaxApis.RequestTokenAsync() == null)
|
|
// return false;
|
|
// }
|
|
// return true;
|
|
//}
|
|
//catch (Exception)
|
|
//{
|
|
// return false;
|
|
//}
|
|
|
|
}
|
|
|
|
|
|
}
|
|
}
|