public void SpecialMarkup_Waybill() { var waybill = new Waybill(address, session.Query <Supplier>().First()); var catalog = session.Query <Catalog>().First(); var product = session.Query <Product>().First(x => x.CatalogId == catalog.Id); var line = new WaybillLine(waybill) { ProductId = product.Id, CatalogId = catalog.Id, Quantity = 10, Nds = 10, ProducerCost = 15.13m, SupplierCostWithoutNds = 18.25m, SupplierCost = 20.8m }; waybill.AddLine(line); session.Save(waybill); var markup = settings.Markups.First(x => x.Type == MarkupType.Special); markup.Markup = 50; session.Save(new SpecialMarkupCatalog { CatalogId = waybill.Lines[0].CatalogId.Value }); var model = Open(new WaybillDetails(waybill.Id)); var waybillLine = model.Waybill.Lines[0]; Assert.AreEqual(30.8, waybillLine.RetailCost); }
public void Revert_value_on_incorrect_input() { var waybill = new Waybill(new Address("тест"), new Supplier()); var line = new WaybillLine(waybill); line.RetailCost = 150; waybill.AddLine(line); WpfTestHelper.WithWindow2(async w => { var grid = new DataGrid2(); grid.IsReadOnly = false; grid.AutoGenerateColumns = false; grid.Columns.Add(new DataGridTextColumnEx { Binding = new Binding("Product") }); grid.Columns.Add(new DataGridTextColumnEx { Binding = new Binding("RetailCost") }); w.Content = grid; grid.ItemsSource = waybill.Lines; await w.WaitIdle(); var cell = grid.Descendants <DataGridCell>() .First(x => x.Column == grid.Columns[1] && x.DataContext == line); Assert.IsTrue(cell.Focus()); cell.SendKey(Key.F2); Assert.IsTrue(cell.IsEditing); var input = cell.Descendants <TextBox>().First(); input.SendText("asd"); grid.SendKey(Key.Down); Assert.IsFalse(cell.IsEditing); Assert.AreEqual(150, line.RetailCost); }); }
public void Mark_waybill_with_reject() { var reject = localSession.Query <Client.Models.Reject>().First(); var waybill = new Waybill(address, localSession.Query <Supplier>().First()); waybill.AddLine(new WaybillLine(waybill) { Product = reject.Product, ProductId = reject.ProductId, SerialNumber = reject.Series, SupplierCost = 42.90m, SupplierCostWithoutNds = 36.36m, Nds = 18, ProducerCost = 28.78m, Quantity = 10 }); localSession.Save(waybill); var cmd = new UpdateCommand(); cmd.Session = localSession; cmd.CalculateRejects(settings); localSession.Refresh(waybill); Assert.IsTrue(waybill.IsRejectChanged, waybill.Id.ToString()); var line = waybill.Lines[0]; localSession.Refresh(line); Assert.IsTrue(line.IsRejectNew); Assert.AreEqual(reject.Id, line.RejectId, line.Id.ToString()); }
public void Calculate_fields_for_user_created_waybill() { waybill.Calculate(settings, new List <uint>()); waybill.IsCreatedByUser = true; var line = new WaybillLine(); waybill.AddLine(line); line.SupplierCostWithoutNds = 67.5m; line.SupplierCost = 75; line.Nds = 10; line.Quantity = 2; line.EndEdit(); Assert.AreEqual(150, line.Amount); Assert.AreEqual(150, waybill.Sum); Assert.AreEqual(89.8, line.RetailCost); }
public void Setup() { supplier = session.Query <Supplier>().First(); waybill = new Waybill(address, supplier); var line = new WaybillLine(waybill) { Product = "АКРИДЕРМ ГК 15,0 МАЗЬ", Certificates = "РОСС RU.ФМ01.Д19782", ProducerCost = 258, Nds = 10, SupplierCostWithoutNds = 258, SupplierCost = 283.8m, Quantity = 2, SerialNumber = "120214" }; waybill.AddLine(line); session.Save(waybill); }
private void CreateMatchedWaybill(SentOrderLine orderLine) { var sendOrder = orderLine.Order; var waybill = new Waybill { ProviderDocumentId = sendOrder.Id.ToString(), DocumentDate = DateTime.Now, WriteTime = DateTime.Now, Address = sendOrder.Address, Supplier = session.Load <Supplier>(sendOrder.Price.SupplierId), }; var line = new WaybillLine { Product = orderLine.ProductSynonym, Producer = orderLine.ProducerSynonym, Quantity = (int?)orderLine.Count, SupplierCost = orderLine.Cost, }; waybill.AddLine(line); waybill.Calculate(settings, new List <uint>()); session.Save(waybill); session.Save(new WaybillOrder(line.Id, orderLine.ServerId.Value)); }
public WaybillDetails(uint id) { DisplayName = "Детализация накладной"; this.id = id; InitFields(); CurrentWaybillLine = CurrentLine.OfType <WaybillLine>().ToValue(); Settings.Subscribe(_ => Calculate()); CurrentTax.Subscribe(v => { if (Lines.Value == null) { return; } if (v == null || v.Value == -1) { Lines.Value.Filter = null; } else { Lines.Value.Filter = o => ((WaybillLine)o).Nds == v.Value; } }); Lines.Select(v => v == null ? Observable.Empty <EventPattern <NotifyCollectionChangedEventArgs> >() : v.ToCollectionChanged()) .Switch() .Subscribe(e => { if (e.EventArgs.Action == NotifyCollectionChangedAction.Remove) { e.EventArgs.OldItems.OfType <WaybillLine>().Each(l => Waybill.RemoveLine(l)); } else if (e.EventArgs.Action == NotifyCollectionChangedAction.Add) { e.EventArgs.NewItems.OfType <WaybillLine>().Each(l => Waybill.AddLine(l)); } }); OrderLines = CurrentWaybillLine .Throttle(Consts.ScrollLoadTimeout, UiScheduler) .Select(v => { if (v == null) { return(new List <SentOrderLine>()); } var lineId = v.Id; var orderLineIds = Session.Query <WaybillOrder>().Where(l => l.DocumentLineId == lineId) .Select(l => (uint?)l.OrderLineId) .ToArray(); var line = Session.Query <SentOrderLine>().FirstOrDefault(l => orderLineIds.Contains(l.ServerId)); if (line != null) { CurrentOrderLine.Value = line; line.Order.Lines.Each(l => l.Configure(User)); return(line.Order.Lines.OrderBy(l => l.ProductSynonym).ToList()); } return(new List <SentOrderLine>()); }) .ToValue(CloseCancellation); EmptyLabelVisibility = OrderLines .Select(v => v == null || v.Count == 0 ? Visibility.Visible : Visibility.Collapsed) .ToValue(); OrderDetailsVisibility = EmptyLabelVisibility .Select(v => v == Visibility.Collapsed ? Visibility.Visible : Visibility.Collapsed) .ToValue(); }