< Summary

Information
Class: Services.BitrixStockServices.BitrixStockSyncActionResolver
Assembly: Services
File(s): /home/runner/work/Studio2Prod/Studio2Prod/AppRepository/BitrixStockServices/BitrixStockSyncActionResolver.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 31
Coverable lines: 31
Total lines: 70
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 18
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
Resolve(...)0%342180%

File(s)

/home/runner/work/Studio2Prod/Studio2Prod/AppRepository/BitrixStockServices/BitrixStockSyncActionResolver.cs

#LineLine coverage
 1namespace Services.BitrixStockServices;
 2
 3/// <summary>Сравнение остатков 1С и Ozon по связанному складу — только рекомендация.</summary>
 4public static class BitrixStockSyncActionResolver
 5{
 6    public static (string Action, string Label, string Icon, string RowClass, string? Note) Resolve(
 7        bool isInactive,
 8        bool hasValidProductId,
 9        bool hasLinkedOneCStore,
 10        bool hasStockLinkageMapping,
 11        int oneCQty,
 12        int ozonQty)
 13    {
 014        if (!hasStockLinkageMapping)
 15        {
 016            return (BitrixStockSyncReportActions.Skip, "Нет связи", "—",
 017                "sync-row-skip", "Склад Ozon не связан с 1С в WarehouseMapping");
 18        }
 19
 020        if (!hasLinkedOneCStore)
 21        {
 022            return (BitrixStockSyncReportActions.Skip, "Нет склада 1С", "—",
 023                "sync-row-skip", "Связь есть, но строка склада 1С на товаре не найдена");
 24        }
 25
 026        if (!hasValidProductId)
 27        {
 028            return (BitrixStockSyncReportActions.Skip, "Нет в каталоге Ozon", "—",
 029                "sync-row-skip", "Нет product_id — накат/обнуление через API невозможны");
 30        }
 31
 032        if (isInactive)
 33        {
 034            if (ozonQty > 0)
 35            {
 036                return (BitrixStockSyncReportActions.Clear, "Обнулить", "⊘",
 037                    "sync-row-clear",
 038                    $"Неактивный товар: на Ozon {ozonQty}, в 1С {oneCQty} — рекомендуется 0");
 39            }
 40
 041            return (BitrixStockSyncReportActions.Match, "Совпадает", "✓",
 042                "sync-row-match", "Неактивный, на Ozon уже 0");
 43        }
 44
 045        var delta = oneCQty - ozonQty;
 046        if (delta == 0)
 47        {
 048            return (BitrixStockSyncReportActions.Match, "Совпадает", "✓",
 049                "sync-row-match", null);
 50        }
 51
 052        if (oneCQty == 0 && ozonQty > 0)
 53        {
 054            return (BitrixStockSyncReportActions.Clear, "Обнулить", "⊘",
 055                "sync-row-clear",
 056                $"В 1С 0, на Ozon {ozonQty}");
 57        }
 58
 059        if (delta > 0)
 60        {
 061            return (BitrixStockSyncReportActions.Push, "Накатить", "↑",
 062                "sync-row-push",
 063                $"Увеличить Ozon на {delta} (1С {oneCQty} → Ozon {ozonQty})");
 64        }
 65
 066        return (BitrixStockSyncReportActions.Decrease, "Уменьшить", "↓",
 067            "sync-row-decrease",
 068            $"Уменьшить Ozon на {-delta} (1С {oneCQty} ← Ozon {ozonQty})");
 69    }
 70}