Exemplo n.º 1
0
 public override void Visit(ReturnLine returnLine)
 {
     foreach (var ticketOperation in ticketOperationList)
     {
         ticketOperation.Visit(returnLine);
     }
 }
        public void Doc_Flow()
        {
            //На складе есть Папаверин в количестве 5шт.
            Assert.AreEqual(stock.Quantity, 5);
            Assert.AreEqual(stock.ReservedQuantity, 0);

            //Мы создаем документ списание на 3 упаковки, после того как строка папаверина
            //добавлена и документ сохранен, на складе у нас будет - Папаверин 2шт, 3шт в резерве
            var line = new ReturnLine(stock, 3);

            doc.Lines.Add(line);
            Assert.AreEqual(stock.Quantity, 2);
            Assert.AreEqual(stock.ReservedQuantity, 3);
            Assert.AreEqual(line.Quantity, 3);

            //Если мы закроем документ то получим - Папаверен 2шт, 0шт в резерве
            doc.Post(session);
            Assert.AreEqual(stock.Quantity, 2);
            Assert.AreEqual(stock.ReservedQuantity, 0);
            Assert.AreEqual(line.Quantity, 3);

            //Если мы снова откроем документ, то получим что было до закрытия - Папаверин 2шт, 3шт в резерве
            doc.UnPost(session);
            Assert.AreEqual(stock.Quantity, 2);
            Assert.AreEqual(stock.ReservedQuantity, 3);
            Assert.AreEqual(line.Quantity, 3);

            //Если документ будет удален то на складе получим - Папаверин 5шт, 0шт в резерве
            doc.BeforeDelete();
            Assert.AreEqual(stock.Quantity, 5);
            Assert.AreEqual(stock.ReservedQuantity, 0);
        }
Exemplo n.º 3
0
        public ActionResult GetSummary(int id)
        {
            var Header = _JobReceiveHeaderService.Find(id);

            var JobReceives = (from p in db.JobReceiveLine
                               join t in db.JobOrderLine on p.JobOrderLineId equals t.JobOrderLineId
                               join RetLine in db.JobReturnLine on p.JobReceiveLineId equals RetLine.JobReceiveLineId
                               into ReturnLine
                               from RetLin in ReturnLine.DefaultIfEmpty()
                               join t2 in db.ViewRugArea on t.ProductId equals t2.ProductId into table
                               from tab in table.DefaultIfEmpty()
                               join t4 in db.Product on tab.ProductId equals t4.ProductId
                               join t6 in db.ProductGroups on t4.ProductGroupId equals t6.ProductGroupId
                               join t5 in db.Units on t4.UnitId equals t5.UnitId
                               where p.JobReceiveHeaderId == id && p.PassQty > 0
                               group new { t, p, tab, t5, t6, RetLin } by new { t.ProductId, t.JobOrderHeaderId } into g
                               orderby g.Max(m => m.t6.ProductGroupName), g.Max(m => m.t.UnitConversionMultiplier)
                               select new JobReceiveSummaryViewModel
            {
                ProductName = g.Max(m => m.t.Product.ProductName),
                JobOrderHeaderId = g.Key.JobOrderHeaderId,
                JobOrderNo = g.Max(m => m.t.JobOrderHeader.DocNo),
                CostCenterName = g.Max(m => m.t.JobOrderHeader.CostCenter.CostCenterName),
                ProductId = g.Key.ProductId,
                Weight = (g.Sum(m => m.p.Weight) - g.Sum(m => m.RetLin == null ? 0 : (m.RetLin.Weight))),
                Qty = g.Sum(m => m.p.PassQty),
                ReturnQty = g.Sum(m => m.RetLin == null ? 0 : (m.RetLin.Qty)),
                UnitName = g.Max(m => m.t5.UnitName),
                MaxDecPlaces = g.Max(m => m.t5.DecimalPlaces),
                DealQty = g.Sum(m => m.p.PassQty * m.t.UnitConversionMultiplier),
                DealQtyPP = g.Max(m => m.t.UnitConversionMultiplier),
                MaxDealUnitDecPlaces = g.Max(m => m.t.DealUnit.DecimalPlaces),
                DealUnitName = g.Max(m => m.t.DealUnit.UnitName),
                ValidationError = (g.Where(m => m.p.Weight > 0 && m.RetLin == null).Any() && g.Where(m => m.p.Weight == 0 && m.RetLin == null).Any()),
                Penalty = g.Sum(m => m.p.PenaltyAmt) - (g.Sum(m => m.p.IncentiveAmt) ?? 0),
            }).ToList();

            JobReceiveSummaryDetailViewModel vm = new JobReceiveSummaryDetailViewModel();

            vm.JobReceiveHeaderId         = id;
            vm.DocData                    = Header.DocDate;
            vm.JobWorkerId                = Header.JobWorkerId;
            vm.JobReceiveSummaryViewModel = JobReceives;
            PrepareViewBag(id);

            if (JobReceives.Count == 0)
            {
                return(Redirect(System.Configuration.ConfigurationManager.AppSettings["JobsDomain"] + "/JobReceiveHeader/Index/" + Header.DocTypeId));
            }
            else
            {
                return(View("Summary", vm));
            }
        }
Exemplo n.º 4
0
    protected void cmdEdit1_ItemCommand(object sender, MagicItemEventArgs args)
    {
        if (args.CommandName == "Save")
        {
            HtmlInputText input = null;
            using (ISession session = new Session())
            {
                try
                {
                    IList <ReturnLine> lines = new List <ReturnLine>();
                    foreach (RepeaterItem item in this.repeatControl.Items)
                    {
                        input = item.FindControl("hidQty") as HtmlInputText;
                        int     sndid     = Cast.Int(input.Attributes["vv_sndid"]);
                        decimal returnQty = Cast.Decimal(input.Value);
                        if (sndid <= 0 || returnQty <= 0M)
                        {
                            continue;
                        }
                        ReturnLine line = new ReturnLine();
                        line.RefOrderLineID = sndid;
                        line.Quantity       = returnQty;
                        lines.Add(line);
                    }
                    if (lines.Count <= 0)
                    {
                        this.Response.Redirect(this.ReturnUrl);
                    }

                    ReturnHead head = ReturnHead.Retrieve(session, this.OrderNumber);
                    session.BeginTransaction();
                    head.UpdateOrCreateLines(session, lines);
                    session.Commit();
                    this.Response.Redirect(this.ReturnUrl);
                }
                catch (Exception er)
                {
                    session.Rollback();
                    WebUtil.ShowError(this, er);
                }
            }
        }
    }
        public IEnumerable <IResult> Add()
        {
            if (Doc.Supplier == null)
            {
                Manager.Warning("Укажите поставщика");
                yield break;
            }
            while (true)
            {
                var search = new StockSearch(Doc.Supplier.Id);
                yield return(new DialogResult(search, false, true));

                var edit = new EditStock(search.CurrentItem)
                {
                    EditMode = EditStock.Mode.EditQuantity
                };
                yield return(new DialogResult(edit));

                var line = new ReturnLine(Session.Load <Stock>(edit.Stock.Id), edit.Stock.Quantity);
                Lines.Add(line);
                Doc.Lines.Add(line);
                Doc.UpdateStat();
            }
        }
Exemplo n.º 6
0
 public override void Visit(ReturnLine line)
 {
 }
Exemplo n.º 7
0
 public virtual void Visit(ReturnLine returnLine)
 {
 }
Exemplo n.º 8
0
        public override void Visit(ReturnLine returnLine)
        {
            int price = Store.Instance().GetPrice(returnLine.Id, returnLine.Units);

            returnLine.Price = -price;
        }
Exemplo n.º 9
0
 public override void Visit(ReturnLine returnLine)
 {
     Console.WriteLine($"SCR: Devoltion {returnLine.Id} - {returnLine.Units}: {returnLine.Price}eu");
 }
Exemplo n.º 10
0
 public void Visit(ReturnLine line)
 {
     Code.Add($"lw $v0, {-line.Variable * 4}($sp)");
     Code.Add($"jr $ra");
 }
Exemplo n.º 11
0
        public void Exchange()
        {
            localSession.Connection.Execute(@"delete from Stocks; delete from StockActions;");
            session.Connection.Execute(@"delete from inventory.Stocks;");
            session.Connection.Execute(@"delete from inventory.StockActions;");
            session.Connection.Execute(@"delete from  Documents.DocumentHeaders;");
            var stockCount = session.Connection.Query <object>("select * from inventory.Stocks").ToArray();
            var actions    = session.Connection.Query <object>("select * from inventory.StockActions").ToArray();

            stockCount = localSession.Connection.Query <object>("select * from Stocks").ToArray();
            actions    = localSession.Connection.Query <object>("select * from StockActions").ToArray();

            Run(new SyncCommand());

            var fixture = new CreateWaybill();

            Fixture(fixture);

            Run(new UpdateCommand("Waybills"));
            var waybill  = localSession.Load <Waybill>(fixture.Waybill.Log.Id);
            var stockids = waybill.Lines.Where(x => x.StockId != null).Select(x => x.StockId).ToArray();
            var map      = localSession.Query <Stock>().Where(x => stockids.Contains(x.ServerId)).ToDictionary(x => x.ServerId);

            waybill.Lines.Each(y =>
            {
                y.Stock = map.GetValueOrDefault(y.StockId);
            });
            waybill.Stock(localSession);
            // чек +0 сток = 33  +1 стокакшин = 34
            var check = new Check(localSession.Query <User>().First(), address, new[] { new CheckLine(waybill.Lines[0].Stock, 1), }, CheckType.SaleBuyer);

            check.Lines.Each(x => x.Doc = check);
            localSession.Save(check);
            localSession.SaveEach(check.Lines);
            localSession.SaveEach(check.Lines.Select(x => x.UpdateStock(x.Stock, CheckType.SaleBuyer)));

            // распаковка +1 сток = 34  +2 стокакшин = 36
            var unpackingDoc  = new UnpackingDoc(address, localSession.Query <User>().First());
            var unpackingLine = new UnpackingLine(waybill.Lines[1].Stock, 10);

            unpackingDoc.Lines.Add(unpackingLine);
            unpackingDoc.Post();
            unpackingDoc.PostStockActions();
            localSession.Save(unpackingDoc);
            foreach (var line in unpackingDoc.Lines)
            {
                localSession.Save(line);
            }
            unpackingDoc.PostStockActions();
            foreach (var line in unpackingDoc.Lines)
            {
                localSession.Save(line.SrcStockAction);
                localSession.Save(line.DstStockAction);
            }

            // Списание +0 сток = 34  +1 стокакшин = 37
            var writeoffDoc  = new WriteoffDoc(address, localSession.Query <User>().First());
            var writeoffLine = new WriteoffLine(waybill.Lines[2].Stock, 1);

            writeoffDoc.Lines.Add(writeoffLine);
            writeoffDoc.Post(localSession);
            localSession.Save(writeoffDoc);

            //Возврат +0 сток = 34  +1 стокакшин = 38
            var ReturnDoc = new ReturnDoc(address, localSession.Query <User>().First());

            ReturnDoc.Supplier = waybill.Supplier;
            var ReturnLine = new ReturnLine(waybill.Lines[3].Stock, 1);

            ReturnDoc.Lines.Add(ReturnLine);
            ReturnDoc.Post(localSession);
            localSession.Save(ReturnDoc);

            //переоценка +1 сток = 35  +2 стокакшин = 40
            var ReassessmentDoc = new ReassessmentDoc(address, localSession.Query <User>().First());
            var stock           = waybill.Lines[4].Stock.Copy();

            stock.RetailCost += 10;
            var ReassessmentLine = new ReassessmentLine(waybill.Lines[4].Stock, stock);

            ReassessmentDoc.Lines.Add(ReassessmentLine);
            ReassessmentDoc.Post(localSession);
            localSession.Save(ReassessmentDoc);

            //переоценка +0 сток = 35  +1 стокакшин = 41
            var InventoryDoc  = new InventoryDoc(address, localSession.Query <User>().First());
            var InventoryLine = new InventoryLine(InventoryDoc, waybill.Lines[5].Stock, 5, localSession);

            InventoryDoc.Lines.Add(InventoryLine);
            InventoryDoc.Post();
            localSession.Save(InventoryDoc);

            //Перемещение +1 сток = 36  +2 стокакшин = 43
            var DisplacementDoc  = new DisplacementDoc(address, localSession.Query <User>().First());
            var DisplacementLine = new DisplacementLine(waybill.Lines[6].Stock, waybill.Lines[6].Stock.Copy(), 1);

            DisplacementDoc.Lines.Add(DisplacementLine);
            DisplacementDoc.Post(localSession);
            localSession.Save(DisplacementDoc);

            Run(new SyncCommand());
            stockCount = session.Connection.Query <object>("select * from inventory.Stocks").ToArray();
            actions    = session.Connection.Query <object>("select * from inventory.StockActions").ToArray();
            Assert.AreEqual(36, stockCount.Length);
            Assert.AreEqual(43, actions.Length);

            Run(new SyncCommand());
            stockCount = session.Connection.Query <object>("select * from inventory.Stocks").ToArray();
            actions    = session.Connection.Query <object>("select * from inventory.StockActions").ToArray();
            Assert.AreEqual(36, stockCount.Length);
            Assert.AreEqual(43, actions.Length);
        }
Exemplo n.º 12
0
    protected void MagicItemCommand(object sender, MagicItemEventArgs e)
    {
        if (e.CommandName == "Save")
        {
            #region 保存
            IList <ReturnLine> linesToSave = new List <ReturnLine>();
            foreach (RepeaterItem item in this.repeatControl.Items)
            {
                HtmlInputCheckBox chk = item.FindControl("checkbox") as HtmlInputCheckBox;
                DropDownList      drp = item.FindControl("drpArea") as DropDownList;
                TextBox           text;
                ReturnLine        line = new ReturnLine();
                line.OrderNumber = this.OrderNumber;
                line.LineNumber  = chk.Value.Trim();
                line.AreaCode    = drp.SelectedValue;
                text             = item.FindControl("txtSection") as TextBox;
                line.SectionCode = text.Text.Trim();

                linesToSave.Add(line);
            }

            using (ISession session = new Session())
            {
                try
                {
                    //检查
                    ReturnHead head = ReturnHead.Retrieve(session, this.OrderNumber);
                    if (head == null)
                    {
                        return;
                    }
                    session.BeginTransaction();
                    head.UpdateLines(session, linesToSave);
                    session.Commit();
                    WebUtil.ShowMsg(this, "保存成功");
                }
                catch (Exception er)
                {
                    session.Rollback();
                    WebUtil.ShowError(this, er);
                }
            }
            #endregion
        }
        else if (e.CommandName == "Release")
        {
            #region 发布
            using (ISession session = new Session())
            {
                try
                {
                    session.BeginTransaction();
                    ReturnHead head = ReturnHead.Retrieve(session, this.OrderNumber);
                    head.Release(session);
                    session.Commit();
                    WebUtil.ShowMsg(this, "发布成功");
                    this.QueryAndBindData(session, head);
                    this.SetView(head);
                }
                catch (Exception er)
                {
                    session.Rollback();
                    WebUtil.ShowError(this, er);
                }
            }
            #endregion
        }
        else if (e.CommandName == "Close")
        {
            #region 关闭
            using (ISession session = new Session())
            {
                try
                {
                    ReturnHead head = ReturnHead.Retrieve(session, this.OrderNumber);
                    if (head == null)
                    {
                        return;
                    }
                    session.BeginTransaction();
                    head.Close(session);
                    session.Commit();
                    WebUtil.ShowMsg(this, "退货单" + head.OrderNumber + "已经完成");
                    this.QueryAndBindData(session, head);
                    this.SetView(head);
                }
                catch (Exception er)
                {
                    session.Rollback();
                    WebUtil.ShowError(this, er);
                }
            }
            #endregion
        }
    }