Files
moadiran/Back/Services/ActionTaxPayer.cs

101 lines
3.7 KiB
C#
Raw Normal View History

2024-06-09 10:03:30 +03:30
using Back.Common;
2024-06-09 17:23:57 +03:30
using Microsoft.IdentityModel.Tokens;
2025-10-03 23:30:01 +03:30
2024-07-09 23:04:19 +03:30
using Shared.DTOs;
2025-10-03 23:30:01 +03:30
2024-06-09 10:03:30 +03:30
namespace Back.Services
{
2024-06-09 17:23:57 +03:30
public class ActionTaxPayer
2024-06-09 10:03:30 +03:30
{
private string _UniqueMemory;
2024-06-09 17:23:57 +03:30
private string _PrivateKey;
private readonly servCompany _servCompany;
2024-11-29 18:52:58 +03:30
private readonly IConfiguration _configuration;
public ActionTaxPayer(servCompany servCompany, IConfiguration configuration)
2024-06-09 10:03:30 +03:30
{
2024-06-09 17:23:57 +03:30
_servCompany = servCompany;
2024-11-29 18:52:58 +03:30
_configuration = configuration;
2024-06-09 10:03:30 +03:30
}
2024-11-29 18:52:58 +03:30
2024-06-09 10:03:30 +03:30
public string GenerateTaxid(string FactorNo, string InvoiceDate)
{
2025-10-03 23:30:01 +03:30
return "testTaxid";
//return TaxApiService.Instance.TaxIdGenerator.GenerateTaxId(_UniqueMemory,
// Convert.ToInt64(FactorNo), InvoiceDate.ToMiladi());
2024-06-09 10:03:30 +03:30
}
2025-10-03 23:30:01 +03:30
//public async Task<InquiryResultModel> GetResultByUid(int CompanyID, string uid)
//{
2024-10-16 16:35:38 +03:30
2025-10-03 23:30:01 +03:30
// 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)
//{
2024-10-16 23:36:52 +03:30
2025-10-03 23:30:01 +03:30
// return await TaxApiService.Instance.TaxApis.GetEconomicCodeInformationAsync(Item);
2024-10-16 23:36:52 +03:30
2025-10-03 23:30:01 +03:30
//}
//public async Task<FiscalInformationModel?> GetFiscalInformation(string Item)
//{
// return await TaxApiService.Instance.TaxApis.GetFiscalInformationAsync(Item);
//}
2024-06-09 10:03:30 +03:30
//-------------------internal
2024-06-09 17:23:57 +03:30
public async Task<bool> login(int CompanyID)
2024-06-09 10:03:30 +03:30
{
2025-10-03 23:30:01 +03:30
return false;
//try
//{
// #region TokenTax
// var resquth = await _servCompany.GetTaxAuth(CompanyID);
// if (string.IsNullOrEmpty(resquth.UniqueMemory) || string.IsNullOrEmpty(resquth.PrivateKey))
// return false;
2024-10-16 16:35:38 +03:30
2025-10-03 23:30:01 +03:30
// if (!string.IsNullOrEmpty(resquth.UniqueMemory) && !string.IsNullOrEmpty(resquth.PrivateKey))
// {
2024-11-29 18:52:58 +03:30
2025-10-03 23:30:01 +03:30
// //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
2024-06-09 17:23:57 +03:30
2025-10-03 23:30:01 +03:30
// if (TaxApiService.Instance.TaxApis.GetToken() is null)
// {
// if (await TaxApiService.Instance.TaxApis.RequestTokenAsync() == null)
// return false;
// }
// return true;
//}
//catch (Exception)
//{
// return false;
//}
2024-06-09 10:03:30 +03:30
}
2024-06-09 17:23:57 +03:30
2024-06-09 10:03:30 +03:30
}
}