public void Updated() { if (checkType == CheckType.SaleBuyer) { var stockQuantity = CurrentLine.Value.Stock.Quantity; if (CurrentLine.Value.Quantity > stockQuantity) { Warning.Show(Common.Tools.Message.Warning( $"Заказ превышает остаток на складе, товар будет заказан в количестве {stockQuantity}")); CurrentLine.Value.Quantity = stockQuantity; } } if (checkType == CheckType.CheckReturn) { var stockQuantity = CheckLinesForReturn .Where(x => x.Stock.Id == CurrentLine.Value.Stock.Id) .First().Quantity; if (CurrentLine.Value.Quantity > stockQuantity) { Warning.Show(Common.Tools.Message.Warning( $"Количество возврата превышает проданное, товар будет возвращен в количестве {stockQuantity}")); CurrentLine.Value.Quantity = stockQuantity; } } CheckSum.Value = Lines.Sum(x => x.RetailSum); DiscontSum.Value = Lines.Sum(x => x.DiscontSum); }
protected override void OnInitialize() { base.OnInitialize(); Lines.Changed.Subscribe(_ => { if (Lines.Count > 0) { Status.Value = (checkType == CheckType.SaleBuyer ? "Открыт чек продажи" : "Открыт возврат по чеку"); } else { Status.Value = "Готов к работе(F1 для справки)"; CheckLinesForReturn.Clear(); checkType = null; } CheckSum.Value = Lines.Sum(x => x.RetailSum); DiscontSum.Value = Lines.Sum(x => x.DiscontSum); }); var lines = Shell.SessionContext.GetValueOrDefault(GetType().Name + "." + nameof(Lines)) as ReactiveCollection <CheckLine>; if (lines != null) { Lines.AddRange(lines); } Shell.SessionContext[GetType().Name + "." + nameof(Lines)] = null; CurrentLine .SelectMany(x => Env.RxQuery(s => { if (x == null) { return(null); } var catalogId = x.CatalogId; return(s.Query <Catalog>() .Fetch(c => c.Name) .ThenFetch(n => n.Mnn) .FirstOrDefault(c => c.Id == catalogId)); })) .Subscribe(CurrentCatalog, CloseCancellation.Token); }