Files
meezi/src/Meezi.Infrastructure/ExternalServices/TarazTaxService.cs
T

65 lines
2.4 KiB
C#
Raw Normal View History

2026-05-27 21:33:48 +03:30
using Meezi.Core.Interfaces;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
2026-05-27 21:33:48 +03:30
using Microsoft.Extensions.Logging;
namespace Meezi.Infrastructure.ExternalServices;
/// <summary>
/// Taraz (سامانه مودیان) invoice submission. The real API integration is not
/// built yet, so this service NEVER fakes a tracking code outside development —
/// a merchant must not believe invoices reached the tax authority when they
/// did not.
/// </summary>
2026-05-27 21:33:48 +03:30
public class TarazTaxService : ITarazTaxService
{
private readonly IConfiguration _configuration;
private readonly IHostEnvironment _environment;
2026-05-27 21:33:48 +03:30
private readonly ILogger<TarazTaxService> _logger;
public TarazTaxService(
IConfiguration configuration,
IHostEnvironment environment,
ILogger<TarazTaxService> logger)
2026-05-27 21:33:48 +03:30
{
_configuration = configuration;
_environment = environment;
2026-05-27 21:33:48 +03:30
_logger = logger;
}
public Task<TarazSubmitResult> SubmitDailyInvoicesAsync(
string cafeId,
DateTime dateUtc,
CancellationToken cancellationToken = default)
{
if (_environment.IsDevelopment())
2026-05-27 21:33:48 +03:30
{
_logger.LogWarning(
"[DEV TARAZ] Pretend-submitted invoices for cafe {CafeId} date {Date}",
2026-05-27 21:33:48 +03:30
cafeId,
dateUtc.Date);
return Task.FromResult(new TarazSubmitResult(
true,
"DEV-TARAZ",
"Development stub — nothing was sent to the tax authority."));
}
var username = _configuration["Taraz:Username"];
if (string.IsNullOrWhiteSpace(username))
{
return Task.FromResult(new TarazSubmitResult(
false,
null,
"سرویس مودیان هنوز پیکربندی نشده است. لطفاً با پشتیبانی تماس بگیرید."));
2026-05-27 21:33:48 +03:30
}
// Credentials exist but the actual Taraz API call is not implemented yet.
// Be honest with the merchant instead of returning a fake tracking code.
_logger.LogWarning("Taraz submit requested for cafe {CafeId} but the integration is not implemented", cafeId);
return Task.FromResult(new TarazSubmitResult(
false,
null,
"اتصال مستقیم به سامانه مودیان هنوز در دست توسعه است."));
2026-05-27 21:33:48 +03:30
}
}