< Summary

Information
Class: Services.TransactionCommentAi.TransactionCommentAiFallbackFormatter
Assembly: Services
File(s): /home/runner/work/Studio2Prod/Studio2Prod/AppRepository/TransactionCommentAi/TransactionCommentAiFallbackFormatter.cs
Line coverage
100%
Covered lines: 32
Uncovered lines: 0
Coverable lines: 32
Total lines: 57
Line coverage: 100%
Branch coverage
83%
Covered branches: 20
Total branches: 24
Branch coverage: 83.3%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.cctor()50%22100%
Format(...)86.36%2222100%

File(s)

/home/runner/work/Studio2Prod/Studio2Prod/AppRepository/TransactionCommentAi/TransactionCommentAiFallbackFormatter.cs

#LineLine coverage
 1using System.Globalization;
 2using System.Text;
 3
 4namespace Services.TransactionCommentAi;
 5
 6public static class TransactionCommentAiFallbackFormatter
 7{
 18    private static readonly CultureInfo Ru = CultureInfo.GetCultureInfo("ru-RU");
 19    private static readonly TimeZoneInfo RussianTimeZone = TimeZoneInfo.FindSystemTimeZoneById(
 110        OperatingSystem.IsWindows() ? "Russian Standard Time" : "Europe/Moscow");
 11
 12    public static string Format(TransactionCommentAiContext context)
 13    {
 514        var sb = new StringBuilder();
 515        var performedLocal = TimeZoneInfo.ConvertTimeFromUtc(
 516            DateTime.SpecifyKind(context.PerformedAtUtc, DateTimeKind.Utc),
 517            RussianTimeZone);
 18
 519        sb.AppendLine($"Тип: {context.TransactionTypeDisplayName} ({context.TransactionType})");
 520        sb.AppendLine(
 521            $"Когда: {context.PerformedAtUtc:dd.MM.yyyy, HH:mm:ss} (UTC) / {performedLocal:HH:mm} (MSK)");
 522        sb.AppendLine($"Пользователь: {context.UserName}");
 523        sb.AppendLine();
 24
 525        sb.AppendLine("Что произошло");
 526        sb.AppendLine(
 527            $"Проведение: {context.Batch.TotalOrders} заказ(ов), отменено {context.Batch.CancelledCount}, статус «{conte
 28
 529        var first = context.Orders.FirstOrDefault();
 530        if (first != null)
 31        {
 432            sb.AppendLine($"Заказ: {first.ShipmentNumber ?? first.OrderId.ToString(Ru)}");
 433            if (!string.IsNullOrWhiteSpace(first.Article))
 434                sb.AppendLine($"Товар: {first.Article}, qty {first.Quantity ?? 0}");
 35        }
 36
 537        if (context.Batch.SplitCount > 0)
 138            sb.AppendLine($"⚠ Split: {context.Batch.SplitCount} строк с частичным количеством.");
 39
 540        if (context.OneC?.Documents.Count > 0)
 41        {
 142            var docs = string.Join(", ", context.OneC.Documents
 143                .Select(d => d.DocumentNumber ?? d.TransactionId)
 244                .Where(x => !string.IsNullOrWhiteSpace(x)));
 145            sb.AppendLine($"1С: документы {docs}");
 46        }
 47
 548        if (context.OzonShip is { Entries.Count: > 0 } ozon)
 49        {
 150            sb.AppendLine(
 151                $"Ozon: успешно {ozon.SuccessCount}, ошибок {ozon.FailedCount}, пропущено {ozon.SkippedCount}.");
 52        }
 53
 554        sb.AppendLine("(Авто-описание без AI — сервис генерации временно недоступен.)");
 555        return sb.ToString().Trim();
 56    }
 57}