Inheritance: BillDetailBase
Exemplo n.º 1
0
 public void RemoveBillDetail(BillDetail billDetail)
 {
     if (this.BillDetails != null)
     {
         this.BillDetails.Remove(billDetail);
     }
 }
Exemplo n.º 2
0
 public void AddBillDetail(BillDetail billDetail)
 {
     if (this.BillDetails == null)
     {
         this.BillDetails = new List<BillDetail>();
     }
     this.BillDetails.Add(billDetail);
 }
        public void RecordBillTransaction(BillDetail billDetail, User user, bool isCancel)
        {
            DateTime dateTimeNow = DateTime.Now;

            BillTransaction billTransaction = new BillTransaction();
            billTransaction.OrderNo = billDetail.ActingBill.OrderHead.OrderNo;
            billTransaction.ExternalReceiptNo = billDetail.ActingBill.ExternalReceiptNo;
            billTransaction.ReceiptNo = billDetail.ActingBill.ReceiptNo;
            billTransaction.Item = billDetail.ActingBill.Item.Code;
            billTransaction.ItemDescription = billDetail.ActingBill.Item.Description;
            billTransaction.Uom = billDetail.ActingBill.Uom.Code;
            billTransaction.BillAddress = billDetail.ActingBill.BillAddress.Code;
            billTransaction.BillAddressDescription = billDetail.ActingBill.BillAddress.Address;
            billTransaction.Party = billDetail.ActingBill.BillAddress.Party.Code;
            billTransaction.PartyName = billDetail.ActingBill.BillAddress.Party.Name;
            if (!isCancel)
            {
                billTransaction.Qty = billDetail.BilledQty;
            }
            else
            {
                billTransaction.Qty = billDetail.BilledQty * -1;
            }
            billTransaction.EffectiveDate = DateTime.Parse(dateTimeNow.ToShortDateString());   //仅保留年月日;
            if (billDetail.ActingBill.TransactionType == BusinessConstants.BILL_TRANS_TYPE_PO)
            {
                billTransaction.TransactionType = BusinessConstants.BILL_TRANS_TYPE_PO_BILL;
            }
            else
            {
                billTransaction.TransactionType = BusinessConstants.BILL_TRANS_TYPE_SO_BILL;
            }
            //billTransaction.PlannedBill = billDetail.ActingBill.Id;
            billTransaction.BillDetailId = billDetail.Id;
            billTransaction.CreateUser = user.Code;
            billTransaction.CreateDate = dateTimeNow;
            billTransaction.ActingBill = billDetail.ActingBill.Id;
            billTransaction.LocationFrom = billDetail.ActingBill.LocationFrom;
            billTransaction.IpNo = billDetail.ActingBill.IpNo;
            billTransaction.ReferenceItemCode = billDetail.ActingBill.ReferenceItemCode;
            //billTransaction.Location = billDetail.ActingBill.LocationFrom;
            //billTransaction.LocationName = locationLotDetail.Location.Name;
            //billTransaction.HuId = locationLotDetail.Hu != null ? locationLotDetail.Hu.HuId : string.Empty;
            //billTransaction.LotNo = locationLotDetail.LotNo;
            //billTransaction.BatchNo = locationLotDetail.Id;

            this.CreateBillTransaction(billTransaction);
        }
        public BillDetail TransferAtingBill2BillDetail(ActingBill actingBill)
        {
            EntityPreference entityPreference = this.entityPreferenceMgrE.LoadEntityPreference(
                BusinessConstants.ENTITY_PREFERENCE_CODE_AMOUNT_DECIMAL_LENGTH);
            int amountDecimalLength = int.Parse(entityPreference.Value);
            BillDetail billDetail = new BillDetail();
            billDetail.ActingBill = actingBill;

            billDetail.Currency = actingBill.Currency;
            billDetail.IsIncludeTax = actingBill.IsIncludeTax;
            billDetail.TaxCode = actingBill.TaxCode;
            billDetail.UnitPrice = actingBill.UnitPrice;
            billDetail.ListPrice = actingBill.ListPrice;
            billDetail.BilledQty = actingBill.CurrentBillQty;
            billDetail.Discount = actingBill.CurrentDiscount;
            billDetail.HeadDiscount = 0;//actingBill.CurrentHeadDiscount;
            billDetail.LocationFrom = actingBill.LocationFrom;
            billDetail.IpNo = actingBill.IpNo;
            billDetail.ReferenceItemCode = actingBill.ReferenceItemCode;
            if (actingBill.CurrentBillQty != (actingBill.BillQty - actingBill.BilledQty))
            {
                //本次开票数量大于剩余数量
                if (actingBill.CurrentBillQty > (actingBill.BillQty - actingBill.BilledQty))
                {
                    throw new BusinessErrorException("ActingBill.Error.CurrentBillQtyGeRemainQty");
                }

                //本次开票数量小于剩余数量
                billDetail.OrderAmount = Math.Round((actingBill.BillAmount / actingBill.BillQty * actingBill.CurrentBillQty), amountDecimalLength, MidpointRounding.AwayFromZero);
            }
            else
            {
                //本次开票数量等于剩余数量
                billDetail.OrderAmount = actingBill.BillAmount - actingBill.BilledAmount;
            }           

            return billDetail;
        }
        public void ReverseUpdateActingBill(BillDetail oldBillDetail, BillDetail newBillDetail, User user)
        {
            if (oldBillDetail != null && newBillDetail != null
                && oldBillDetail.ActingBill.Id != newBillDetail.ActingBill.Id)
            {
                throw new TechnicalException("oldBillDetail.ActingBill.Id != newBillDetail.ActingBill.Id when ReverseUpdateActingBill");
            }

            DateTime dateTimeNow = DateTime.Now;
            #region 扣减旧BillDetail的数量和金额
            if (oldBillDetail != null)
            {
                //todo 校验数量、金额
                ActingBill actingBill = this.LoadActingBill(oldBillDetail.ActingBill.Id);
                actingBill.BilledQty -= oldBillDetail.BilledQty;
                actingBill.BilledAmount -= oldBillDetail.OrderAmount;
                actingBill.LastModifyDate = dateTimeNow;
                actingBill.LastModifyUser = user;
                if (Math.Round(actingBill.BillQty,2) == Math.Round(actingBill.BilledQty,2))
                {
                    actingBill.Status = BusinessConstants.CODE_MASTER_STATUS_VALUE_CLOSE;
                }
                else
                {
                    actingBill.Status = BusinessConstants.CODE_MASTER_STATUS_VALUE_CREATE;
                }
                this.UpdateActingBill(actingBill);
            }
            #endregion

            #region 增加新BillDetail的数量和金额
            if (newBillDetail != null)
            {
                //todo 校验数量、金额
                ActingBill actingBill = this.LoadActingBill(newBillDetail.ActingBill.Id);

                #region 根据新开票数量计算开票金额
                EntityPreference entityPreference = this.entityPreferenceMgrE.LoadEntityPreference(
                                BusinessConstants.ENTITY_PREFERENCE_CODE_AMOUNT_DECIMAL_LENGTH);
                int amountDecimalLength = int.Parse(entityPreference.Value);
                if (newBillDetail.BilledQty != (actingBill.BillQty - actingBill.BilledQty))
                {
                    //本次开票数量大于剩余数量
                    if ((actingBill.BillQty > 0 && actingBill.BillQty - actingBill.BilledQty - newBillDetail.BilledQty < 0)
                        || (actingBill.BillQty < 0 && actingBill.BillQty - actingBill.BilledQty - newBillDetail.BilledQty > 0))
                    {
                        throw new BusinessErrorException("ActingBill.Error.CurrentBillQtyGeRemainQty");
                    }

                    //本次开票数量小于剩余数量
                    newBillDetail.OrderAmount = Math.Round((actingBill.BillAmount / actingBill.BillQty * newBillDetail.BilledQty), amountDecimalLength, MidpointRounding.AwayFromZero);
                }
                else
                {
                    //本次开票数量等于剩余数量
                    newBillDetail.OrderAmount = actingBill.BillAmount - actingBill.BilledAmount;
                }
                #endregion

                actingBill.BilledQty += newBillDetail.BilledQty;
                actingBill.BilledAmount += newBillDetail.OrderAmount;
                actingBill.LastModifyDate = dateTimeNow;
                actingBill.LastModifyUser = user;
                if (Math.Round(actingBill.BillQty,2) == Math.Round(actingBill.BilledQty,2))
                {
                    actingBill.Status = BusinessConstants.CODE_MASTER_STATUS_VALUE_CLOSE;
                }
                else
                {
                    actingBill.Status = BusinessConstants.CODE_MASTER_STATUS_VALUE_CREATE;
                }
                this.UpdateActingBill(actingBill);
            }
            #endregion
        }
Exemplo n.º 6
0
    private BillingItem fillBillDetail(BillDetail billDetail)
    {
        com.Sconit.Entity.Svp.BillingItem item = new com.Sconit.Entity.Svp.BillingItem();

        item.memo = string.Empty;
        item.billingQuantity =Convert.ToDouble(billDetail.BilledQty);
        item.unitPrice = billDetail.UnitPrice;
        item.unitPriceSpecified = true;

           UOM u = new UOM();
        u.abbreviation = billDetail.ActingBill.Uom.Code;
        u.description = billDetail.ActingBill.Uom.Description;

        Material m = new Material();
        m.quantityUOM = u;
        m.id = billDetail.ActingBill.Item.Code;
        m.no = billDetail.ActingBill.Item.Code;
        m.name = billDetail.ActingBill.Item.Description;
        m.description = billDetail.ActingBill.Item.Description;

        RequisitionOrder requisitionOrder = new RequisitionOrder();
        requisitionOrder.requisitionOrderNo = billDetail.ActingBill.OrderNo;

        DeliveryOrder deliveryOrder = new DeliveryOrder();
        deliveryOrder.requisitionOrder = requisitionOrder;

        ReceivingNote receiveNote = new ReceivingNote();
        receiveNote.id = billDetail.ActingBill.ReceiptNo;
        receiveNote.receivingNo = billDetail.ActingBill.ReceiptNo;
        receiveNote.deliveryOrder = deliveryOrder;

        ReceivingNoteItem receiveItem = new ReceivingNoteItem();
        receiveItem.material = m;
        receiveItem.receiveQuantity = Convert.ToDouble(billDetail.BilledQty);
        receiveItem.receiveQuantitySpecified = true;
        receiveItem.totalBillingQuantity = Convert.ToDouble( billDetail.BilledQty);
        receiveItem.totalBillingQuantitySpecified = true;
        receiveItem.receivingNote = receiveNote;

        item.material = m;
        item.receivingNoteItem = receiveItem;

        return item;
    }
Exemplo n.º 7
0
    private IList<BillDetail> PopulateData(bool isChecked)
    {
        if (this.Gv_List.Rows != null && this.Gv_List.Rows.Count > 0)
        {
            IList<BillDetail> billDetailList = new List<BillDetail>();
            foreach (GridViewRow row in this.Gv_List.Rows)
            {
                CheckBox checkBoxGroup = row.FindControl("CheckBoxGroup") as CheckBox;
                if (checkBoxGroup.Checked || !isChecked)
                {
                    HiddenField hfId = row.FindControl("hfId") as HiddenField;
                    TextBox tbQty = row.FindControl("tbQty") as TextBox;
                    TextBox tbDiscount = row.FindControl("tbDiscount") as TextBox;

                    BillDetail billDetail = new BillDetail();
                    billDetail.Id = int.Parse(hfId.Value);
                    billDetail.BilledQty = decimal.Parse(tbQty.Text);
                    billDetail.Discount = decimal.Parse(tbDiscount.Text);

                    billDetailList.Add(billDetail);
                }
            }
            return billDetailList;
        }

        return null;
    }
 public virtual void DeleteBillDetail(BillDetail entity)
 {
     Delete(entity);
 }
 public virtual void UpdateBillDetail(BillDetail entity)
 {
     Update(entity);
 }
 public virtual void CreateBillDetail(BillDetail entity)
 {
     Create(entity);
 }
 public virtual void DeleteBillDetail(BillDetail entity)
 {
     entityDao.DeleteBillDetail(entity);
 }
 public virtual void UpdateBillDetail(BillDetail entity)
 {
     entityDao.UpdateBillDetail(entity);
 }
 public virtual void CreateBillDetail(BillDetail entity)
 {
     entityDao.CreateBillDetail(entity);
 }
Exemplo n.º 14
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;
        }