상속: BillBase
예제 #1
0
        public virtual BillDetail LoadBillDetail(com.Sconit.Entity.MasterData.Bill billNo, com.Sconit.Entity.MasterData.ActingBill actingBill)
        {
            string             hql    = @"from BillDetail entity where entity.BillNo.BillNo = ? and entity.ActingBill.Id = ?";
            IList <BillDetail> result = FindAllWithCustomQuery <BillDetail>(hql, new object[] { billNo.BillNo, actingBill.Id }, new IType[] { NHibernateUtil.String, NHibernateUtil.Int32 });

            if (result != null && result.Count > 0)
            {
                return(result[0]);
            }
            else
            {
                return(null);
            }
        }
예제 #2
0
        public Bill VoidBill(string billNo, User user)
        {
            Bill oldBill = this.CheckAndLoadBill(billNo, true);
            DateTime dateTimeNow = DateTime.Now;

            #region 检查状态
            if (oldBill.Status != BusinessConstants.CODE_MASTER_STATUS_VALUE_CLOSE)
            {
                throw new BusinessErrorException("Bill.Error.StatusErrorWhenVoid", oldBill.Status, oldBill.BillNo);
            }
            #endregion

            #region 创建作废账单
            Bill voidBill = new Bill();
            CloneHelper.CopyProperty(oldBill, voidBill, this.BillCloneField);

            voidBill.BillNo = this.numberControlMgrE.GenerateNumber(BusinessConstants.CODE_PREFIX_BILL_RED);
            voidBill.Status = BusinessConstants.CODE_MASTER_STATUS_VALUE_CLOSE;
            voidBill.CloseDate = dateTimeNow;
            voidBill.CloseUser = user;

            if (oldBill.Discount.HasValue)
            {
                voidBill.Discount = 0 - oldBill.Discount.Value;
            }
            voidBill.ReferenceBillNo = oldBill.BillNo;
            voidBill.BillType = BusinessConstants.CODE_MASTER_BILL_TYPE_VALUE_CANCEL;
            voidBill.CreateDate = dateTimeNow;
            voidBill.CreateUser = user;
            voidBill.LastModifyDate = dateTimeNow;
            voidBill.LastModifyUser = user;

            this.CreateBill(voidBill);
            #endregion

            #region 创建作废账单明细
            foreach (BillDetail oldBillDetail in oldBill.BillDetails)
            {
                BillDetail voidBillDetail = new BillDetail();
                CloneHelper.CopyProperty(oldBillDetail, voidBillDetail, this.BillDetailCloneField);
                voidBillDetail.BilledQty = 0 - oldBillDetail.BilledQty;
                voidBillDetail.Discount = 0 - oldBillDetail.Discount;
                voidBillDetail.OrderAmount = 0 - oldBillDetail.OrderAmount;
                voidBillDetail.Bill = voidBill;

                this.billDetailMgrE.CreateBillDetail(voidBillDetail);
                voidBill.AddBillDetail(voidBillDetail);
                voidBill.UpdateAmount();

                //反向更新ActingBill
                this.actingBillMgrE.ReverseUpdateActingBill(null, voidBillDetail, user);
            }
            #endregion

            #region 记录开票事务
            foreach (BillDetail billDetail in oldBill.BillDetails)
            {
                this.billTransactionMgrE.RecordBillTransaction(billDetail, user, true);
            }
            #endregion

            #region 更新原账单
            oldBill.ReferenceBillNo = voidBill.BillNo;
            oldBill.Status = BusinessConstants.CODE_MASTER_STATUS_VALUE_VOID;
            oldBill.ScrapDate = dateTimeNow;
            oldBill.ScrapUser = user;

            oldBill.LastModifyDate = dateTimeNow;
            oldBill.LastModifyUser = user;

            this.UpdateBill(oldBill);
            #endregion

            return voidBill;
        }
예제 #3
0
 public void CloseBill(Bill bill, User user)
 {
     this.CloseBill(bill.BillNo, user);
 }
예제 #4
0
 public virtual BillDetail LoadBillDetail(com.Sconit.Entity.MasterData.Bill billNo, com.Sconit.Entity.MasterData.ActingBill actingBill)
 {
     return(entityDao.LoadBillDetail(billNo, actingBill));
 }
예제 #5
0
 public virtual void UpdateBill(Bill entity)
 {
     entityDao.UpdateBill(entity);
 }
예제 #6
0
 public virtual void CreateBill(Bill entity)
 {
     entityDao.CreateBill(entity);
 }
 public virtual void DeleteBill(Bill entity)
 {
     Delete(entity);
 }
 public virtual void CreateBill(Bill entity)
 {
     Create(entity);
 }
예제 #9
0
 public void DeleteBill(Bill bill, User user)
 {
     this.DeleteBill(bill.BillNo, user);
 }
예제 #10
0
 public void AddBillDetail(Bill bill, IList<ActingBill> actingBillList, User user)
 {
     this.AddBillDetail(bill.BillNo, actingBillList, user);
 }
예제 #11
0
 public void AddBillDetail(Bill bill, IList<ActingBill> actingBillList, string userCode)
 {
     this.AddBillDetail(bill.BillNo, actingBillList, this.userMgrE.CheckAndLoadUser(userCode));
 }
예제 #12
0
        public IList<Bill> CreateBill(IList<ActingBill> actingBillList, User user, string status, decimal discount)
        {
            if (status != BusinessConstants.CODE_MASTER_STATUS_VALUE_CREATE
                && status != BusinessConstants.CODE_MASTER_STATUS_VALUE_SUBMIT
                && status != BusinessConstants.CODE_MASTER_STATUS_VALUE_CLOSE)
            {
                throw new TechnicalException("status specified is not valided");
            }


            if (actingBillList == null || actingBillList.Count == 0)
            {
                throw new BusinessErrorException("Bill.Error.EmptyBillDetails");
            }

            DateTime dateTimeNow = DateTime.Now;
            IList<Bill> billList = new List<Bill>();

            foreach (ActingBill actingBill in actingBillList)
            {
                ActingBill oldActingBill = this.actingBillMgrE.LoadActingBill(actingBill.Id);
                oldActingBill.CurrentBillQty = actingBill.CurrentBillQty;
                oldActingBill.CurrentDiscount = actingBill.CurrentDiscount;

                ////检查ActingBill的剩余待开数量是否为0
                //if (oldActingBill.Qty - oldActingBill.BilledQty == 0)
                //{
                //    throw new BusinessErrorException("Bill.Create.Error.ZeroActingBillRemainQty");
                //}

                Bill bill = null;

                #region 查找和待开明细的transactionType、billAddress、currency一致的BillMstr
                foreach (Bill thisBill in billList)
                {
                    if (thisBill.TransactionType == oldActingBill.TransactionType
                        && thisBill.BillAddress.Code == oldActingBill.BillAddress.Code
                        && thisBill.Currency.Code == oldActingBill.Currency.Code)
                    {
                        bill = thisBill;
                        break;
                    }
                }
                #endregion

                #region 没有找到匹配的Bill,新建
                if (bill == null)
                {
                    #region 检查权限
                    bool hasPermission = false;
                    foreach (Permission permission in user.OrganizationPermission)
                    {
                        if (permission.Code == oldActingBill.BillAddress.Party.Code)
                        {
                            hasPermission = true;
                            break;
                        }
                    }

                    if (!hasPermission)
                    {
                        throw new BusinessErrorException("Bill.Create.Error.NoAuthrization", oldActingBill.BillAddress.Party.Code);
                    }
                    #endregion

                    #region 创建Bill
                    bill = new Bill();
                    bill.BillNo = numberControlMgrE.GenerateNumber(BusinessConstants.CODE_PREFIX_BILL);
                    bill.Status = status;

                    if (status == BusinessConstants.CODE_MASTER_STATUS_VALUE_SUBMIT)
                    {
                        bill.SubmitDate = dateTimeNow;
                        bill.EffectiveDate = dateTimeNow;
                        bill.SubmitUser = user;
                        bill.CloseDate = null;
                        bill.CloseUser = null;
                    }
                    if (status == BusinessConstants.CODE_MASTER_STATUS_VALUE_CLOSE)
                    {
                        bill.CloseDate = dateTimeNow;
                        bill.CloseUser = user;
                    }

                    bill.TransactionType = oldActingBill.TransactionType;
                    bill.BillAddress = oldActingBill.BillAddress;
                    bill.Currency = oldActingBill.Currency;
                    bill.Discount = discount;                   //可能有问题
                    bill.BillType = BusinessConstants.CODE_MASTER_BILL_TYPE_VALUE_NORMAL;
                    bill.CreateDate = dateTimeNow;
                    bill.CreateUser = user;
                    bill.LastModifyDate = dateTimeNow;
                    bill.LastModifyUser = user;

                    this.CreateBill(bill);
                    billList.Add(bill);
                    #endregion
                }
                #endregion

                BillDetail billDetail = this.billDetailMgrE.TransferAtingBill2BillDetail(oldActingBill);
                billDetail.Bill = bill;

                bill.AddBillDetail(billDetail);

                this.billDetailMgrE.CreateBillDetail(billDetail);

                bill.UpdateAmount();
                this.UpdateBill(bill);

                //扣减ActingBill数量和金额
                this.actingBillMgrE.ReverseUpdateActingBill(null, billDetail, user);
            }

            return billList;
        }
예제 #13
0
 public void CancelBill(Bill bill, string userCode)
 {
     this.CancelBill(bill.BillNo, this.userMgr.CheckAndLoadUser(userCode));
 }
예제 #14
0
 public void ReleaseBill(Bill bill, string userCode)
 {
     this.ReleaseBill(bill.BillNo, this.userMgr.CheckAndLoadUser(userCode));
 }
예제 #15
0
 public Bill VoidBill(Bill bill, string userCode)
 {
     return this.VoidBill(bill.BillNo, this.userMgrE.CheckAndLoadUser(userCode));
 }
예제 #16
0
 public Bill VoidBill(Bill bill, User user)
 {
     return this.VoidBill(bill.BillNo, user);
 }
예제 #17
0
 public void UpdateBill(Bill bill, string userCode)
 {
     this.UpdateBill(bill, this.userMgrE.CheckAndLoadUser(userCode));
 }
예제 #18
0
 public virtual void UpdateBill(Bill entity)
 {
     Update(entity);
 }
예제 #19
0
        public void UpdateBill(Bill bill, User user)
        {
            Bill oldBill = this.CheckAndLoadBill(bill.BillNo, true);
            oldBill.Discount = bill.Discount;
            oldBill.ExternalBillNo = bill.ExternalBillNo;
            oldBill.BackwashAmount = bill.BackwashAmount;
            oldBill.FixtureDate = bill.FixtureDate;

            #region 检查状态
            if (oldBill.Status != BusinessConstants.CODE_MASTER_STATUS_VALUE_CREATE)
            {
                throw new BusinessErrorException("Bill.Error.StatusErrorWhenUpdate", oldBill.Status, oldBill.BillNo);
            }
            #endregion

            #region 更新明细
            if (bill.BillDetails != null && bill.BillDetails.Count > 0)
            {
                foreach (BillDetail newBillDetail in bill.BillDetails)
                {
                    BillDetail oldBillDetail = this.billDetailMgrE.LoadBillDetail(newBillDetail.Id);
                    newBillDetail.ActingBill = oldBillDetail.ActingBill;
                    newBillDetail.OrderAmount = oldBillDetail.OrderAmount;
                    newBillDetail.UnitPrice = oldBillDetail.UnitPrice;
                    newBillDetail.Currency = oldBillDetail.Currency;
                    newBillDetail.IsIncludeTax = oldBillDetail.IsIncludeTax;
                    newBillDetail.TaxCode = oldBillDetail.TaxCode;

                    //反向更新ActingBill,会重新计算开票金额
                    if (oldBillDetail.BilledQty != newBillDetail.BilledQty)
                    {
                        this.actingBillMgrE.ReverseUpdateActingBill(oldBillDetail, newBillDetail, user);
                    }

                    oldBillDetail.OrderAmount = newBillDetail.OrderAmount;
                    oldBillDetail.BilledQty = newBillDetail.BilledQty;
                    oldBillDetail.Discount = newBillDetail.Discount;



                    this.billDetailMgrE.UpdateBillDetail(oldBillDetail);
                }
            }
            #endregion

            oldBill.UpdateAmount();
            
            oldBill.LastModifyUser = user;
            oldBill.LastModifyDate = DateTime.Now;

            this.UpdateBill(oldBill);
        }
예제 #20
0
 /*
  * 填充报表头
  *
  * Param repack 报验单头对象
  */
 private void FillHead(Bill bill)
 {
     this.SetRowCell(3, 2, bill.BillAddress.Party.Name);
     this.SetRowCell(3, 8, bill.BillNo);
 }
예제 #21
0
 public void ReleaseBill(Bill bill, User user)
 {
     this.ReleaseBill(bill.BillNo, user);
 }
예제 #22
0
 public virtual void DeleteBill(Bill entity)
 {
     entityDao.DeleteBill(entity);
 }
예제 #23
0
 public void CancelBill(Bill bill, User user)
 {
     this.CancelBill(bill.BillNo, user);
 }
 /*
  * 填充报表头
  * 
  * Param repack 报验单头对象
  */
 private void FillHead(Bill bill)
 {
     if (bill.BillDetails != null && bill.BillDetails.Count > 0
         && bill.BillDetails[0].ActingBill != null
         && bill.BillDetails[0].ActingBill.OrderHead != null
         && bill.BillDetails[0].ActingBill.OrderHead.BillFrom != null)
     {
         this.SetRowCell(0, 0, bill.BillDetails[0].ActingBill.OrderHead.BillFrom.Address);
     }
     this.SetRowCell(3, 2, bill.BillAddress.Party.Name);
     this.SetRowCell(3, 8, bill.BillNo);
 }
예제 #25
0
 public void CloseBill(Bill bill, string userCode)
 {
     this.CloseBill(bill.BillNo, this.userMgrE.CheckAndLoadUser(userCode));
 }