Exemplo n.º 1
0
 public void Setup()
 {
     payer             = DataMother.CreatePayerForBillingDocumentTest();
     payer.AutoInvoice = InvoiceType.Auto;
     session.Save(payer);
     Flush();
     filter = new DocumentBuilderFilter();
 }
Exemplo n.º 2
0
        public void Index([SmartBinder] PayerDocumentFilter filter)
        {
            PropertyBag["filter"]      = filter;
            PropertyBag["acts"]        = filter.Find <Act>(DbSession);
            PropertyBag["buildFilter"] = new DocumentBuilderFilter();

            PropertyBag["printers"] = Printer.All();
        }
Exemplo n.º 3
0
        public void Build([ARDataBind("buildFilter", AutoLoad = AutoLoadBehavior.NullIfInvalidKey)] DocumentBuilderFilter filter, DateTime invoiceDate, string printer)
        {
            var createdTime = DateTime.Now;

            filter.BuildInvoices(invoiceDate);

            Notify("Счета сформированы");
            var destinationFilter = filter.ToDocumentFilter();

            destinationFilter.CreatedOn = createdTime;
            RedirectToAction("Index", destinationFilter.GetQueryString());
        }
Exemplo n.º 4
0
        public void BuildActsTest()
        {
            var filter = new DocumentBuilderFilter {
                PayerId = new[] { _payer.Id },
                Period  = new Period(2012, Interval.January)
            };

            _controller.Build(filter, DateTime.Now);
            var acts    = session.Query <Act>().Where(a => a.Payer == _payer && a.Period == new Period(2012, Interval.January));
            var invoice = session.Load <Invoice>(_invoice.Id);

            Assert.That(acts.Count(), Is.EqualTo(1));
            Assert.That(invoice.Act, Is.EqualTo(acts.First()));
        }
Exemplo n.º 5
0
        public void Build([ARDataBind("buildFilter", AutoLoad = AutoLoadBehavior.NullIfInvalidKey)] DocumentBuilderFilter filter, DateTime actDate)
        {
            var sourceInvoices = filter.Find <Invoice>();
            var invoices       = sourceInvoices
                                 .Where(i => !DbSession.Query <Act>().Any(a => a.Payer == i.Payer && a.Period == i.Period)).ToList();
            var createdTime = DateTime.Now;

            foreach (var act in Act.Build(invoices, actDate))
            {
                DbSession.Save(act);
            }
            var destinationFilter = filter.ToDocumentFilter();

            destinationFilter.CreatedOn = createdTime;
            RedirectToAction("Index", destinationFilter.GetQueryString());
        }
Exemplo n.º 6
0
        public void NoBuildActsIfExistsTest()
        {
            var act = new Act {
                Payer  = _payer,
                Period = new Period(2012, Interval.January)
            };

            session.Save(act);
            session.Flush();
            var filter = new DocumentBuilderFilter {
                PayerId = new[] { _payer.Id },
                Period  = new Period(2012, Interval.January)
            };

            _controller.Build(filter, DateTime.Now);
            var acts = session.Query <Act>().Where(a => a.Payer == _payer && a.Period == new Period(2012, Interval.January));

            Assert.That(acts.Count(), Is.EqualTo(1));
        }