| | | 1 | | using OzonDomains.Models; |
| | | 2 | | using OzonOrdersWeb.Areas.Studio2.ViewModels.Bitrix; |
| | | 3 | | |
| | | 4 | | namespace Services.BitrixStockServices; |
| | | 5 | | |
| | | 6 | | /// <summary>Те же правила, что в BitrixStockController.Index (пресеты OnlyInactive и склады).</summary> |
| | | 7 | | public static class BitrixStockFilterNormalizer |
| | | 8 | | { |
| | 1 | 9 | | public static readonly string[] DefaultStoreTitles = { "B1", "B2", "M1", "M2", "M3" }; |
| | | 10 | | |
| | | 11 | | public static IReadOnlyList<string> DefaultStoreTitlesFor(IReadOnlyCollection<string>? activeStores) => |
| | 36 | 12 | | DefaultStoreTitles.Where(s => (activeStores ?? DefaultStoreTitles).Contains(s)).ToList(); |
| | | 13 | | |
| | | 14 | | public static RemainingStockFilter Normalize( |
| | | 15 | | RemainingStockFilter filter, |
| | | 16 | | string actionType, |
| | | 17 | | int ozonClientId, |
| | | 18 | | IReadOnlyCollection<string>? activeStores = null) |
| | | 19 | | { |
| | 3 | 20 | | filter.SelectedClientId = ozonClientId; |
| | 3 | 21 | | filter.LoadOzonWarehouses = true; |
| | 3 | 22 | | filter.DisablePagination = true; |
| | 3 | 23 | | filter.Page = 1; |
| | 3 | 24 | | if (filter.PageSize <= 0) |
| | | 25 | | { |
| | 1 | 26 | | filter.PageSize = 10_000; |
| | | 27 | | } |
| | | 28 | | |
| | 3 | 29 | | if (filter.SelectedStoreTitles == null || filter.SelectedStoreTitles.Count == 0) |
| | | 30 | | { |
| | 2 | 31 | | filter.SelectedStoreTitles = DefaultStoreTitlesFor(activeStores).ToList(); |
| | | 32 | | } |
| | | 33 | | |
| | 3 | 34 | | return filter; |
| | | 35 | | } |
| | | 36 | | } |