public void Set_replication_if_matrix_settings_changed()
        {
            var supplier = DataMother.CreateSupplier();
            var price    = supplier.Prices[0];

            Save(supplier);
            var client = DataMother.CreateTestClientWithUser();
            var user   = client.Users[0];

            Flush();

            session
            .CreateSQLQuery("insert into Usersettings.AnalitfReplicationInfo(UserId, FirmCode, ForceReplication) values (:UserId, :SupplierId, 0)")
            .SetParameter("UserId", user.Id)
            .SetParameter("SupplierId", supplier.Id)
            .ExecuteUpdate();

            client.Settings.BuyingMatrixPrice  = price;
            client.Settings.BuyingMatrixType   = MatrixType.BlackList;
            client.Settings.BuyingMatrixAction = MatrixAction.Block;
            session.SaveOrUpdate(client.Settings);
            Flush();

            var info = session.CreateSQLQuery("select ForceReplication from Usersettings.AnalitfReplicationInfo where UserId = :UserId")
                       .SetParameter("UserId", user.Id)
                       .List <object>()
                       .Select(v => Convert.ToBoolean(v))
                       .ToList();

            Assert.That(info.Count, Is.GreaterThan(0));
            Assert.That(info, Is.EqualTo(new[] { true }));
        }
Example #2
0
        public void Vip_Price()
        {
            var client = DataMother.CreateTestClientWithUser(supplier.PricesRegions.First());

            session.Save(client);

            //Тут нужно понимать, что предупреждалка после обновления страницы, появляется только в том, случае
            //Если клиенты действительно были отключены от вип прайса, что случается не всегда
            //Поэтому необходимо добавить интерсекции
            var intersection = new Intersection();

            intersection.Price  = supplier.Prices.First();
            intersection.Client = client;
            intersection.Region = supplier.PricesRegions.First();
            var payer = new Payer("dasdas", "dasdasda");

            session.Save(payer);
            var legal = new LegalEntity("DASDA", "DASD", payer);

            session.Save(legal);
            intersection.Org = legal;
            session.Save(intersection);

            Open(supplier);
            Click("Настройка");
            Css("#MainContentPlaceHolder_PricesGrid_PriceTypeList_0").SelectByValue(((int)PriceType.Vip).ToString());
            Click("Применить");
            AssertText("Все клиенты были отключены от VIP прайсов");
        }
 public void Setup()
 {
     _client = DataMother.CreateTestClientWithUser();
     _user   = _client.Users.First();
     session.Save(_client);
     session.Save(_user);
 }
        public void Setup()
        {
            testClient = DataMother.CreateTestClientWithUser();

            Open(testClient);
            AssertText("Клиент");
        }
        public void SearchPayerForDrugstoreWithoutSuppliersWithDrugsSearchRegion()
        {
            var client    = DataMother.CreateTestClientWithUser();
            var payer     = client.Payers.First();
            var recipient = session.Query <Recipient>().First();

            payer.Recipient = recipient;
            session.Save(payer);
            var homeRegion = session.Load <Region>(1UL);
            var supplier   = new Supplier(homeRegion, payer)
            {
                Name              = "Тестовый поставщик",
                FullName          = "Тестовый поставщик",
                ContactGroupOwner = new ContactGroupOwner(ContactGroupType.ClientManagers)
            };

            supplier.AddRegion(session.Query <Region>().First(r => r.DrugsSearchRegion), session);
            session.Save(supplier);

            var filter = new PayerFilter(session)
            {
                SearchBy         = SearchBy.PayerId,
                SearchText       = payer.Id.ToString(),
                ClientType       = SearchClientType.Drugstore,
                WithoutSuppliers = true
            };
            var items = filter.Find();

            Assert.That(items.Count, Is.EqualTo(1));
        }
        public void UpdateLogWithOtherTypeTest()
        {
            var client  = DataMother.CreateTestClientWithUser();
            var user    = client.Users[0];
            var oldName = user.Name;

            user.Name += "1";
            session.SaveOrUpdate(user);

            Flush();
            var logs = session.Query <AuditRecord>().Where(l => l.ObjectId == user.Id && l.Type == LogObjectType.User).ToList();

            Assert.That(logs.Implode(x => x.Message),
                        Is.StringContaining(String.Format("$$$Изменено 'Комментарий' было '{0}' стало '{1}'", oldName, user.Name)));
            Assert.That(logs[0].Service.Id, Is.EqualTo(client.Id));
            session.Clear();
            var newClient = DataMother.TestClient();
            var address   = new Address()
            {
                Id = user.Id
            };

            AuditRecord.UpdateLogs(newClient.Id, address);
            logs = session.Query <AuditRecord>().Where(l => l.ObjectId == user.Id && l.Type == LogObjectType.User).ToList();
            Assert.That(logs.Implode(x => x.Message),
                        Is.StringContaining(String.Format("$$$Изменено 'Комментарий' было '{0}' стало '{1}'", oldName, user.Name)));
            Assert.That(logs[0].Service.Id, Is.EqualTo(client.Id));
        }
Example #7
0
        public void SortColumns()
        {
            Client client = DataMother.CreateTestClientWithUser();
            IEnumerable <UpdateLogEntity> updateLog = new List <UpdateLogEntity>();

            for (int i = 0; i < 2; i++)
            {
                updateLog = updateLog.Concat(new[] { new UpdateLogEntity(client.Users.First())
                                                     {
                                                         RequestTime = DateTime.Now.AddHours(-i * 2),
                                                         UpdateType  = (UpdateType)i,
                                                         ResultSize  = (uint)i,
                                                         AppVersion  = (uint)i,
                                                         Addition    = String.Format("Test update{0}", i),
                                                         Commit      = false,
                                                     } });
            }

            session.SaveEach(updateLog);
            Flush();

            var filter = new UpdateFilter();

            filter.Client = client;
            TrySortDate(filter);
        }
Example #8
0
        public void ChangePriceEnabledAndForceReplication()
        {
            var client   = DataMother.CreateTestClientWithUser();
            var user     = client.Users[0];
            var supplier = DataMother.CreateSupplier();

            Save(supplier);
            var price = supplier.Prices[0];

            session
            .CreateSQLQuery("insert into Usersettings.AnalitfReplicationInfo(UserId, FirmCode, ForceReplication) values (:UserId, :SupplierId, 0)")
            .SetParameter("UserId", user.Id)
            .SetParameter("SupplierId", supplier.Id)
            .ExecuteUpdate();

            price.AgencyEnabled = false;
            price.Enabled       = false;
            Save(price);

            Flush();

            CheckForceReplicationIsValue(supplier, true);

            ClearForceReplication(supplier);

            price.AgencyEnabled = true;
            Save(price);

            Flush();

            CheckForceReplicationIsValue(supplier, true);
        }
        public void RegisterUserAndAddressWithSamePayerForMultipayerClient()
        {
            var client = DataMother.CreateTestClientWithUser();
            var payer  = new Payer("Тестовый плательщик");

            session.Save(payer);
            client.Payers.Add(payer);
            session.SaveOrUpdate(client);

            Prepare();
            var legalEntity = client.Orgs().First(entity => entity.Payer.Id == payer.Id);

            Request.Params.Add("user.Payer.Id", payer.Id.ToString());
            Request.Params.Add("address.LegalEntity.Id", legalEntity.Id.ToString());
            Request.Params.Add("address.Value", "новый адрес");
            controller.Add(new Contact[0], new[] {
                new RegionSettings {
                    Id = 1, IsAvaliableForBrowse = true, IsAvaliableForOrder = true
                },
            }, new Person[0], "тестовое сообщение для биллинга", true, client.Id, null, null, null, null);

            Assert.IsTrue(Response.WasRedirected);
            var user = Registred();

            Assert.That(user.Payer, Is.EqualTo(payer));
        }
Example #10
0
        public void SearchByClientName()
        {
            var client = DataMother.CreateTestClientWithUser();

            MakeNameUniq(client);
            FlushAndCommit();
            AssetSearch(SearchUserBy.ByClientName, client.Name, client);
        }
        public void Setup()
        {
            client   = DataMother.CreateTestClientWithUser();
            settings = client.Settings;

            Open(client, "Settings");
            AssertText("Конфигурация клиента");
        }
Example #12
0
        public void Setup()
        {
            var supplier = DataMother.CreateSupplier();

            Save(supplier);
            client = DataMother.CreateTestClientWithUser();
            Open(client);
            AssertText("Клиент");
        }
Example #13
0
 public void Setup()
 {
     begin      = DateTime.Now;
     client     = DataMother.CreateTestClientWithUser();
     user       = client.Users.First();
     controller = new AddressesController();
     PrepareController(controller, "Addresses", "Add");
     controller.DbSession = session;
 }
Example #14
0
        public void SearchByPayerId()
        {
            var client = DataMother.CreateTestClientWithUser();
            var payer  = client.Payers[0];

            FlushAndCommit();

            AssetSearch(SearchUserBy.ByPayerId, payer.Id.ToString(), client);
        }
        public void Send_client_card()
        {
            var client   = DataMother.CreateTestClientWithUser();
            var defaults = session.Query <DefaultValues>().First();

            Flush();

            Assert.That(ReportHelper.SendClientCard(client.Users.First(), "", true, defaults, "*****@*****.**"), Is.Not.EqualTo(0));
        }
        public void Setup()
        {
            client   = DataMother.CreateTestClientWithUser();
            settings = client.Settings;
            user     = client.Users.First();

            Open(client);
            AssertText("Клиент");
        }
Example #17
0
        public void Search_with_number_symbol()
        {
            var client = DataMother.CreateTestClientWithUser();

            FlushAndCommit();

            browser.TextField(Find.ById("filter_SearchText")).TypeText(client.Users[0].Id.ToString());
            ClickButton("Поиск");

            CheckThatIsUserPage(browser, client);
        }
Example #18
0
        public void SearchByJuridicalName()
        {
            var client = DataMother.CreateTestClientWithUser();
            var payer  = client.Payers[0];

            payer.JuridicalName = payer.JuridicalOrganizations[0].Name;
            session.Save(payer);
            FlushAndCommit();
            var name = payer.JuridicalName;

            AssetSearch(SearchUserBy.ByJuridicalName, name, client);
        }
        public void Do_not_edit_payment_without_permission()
        {
            var client = DataMother.CreateTestClientWithUser();
            var user   = client.Users[0];
            var payer  = user.Payer;

            Open(payer);
            AssertText("Плательщик");
            var input = (TextField)Css(string.Format("#UserRow{0} input[name='payment']", user.Id));

            Assert.That(input.Enabled, Is.False);
        }
        public void Find_order_for_user()
        {
            var client = DataMother.CreateTestClientWithUser();

            Flush();

            var user = client.Users.First();

            new OrderFilter {
                User   = user,
                Client = client
            }.Find();
        }
Example #21
0
        public void Show_update_in_process()
        {
            var client = DataMother.CreateTestClientWithUser();
            var log    = new PrgDataLog(client.Users.First(), "FileHandler");

            session.Save(log);

            Open();
            Css("#updates-monitoring").Click();
            OpenedWindow("Обновляющиеся клиенты");

            AssertText("Обновляющиеся клиенты");
            AssertText("FileHandler");
        }
Example #22
0
        public void Autosearch_by_client_name()
        {
            var client = DataMother.CreateTestClientWithUser();

            FlushAndCommit();

            browser.TextField(Find.ById("filter_SearchText")).TypeText(client.Name);
            ClickButton("Поиск");

            var tableBody = browser.TableBody(Find.ById("SearchResults"));

            Assert.That(tableBody.TableRows.Count, Is.GreaterThan(0));
            Assert.That(tableBody.Text, Is.StringContaining(client.Id.ToString()));
            Assert.That(browser.Text, Is.Not.StringContaining("По вашему запросу ничего не найдено"));
        }
Example #23
0
        public void Accounting_changed()
        {
            var client = DataMother.CreateTestClientWithUser();
            var user   = client.Users[0];
            var payer  = user.Payer;

            session.SaveOrUpdate(payer);

            user.Accounting.Payment = 200;
            session.SaveOrUpdate(user);

            mailer.AccountChanged(user.Accounting);
            mailer.Send();
            Assert.That(message.Subject, Is.EqualTo(String.Format("Изменение стоимости Тестовый плательщик - {0}, test - {1}, Аптека", payer.Id, client.Id)));
            Assert.That(message.Body, Is.StringContaining("было 800,00р. стало 200,00р."));
        }
        public void SetUp()
        {
            var phones = new[] { "4732299222", "4732605000", "4732299223", "4732299224", "4732606000" };

            session.CreateSQLQuery("delete from telephony.UnresolvedPhone where Phone in (:phones)")
            .SetParameterList("phones", phones)
            .ExecuteUpdate();

            foreach (var phone in phones)
            {
                Save(new UnresolvedCall(phone));
            }

            client = DataMother.CreateTestClientWithUser();
            Open(client.Users[0]);
        }
Example #25
0
        public void AF_Net_Updates()
        {
            var client = DataMother.CreateTestClientWithUser();
            var log    = new RequestLog(client.Users.First())
            {
                Version     = "1.11",
                IsCompleted = true,
                UpdateType  = "MainController",
                ErrorType   = 1
            };

            session.Save(log);
            Open();
            AssertText("AnalitF.Net:");
            Css("#af-net-ban").Click();
            AssertText("История обновлений AnalitF.net");
        }
        public void Register_user_with_comment()
        {
            var client = DataMother.CreateTestClientWithUser();

            Prepare();
            Request.Params.Add("user.Payer.Id", client.Payers.First().Id.ToString());
            controller.Add(new Contact[0], new[] {
                new RegionSettings {
                    Id = 1, IsAvaliableForBrowse = true, IsAvaliableForOrder = true
                },
            }, new Person[0], "тестовое сообщение для биллинга", true, client.Id, null, null, null, null);

            var user     = Registred();
            var messages = session.Query <AuditRecord>().Where(l => l.ObjectId == user.Id);

            Assert.That(messages.Any(m => m.Message == "Сообщение в биллинг: тестовое сообщение для биллинга"), Is.True, messages.Implode(m => m.Message));
        }
        public void Search_payer_by_invoice_type()
        {
            var client = DataMother.CreateTestClientWithUser();
            var payer  = client.Payers.First();

            payer.AutoInvoice = InvoiceType.Auto;
            session.Save(payer);
            session.Flush();

            var items = new PayerFilter(session)
            {
                InvoiceType = InvoiceType.Manual
            }.Find();

            Assert.That(items.Any(i => i.PayerId == payer.Id), Is.False,
                        "не должны были найти плательщика {0}, есть {1}", payer.Id, items.Implode(i => i.PayerId.ToString()));
        }
        public void Search_by_inn()
        {
            var client = DataMother.CreateTestClientWithUser();
            var payer  = client.Payers.First();

            payer.INN = DataMother.RandomInn();
            session.Save(payer);
            session.Flush();

            var items = new PayerFilter(session)
            {
                SearchText = payer.INN, SearchBy = SearchBy.Inn, ClientStatus = SearchClientStatus.All
            }.Find();

            Assert.That(items.Count, Is.EqualTo(1));
            Assert.That(items[0].PayerId, Is.EqualTo(payer.Id));
        }
Example #29
0
        public void SearchByLogin()
        {
            var client = DataMother.CreateTestClientWithUser();
            var user   = client.Users[0];

            FlushAndCommit();

            AssetSearch(SearchUserBy.ByLogin, user.Login, client);
            if (browser.TableBody(Find.ById("SearchResults")).Exists)
            {
                Assert.That(browser.TableBody(Find.ById("SearchResults")).TableRows.Count, Is.EqualTo(1));
            }
            else
            {
                CheckThatIsUserPage(browser, client);
            }
        }
        public void Send_notification_for_debtors()
        {
            var client = DataMother.CreateTestClientWithUser();
            var payer  = client.Payers.First();

            payer.Balance = -1000;
            payer.SendPaymentNotification = true;
            session.Save(payer);
            Flush();
            SystemTime.Now = () => new DateTime(2011, 7, 27, 1, 2, 1);
            FlushAndCommit();

            new SendPaymentNotification().Process();
            var message = session.Load <UserMessage>(client.Users.First().Id);

            Assert.That(message.Message, Is.StringContaining("обслуживание будет приостановлено"));
            Assert.That(message.ShowMessageCount, Is.EqualTo(1));
        }