Ejemplo n.º 1
0
 private DXInfo.Models.RdRecord NewSaleOutStock(DateTime dtNow, Guid whId, bool isVerify)
 {
     DXInfo.Models.RdRecord rdRecord = new DXInfo.Models.RdRecord();
     rdRecord.Code      = common.GetVouchCode(DXInfo.Models.VouchTypeCode.SaleOutStock);
     rdRecord.VouchType = DXInfo.Models.VouchTypeCode.SaleOutStock;
     rdRecord.Maker     = operId;
     rdRecord.MakeDate  = dtNow;
     rdRecord.MakeTime  = dtNow;
     rdRecord.RdFlag    = 1;
     rdRecord.RdCode    = DXInfo.Models.VouchTypeCode.SaleOutStock;
     rdRecord.DeptId    = deptId;
     rdRecord.STCode    = "002";
     rdRecord.RdDate    = dtNow;
     rdRecord.Salesman  = operId;
     rdRecord.WhId      = whId;
     rdRecord.BusType   = DXInfo.Models.VouchTypeCode.SaleOutStock;
     rdRecord.IsVerify  = isVerify;
     if (isVerify)
     {
         rdRecord.Verifier   = operId;
         rdRecord.VerifyDate = dtNow;
         rdRecord.VerifyTime = dtNow;
     }
     return(rdRecord);
 }
Ejemplo n.º 2
0
 private DXInfo.Models.CurrentStock GetCurInStock(Guid rdsId)
 {
     DXInfo.Models.CurrentStock oldCurStock = null;
     DXInfo.Models.RdRecords    rds         = uow.RdRecords.GetById(g => g.Id == rdsId);
     if (rds != null)
     {
         DXInfo.Models.RdRecord rd = uow.RdRecord.GetById(g => g.Id == rds.RdId);
         if (rd != null)
         {
             if (string.IsNullOrEmpty(rds.Batch))
             {
                 oldCurStock = (from d in uow.CurrentStock.GetAll()
                                where d.WhId == rd.WhId && d.InvId == rds.InvId && d.Batch == null
                                orderby d.Num
                                select d).FirstOrDefault();
             }
             else
             {
                 oldCurStock = (from d in uow.CurrentStock.GetAll()
                                where d.WhId == rd.WhId && d.InvId == rds.InvId && d.Batch == rds.Batch
                                orderby d.Num
                                select d).FirstOrDefault();
             }
             if (oldCurStock == null)
             {
                 oldCurStock               = new DXInfo.Models.CurrentStock();
                 oldCurStock.WhId          = rd.WhId;
                 oldCurStock.InvId         = rds.InvId;
                 oldCurStock.MainUnit      = rds.MainUnit;
                 oldCurStock.STUnit        = rds.STUnit;
                 oldCurStock.ExchRate      = rds.ExchRate;
                 oldCurStock.Quantity      = rds.Quantity;
                 oldCurStock.Num           = rds.Num;
                 oldCurStock.Batch         = rds.Batch;
                 oldCurStock.Price         = rds.Price;
                 oldCurStock.Amount        = oldCurStock.Num * oldCurStock.Price;
                 oldCurStock.InvalidDate   = rds.InvalidDate;
                 oldCurStock.MadeDate      = rds.MadeDate;
                 oldCurStock.ShelfLife     = rds.ShelfLife;
                 oldCurStock.ShelfLifeType = rds.ShelfLifeType;
                 uow.CurrentStock.Add(oldCurStock);
                 uow.Commit();
             }
         }
     }
     return(oldCurStock);
 }
Ejemplo n.º 3
0
        public void AddRetailOutStock(DXInfo.Models.ClientRetailOutStock retail, string stockVouchLocalCode)
        {
            using (TransactionScope transaction = new TransactionScope())
            {
                DateTime dtNow    = DateTime.Now;
                var      rdRecord = uow.RdRecord.GetAll().Where(w =>
                                                                w.WhId == retail.WhId &&
                                                                w.DeptId == retail.DeptId &&
                                                                w.Maker == retail.UserId &&
                                                                w.RdDate == dtNow.Date &&
                                                                w.STCode == "002" &&
                                                                w.VouchType == DXInfo.Models.VouchTypeCode.SaleOutStock &&
                                                                !w.IsVerify).FirstOrDefault();
                if (rdRecord == null)
                {
                    rdRecord           = new DXInfo.Models.RdRecord();
                    rdRecord.Code      = common.GetVouchCode(DXInfo.Models.VouchTypeCode.SaleOutStock, stockVouchLocalCode);
                    rdRecord.VouchType = DXInfo.Models.VouchTypeCode.SaleOutStock;
                    rdRecord.Maker     = retail.UserId;
                    rdRecord.MakeDate  = dtNow;
                    rdRecord.MakeTime  = dtNow;
                    rdRecord.RdFlag    = 1;
                    rdRecord.RdCode    = DXInfo.Models.VouchTypeCode.SaleOutStock;
                    rdRecord.DeptId    = retail.DeptId;
                    rdRecord.STCode    = "002";
                    rdRecord.RdDate    = dtNow;
                    rdRecord.Salesman  = retail.UserId;
                    rdRecord.WhId      = retail.WhId;
                    rdRecord.BusType   = DXInfo.Models.VouchTypeCode.SaleOutStock;
                    uow.RdRecord.Add(rdRecord);
                    uow.Commit();
                }
                foreach (DXInfo.Models.ClientRetailOutStockDetail detail in retail.Detail)
                {
                    DXInfo.Models.RdRecords rdRecords;
                    if (string.IsNullOrEmpty(detail.Batch))
                    {
                        rdRecords = uow.RdRecords.GetAll()
                                    .Where(w => w.InvId == detail.InvId &&
                                           w.RdId == rdRecord.Id &&
                                           w.Batch == null && w.Price == detail.Price).FirstOrDefault();
                    }
                    else
                    {
                        rdRecords = uow.RdRecords.GetAll()
                                    .Where(w => w.InvId == detail.InvId &&
                                           w.RdId == rdRecord.Id &&
                                           w.Batch == detail.Batch && w.Price == detail.Price).FirstOrDefault();
                    }
                    if (rdRecords == null)
                    {
                        rdRecords        = new DXInfo.Models.RdRecords();
                        rdRecords.RdId   = rdRecord.Id;
                        rdRecords.InvId  = detail.InvId;
                        rdRecords.Num    = detail.Num;
                        rdRecords.Price  = detail.Price;
                        rdRecords.Batch  = detail.Batch;
                        rdRecords.Amount = detail.Num * detail.Price;
                        this.SetUnitAndQuantity(rdRecords, detail);
                        if (isShelfLife)
                        {
                            DXInfo.Models.CurrentStock currentStock;

                            var q = uow.CurrentStock.GetAll().Where(w =>
                                                                    w.WhId == retail.WhId &&
                                                                    w.InvId == detail.InvId);

                            if (string.IsNullOrEmpty(rdRecords.Batch))
                            {
                                currentStock = q.Where(w => w.Batch == null).FirstOrDefault();
                            }
                            else
                            {
                                currentStock = q.Where(w => w.Batch == detail.Batch).FirstOrDefault();
                            }
                            rdRecords.MadeDate      = currentStock.MadeDate;
                            rdRecords.ShelfLife     = currentStock.ShelfLife;
                            rdRecords.ShelfLifeType = currentStock.ShelfLifeType;
                            rdRecords.InvalidDate   = currentStock.InvalidDate;
                        }
                        uow.RdRecords.Add(rdRecords);
                    }
                    else
                    {
                        rdRecords.Num    = rdRecords.Num + detail.Num;
                        rdRecords.Amount = rdRecords.Num * rdRecords.Price;
                        this.SetUnitAndQuantity(rdRecords, detail);
                        uow.RdRecords.Update(rdRecords);
                    }
                    uow.Commit();
                }
                uow.Commit();
                transaction.Complete();
            }
        }