< Summary

Information
Class: Services.AiAssistant.AiOrderFilterCriteria
Assembly: Services
File(s): /home/runner/work/Studio2Prod/Studio2Prod/AppRepository/AiAssistant/AiOrderFilterCriteria.cs
Line coverage
63%
Covered lines: 69
Uncovered lines: 39
Coverable lines: 108
Total lines: 141
Line coverage: 63.8%
Branch coverage
47%
Covered branches: 72
Total branches: 152
Branch coverage: 47.3%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

File(s)

/home/runner/work/Studio2Prod/Studio2Prod/AppRepository/AiAssistant/AiOrderFilterCriteria.cs

#LineLine coverage
 1namespace Services.AiAssistant;
 2
 3/// <summary>Критерии гибкого поиска заказов (tool orders_filter).</summary>
 4public sealed class AiOrderFilterCriteria
 5{
 6    // ── Базовые ──────────────────────────────────────────────────────────────
 1497    public bool ActionableOnly { get; init; }
 1198    public bool OverdueOnly    { get; init; }
 1199    public bool EmptyPrice     { get; init; }
 16310    public bool IncludeArchived { get; init; }
 11
 12    // ── Участники ─────────────────────────────────────────────────────────────
 17213    public string? OzonClientName           { get; init; }
 16114    public string? SupplierName             { get; init; }
 11315    public string? TransactionConductedBy   { get; init; }
 11316    public string? ChangedByUser            { get; init; }   // orders_history.ChangedBy
 17
 18    // ── Статусы ───────────────────────────────────────────────────────────────
 14819    public string? AppStatusName    { get; init; }
 11320    public string? ClientStatusName { get; init; }   // ClientStatus (Ozon)
 13621    public bool?   OnlyWithReturns  { get; init; }   // IsReturned = true
 22
 23    // ── Товар ────────────────────────────────────────────────────────────────
 14724    public string? Article          { get; init; }
 13325    public string? ProductName      { get; init; }
 13226    public string? ManufacturerName { get; init; }
 13227    public string? NewCategory      { get; init; }
 11928    public int?    MinQuantity      { get; init; }
 11529    public int?    MaxQuantity      { get; init; }
 30
 31    // ── Финансы ───────────────────────────────────────────────────────────────
 11632    public decimal? PriceMin           { get; init; }
 11433    public decimal? PriceMax           { get; init; }
 13534    public decimal? ProfitMin          { get; init; }
 13435    public decimal? ProfitMax          { get; init; }
 14536    public bool?    OnlyNegativeProfit { get; init; }   // MinProfit < 0
 11437    public decimal? PurchasePriceMax   { get; init; }
 38
 39    // ── Логистика ────────────────────────────────────────────────────────────
 16840    public string? ShipmentWarehouseName  { get; init; }
 13141    public string? DeliveryProviderName   { get; init; }
 13142    public string? DeliveryName           { get; init; }
 13243    public string? DeliveryCity           { get; init; }
 13644    public bool?   OnlyWithTrackingNumber { get; init; }
 45
 46    // ── Даты ─────────────────────────────────────────────────────────────────
 13347    public DateTime? ShippingDateFrom    { get; init; }
 13348    public DateTime? ShippingDateTo      { get; init; }
 11449    public DateTime? ProcessingDateFrom  { get; init; }
 11450    public DateTime? ProcessingDateTo    { get; init; }
 14651    public int?      LastMonths          { get; init; }   // ProcessingDate >= now - N months
 52
 53    // ── История изменений ────────────────────────────────────────────────────
 11354    public DateTime? ChangedFrom       { get; init; }   // orders_history.ChangedAt >=
 11355    public DateTime? ChangedTo         { get; init; }   // orders_history.ChangedAt <=
 11256    public string?   FieldChangedName  { get; init; }   // ColumnName или ColumnDisplayName (contains)
 11257    public string?   FieldChangedToValue { get; init; } // NewValue (contains)
 58
 59    // ── Вычисляемые ──────────────────────────────────────────────────────────
 60    public bool HasCriteria =>
 1561        ActionableOnly
 1562        || OverdueOnly
 1563        || EmptyPrice
 1564        || IncludeArchived
 1565        || MinQuantity.HasValue
 1566        || MaxQuantity.HasValue
 1567        || OnlyNegativeProfit == true
 1568        || OnlyWithReturns == true
 1569        || OnlyWithTrackingNumber == true
 1570        || PriceMin.HasValue || PriceMax.HasValue
 1571        || ProfitMin.HasValue || ProfitMax.HasValue
 1572        || PurchasePriceMax.HasValue
 1573        || ShippingDateFrom.HasValue || ShippingDateTo.HasValue
 1574        || ProcessingDateFrom.HasValue || ProcessingDateTo.HasValue
 1575        || LastMonths.HasValue
 1576        || ChangedFrom.HasValue || ChangedTo.HasValue
 1577        || !string.IsNullOrWhiteSpace(OzonClientName)
 1578        || !string.IsNullOrWhiteSpace(SupplierName)
 1579        || !string.IsNullOrWhiteSpace(TransactionConductedBy)
 1580        || !string.IsNullOrWhiteSpace(ChangedByUser)
 1581        || !string.IsNullOrWhiteSpace(AppStatusName)
 1582        || !string.IsNullOrWhiteSpace(ClientStatusName)
 1583        || !string.IsNullOrWhiteSpace(Article)
 1584        || !string.IsNullOrWhiteSpace(ProductName)
 1585        || !string.IsNullOrWhiteSpace(ManufacturerName)
 1586        || !string.IsNullOrWhiteSpace(NewCategory)
 1587        || !string.IsNullOrWhiteSpace(ShipmentWarehouseName)
 1588        || !string.IsNullOrWhiteSpace(DeliveryProviderName)
 1589        || !string.IsNullOrWhiteSpace(DeliveryName)
 1590        || !string.IsNullOrWhiteSpace(DeliveryCity)
 1591        || !string.IsNullOrWhiteSpace(FieldChangedName)
 1592        || !string.IsNullOrWhiteSpace(FieldChangedToValue);
 93
 94    public string DescribeRu()
 95    {
 096        var parts = new List<string>();
 097        if (ActionableOnly)             parts.Add("актуальные (нефинальный AppStatus, не в архиве)");
 098        if (OverdueOnly)                parts.Add("просроченные (дедлайн отгрузки прошёл)");
 099        if (IncludeArchived)            parts.Add("включая архивные");
 0100        if (EmptyPrice)                 parts.Add("пустая цена продажи");
 0101        if (OnlyNegativeProfit == true) parts.Add("прибыль < 0");
 0102        if (OnlyWithReturns == true)    parts.Add("есть возврат");
 0103        if (OnlyWithTrackingNumber == true) parts.Add("есть трек-номер");
 104
 0105        if (MinQuantity is > 0)         parts.Add($"кол-во > {MinQuantity}");
 0106        if (MaxQuantity is > 0)         parts.Add($"кол-во ≤ {MaxQuantity}");
 0107        if (PriceMin.HasValue)          parts.Add($"цена ≥ {PriceMin:F0} ₽");
 0108        if (PriceMax.HasValue)          parts.Add($"цена ≤ {PriceMax:F0} ₽");
 0109        if (ProfitMin.HasValue)         parts.Add($"прибыль ≥ {ProfitMin:F0} ₽");
 0110        if (ProfitMax.HasValue)         parts.Add($"прибыль ≤ {ProfitMax:F0} ₽");
 0111        if (PurchasePriceMax.HasValue)  parts.Add($"закупка ≤ {PurchasePriceMax:F0} ₽");
 112
 0113        if (!string.IsNullOrWhiteSpace(SupplierName))           parts.Add($"поставщик «{SupplierName.Trim()}»");
 0114        if (!string.IsNullOrWhiteSpace(OzonClientName))         parts.Add($"Ozon-клиент «{OzonClientName.Trim()}»");
 0115        if (!string.IsNullOrWhiteSpace(AppStatusName))          parts.Add($"статус в отчёте «{AppStatusName.Trim()}»");
 0116        if (!string.IsNullOrWhiteSpace(ClientStatusName))       parts.Add($"статус Ozon «{ClientStatusName.Trim()}»");
 0117        if (!string.IsNullOrWhiteSpace(Article))                parts.Add($"артикул «{Article.Trim()}»");
 0118        if (!string.IsNullOrWhiteSpace(ProductName))            parts.Add($"товар «{ProductName.Trim()}»");
 0119        if (!string.IsNullOrWhiteSpace(ManufacturerName))       parts.Add($"производитель «{ManufacturerName.Trim()}»");
 0120        if (!string.IsNullOrWhiteSpace(NewCategory))            parts.Add($"категория «{NewCategory.Trim()}»");
 0121        if (!string.IsNullOrWhiteSpace(ShipmentWarehouseName))  parts.Add($"склад «{ShipmentWarehouseName.Trim()}»");
 0122        if (!string.IsNullOrWhiteSpace(DeliveryProviderName))   parts.Add($"провайдер «{DeliveryProviderName.Trim()}»");
 0123        if (!string.IsNullOrWhiteSpace(DeliveryName))           parts.Add($"тип доставки «{DeliveryName.Trim()}»");
 0124        if (!string.IsNullOrWhiteSpace(DeliveryCity))           parts.Add($"город «{DeliveryCity.Trim()}»");
 0125        if (!string.IsNullOrWhiteSpace(TransactionConductedBy)) parts.Add($"транзакцию провёл «{TransactionConductedBy.T
 126
 0127        if (!string.IsNullOrWhiteSpace(ChangedByUser))    parts.Add($"изменял «{ChangedByUser.Trim()}»");
 0128        if (!string.IsNullOrWhiteSpace(FieldChangedName)) parts.Add($"поле «{FieldChangedName.Trim()}» менялось");
 0129        if (!string.IsNullOrWhiteSpace(FieldChangedToValue)) parts.Add($"новое значение «{FieldChangedToValue.Trim()}»")
 130
 0131        if (LastMonths.HasValue)           parts.Add($"за последние {LastMonths} мес.");
 0132        if (ShippingDateFrom.HasValue)     parts.Add($"отгрузка с {ShippingDateFrom:dd.MM.yyyy}");
 0133        if (ShippingDateTo.HasValue)       parts.Add($"отгрузка по {ShippingDateTo:dd.MM.yyyy}");
 0134        if (ProcessingDateFrom.HasValue)   parts.Add($"принят с {ProcessingDateFrom:dd.MM.yyyy}");
 0135        if (ProcessingDateTo.HasValue)     parts.Add($"принят по {ProcessingDateTo:dd.MM.yyyy}");
 0136        if (ChangedFrom.HasValue)          parts.Add($"изменён с {ChangedFrom:dd.MM.yyyy}");
 0137        if (ChangedTo.HasValue)            parts.Add($"изменён по {ChangedTo:dd.MM.yyyy}");
 138
 0139        return parts.Count == 0 ? "активные заказы" : string.Join("; ", parts);
 140    }
 141}