예제 #1
0
 public void StockIn(StockInVoucher stockInVoucher)
 {
     if (stockInVoucher.Status != StockInVoucherStatus.Unsubmit)
     {
         throw new DomainException("单据状态异常");
     }
     stockInVoucher.Status = StockInVoucherStatus.Confirm;
     foreach (var item in stockInVoucher.Items)
     {
         ProductStockIn(stockInVoucher.DepartmentID, item.PositionID, item.ProductSkuID, item.SerialNumber, item.Quantity, item.AuxiliaryQuantity);
     }
 }
예제 #2
0
            void ProductMgrSeed(AlpsContext context)
            {
                var ysjsID = context.Departments.FirstOrDefault(p => p.Name == "轧钢车间").ID;
                var cgID   = context.ProductSkus.FirstOrDefault().ID;

                #region 初始化库存
                context.ProductStocks.Add(ProductStock.Create(ysjsID, positionID, cgID, "900001", 2.5m, 1));
                context.ProductStocks.Add(ProductStock.Create(ysjsID, positionID, cgID, "900002", 2.52m, 1));
                context.SaveChanges();
                #endregion

                #region 初始化入库单--StockInVoucher
                var            skuID   = context.ProductSkus.Find(gcSkuID).ID;
                var            sID     = context.Suppliers.FirstOrDefault().ID;
                var            dID     = context.Departments.OrderByDescending(p => p.ID).FirstOrDefault().ID;
                StockInVoucher voucher = StockInVoucher.Create(sID, dID, "系统初始化");
                context.StockInVouchers.Add(voucher);
                voucher.AddItem(positionID, skuID, "12345", 2.3m, 1, 2100);
                voucher.AddItem(positionID, skuID, "151515", 2.5m, 1, 2100);
                context.SaveChanges();
                voucher = StockInVoucher.Create(sID, dID, "系统初始化2");
                context.StockInVouchers.Add(voucher);
                voucher.AddItem(positionID, skuID, "600001", 2.4m, 1, 2000);
                voucher.AddItem(positionID, skuID, "600002", 2.6m, 1, 2000);

                skuID   = context.ProductSkus.Find(gpSkuID).ID;
                voucher = StockInVoucher.Create(sID, dID, "系统初始化3");
                context.StockInVouchers.Add(voucher);
                voucher.AddItem(positionID, skuID, "", 1000m, 1500, 1800);
                voucher.AddItem(positionID, skuID, "", 2000m, 3000, 1700);

                voucher = StockInVoucher.Create(sID, dID, "系统初始化3");
                context.StockInVouchers.Add(voucher);
                voucher.AddItem(positionID, skuID, "", 500m, 750, 1700);

                context.SaveChanges();
                #endregion

                #region 初始化出库单--StockOutVoucher
                var             cID = context.Customers.FirstOrDefault().ID;
                StockOutVoucher dv  = StockOutVoucher.Create(dID, cID, "系统初始化");
                skuID = context.ProductSkus.Find(gcSkuID).ID;
                dv.AddItem(positionID, skuID, "900001", 2.5m, 1, 2000);
                context.StockOutVouchers.Add(dv);
                skuID = context.ProductSkus.Find(gpSkuID).ID;
                dv    = StockOutVoucher.Create(dID, cID, "系统初始化");
                dv.AddItem(positionID, skuID, "900003", 2.5m, 2, 2000);
                context.StockOutVouchers.Add(dv);
                context.SaveChanges();
                #endregion
            }
예제 #3
0
        public IActionResult Post([FromBody] StockInVoucherEditDto dto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }
            var voucher = StockInVoucher.Create(dto.SupplierID, dto.DepartmentID, this.User.Identity.Name);

            voucher.SetDispatchRecordID(dto.DispatchRecordID);
            voucher.UpdateItems(dto.Items);
            _context.StockInVouchers.Add(voucher);
            _context.SaveChanges();
            return(this.AlpsActionOk());
        }