< Summary

Information
Class: OzonOrdersWeb.WebServices.Transactions.Grid.Contracts.TransactionDefinitionDto
Assembly: OzonOrdersWeb
File(s): /home/runner/work/Studio2Prod/Studio2Prod/OzonOrdersWeb/WebServices/Transactions/Grid/Contracts/TransactionGridPageDto.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 83
Coverable lines: 83
Total lines: 171
Line coverage: 0%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

File(s)

/home/runner/work/Studio2Prod/Studio2Prod/OzonOrdersWeb/WebServices/Transactions/Grid/Contracts/TransactionGridPageDto.cs

#LineLine coverage
 1using OzonDomains;
 2using OzonOrdersWeb.WebServices.Orders.Grid;
 3using OzonOrdersWeb.WebServices.Transactions.Grid.Definitions;
 4using Services.ApiServices.OzonApi;
 5
 6namespace OzonOrdersWeb.WebServices.Transactions.Grid.Contracts;
 7
 8/// <summary>Ответ <c>POST /Studio2/TransactionsGrid/{slug}/Load</c>: строки, справочники и параметры страницы.</summary
 9public sealed class TransactionGridPageDto
 10{
 11    public required TransactionDefinitionDto Definition { get; init; }
 12    public List<TransactionGridRowDto> Rows { get; init; } = new();
 13    public required TransactionGridLookups Lookups { get; init; }
 14
 15    /// <summary>Предупреждения уровня страницы (смешанные поставщики/склады, недоступные заказы).</summary>
 16    public List<string> Warnings { get; init; } = new();
 17
 18    /// <summary>Заказы из ссылки, недоступные пользователю или не найденные.</summary>
 19    public List<int> SkippedIds { get; init; } = new();
 20
 21    /// <summary>Ключ сессии учёта времени — возвращается в Commit.</summary>
 22    public string? TrackingKey { get; init; }
 23
 24    /// <summary>Пользователь — администратор (свободный выбор складов и т.п.).</summary>
 25    public bool IsAdmin { get; init; }
 26}
 27
 28/// <summary>Строка грида: базовые колонки заказа (как в OrdersGrid) + редактируемая часть.</summary>
 29public sealed class TransactionGridRowDto
 30{
 31    public required OrderGridRowDto Base { get; init; }
 32    public required TransactionGridRowEdit Edit { get; init; }
 33}
 34
 35/// <summary>Определение транзакции в виде, пригодном для клиента (без делегатов).</summary>
 36public sealed class TransactionDefinitionDto
 37{
 038    public int Type { get; init; }
 039    public string Slug { get; init; } = string.Empty;
 040    public string Title { get; init; } = string.Empty;
 041    public string? ShortName { get; init; }
 042    public string Icon { get; init; } = string.Empty;
 043    public string Color { get; init; } = string.Empty;
 044    public string Group { get; init; } = string.Empty;
 045    public string? Hint { get; init; }
 046    public string? TargetStatusName { get; init; }
 047    public int? TargetStatusId { get; init; }
 048    public IReadOnlyList<string> AllowedSourceStatuses { get; init; } = Array.Empty<string>();
 049    public IReadOnlyList<string> StatusOnlyWhenAlreadyIn { get; init; } = Array.Empty<string>();
 050    public string OneCMode { get; init; } = "none";
 051    public string OneCDocument { get; init; } = "none";
 052    public string WarehouseMode { get; init; } = "none";
 053    public string ZeroQuantityPolicy { get; init; } = "none";
 054    public bool CheckStockBefore1C { get; init; }
 055    public bool SupportsQuantitySplit { get; init; }
 056    public bool ClearPurchasePriceOnLoad { get; init; }
 057    public bool RequiresPurchasePrice { get; init; }
 058    public bool PurchasePriceOptional { get; init; }
 059    public bool AutoFillPurchasePriceFromC0 { get; init; }
 060    public bool OzonCancelPanel { get; init; }
 061    public bool OzonCancelPreselected { get; init; }
 062    public bool ProcessingGroupOpen { get; init; }
 063    public bool ShipInOzon { get; init; }
 064    public bool SupplierOffers { get; init; }
 065    public bool SupplierCarts { get; init; }
 066    public bool PriceEditingOnly { get; init; }
 067    public bool RequirePriorOneCGuid { get; init; }
 068    public bool RequireWsStock { get; init; }
 069    public bool SupportsBulkFromFile { get; init; }
 070    public bool ReceiptDocumentFields { get; init; }
 071    public bool ExpenseDocumentFields { get; init; }
 072    public bool CountryAndGtdFields { get; init; }
 073    public bool RequireSingleSupplierAndWarehouse { get; init; }
 074    public IReadOnlyList<string> EditableFields { get; init; } = Array.Empty<string>();
 075    public string? DefaultsJson { get; init; }
 076    public string LegacyEndpoint { get; init; } = string.Empty;
 77
 078    public static TransactionDefinitionDto From(TransactionDefinition d, int? targetStatusId) => new()
 079    {
 080        Type = (int)d.Type,
 081        Slug = d.Slug,
 082        Title = d.Title,
 083        ShortName = d.ShortName,
 084        Icon = d.Icon,
 085        Color = d.Color,
 086        Group = d.Group,
 087        Hint = d.Hint,
 088        TargetStatusName = d.TargetStatusName,
 089        TargetStatusId = targetStatusId,
 090        AllowedSourceStatuses = d.AllowedSourceStatuses,
 091        StatusOnlyWhenAlreadyIn = d.StatusOnlyWhenAlreadyIn,
 092        OneCMode = Camel(d.OneCMode),
 093        OneCDocument = Camel(d.OneCDocument),
 094        WarehouseMode = Camel(d.WarehouseMode),
 095        ZeroQuantityPolicy = Camel(d.ZeroQuantityPolicy),
 096        CheckStockBefore1C = d.CheckStockBefore1C,
 097        SupportsQuantitySplit = d.SupportsQuantitySplit,
 098        ClearPurchasePriceOnLoad = d.ClearPurchasePriceOnLoad,
 099        RequiresPurchasePrice = d.RequiresPurchasePrice,
 0100        PurchasePriceOptional = d.PurchasePriceOptional,
 0101        AutoFillPurchasePriceFromC0 = d.AutoFillPurchasePriceFromC0,
 0102        OzonCancelPanel = d.OzonCancelPanel,
 0103        OzonCancelPreselected = d.OzonCancelPreselected,
 0104        ProcessingGroupOpen = d.ProcessingGroupOpen,
 0105        ShipInOzon = d.ShipInOzon,
 0106        SupplierOffers = d.SupplierOffers,
 0107        SupplierCarts = d.SupplierCarts,
 0108        PriceEditingOnly = d.PriceEditingOnly,
 0109        RequirePriorOneCGuid = d.RequirePriorOneCGuid,
 0110        RequireWsStock = d.RequireWsStock,
 0111        SupportsBulkFromFile = d.SupportsBulkFromFile,
 0112        ReceiptDocumentFields = d.ReceiptDocumentFields,
 0113        ExpenseDocumentFields = d.ExpenseDocumentFields,
 0114        CountryAndGtdFields = d.CountryAndGtdFields,
 0115        RequireSingleSupplierAndWarehouse = d.RequireSingleSupplierAndWarehouse,
 0116        EditableFields = d.EditableFields,
 0117        DefaultsJson = d.DefaultsJson,
 0118        LegacyEndpoint = d.LegacyEndpoint
 0119    };
 120
 121    private static string Camel<T>(T value) where T : struct, Enum
 122    {
 0123        var s = value.ToString();
 0124        return char.ToLowerInvariant(s[0]) + s[1..];
 125    }
 126}
 127
 128/// <summary>Справочники страницы; тяжёлые (склады 1С, договоры) грузятся лениво через <c>Lookups</c>.</summary>
 129public sealed class TransactionGridLookups
 130{
 131    public List<StatusOption> Statuses { get; init; } = new();
 132    public List<SupplierOption> Suppliers { get; init; } = new();
 133    public List<IdName> Warehouses { get; init; } = new();
 134    public List<IdName> ExpenseTypes { get; init; } = new();
 135
 136    /// <summary>Значения засыла (названия складов 1С в скоупе пользователя).</summary>
 137    public List<string> ZasylValues { get; init; } = new();
 138
 139    /// <summary>Причины отмены Ozon по заказу (только для клиентов OZON при OzonCancelPanel).</summary>
 140    public Dictionary<int, OzonOrderCancelReasonsInfo> CancelReasonsByOrder { get; init; } = new();
 141
 142    /// <summary>providerKey → разрешённые склады (Id) для предложений API-поставщиков.</summary>
 143    public Dictionary<string, List<int>> ApiSupplierAllowedWarehouses { get; init; } = new();
 144
 145    public decimal RateUsd { get; init; }
 146    public decimal RateEur { get; init; }
 147    public decimal RateByn { get; init; }
 148
 149    /// <summary>Склады 1С (для режимов GlobalPair/PerOrder*); пусто, если 1С не участвует.</summary>
 150    public List<string> OneCWarehouses { get; init; } = new();
 151
 152    /// <summary>Подсказки складов по <c>WarehouseSelectionResolver</c> для режима GlobalPair.</summary>
 153    public string? SuggestedSenderWarehouse { get; set; }
 154    public List<string> SuggestedRecipientWarehouses { get; init; } = new();
 155    public bool ForceSenderWarehouse { get; init; }
 156
 157    /// <summary>Страны происхождения из 1С (приходная накладная).</summary>
 158    public List<string> Countries { get; init; } = new();
 159
 160    /// <summary>Договоры 1С по ИНН поставщика/клиента (приход/расход); ключ — Ref_Key.</summary>
 161    public List<IdName<string>> Treaties { get; init; } = new();
 162    public string? TreatiesInn { get; init; }
 163}
 164
 165public sealed record StatusOption(int Id, string Name, string Color, bool IsFinal);
 166
 167public sealed record SupplierOption(int Id, string Name, string? Site, CurrencyCode CurrencyCode, decimal? WeightFactor,
 168
 169public sealed record IdName(int Id, string Name);
 170
 171public sealed record IdName<TId>(TId Id, string Name);