< Summary

Information
Class: OzonOrdersWeb.WebServices.Transactions.Grid.Commit.Steps.HistoryStep
Assembly: OzonOrdersWeb
File(s): /home/runner/work/Studio2Prod/Studio2Prod/OzonOrdersWeb/WebServices/Transactions/Grid/Commit/Steps/HistoryStep.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 23
Coverable lines: 23
Total lines: 57
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
.ctor(...)100%210%
get_Key()100%210%
ExecuteAsync()0%342180%

File(s)

/home/runner/work/Studio2Prod/Studio2Prod/OzonOrdersWeb/WebServices/Transactions/Grid/Commit/Steps/HistoryStep.cs

#LineLine coverage
 1using Services.DataServices;
 2
 3namespace OzonOrdersWeb.WebServices.Transactions.Grid.Commit.Steps;
 4
 5/// <summary>История проводок 1С (по группам складов) и история переходов статусов — только после записи транзакции.</su
 6public sealed class HistoryStep : ITransactionCommitStep
 7{
 8    private readonly IStatusTransitionHistoryService? _statusHistory;
 9
 010    public HistoryStep(IStatusTransitionHistoryService? statusHistory = null)
 11    {
 012        _statusHistory = statusHistory;
 013    }
 14
 015    public string Key => TransactionCommitStepKeys.History;
 16
 17    public async Task ExecuteAsync(TransactionCommitContext ctx)
 18    {
 019        if (ctx.TransactionId <= 0)
 20        {
 021            return;
 22        }
 23
 024        if (ctx.ProcessIn1C && ctx.OneCResponses.Count > 0)
 25        {
 026            var kind = ctx.Definition.OneCDocument;
 027            if (ctx.OneCGroups.Count > 0)
 28            {
 029                foreach (var g in ctx.OneCGroups)
 30                {
 031                    await OrderHistoryOneCPostingRecorder.TryRecordMovementAsync(ctx.Services, g.Orders, g.Result, ctx.U
 32                }
 33            }
 034            else if (kind == Definitions.OneCDocumentKind.Receipt)
 35            {
 036                await OrderHistoryOneCPostingRecorder.TryRecordReceiptAsync(ctx.Services, ctx.OrdersToTransaction, ctx.O
 37            }
 038            else if (kind == Definitions.OneCDocumentKind.Expense)
 39            {
 040                await OrderHistoryOneCPostingRecorder.TryRecordExpenseAsync(ctx.Services, ctx.OrdersToTransaction, ctx.O
 41            }
 42            else
 43            {
 044                await OrderHistoryOneCPostingRecorder.TryRecordMovementAsync(ctx.Services, ctx.OrdersToTransaction, ctx.
 45            }
 46        }
 47
 048        if (ctx.Transitions.Count > 0 && _statusHistory != null)
 49        {
 050            var comment = TransactionServices.TransactionCommentAiSchedulingHelper.ResolveCommentForDatabase(
 051                ctx.CommentFlow.UserCommentOnly, ctx.CommentFlow.ScheduleAiComment, ctx.TechnicalComment);
 052            await _statusHistory.RecordStatusTransitionHistoryAsync(
 053                ctx.Definition.Type, ctx.OrdersToTransaction, ctx.FromStatusByOrderId, ctx.Transitions,
 054                comment, ctx.User.AccessProfileId, ctx.CreatedAt, null);
 55        }
 056    }
 57}