| | | 1 | | using Microsoft.Extensions.Caching.Memory; |
| | | 2 | | using OzonDomains; |
| | | 3 | | using OzonDomains.Models; |
| | | 4 | | using OzonOrdersWeb.WebServices.Transactions.Grid.Definitions; |
| | | 5 | | using Services.DataServices; |
| | | 6 | | |
| | | 7 | | namespace OzonOrdersWeb.WebServices; |
| | | 8 | | |
| | | 9 | | public class TransactionTransitionRuleService |
| | | 10 | | { |
| | | 11 | | private const string CacheKey = "TransactionTransitionRules"; |
| | 1 | 12 | | private static readonly TimeSpan CacheSlidingExpiration = TimeSpan.FromMinutes(2); |
| | | 13 | | |
| | | 14 | | private readonly StatusTransitionDataServices _statusTransitionDataServices; |
| | | 15 | | private readonly IMemoryCache _cache; |
| | | 16 | | private readonly ITransactionDefinitionProvider? _definitions; |
| | | 17 | | |
| | 1 | 18 | | public TransactionTransitionRuleService( |
| | 1 | 19 | | StatusTransitionDataServices statusTransitionDataServices, |
| | 1 | 20 | | IMemoryCache cache, |
| | 1 | 21 | | ITransactionDefinitionProvider? definitions = null) |
| | | 22 | | { |
| | 1 | 23 | | _statusTransitionDataServices = statusTransitionDataServices; |
| | 1 | 24 | | _cache = cache; |
| | 1 | 25 | | _definitions = definitions; |
| | 1 | 26 | | } |
| | | 27 | | |
| | | 28 | | public async Task<IReadOnlyList<TransactionTransitionRuleVm>> GetRulesAsync() |
| | | 29 | | { |
| | 1 | 30 | | return await _cache.GetOrCreateAsync(CacheKey, async entry => |
| | 1 | 31 | | { |
| | 1 | 32 | | entry.SlidingExpiration = CacheSlidingExpiration; |
| | 1 | 33 | | var defaults = BuildDefaultRules(); |
| | 1 | 34 | | await ApplyDefinitionsAsync(defaults); |
| | 1 | 35 | | var transitions = await _statusTransitionDataServices.GetActive(); |
| | 1 | 36 | | |
| | 1 | 37 | | var byType = transitions |
| | 0 | 38 | | .Where(t => t.FromStatus != null && t.ToStatus != null) |
| | 0 | 39 | | .GroupBy(t => t.TransactionType) |
| | 1 | 40 | | .ToDictionary(g => g.Key, g => g.ToList()); |
| | 1 | 41 | | |
| | 32 | 42 | | foreach (var rule in defaults) |
| | 1 | 43 | | { |
| | 15 | 44 | | if (!Enum.TryParse<TransactionType>(rule.TransactionType.ToString(), out var type)) |
| | 1 | 45 | | { |
| | 1 | 46 | | continue; |
| | 1 | 47 | | } |
| | 1 | 48 | | |
| | 15 | 49 | | if (!byType.TryGetValue(type, out var typeTransitions) || typeTransitions.Count == 0) |
| | 1 | 50 | | { |
| | 1 | 51 | | continue; |
| | 1 | 52 | | } |
| | 1 | 53 | | |
| | 0 | 54 | | var toStatuses = typeTransitions |
| | 0 | 55 | | .Select(t => t.ToStatus?.Name) |
| | 0 | 56 | | .Where(n => !string.IsNullOrWhiteSpace(n)) |
| | 0 | 57 | | .Distinct(StringComparer.OrdinalIgnoreCase) |
| | 0 | 58 | | .ToList(); |
| | 1 | 59 | | |
| | 0 | 60 | | var fromStatuses = typeTransitions |
| | 0 | 61 | | .Select(t => t.FromStatus?.Name) |
| | 0 | 62 | | .Where(n => !string.IsNullOrWhiteSpace(n)) |
| | 0 | 63 | | .Distinct(StringComparer.OrdinalIgnoreCase) |
| | 0 | 64 | | .ToList(); |
| | 1 | 65 | | |
| | 0 | 66 | | if (toStatuses.Count > 0) |
| | 1 | 67 | | { |
| | 0 | 68 | | rule.ToStatus = toStatuses[0]!; |
| | 1 | 69 | | } |
| | 1 | 70 | | |
| | 0 | 71 | | if (fromStatuses.Count > 0) |
| | 1 | 72 | | { |
| | 0 | 73 | | rule.AllowedStatuses = fromStatuses.Select(s => s!).ToList(); |
| | 1 | 74 | | } |
| | 1 | 75 | | |
| | 0 | 76 | | rule.HasRepeatableSelfTransition = typeTransitions |
| | 0 | 77 | | .Any(t => t.FromStatusId == t.ToStatusId && t.IsRepeatable); |
| | 1 | 78 | | } |
| | 1 | 79 | | |
| | 1 | 80 | | return (IReadOnlyList<TransactionTransitionRuleVm>)defaults; |
| | 2 | 81 | | }) ?? Array.Empty<TransactionTransitionRuleVm>(); |
| | 1 | 82 | | } |
| | | 83 | | |
| | | 84 | | public void InvalidateCache() |
| | | 85 | | { |
| | 0 | 86 | | _cache.Remove(CacheKey); |
| | 0 | 87 | | } |
| | | 88 | | |
| | | 89 | | /// <summary> |
| | | 90 | | /// Накладывает имена/цвета/иконки из админки типов транзакций и адрес нового грида. |
| | | 91 | | /// <see cref="TransactionTransitionRuleVm.Endpoint"/> не меняется — его читает классическая страница заказов; |
| | | 92 | | /// OrdersGrid выбирает <see cref="TransactionTransitionRuleVm.GridEndpoint"/> по флагу <see cref="TransactionTransi |
| | | 93 | | /// </summary> |
| | | 94 | | private async Task ApplyDefinitionsAsync(List<TransactionTransitionRuleVm> rules) |
| | | 95 | | { |
| | 1 | 96 | | if (_definitions == null) |
| | | 97 | | { |
| | 0 | 98 | | return; |
| | | 99 | | } |
| | | 100 | | |
| | | 101 | | var definitions = (await _definitions.GetAllAsync()).ToDictionary(d => (int)d.Type); |
| | 34 | 102 | | foreach (var rule in rules) |
| | | 103 | | { |
| | 16 | 104 | | if (!definitions.TryGetValue(rule.TransactionType, out var d)) |
| | | 105 | | { |
| | | 106 | | continue; |
| | | 107 | | } |
| | | 108 | | |
| | 16 | 109 | | rule.Label = d.Title; |
| | 16 | 110 | | rule.ShortName = d.ShortName ?? d.Title; |
| | 16 | 111 | | rule.Icon = string.IsNullOrWhiteSpace(d.Icon) ? rule.Icon : d.Icon + " me-2"; |
| | 16 | 112 | | rule.TransactionColor = string.IsNullOrWhiteSpace(d.Color) ? rule.TransactionColor : d.Color; |
| | 16 | 113 | | rule.Slug = d.Slug; |
| | 16 | 114 | | rule.GridEndpoint = d.GridEndpoint; |
| | 16 | 115 | | rule.PermissionEndpoint = d.LegacyEndpoint; |
| | 16 | 116 | | rule.UseGrid = d.UseGrid; |
| | 16 | 117 | | rule.IsEnabled = d.IsEnabled; |
| | 16 | 118 | | rule.Group = d.Group; |
| | 16 | 119 | | rule.DisplayOrder = d.DisplayOrder; |
| | 16 | 120 | | rule.Hint = d.Hint; |
| | | 121 | | } |
| | | 122 | | |
| | | 123 | | rules.RemoveAll(r => !r.IsEnabled); |
| | 1 | 124 | | } |
| | | 125 | | |
| | | 126 | | private static List<TransactionTransitionRuleVm> BuildDefaultRules() |
| | | 127 | | { |
| | 1 | 128 | | return new List<TransactionTransitionRuleVm> |
| | 1 | 129 | | { |
| | 1 | 130 | | new() |
| | 1 | 131 | | { |
| | 1 | 132 | | TransactionType = (int)TransactionType.OrderedToSupplier, |
| | 1 | 133 | | Endpoint = "/Studio2/OrderToSupplierTransaction/CreateOrderToSupplierTransactionV2", |
| | 1 | 134 | | Label = "Заказан поставщику", |
| | 1 | 135 | | Icon = "fas fa-shopping-cart me-2", |
| | 1 | 136 | | LinkClass = "btn btn-link link-success", |
| | 1 | 137 | | Action = "createOrderToSupplierTransaction()", |
| | 1 | 138 | | AllowedStatuses = new List<string> { "Не указан", "Заказан поставщику", "Заказан реализатору" }, |
| | 1 | 139 | | ToStatus = "Заказан поставщику", |
| | 1 | 140 | | TransactionColor = "#198754", |
| | 1 | 141 | | IntegrationMode = "none", |
| | 1 | 142 | | UiConditions = new List<string>() |
| | 1 | 143 | | }, |
| | 1 | 144 | | new() |
| | 1 | 145 | | { |
| | 1 | 146 | | TransactionType = (int)TransactionType.OrderedToSeller, |
| | 1 | 147 | | Endpoint = "/Studio2/OrderedToSellerTransaction/CreateOrderedToSellerTransaction", |
| | 1 | 148 | | Label = "Заказан реализатору", |
| | 1 | 149 | | Icon = "fas fa-handshake me-2", |
| | 1 | 150 | | LinkClass = "btn btn-link link-secondary", |
| | 1 | 151 | | Action = "createOrderedToSellerTransaction()", |
| | 1 | 152 | | AllowedStatuses = new List<string> { "Не указан", "Заказан поставщику", "Заказан реализатору" }, |
| | 1 | 153 | | ToStatus = "Заказан реализатору", |
| | 1 | 154 | | TransactionColor = "#6c757d", |
| | 1 | 155 | | IntegrationMode = "none", |
| | 1 | 156 | | UiConditions = new List<string>() |
| | 1 | 157 | | }, |
| | 1 | 158 | | new() |
| | 1 | 159 | | { |
| | 1 | 160 | | TransactionType = (int)TransactionType.ShippedBySupplier, |
| | 1 | 161 | | Endpoint = "/Studio2/ShippedBySupplierTransaction/CreateShippedBySupplierTransaction", |
| | 1 | 162 | | Label = "Отгружен поставщиком", |
| | 1 | 163 | | Icon = "fas fa-truck-loading me-2", |
| | 1 | 164 | | LinkClass = "btn btn-link link-info", |
| | 1 | 165 | | Action = "createShippedBySupplierTransaction()", |
| | 1 | 166 | | AllowedStatuses = new List<string> { "Заказан поставщику" }, |
| | 1 | 167 | | ToStatus = "Отгружен поставщиком", |
| | 1 | 168 | | TransactionColor = "#0dcaf0", |
| | 1 | 169 | | IntegrationMode = "optional", |
| | 1 | 170 | | OneCDocumentType = "receipt", |
| | 1 | 171 | | UiConditions = new List<string> |
| | 1 | 172 | | { |
| | 1 | 173 | | "Единый поставщик", |
| | 1 | 174 | | "Единый эффективный склад", |
| | 1 | 175 | | "Нужен ИНН поставщика (договор 1С)", |
| | 1 | 176 | | "Для 1С: заполнить страну происхождения и ГТД" |
| | 1 | 177 | | } |
| | 1 | 178 | | }, |
| | 1 | 179 | | new() |
| | 1 | 180 | | { |
| | 1 | 181 | | TransactionType = (int)TransactionType.ShippedToSeller, |
| | 1 | 182 | | Endpoint = "/Studio2/ShippedToSellerTransaction/CreateShippedToSellerTransaction", |
| | 1 | 183 | | Label = "Отгружен реализатором", |
| | 1 | 184 | | Icon = "fas fa-truck me-2", |
| | 1 | 185 | | LinkClass = "btn btn-link link-warning", |
| | 1 | 186 | | Action = "createShippedToSellerTransaction()", |
| | 1 | 187 | | AllowedStatuses = new List<string> { "Заказан реализатору" }, |
| | 1 | 188 | | ToStatus = "Отгружен реализатором", |
| | 1 | 189 | | TransactionColor = "#ffc107", |
| | 1 | 190 | | IntegrationMode = "optional", |
| | 1 | 191 | | OneCDocumentType = "transfer", |
| | 1 | 192 | | UiConditions = new List<string> |
| | 1 | 193 | | { |
| | 1 | 194 | | "Единый поставщик", |
| | 1 | 195 | | "Единый эффективный склад", |
| | 1 | 196 | | "Склад должен быть разрешен в маппинге" |
| | 1 | 197 | | } |
| | 1 | 198 | | }, |
| | 1 | 199 | | new() |
| | 1 | 200 | | { |
| | 1 | 201 | | TransactionType = (int)TransactionType.AcceptedToWarehouse, |
| | 1 | 202 | | Endpoint = "/Studio2/AcceptedToWarehouseTransaction/AcceptedToWarehouseTransaction", |
| | 1 | 203 | | Label = "Принят на склад", |
| | 1 | 204 | | Icon = "fas fa-warehouse me-2", |
| | 1 | 205 | | LinkClass = "btn btn-link link-info", |
| | 1 | 206 | | Action = "createAcceptedToWarehouseTransaction()", |
| | 1 | 207 | | AllowedStatuses = new List<string> { "Заказан поставщику", "Не указан", "Отгружен поставщиком" }, |
| | 1 | 208 | | ToStatus = "ПринятНаСкладе", |
| | 1 | 209 | | TransactionColor = "#0dcaf0", |
| | 1 | 210 | | IntegrationMode = "required", |
| | 1 | 211 | | OneCDocumentType = "transfer", |
| | 1 | 212 | | UiConditions = new List<string> |
| | 1 | 213 | | { |
| | 1 | 214 | | "Обязательно указать склад отправителя и получателя", |
| | 1 | 215 | | "Склады не должны совпадать" |
| | 1 | 216 | | } |
| | 1 | 217 | | }, |
| | 1 | 218 | | new() |
| | 1 | 219 | | { |
| | 1 | 220 | | TransactionType = (int)TransactionType.ShippedToClient, |
| | 1 | 221 | | Endpoint = "/Studio2/ShippedToClientTransaction/CreateShippedToClientTransaction", |
| | 1 | 222 | | Label = "Отгружен клиенту", |
| | 1 | 223 | | Icon = "fas fa-shipping-fast me-2", |
| | 1 | 224 | | LinkClass = "btn btn-link link-success", |
| | 1 | 225 | | Action = "createShippedToClientTransaction()", |
| | 1 | 226 | | AllowedStatuses = new List<string> { "Заказан реализатору" }, |
| | 1 | 227 | | ToStatus = "Отгружен клиенту", |
| | 1 | 228 | | TransactionColor = "#198754", |
| | 1 | 229 | | IntegrationMode = "optional", |
| | 1 | 230 | | OneCDocumentType = "transfer+expense", |
| | 1 | 231 | | UiConditions = new List<string>() |
| | 1 | 232 | | }, |
| | 1 | 233 | | new() |
| | 1 | 234 | | { |
| | 1 | 235 | | TransactionType = (int)TransactionType.CustomerReturn, |
| | 1 | 236 | | Endpoint = "/Studio2/CustomerReturnTransaction/CreateCustomerReturnTransaction", |
| | 1 | 237 | | Label = "Возврат покупателя", |
| | 1 | 238 | | Icon = "fas fa-undo me-2", |
| | 1 | 239 | | LinkClass = "btn btn-link link-warning", |
| | 1 | 240 | | Action = "createCustomerReturnTransaction()", |
| | 1 | 241 | | AllowedStatuses = new List<string> { "Отгружен клиенту", "Отменен" }, |
| | 1 | 242 | | ToStatus = "Возврат покупателя", |
| | 1 | 243 | | TransactionColor = "#ffc107", |
| | 1 | 244 | | IntegrationMode = "optional", |
| | 1 | 245 | | OneCDocumentType = "transfer", |
| | 1 | 246 | | UiConditions = new List<string> |
| | 1 | 247 | | { |
| | 1 | 248 | | "Для 1С: выбрать/проверить склады отправителя и получателя", |
| | 1 | 249 | | "Для 1С: склад получателя обязателен по каждому заказу", |
| | 1 | 250 | | "Склады отправителя и получателя не должны совпадать" |
| | 1 | 251 | | } |
| | 1 | 252 | | }, |
| | 1 | 253 | | new() |
| | 1 | 254 | | { |
| | 1 | 255 | | TransactionType = (int)TransactionType.ReturnToSupplier, |
| | 1 | 256 | | Endpoint = "/Studio2/ReturnToSupplierTransaction/CreateReturnToSupplierTransaction", |
| | 1 | 257 | | Label = "Возвращено поставщику", |
| | 1 | 258 | | Icon = "fas fa-reply-all me-2", |
| | 1 | 259 | | LinkClass = "btn btn-link link-warning", |
| | 1 | 260 | | Action = "createReturnToSupplierTransaction()", |
| | 1 | 261 | | AllowedStatuses = new List<string> { "Заказан поставщику", "ПринятНаСкладе", "Возврат поставщику", "Возв |
| | 1 | 262 | | ToStatus = "Возвращено поставщику", |
| | 1 | 263 | | TransactionColor = "#ffc107", |
| | 1 | 264 | | IntegrationMode = "optional", |
| | 1 | 265 | | OneCDocumentType = "transfer", |
| | 1 | 266 | | UiConditions = new List<string> |
| | 1 | 267 | | { |
| | 1 | 268 | | "Для 1С: обязательны склад отправителя и получателя", |
| | 1 | 269 | | "Склады не должны совпадать" |
| | 1 | 270 | | } |
| | 1 | 271 | | }, |
| | 1 | 272 | | new() |
| | 1 | 273 | | { |
| | 1 | 274 | | TransactionType = (int)TransactionType.ReturnToWarehouse, |
| | 1 | 275 | | Endpoint = "/Studio2/ReturnToWarehouseTransaction/CreateReturnToWarehouseTransaction", |
| | 1 | 276 | | Label = "Возврат на склад", |
| | 1 | 277 | | Icon = "fas fa-undo-alt me-2", |
| | 1 | 278 | | LinkClass = "btn btn-link link-info", |
| | 1 | 279 | | Action = "createReturnToWarehouseTransaction()", |
| | 1 | 280 | | AllowedStatuses = new List<string> { "ПринятНаСкладе", "Отгружен поставщиком", "Отгружен реализатором" } |
| | 1 | 281 | | ToStatus = "Возвращен на склад", |
| | 1 | 282 | | TransactionColor = "#0dcaf0", |
| | 1 | 283 | | IntegrationMode = "required", |
| | 1 | 284 | | OneCDocumentType = "transfer", |
| | 1 | 285 | | UiConditions = new List<string> |
| | 1 | 286 | | { |
| | 1 | 287 | | "Заказ должен быть ранее проведен в 1С (GUID в истории)", |
| | 1 | 288 | | "Только заказы одного клиента" |
| | 1 | 289 | | } |
| | 1 | 290 | | }, |
| | 1 | 291 | | new() |
| | 1 | 292 | | { |
| | 1 | 293 | | TransactionType = (int)TransactionType.WarehouseChange, |
| | 1 | 294 | | Endpoint = "/Studio2/WarehouseChangeTransaction/CreateWarehouseChangeTransaction", |
| | 1 | 295 | | Label = "Изменение склада", |
| | 1 | 296 | | Icon = "fas fa-edit me-2", |
| | 1 | 297 | | LinkClass = "btn btn-link link-primary", |
| | 1 | 298 | | Action = "createWarehouseChangeTransaction()", |
| | 1 | 299 | | AllowedStatuses = new List<string>(), |
| | 1 | 300 | | ToStatus = null, |
| | 1 | 301 | | TransactionColor = "#0d6efd", |
| | 1 | 302 | | IntegrationMode = "none", |
| | 1 | 303 | | UiConditions = new List<string>() |
| | 1 | 304 | | }, |
| | 1 | 305 | | new() |
| | 1 | 306 | | { |
| | 1 | 307 | | TransactionType = (int)TransactionType.WarehouseTransfer, |
| | 1 | 308 | | Endpoint = "/Studio2/WarehouseTransferTransaction/CreateWarehouseTransferTransaction", |
| | 1 | 309 | | Label = "Перемещение между складами", |
| | 1 | 310 | | Icon = "fas fa-exchange-alt me-2", |
| | 1 | 311 | | LinkClass = "btn btn-link link-primary", |
| | 1 | 312 | | Action = "createWarehouseTransferTransaction()", |
| | 1 | 313 | | AllowedStatuses = new List<string>(), |
| | 1 | 314 | | DisallowMarketplaceStatuses = new List<string> { "Отменен покупателем" }, |
| | 1 | 315 | | ToStatus = "Перемещен между складами", |
| | 1 | 316 | | TransactionColor = "#0d6efd", |
| | 1 | 317 | | IntegrationMode = "optional", |
| | 1 | 318 | | OneCDocumentType = "transfer", |
| | 1 | 319 | | UiConditions = new List<string> |
| | 1 | 320 | | { |
| | 1 | 321 | | "Для 1С: обязательны склады отправителя и получателя", |
| | 1 | 322 | | "Склады не должны совпадать" |
| | 1 | 323 | | } |
| | 1 | 324 | | }, |
| | 1 | 325 | | new() |
| | 1 | 326 | | { |
| | 1 | 327 | | TransactionType = (int)TransactionType.ShippedToCommissioner, |
| | 1 | 328 | | Endpoint = "/Studio2/ShippedToCommissionerTransaction/CreateShippedToCommissionerTransaction", |
| | 1 | 329 | | Label = "Отгружен комиссионеру", |
| | 1 | 330 | | Icon = "fas fa-dolly me-2", |
| | 1 | 331 | | LinkClass = "btn btn-link link-primary", |
| | 1 | 332 | | Action = "createShippedToCommissionerTransaction()", |
| | 1 | 333 | | AllowedStatuses = new List<string>(), |
| | 1 | 334 | | DisallowMarketplaceStatuses = new List<string> { "Отменен покупателем" }, |
| | 1 | 335 | | ToStatus = "Отгружен комиссионеру", |
| | 1 | 336 | | TransactionColor = "#0d6efd", |
| | 1 | 337 | | IntegrationMode = "optional", |
| | 1 | 338 | | OneCDocumentType = "transfer", |
| | 1 | 339 | | UiConditions = new List<string> |
| | 1 | 340 | | { |
| | 1 | 341 | | "Начальный статус не ограничен, если переходы не заданы в StatusTransition", |
| | 1 | 342 | | "Для 1С: нужен корректный клиент Ozon и эффективный склад", |
| | 1 | 343 | | "Для 1С: у выбранных заказов должен быть единый поставщик и единый эффективный склад" |
| | 1 | 344 | | } |
| | 1 | 345 | | }, |
| | 1 | 346 | | new() |
| | 1 | 347 | | { |
| | 1 | 348 | | TransactionType = (int)TransactionType.ToCancellation, |
| | 1 | 349 | | Endpoint = "/Studio2/ToCancellationTransaction/CreateToCancellationTransaction", |
| | 1 | 350 | | Label = "К отмене", |
| | 1 | 351 | | Icon = "fas fa-hourglass-half me-2", |
| | 1 | 352 | | LinkClass = "btn btn-link link-secondary", |
| | 1 | 353 | | Action = "createToCancellationTransaction()", |
| | 1 | 354 | | AllowedStatuses = new List<string> { "Заказан поставщику", "Заказан реализатору" }, |
| | 1 | 355 | | ToStatus = "К отмене", |
| | 1 | 356 | | TransactionColor = "#6c757d", |
| | 1 | 357 | | IntegrationMode = "none", |
| | 1 | 358 | | UiConditions = new List<string>() |
| | 1 | 359 | | }, |
| | 1 | 360 | | new() |
| | 1 | 361 | | { |
| | 1 | 362 | | TransactionType = (int)TransactionType.Cancelled, |
| | 1 | 363 | | Endpoint = "/Studio2/CancelledTransaction/CreateCancelledTransaction", |
| | 1 | 364 | | Label = "Отменен", |
| | 1 | 365 | | Icon = "fas fa-times-circle me-2", |
| | 1 | 366 | | LinkClass = "btn btn-link link-danger", |
| | 1 | 367 | | Action = "createCancelledTransaction()", |
| | 1 | 368 | | AllowedStatuses = new List<string> { "Заказан поставщику" }, |
| | 1 | 369 | | ToStatus = "Отменен", |
| | 1 | 370 | | TransactionColor = "#dc3545", |
| | 1 | 371 | | IntegrationMode = "none", |
| | 1 | 372 | | UiConditions = new List<string>() |
| | 1 | 373 | | }, |
| | 1 | 374 | | new() |
| | 1 | 375 | | { |
| | 1 | 376 | | TransactionType = (int)TransactionType.ReturnTransfer, |
| | 1 | 377 | | Endpoint = "/Studio2/ReturnTransferTransaction/CreateReturnTransferTransaction", |
| | 1 | 378 | | Label = "Перемещение", |
| | 1 | 379 | | Icon = "fas fa-forward me-2", |
| | 1 | 380 | | LinkClass = "btn btn-link link-primary", |
| | 1 | 381 | | Action = "createReturnTransferTransaction()", |
| | 1 | 382 | | AllowedStatuses = new List<string> { "Возврат покупателя" }, |
| | 1 | 383 | | ToStatus = "Перемещение", |
| | 1 | 384 | | TransactionColor = "#0d6efd", |
| | 1 | 385 | | IntegrationMode = "none", |
| | 1 | 386 | | UiConditions = new List<string>() |
| | 1 | 387 | | }, |
| | 1 | 388 | | new() |
| | 1 | 389 | | { |
| | 1 | 390 | | TransactionType = (int)TransactionType.LostByCommissioner, |
| | 1 | 391 | | Endpoint = "/Studio2/LostByCommissionerTransaction/CreateLostByCommissionerTransaction", |
| | 1 | 392 | | Label = "Утерян реализатором", |
| | 1 | 393 | | Icon = "fas fa-question-circle me-2", |
| | 1 | 394 | | LinkClass = "btn btn-link link-danger", |
| | 1 | 395 | | Action = "createLostByCommissionerTransaction()", |
| | 1 | 396 | | AllowedStatuses = new List<string>(), |
| | 1 | 397 | | ToStatus = "Утерян реализатором", |
| | 1 | 398 | | TransactionColor = "#dc3545", |
| | 1 | 399 | | IntegrationMode = "optional", |
| | 1 | 400 | | OneCDocumentType = "transfer", |
| | 1 | 401 | | UiConditions = new List<string> |
| | 1 | 402 | | { |
| | 1 | 403 | | "Начальный статус не ограничен", |
| | 1 | 404 | | "Для 1С: склад-получатель определяется автоматически как «{склад} (transit)»", |
| | 1 | 405 | | "Для 1С: транзитный склад должен существовать в 1С" |
| | 1 | 406 | | } |
| | 1 | 407 | | } |
| | 1 | 408 | | }; |
| | | 409 | | } |
| | | 410 | | } |
| | | 411 | | |
| | | 412 | | public class TransactionTransitionRuleVm |
| | | 413 | | { |
| | | 414 | | public int TransactionType { get; set; } |
| | | 415 | | public string Endpoint { get; set; } = string.Empty; |
| | | 416 | | public string Label { get; set; } = string.Empty; |
| | | 417 | | public string Icon { get; set; } = string.Empty; |
| | | 418 | | public string LinkClass { get; set; } = string.Empty; |
| | | 419 | | public string Action { get; set; } = string.Empty; |
| | | 420 | | public List<string> AllowedStatuses { get; set; } = new(); |
| | | 421 | | public List<string> DisallowMarketplaceStatuses { get; set; } = new(); |
| | | 422 | | public string? ToStatus { get; set; } |
| | | 423 | | public string TransactionColor { get; set; } = "#6c757d"; |
| | | 424 | | /// <summary> |
| | | 425 | | /// Режим интеграции с 1С: none | optional | required |
| | | 426 | | /// </summary> |
| | | 427 | | public string IntegrationMode { get; set; } = "none"; |
| | | 428 | | /// <summary> |
| | | 429 | | /// Тип документа 1С: "receipt" | "transfer" | "expense" | "transfer+expense" | "" |
| | | 430 | | /// </summary> |
| | | 431 | | public string OneCDocumentType { get; set; } = ""; |
| | | 432 | | public List<string> UiConditions { get; set; } = new(); |
| | | 433 | | /// <summary> |
| | | 434 | | /// Есть активный повторяемый самопереход (FromStatus == ToStatus, IsRepeatable) — например, перезаказ. |
| | | 435 | | /// </summary> |
| | | 436 | | public bool HasRepeatableSelfTransition { get; set; } |
| | | 437 | | |
| | | 438 | | // ---- Грид транзакций (/Studio2/TransactionsGrid) и админка типов ---- |
| | | 439 | | |
| | | 440 | | /// <summary>Сегмент URL грида; пусто, если тип не описан в каталоге.</summary> |
| | | 441 | | public string? Slug { get; set; } |
| | | 442 | | |
| | | 443 | | /// <summary>Адрес страницы грида; OrdersGrid идёт по нему, когда <see cref="UseGrid"/>.</summary> |
| | | 444 | | public string? GridEndpoint { get; set; } |
| | | 445 | | |
| | | 446 | | /// <summary>Адрес для проверки прав на клиенте — всегда классический (права настроены на него).</summary> |
| | | 447 | | public string? PermissionEndpoint { get; set; } |
| | | 448 | | |
| | | 449 | | public bool UseGrid { get; set; } |
| | | 450 | | |
| | | 451 | | public bool IsEnabled { get; set; } = true; |
| | | 452 | | |
| | | 453 | | public string? ShortName { get; set; } |
| | | 454 | | |
| | | 455 | | public string? Group { get; set; } |
| | | 456 | | |
| | | 457 | | public int DisplayOrder { get; set; } |
| | | 458 | | |
| | | 459 | | public string? Hint { get; set; } |
| | | 460 | | } |