public void Check_add_from_catalog_enabling() { user.IsStockEnabled = true; session.Save(user); var waybill = new Waybill(address, session.Query <Supplier>().First()); waybill.IsCreatedByUser = true; var line = new WaybillLine(waybill) { Quantity = 1 }; waybill.Lines.Add(line); session.Save(waybill); WpfTestHelper.WithWindow2(async w => { var model = new WaybillDetails(waybill.Id); var view = (WaybillDetailsView)Bind(model); w.Content = view; await view.WaitLoaded(); var addButton = view.Descendants <Button>().First(b => b.Name == "AddFromCatalog"); Assert.IsTrue(addButton.Visibility == Visibility.Visible); Assert.IsTrue(addButton.IsEnabled); view.Descendants <Button>().First(b => b.Name == "Stock") .RaiseEvent(new RoutedEventArgs(ButtonBase.ClickEvent)); Assert.IsTrue(addButton.Visibility == Visibility.Visible); Assert.IsFalse(addButton.IsEnabled); }); WpfTestHelper.CleanSafeError(); }
public IEnumerable <IResult> AddFromCatalog() { if (!User.IsStockEnabled || !CanAddFromCatalog) { yield break; } var dlg = new AddWaybillLineFromCatalog(); yield return(new DialogResult(dlg)); if (dlg.WasCancelled) { yield break; } var line = new WaybillLine(Waybill) { CatalogId = dlg.CurrentCatalog.Value.Id, ProductId = Session.Query <Product>().FirstOrDefault(r => r.CatalogId == dlg.CurrentCatalog.Value.Id)?.Id, Product = dlg.CurrentCatalog.Value.FullName, ProducerId = dlg.CurrentProducer.Value.Id, Producer = dlg.CurrentProducer.Value.Name, SupplierCost = dlg.SupplierCost.Value, Quantity = dlg.Quantity.Value }; CurrentLine.Value = Lines.Value.AddNewItem(line); CurrentWaybillLine = CurrentLine.OfType <WaybillLine>().ToValue(); }
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 Calculate_markup_with_supplierPriceWithNDS_flag() { //Подстраиваем диапазоны наценок под товар в накладной var markups = settings.Markups; var minorMarkup = markups.First(x => x.Begin == 0 && x.Type == MarkupType.VitallyImportant); minorMarkup.End = 78; var majorMarkup = markups.First(x => x.Begin == 50 && x.Type == MarkupType.VitallyImportant); majorMarkup.Begin = minorMarkup.End; majorMarkup.Markup = 40; majorMarkup.MaxMarkup = 40; var line = new WaybillLine(waybill) { Nds = 10, SupplierCost = 82.63m, SupplierCostWithoutNds = 75.12m, ProducerCost = 72.89m, Quantity = 10, VitallyImportant = true }; //Стандартный расклад Calculate(line); Assert.AreEqual(19.92, line.RetailMarkup); //Проверяем расчет с флагом settings.UseSupplierPriceWithNdsForMarkup = true; Calculate(line); Assert.That(line.ProducerCostWithTax, Is.GreaterThan(majorMarkup.Begin)); Assert.AreEqual(40, line.RetailMarkup); }
private WaybillLine Calculate(WaybillLine line) { waybill.WaybillSettings = waybillSettings; waybill.Lines.Add(line); waybill.Calculate(settings, new List <uint>()); return(line); }
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 Create_new_line() { waybill.IsCreatedByUser = true; var waybillLine = new WaybillLine(); model.Lines.Value.AddNewItem(waybillLine); Assert.AreEqual(14, model.Waybill.Lines.Count); Assert.AreEqual(waybillLine.Waybill.Id, model.Waybill.Id); }
private string GetRetailMarkupInRubles(WaybillLine line) { if (waybill.WaybillSettings.Taxation == Taxation.Envd && line.RetailCost.HasValue && line.SupplierCost.HasValue) { return((line.RetailCost - line.SupplierCost).Value.ToString("0.00")); } if (waybill.WaybillSettings.Taxation == Taxation.Nds && line.RetailCostWithoutNds.HasValue && line.SupplierCostWithoutNds.HasValue) { return((line.RetailCostWithoutNds - line.SupplierCostWithoutNds).Value.ToString("0.00")); } return(""); }
private string GetRetailCost(WaybillLine line) { // неплательщик НДС указывает фактическую отпускную цену if (waybill.WaybillSettings.Taxation == Taxation.Envd && line.RetailCost.HasValue) { return(line.RetailCost.Value.ToString("0.00")); } if (waybill.WaybillSettings.Taxation == Taxation.Nds && line.RetailCostWithoutNds.HasValue) { return(line.RetailCostWithoutNds.Value.ToString("0.00")); } return(""); }
private string GetSupplierPriceMarkup(WaybillLine line) { if (!line.SupplierPriceMarkup.HasValue) { return(""); } // при реализации ниже уровня приобретения ставится прочерк if (line.SupplierPriceMarkup.Value < 0) { return("–"); } return(line.SupplierPriceMarkup.Value.ToString("0.00")); }
private WaybillLine Line() { settings.Markups.First(x => x.Type == MarkupType.Nds18).Markup = 30; var line = new WaybillLine(waybill) { SupplierCost = 42.90m, SupplierCostWithoutNds = 36.36m, Nds = 18, ProducerCost = 28.78m, Quantity = 10 }; return(line); }
public void Calculate_without_producer_cost1() { var line = new WaybillLine(waybill) { Nds = 10, SupplierCost = 370.35m, SupplierCostWithoutNds = 336.68m, ProducerCost = 327.27m, Quantity = 2 }; Calculate(line); Assert.AreEqual(444.4, line.RetailCost); }
public void Invalid_nds() { var waybillLine = new WaybillLine(waybill) { Nds = 18, Quantity = 20, SupplierCost = 9.72m, SupplierCostWithoutNds = 8.84m }; Calculate(waybillLine); Assert.IsTrue(waybill.CanBeVitallyImportant); waybill.VitallyImportant = true; Assert.IsTrue(waybillLine.IsNdsInvalid); }
public void Calculate_without_producer_cost() { var line = new WaybillLine(waybill) { VitallyImportant = true, Nds = 10, SupplierCost = 196.59m, SupplierCostWithoutNds = 178.72m, ProducerCost = 164.54m, Quantity = 2 }; Calculate(line); Assert.AreEqual(232.70, line.RetailCost); }
private string GetSupplierPriceMarkupInRubles(WaybillLine line) { if (!line.ProducerCost.HasValue || !line.SupplierCostWithoutNds.HasValue) { return(""); } var result = line.SupplierCostWithoutNds - line.ProducerCost; // при реализации ниже уровня приобретения ставится прочерк if (result < 0) { return("–"); } return(result.Value.ToString("0.00")); }
public void Roung_to_1_00() { settings.Rounding = Rounding.To1_00; var line = new WaybillLine(waybill) { Nds = 10, SupplierCost = 251.20m, SupplierCostWithoutNds = 228.36m, Quantity = 1 }; Calculate(line); Assert.AreEqual(301, line.RetailCost); Assert.AreEqual(19.83, line.RetailMarkup); }
public void Round_value() { settings.Rounding = Rounding.None; var line = new WaybillLine(waybill) { Nds = 10, SupplierCost = 251.20m, SupplierCostWithoutNds = 228.36m, Quantity = 1 }; Calculate(line); Assert.AreEqual(301.44, line.RetailCost); Assert.AreEqual(20, line.RetailMarkup); }
public void Waybill_CreatedByUser() { waybill.IsCreatedByUser = true; var line = new WaybillLine(waybill) { Product = "Тестовый продукт", SupplierCostWithoutNds = 1298.18m, Nds = 10, SupplierCost = 1428, Quantity = 5 }; Calculate(line); Assert.AreEqual(1, waybill.Lines.Count); }
public void Respect_server_retail_cost() { var line = new WaybillLine(waybill) { SupplierCost = 251.20m, SupplierCostWithoutNds = 228.36m, Quantity = 1, ServerRetailCost = 276.3m, ServerRetailMarkup = 10, }; Calculate(line); Assert.AreEqual(276.3, line.RetailCost); Assert.AreEqual(10, line.RetailMarkup); }
public void Calculate_real_retail_markup() { var line = new WaybillLine(waybill) { SupplierCost = 34.10m, SupplierCostWithoutNds = 31m, Nds = 10, ProducerCost = 32.39m, VitallyImportant = true, }; Calculate(line); Assert.AreEqual(41.20, line.RetailCost); Assert.AreEqual(19.93m, line.RetailMarkup); Assert.AreEqual(20.82m, line.RealRetailMarkup); }
public void Calculate_max_markup() { var line = new WaybillLine(waybill) { Nds = 10, SupplierCost = 82.63m, SupplierCostWithoutNds = 75.12m, ProducerCost = 72.89m, Quantity = 10 }; Calculate(line); Assert.AreEqual(20, line.MaxRetailMarkup); Assert.AreEqual(99.1, line.RetailCost); Assert.AreEqual(991, line.RetailSum); Assert.AreEqual(19.93, line.RetailMarkup); }
public void Select_markup_by_supplierCostWithNds_1() { settings.Rounding = Rounding.None; settings.Markups.RemoveEach(x => x.Type == MarkupType.Over); settings.Markups.Add(new MarkupConfig(address, 0, 550, 10, MarkupType.Over)); settings.Markups.Add(new MarkupConfig(address, 550, 1000000, 9, MarkupType.Over)); var line = new WaybillLine(waybill) { SupplierCostWithoutNds = 536.17m, SupplierCost = 589.79m, Quantity = 1 }; WaybillLine calculatedLine = Calculate(line); Assert.AreEqual(9, calculatedLine.RetailMarkup); Assert.AreEqual(642.87, calculatedLine.RetailCost); }
public void Recalculate_on_real_markup_change() { var line = new WaybillLine(waybill) { SupplierCost = 34.10m, SupplierCostWithoutNds = 31m, Nds = 10, ProducerCost = 32.39m, Quantity = 10, VitallyImportant = true }; Calculate(line); line.RealRetailMarkup = 30; Assert.AreEqual(44.30, line.RetailCost); Assert.AreEqual(29.91, line.RealRetailMarkup); Assert.AreEqual(28.63, line.RetailMarkup); }
public void Do_not_recalc_markup() { settings.Rounding = Rounding.None; var line = new WaybillLine(waybill) { ProducerCost = 30.57m, SupplierCostWithoutNds = 26.80m, Nds = 10, SupplierCost = 29.48m, VitallyImportant = true, }; waybill.AddLine(line); waybill.Calculate(settings, new List <uint>()); Assert.AreEqual(20, line.RetailMarkup); Assert.AreEqual(22.81, line.RealRetailMarkup); Assert.AreEqual(36.21, line.RetailCost); }
public Stock(Waybill waybill, WaybillLine line, ISession session) { Timestamp = DateTime.Now; WaybillId = waybill.Id; WaybillLineId = line.Id; Status = StockStatus.Available; Address = waybill.Address; SupplierId = waybill.Supplier?.Id; SupplierFullName = waybill.Supplier?.FullName; WaybillNumber = waybill.ProviderDocumentId; Product = line.CatalogId.HasValue ? session.Load <Catalog>(line.CatalogId).FullName : line.Product; ProductId = line.ProductId; CatalogId = line.CatalogId; Producer = line.Producer; ProducerId = line.ProducerId; Country = line.Country; CountryCode = line.CountryCode; Period = line.Period; Exp = line.Exp; SerialNumber = line.SerialNumber; Certificates = line.Certificates; Unit = line.Unit; ExciseTax = line.ExciseTax; BillOfEntryNumber = line.BillOfEntryNumber; VitallyImportant = line.VitallyImportant; ProducerCost = line.ProducerCost; RegistryCost = line.RegistryCost; SupplierPriceMarkup = line.SupplierPriceMarkup; SupplierCostWithoutNds = line.SupplierCostWithoutNds; Nds = line.Nds; Barcode = line.EAN13; Quantity = line.Quantity.GetValueOrDefault(); SupplyQuantity = line.Quantity.GetValueOrDefault(); SupplierCost = line.SupplierCost.GetValueOrDefault(); RetailCost = line.RetailCost.GetValueOrDefault(); RetailMarkup = line.RetailMarkup; RejectId = line.RejectId; if (line.IsReject) { RejectStatus = RejectStatus.Defective; } }
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); }
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 Calculate_with_zero_producer_cost() { var markup = settings.Markups.First(x => x.Type == MarkupType.Nds18); markup.Markup = 38; var line = new WaybillLine(waybill) { Nds = 18, SupplierCost = 251.20m, SupplierCostWithoutNds = 228.36m, ProducerCost = 0, Quantity = 1, VitallyImportant = true }; Calculate(line); Assert.AreEqual(353.60, line.RetailCost); Assert.AreEqual(37.96, line.RetailMarkup); }
public void Do_not_recalculate_edited_lines() { var line = new WaybillLine(waybill) { Product = "ТЕСТ-ПОЛОСКИ", SupplierCostWithoutNds = 1298.18m, Nds = 10, SupplierCost = 1428, }; Calculate(line); Assert.AreEqual(1713.6, line.RetailCost); line.RetailCost = 5000; Assert.AreEqual(5000, line.RetailCost); Assert.AreEqual(250.14, line.RetailMarkup); waybill.Calculate(settings, new List <uint>()); Assert.AreEqual(5000, line.RetailCost); }
public void Calculate_markup_not_include_nds() { var markup = settings.Markups.First(m => m.Type == MarkupType.Nds18); markup.Markup = 60; markup.MaxMarkup = 60; settings.Rounding = Rounding.None; waybillSettings.IncludeNds = false; var line = new WaybillLine(waybill) { SupplierCostWithoutNds = 185.50m, Nds = 18, SupplierCost = 218.89m, }; Calculate(line); Assert.AreEqual(60, line.MaxRetailMarkup); Assert.AreEqual(60, line.RetailMarkup); Assert.AreEqual(50.85, line.RealRetailMarkup); Assert.AreEqual(330.19, line.RetailCost); }