2026-05-27 21:33:48 +03:30
|
|
|
using Meezi.Core.Interfaces;
|
|
|
|
|
using Microsoft.Extensions.Configuration;
|
2026-06-12 10:16:01 +03:30
|
|
|
using Microsoft.Extensions.Hosting;
|
2026-05-27 21:33:48 +03:30
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
|
|
|
|
|
namespace Meezi.Infrastructure.ExternalServices;
|
|
|
|
|
|
2026-06-12 10:16:01 +03:30
|
|
|
/// <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;
|
2026-06-12 10:16:01 +03:30
|
|
|
private readonly IHostEnvironment _environment;
|
2026-05-27 21:33:48 +03:30
|
|
|
private readonly ILogger<TarazTaxService> _logger;
|
|
|
|
|
|
2026-06-12 10:16:01 +03:30
|
|
|
public TarazTaxService(
|
|
|
|
|
IConfiguration configuration,
|
|
|
|
|
IHostEnvironment environment,
|
|
|
|
|
ILogger<TarazTaxService> logger)
|
2026-05-27 21:33:48 +03:30
|
|
|
{
|
|
|
|
|
_configuration = configuration;
|
2026-06-12 10:16:01 +03:30
|
|
|
_environment = environment;
|
2026-05-27 21:33:48 +03:30
|
|
|
_logger = logger;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Task<TarazSubmitResult> SubmitDailyInvoicesAsync(
|
|
|
|
|
string cafeId,
|
|
|
|
|
DateTime dateUtc,
|
|
|
|
|
CancellationToken cancellationToken = default)
|
|
|
|
|
{
|
2026-06-12 10:16:01 +03:30
|
|
|
if (_environment.IsDevelopment())
|
2026-05-27 21:33:48 +03:30
|
|
|
{
|
2026-06-12 10:16:01 +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,
|
2026-06-12 10:16:01 +03:30
|
|
|
"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
|
|
|
}
|
|
|
|
|
|
2026-06-12 10:16:01 +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
|
|
|
}
|
|
|
|
|
}
|