public void Build_all_tags() { var lines = new List <TagPrintable>(); for (var i = 0; i < 25; i++) { var line = new TagPrintable() { Nds = 10, RetailCost = 251.20m, Product = "Диклофенак", Quantity = 1 }; lines.Add(line); } var priceTagSettings = new PriceTagSettings() { Type = PriceTagType.Normal }; var doc = new PriceTagDocument(lines, priceTagSettings, null).Build(); Assert.IsNotNull(doc); Assert.AreEqual(2, doc.Pages.Count); var page1 = doc.Pages[0].Child; Assert.AreEqual(24, page1.Descendants <Grid>().First().Children.Count); var page2 = doc.Pages[1].Child; Assert.AreEqual(1, page2.Descendants <Grid>().First().Children.Count); }
public void Check_custom_price_tag_address() { var address = new Address("Тестовый адрес"); var lines = new List <TagPrintable>(); var line = new TagPrintable() { AddressName = "Тестовый измененный адрес", ClientName = "Тестовый клиент", Nds = 10, RetailCost = 251.20m, Product = "Диклофенак", Quantity = 1 }; lines.Add(line); var priceTagSettings = new PriceTagSettings() { Type = PriceTagType.Custom, Address = address }; var priceTag = PriceTag.Default(TagType.PriceTag, address); var doc = new PriceTagDocument(lines, priceTagSettings, priceTag).Build(); Assert.IsNotNull(doc); var text = doc.Descendants <StackPanel>() .First() .Descendants <Label>() .First() .Content.ToString().Trim(); Assert.AreEqual($"{line.ClientName}, {line.AddressName}", text); }
public void Print_price_tag() { var address = new Address("Тестовый"); var lines = new List <TagPrintable>(); var line = new TagPrintable() { Nds = 10, RetailCost = 251.20m, Product = "Диклофенак", Quantity = 1 }; lines.Add(line); var priceTagSettings = new PriceTagSettings() { Type = PriceTagType.Normal }; var doc = new PriceTagDocument(lines, priceTagSettings, null).Build(); Assert.IsNotNull(doc); var priceTag = PriceTag.Default(TagType.RackingMap, null); var settings = new Settings(address); settings.RackingMap.Size = RackingMapSize.Custom; var doc2 = new RackingMapDocument(lines, settings, priceTag).Build(); Assert.IsNotNull(doc2); }
protected override void OnInitialize() { base.OnInitialize(); address = address ?? Address; RxQuery(s => PriceTag.LoadOrDefault(s.Connection, TagType.PriceTag, address)) .Subscribe(x => priceTag = x); RxQuery(s => PriceTag.LoadOrDefault(s.Connection, TagType.RackingMap, null)) .Subscribe(x => rackingMap = x); this.priceTagSettings = Settings.Value.PriceTags.First(r => r.Address?.Id == address?.Id); }
public PriceTagDocument(IList <TagPrintable> lines, PriceTagSettings priceTagSettings, PriceTag priceTag) { this.lines = lines; this.priceTag = priceTag; this.priceTagSettings = priceTagSettings; }
private bool CheckSettings(bool overrideHash) { using (var session = Factory.OpenSession()) using (var transaction = session.BeginTransaction()) { var settings = session.Query <Settings>().FirstOrDefault(); var mappingToken = AppBootstrapper.NHibernate.MappingHash; if (settings == null) { settings = new Settings(mappingToken, session.Query <Address>().ToArray()); settings.CheckToken(); session.Save(settings); } else { settings.CheckToken(); if (overrideHash) { settings.MappingToken = mappingToken; } if (settings.MappingToken != mappingToken) { return(true); } if (settings.Waybills.Count == 0) { session.Query <WaybillSettings>().Each(settings.Waybills.Add); } } var markupGlobalConfigList = session.Query <MarkupGlobalConfig>().ToList(); var addresses = session.Query <Address>().ToList(); settings.SetGlobalMarkupsSettingsForAddress(addresses, markupGlobalConfigList); var mainAddress = addresses.FirstOrDefault(); foreach (var address in addresses.Except(new [] { mainAddress })) { settings.CopyMarkups(mainAddress, address); } //если ничего восстановить не удалось тогда берем значения по умолчанию foreach (var address in addresses) { foreach (MarkupType type in Enum.GetValues(typeof(MarkupType))) { if (settings.Markups.Count(x => x.Address == address && x.Type == type) == 0) { MarkupConfig.Defaults(address).Where(x => x.Type == type).Each(settings.AddMarkup); } } if (settings.PriceTags.Count(r => r.Address == address) == 0) { PriceTagSettings.Defaults(address).Each(settings.AddPriceTag); } } settings.PriceTags.RemoveEach(settings.PriceTags.Where(x => x.Address == null || !addresses.Contains(x.Address))); var addressConfigs = session.Query <AddressConfig>().ToArray(); session.DeleteEach(addressConfigs.Where(x => x.Address == null)); session.SaveEach(addresses.Except(addressConfigs.Select(x => x.Address)).Select(x => new AddressConfig(x))); //если есть адреса то должен быть и пользователь //если только база не была поломана var user = session.Query <User>().FirstOrDefault() ?? new User(); settings.Waybills.AddEach(addresses .Except(settings.Waybills.Select(w => w.BelongsToAddress)) .Select(a => new WaybillSettings(user, a))); if (!session.Query <WriteoffReason>().Any()) { session.SaveEach(WriteoffReason.Default()); } var suppliers = session.Query <Supplier>().ToList(); var dirMaps = session.Query <DirMap>().ToList(); var newDirMaps = suppliers .Except(dirMaps.Select(m => m.Supplier)) .Select(s => new DirMap(settings, s)) .ToArray(); session.SaveEach(newDirMaps); transaction.Commit(); } return(false); }