public void CreateTransportationActBill(TransportPriceListDetail priceListDetail) { TransportationActBill actBill = new TransportationActBill(); actBill.BillAddress = billAddressMgr.GetDefaultBillAddress(priceListDetail.TransportPriceList.Party.Code); if (actBill.BillAddress == null) { throw new BusinessErrorException("Transportation.Error.CarrierPrimaryBillAddressEmpty"); } actBill.PriceListDetail = priceListDetail; actBill.PriceList = priceListDetail.TransportPriceList; actBill.UnitPrice = priceListDetail.UnitPrice * (1 + priceListDetail.ServiceCharge); actBill.TransType = BusinessConstants.TRANSPORTATION_PRICELIST_DETAIL_TYPE_WAREHOUSELEASE; actBill.BillQty = 1; actBill.BillAmount = actBill.BillQty * actBill.UnitPrice; actBill.Currency = priceListDetail.Currency; actBill.EffectiveDate = DateTime.Now.Date; actBill.CreateDate = DateTime.Now; actBill.CreateUser = userMgr.GetMonitorUser(); actBill.IsIncludeTax = priceListDetail.IsIncludeTax; actBill.IsProvisionalEstimate = priceListDetail.IsProvisionalEstimate; actBill.LastModifyDate = DateTime.Now; actBill.LastModifyUser = userMgr.GetMonitorUser(); actBill.Status = BusinessConstants.CODE_MASTER_STATUS_VALUE_CREATE; actBill.TaxCode = priceListDetail.TaxCode; CreateTransportationActBill(actBill); }
public void AddTransportationBillDetail(string billNo, IList <TransportationActBill> transportationActBillList, User user) { TransportationBill oldTransportationBill = this.CheckAndLoadTransportationBill(billNo, true); #region 检查状态 if (oldTransportationBill.Status != BusinessConstants.CODE_MASTER_STATUS_VALUE_CREATE) { throw new BusinessErrorException("TransportationBill.Error.StatusErrorWhenAddDetail", oldTransportationBill.Status, oldTransportationBill.BillNo); } #endregion if (transportationActBillList != null && transportationActBillList.Count > 0) { foreach (TransportationActBill transportationActBill in transportationActBillList) { TransportationActBill oldTransportationActBill = this.transportationActBillMgr.LoadTransportationActBill(transportationActBill.Id); oldTransportationActBill.CurrentBillQty = transportationActBill.CurrentBillQty; oldTransportationActBill.CurrentDiscount = transportationActBill.CurrentDiscount; TransportationBillDetail transportationBillDetail = this.transportationBillDetailMgr.TransferTransportationActBill2TransportationBillDetail(oldTransportationActBill); transportationBillDetail.Bill = oldTransportationBill; oldTransportationBill.AddTransportationBillDetail(transportationBillDetail); this.transportationBillDetailMgr.CreateTransportationBillDetail(transportationBillDetail); //扣减TransportationActBill数量和金额 this.transportationActBillMgr.ReverseUpdateTransportationActBill(null, transportationBillDetail, user); } oldTransportationBill.LastModifyDate = DateTime.Now; oldTransportationBill.LastModifyUser = user; this.UpdateTransportationBill(oldTransportationBill); } }
public IList <TransportationActBill> PopulateSelectedData() { if (this.GV_List.Rows != null && this.GV_List.Rows.Count > 0) { IList <TransportationActBill> transportationActBillList = new List <TransportationActBill>(); foreach (GridViewRow row in this.GV_List.Rows) { CheckBox checkBoxGroup = row.FindControl("CheckBoxGroup") as CheckBox; if (checkBoxGroup.Checked) { HiddenField hfId = row.FindControl("hfId") as HiddenField; TextBox tbQty = row.FindControl("tbQty") as TextBox; TextBox tbAmount = row.FindControl("tbAmount") as TextBox; TextBox tbDiscount = row.FindControl("tbDiscount") as TextBox; TransportationActBill transportationActBill = new TransportationActBill(); transportationActBill.Id = int.Parse(hfId.Value); transportationActBill.CurrentBillQty = decimal.Parse(tbQty.Text); transportationActBill.CurrentBillAmount = decimal.Parse(tbAmount.Text); transportationActBill.CurrentDiscount = decimal.Parse(tbDiscount.Text); transportationActBillList.Add(transportationActBill); } } return(transportationActBillList); } return(null); }
protected void GV_List_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { TransportationActBill transportationActBill = (TransportationActBill)e.Row.DataItem; decimal billAmount = transportationActBill.BillAmount; decimal unitPrice = transportationActBill.UnitPrice; decimal remailQty = transportationActBill.BillQty - transportationActBill.BilledQty; decimal remailAmount = transportationActBill.BillAmount - transportationActBill.BilledAmount; //decimal discount = unitPrice * remailQty - remailAmount; TextBox tbQty = e.Row.FindControl("tbQty") as TextBox; //TextBox tbDiscountRate = e.Row.FindControl("tbDiscountRate") as TextBox; //TextBox tbDiscount = e.Row.FindControl("tbDiscount") as TextBox; TextBox tbAmount = e.Row.FindControl("tbAmount") as TextBox; /* * * 1.TransType=Transportation 价格单明细(承运商) 或 短拨费(区域)时 * a.PricingMethod=M3或KG 按数量 * b.SHIPT 按金额 * 2.TransType=WarehouseLease(固定费用) 按金额 * 3.TransType=Operation(操作费) 按数量 */ if (transportationActBill.TransType == BusinessConstants.TRANSPORTATION_PRICELIST_DETAIL_TYPE_OPERATION || (transportationActBill.TransType == BusinessConstants.TRANSPORTATION_PRICELIST_DETAIL_TYPE_TRANSPORTATION && (transportationActBill.PricingMethod == BusinessConstants.TRANSPORTATION_PRICING_METHOD_M3 || transportationActBill.PricingMethod == BusinessConstants.TRANSPORTATION_PRICING_METHOD_KG) ) ) { tbQty.Attributes["onchange"] = "CalCulateRowAmount(this, 'tbQty', 'BaseOnDiscountRate', 'hfUnitPrice', 'tbQty', 'tbDiscount', 'tbDiscountRate', 'tbAmount',false);"; tbQty.Attributes["onmouseup"] = "if(!readOnly)select();"; tbAmount.Attributes["onfocus"] = "this.blur();"; tbQty.Text = remailQty.ToString(); } else { tbQty.Attributes["onfocus"] = "this.blur();"; tbQty.Text = "1"; tbAmount.Attributes["onmouseup"] = "if(!readOnly)select();"; } //if (unitPrice != 0 && remailQty != 0) //{ // tbDiscountRate.Text = (Math.Round(discount / (unitPrice * remailQty), this.DecimalLength, MidpointRounding.AwayFromZero) * 100).ToString("F2"); //} //tbDiscount.Text = discount.ToString("F2"); tbAmount.Text = (Math.Floor(remailAmount * 100) / 100).ToString("F2"); tbAmount.Attributes["oldValue"] = tbAmount.Text; } }
public TransportationActBill CreateTransportationItemActBill(Receipt receipt, string billingMethod) { TransportationActBill actBill = new TransportationActBill(); TransportPriceList transportPriceList = null; if (billingMethod == BusinessConstants.TRANSPORTATION_BILLING_METHOD_OUT) { transportPriceList = transportPriceListMgr.LoadTransportPriceList(receipt.PartyFrom.Code); } if (transportPriceList != null) { Currency currency = receipt.ReceiptDetails[0].OrderLocationTransaction.OrderDetail.OrderHead.Currency; foreach (ReceiptDetail receiptDetail in receipt.ReceiptDetails) { TransportPriceListDetail priceListDetail = transportPriceListDetailMgr.GetLastestTransportPriceListDetail(transportPriceList, receiptDetail.OrderLocationTransaction.Item, receipt.CreateDate, currency, receiptDetail.OrderLocationTransaction.OrderDetail.Item.Uom, BusinessConstants.TRANSPORTATION_PRICELIST_DETAIL_TYPE_OPERATION, billingMethod); if (priceListDetail != null) { priceListDetail = transportPriceListDetailMgr.GetLastestTransportPriceListDetail(transportPriceList, null, receipt.CreateDate, currency, null, BusinessConstants.TRANSPORTATION_PRICELIST_DETAIL_TYPE_OPERATION, billingMethod); } actBill.BillAddress = billAddressMgr.GetDefaultBillAddress(priceListDetail.TransportPriceList.Party.Code); actBill.PriceListDetail = priceListDetail; actBill.PriceList = priceListDetail.TransportPriceList; actBill.UnitPrice = priceListDetail.UnitPrice * (1 + priceListDetail.ServiceCharge); actBill.TransType = BusinessConstants.TRANSPORTATION_PRICELIST_DETAIL_TYPE_OPERATION; actBill.BillQty = receiptDetail.ReceivedQty.Value; actBill.BillAmount = actBill.BillQty * actBill.UnitPrice; actBill.Currency = priceListDetail.Currency; actBill.EffectiveDate = DateTime.Now.Date; actBill.CreateDate = DateTime.Now; actBill.CreateUser = userMgr.GetMonitorUser(); actBill.IsIncludeTax = priceListDetail.IsIncludeTax; actBill.IsProvisionalEstimate = priceListDetail.IsProvisionalEstimate; actBill.LastModifyDate = DateTime.Now; actBill.LastModifyUser = userMgr.GetMonitorUser(); actBill.Status = BusinessConstants.CODE_MASTER_STATUS_VALUE_CREATE; actBill.TaxCode = priceListDetail.TaxCode; } } return(actBill); }
public IList <TransportationActBill> PopulateSelectedData() { if (this.GV_List.Rows != null && this.GV_List.Rows.Count > 0) { IList <TransportationActBill> transportationActBillList = new List <TransportationActBill>(); foreach (GridViewRow row in this.GV_List.Rows) { CheckBox checkBoxGroup = row.FindControl("CheckBoxGroup") as CheckBox; if (checkBoxGroup.Checked) { HiddenField hfId = row.FindControl("hfId") as HiddenField; TransportationActBill transportationActBill = TheTransportationActBillMgr.LoadTransportationActBill(int.Parse(hfId.Value)); transportationActBillList.Add(transportationActBill); } } return(transportationActBillList); } return(null); }
public virtual void DeleteTransportationActBill(TransportationActBill entity) { Delete(entity); }
public virtual void UpdateTransportationActBill(TransportationActBill entity) { Update(entity); }
public virtual void CreateTransportationActBill(TransportationActBill entity) { Create(entity); }
public void ReverseUpdateTransportationActBill(TransportationBillDetail oldBillDetail, TransportationBillDetail newBillDetail, User user) { if (oldBillDetail != null && newBillDetail != null && oldBillDetail.ActBill.Id != newBillDetail.ActBill.Id) { throw new TechnicalException("oldBillDetail.ActingBill.Id != newBillDetail.ActingBill.Id when ReverseUpdateActingBill"); } DateTime dateTimeNow = DateTime.Now; #region 扣减旧TransportationBillDetail的数量和金额 if (oldBillDetail != null) { //todo 校验数量、金额 TransportationActBill transportationActBill = this.LoadTransportationActBill(oldBillDetail.ActBill.Id); /* * * 1.TransType=Transportation 价格单明细(承运商) 或 短拨费(区域)时 * a.PricingMethod=M3或KG 按数量 * b.SHIPT 按金额 * 2.TransType=WarehouseLease(固定费用) 按金额 * 3.TransType=Operation(操作费) 按数量 */ if (transportationActBill.TransType == BusinessConstants.TRANSPORTATION_PRICELIST_DETAIL_TYPE_OPERATION || (transportationActBill.TransType == BusinessConstants.TRANSPORTATION_PRICELIST_DETAIL_TYPE_TRANSPORTATION && (transportationActBill.PricingMethod == BusinessConstants.TRANSPORTATION_PRICING_METHOD_M3 || transportationActBill.PricingMethod == BusinessConstants.TRANSPORTATION_PRICING_METHOD_KG) ) ) { transportationActBill.BilledQty -= oldBillDetail.BilledQty; transportationActBill.BilledAmount -= oldBillDetail.Amount; if (transportationActBill.BillQty == transportationActBill.BilledQty) { transportationActBill.Status = BusinessConstants.CODE_MASTER_STATUS_VALUE_CLOSE; } else { transportationActBill.Status = BusinessConstants.CODE_MASTER_STATUS_VALUE_CREATE; } } else { transportationActBill.BilledAmount -= oldBillDetail.Amount; if (transportationActBill.BilledAmount == 0) { transportationActBill.BilledQty = 0; } if (transportationActBill.BillAmount == transportationActBill.BilledAmount) { transportationActBill.Status = BusinessConstants.CODE_MASTER_STATUS_VALUE_CLOSE; } else { transportationActBill.Status = BusinessConstants.CODE_MASTER_STATUS_VALUE_CREATE; } } transportationActBill.LastModifyDate = dateTimeNow; transportationActBill.LastModifyUser = user; this.UpdateTransportationActBill(transportationActBill); } #endregion #region 增加新BillDetail的数量和金额 if (newBillDetail != null) { //todo 校验数量、金额 TransportationActBill transportationActBill = this.LoadTransportationActBill(newBillDetail.ActBill.Id); EntityPreference entityPreference = this.entityPreferenceMgr.LoadEntityPreference( BusinessConstants.ENTITY_PREFERENCE_CODE_AMOUNT_DECIMAL_LENGTH); int amountDecimalLength = int.Parse(entityPreference.Value); /* * * 1.TransType=Transportation 价格单明细(承运商) 或 短拨费(区域)时 * a.PricingMethod=M3或KG 按数量 * b.SHIPT 按金额 * 2.TransType=WarehouseLease(固定费用) 按金额 * 3.TransType=Operation(操作费) 按数量 */ if (transportationActBill.TransType == BusinessConstants.TRANSPORTATION_PRICELIST_DETAIL_TYPE_OPERATION || (transportationActBill.TransType == BusinessConstants.TRANSPORTATION_PRICELIST_DETAIL_TYPE_TRANSPORTATION && (transportationActBill.PricingMethod == BusinessConstants.TRANSPORTATION_PRICING_METHOD_M3 || transportationActBill.PricingMethod == BusinessConstants.TRANSPORTATION_PRICING_METHOD_KG) ) ) { #region 根据新开票数量计算开票金额 if (newBillDetail.BilledQty != (transportationActBill.BillQty - transportationActBill.BilledQty)) { //本次开票数量大于剩余数量 if ((transportationActBill.BillQty > 0 && transportationActBill.BillQty - transportationActBill.BilledQty - newBillDetail.BilledQty < 0) || (transportationActBill.BillQty < 0 && transportationActBill.BillQty - transportationActBill.BilledQty - newBillDetail.BilledQty > 0)) { throw new BusinessErrorException("TransportationActBill.Error.CurrentBillQtyGeRemainQty"); } //本次开票数量小于剩余数量 newBillDetail.Amount = Math.Round( (transportationActBill.BillAmount / transportationActBill.BillQty * newBillDetail.BilledQty), amountDecimalLength, MidpointRounding.AwayFromZero); } else { //本次开票数量等于剩余数量 newBillDetail.Amount = transportationActBill.BillAmount - transportationActBill.BilledAmount; } #endregion transportationActBill.BilledQty += newBillDetail.BilledQty; transportationActBill.BilledAmount += newBillDetail.Amount; if (transportationActBill.BillQty == transportationActBill.BilledQty) { transportationActBill.Status = BusinessConstants.CODE_MASTER_STATUS_VALUE_CLOSE; } else { transportationActBill.Status = BusinessConstants.CODE_MASTER_STATUS_VALUE_CREATE; } } else { if (newBillDetail.Amount != (transportationActBill.BillAmount - transportationActBill.BilledAmount)) { //本次开票金额大于剩余金额 if ((transportationActBill.BillAmount > 0 && transportationActBill.BillAmount - transportationActBill.BilledAmount - newBillDetail.Amount < 0) || (transportationActBill.BillAmount < 0 && transportationActBill.BillAmount - transportationActBill.BilledAmount - newBillDetail.Amount > 0)) { throw new BusinessErrorException("TransportationActBill.Error.CurrentBillAmountGeRemainAmount"); } } else { //本次开票金额等于剩余金额 newBillDetail.Amount = transportationActBill.BillAmount - transportationActBill.BilledAmount; } transportationActBill.BilledQty = 1; transportationActBill.BilledAmount += newBillDetail.Amount; if (transportationActBill.BillAmount == transportationActBill.BilledAmount) { transportationActBill.Status = BusinessConstants.CODE_MASTER_STATUS_VALUE_CLOSE; } else { transportationActBill.Status = BusinessConstants.CODE_MASTER_STATUS_VALUE_CREATE; } } transportationActBill.LastModifyDate = dateTimeNow; transportationActBill.LastModifyUser = user; this.UpdateTransportationActBill(transportationActBill); } #endregion }
public TransportationActBill CreateTransportationActBill(TransportationOrder order, User user) { TransportationActBill actBill = new TransportationActBill(); if (order.Expense != null) { actBill.BillAmount = order.Expense.Amount; actBill.UnitPrice = order.Expense.Amount; actBill.BillQty = 1; actBill.Currency = order.Expense.Currency; actBill.IsIncludeTax = order.Expense.IsIncludeTax; actBill.Currency.Code = order.Expense.Currency.Code; actBill.IsProvisionalEstimate = false; } else { string currency = null; foreach (TransportationOrderDetail orderDetail in order.OrderDetails) { #region currency if (orderDetail.InProcessLocation.Flow.Currency == null) { throw new BusinessErrorException("Transportation.Flow.CurrencyEmpty", orderDetail.InProcessLocation.Flow.Code); } if (currency == null) { currency = orderDetail.InProcessLocation.Flow.Currency.Code; } else if (currency != orderDetail.InProcessLocation.Flow.Currency.Code) { throw new BusinessErrorException("Transportation.OrderDetail.CurrencyNotEqual"); } #endregion } IList <TransportPriceList> transportPriceList = transportPriceListMgr.GetTransportPriceList(order.Carrier.Code); if (transportPriceList == null || transportPriceList.Count == 0) { throw new BusinessErrorException("Transportation.PriceList.Empty", order.Carrier.Code); } if (transportPriceList.Count > 1) { throw new BusinessErrorException("Transportation.PriceList.MoreThanOne", order.Carrier.Code); } TransportPriceListDetail priceListDetail = null; if (order.PricingMethod != BusinessConstants.TRANSPORTATION_PRICING_METHOD_LADDERSTERE) { priceListDetail = this.transportPriceListDetailMgr.GetLastestTransportPriceListDetail(transportPriceList[0] , order.CreateDate, currencyMgr.LoadCurrency(currency), order.PricingMethod, order.TransportationRoute.ShipFrom, order.TransportationRoute.ShipTo, BusinessConstants.TRANSPORTATION_PRICELIST_DETAIL_TYPE_TRANSPORTATION, order.VehicleType, order.TransportMethod); } #region 包车 if (order.PricingMethod == BusinessConstants.TRANSPORTATION_PRICING_METHOD_SHIPT) { actBill.BillQty = 1; if (priceListDetail != null && actBill.UnitPrice == 0) { actBill.UnitPrice = priceListDetail.UnitPrice; actBill.BillAmount = actBill.UnitPrice * actBill.BillQty; } } #endregion #region 体积和阶梯 else if (order.PricingMethod == BusinessConstants.TRANSPORTATION_PRICING_METHOD_M3 || order.PricingMethod == BusinessConstants.TRANSPORTATION_PRICING_METHOD_LADDERSTERE) { decimal totalVolume = 0; foreach (TransportationOrderDetail orderDetail in order.OrderDetails) { foreach (InProcessLocationDetail ipDet in orderDetail.InProcessLocation.InProcessLocationDetails) { if (!ipDet.OrderLocationTransaction.OrderDetail.PackageVolumn.HasValue || ipDet.OrderLocationTransaction.OrderDetail.PackageVolumn.Value == 0) { throw new BusinessErrorException("Transportation.PackageVolumn.Empty", ipDet.InProcessLocation.IpNo, ipDet.OrderLocationTransaction.Item.Code); } else { if (ipDet.OrderLocationTransaction.OrderDetail.HuLotSize == null || ipDet.OrderLocationTransaction.OrderDetail.HuLotSize.Value == 0) { throw new BusinessErrorException("Transportation.HuLotSize.Empty", ipDet.InProcessLocation.IpNo, ipDet.OrderLocationTransaction.Item.Code); } int box = Convert.ToInt32(Math.Ceiling(ipDet.Qty / (decimal)(ipDet.OrderLocationTransaction.OrderDetail.HuLotSize.Value))); totalVolume += ipDet.OrderLocationTransaction.OrderDetail.PackageVolumn.Value * box; } } } #region 托盘数 if (order.PallentCount != 0) { decimal pallentVolume = decimal.Parse(entityPreferenceMgr.LoadEntityPreference( BusinessConstants.ENTITY_PREFERENCE_CODE_PALLENTVOLUME).Value); totalVolume += pallentVolume * order.PallentCount; } #endregion if (order.PricingMethod == BusinessConstants.TRANSPORTATION_PRICING_METHOD_M3) { #region 最小起运量 if (totalVolume < priceListDetail.MinVolume) { totalVolume = priceListDetail.MinVolume; } #endregion actBill.BillQty = totalVolume; if (priceListDetail != null && actBill.UnitPrice == 0) { actBill.UnitPrice = priceListDetail.UnitPrice; } actBill.BillAmount = actBill.UnitPrice * actBill.BillQty; } #region 阶梯 else if (order.PricingMethod == BusinessConstants.TRANSPORTATION_PRICING_METHOD_LADDERSTERE) { priceListDetail = this.transportPriceListDetailMgr.GetLastestLadderStereTransportPriceListDetail(transportPriceList[0], null, order.CreateDate, currencyMgr.LoadCurrency(currency), null, order.PricingMethod, order.TransportationRoute.ShipFrom, order.TransportationRoute.ShipTo, BusinessConstants.TRANSPORTATION_PRICELIST_DETAIL_TYPE_TRANSPORTATION, null, order.VehicleType, totalVolume); if (priceListDetail == null) { throw new BusinessErrorException("Transportation.PriceListDetail.Empty", order.PricingMethod); } #region 最小起运量 if (totalVolume < priceListDetail.MinVolume) { totalVolume = priceListDetail.MinVolume; } #endregion actBill.UnitPrice = priceListDetail.UnitPrice; actBill.BillQty = totalVolume; decimal minPrice = priceListDetail.MinPrice.HasValue ? priceListDetail.MinPrice.Value : 0; actBill.BillAmount = minPrice + actBill.UnitPrice * actBill.BillQty; } #endregion } #endregion #region 重量 else if (order.PricingMethod == BusinessConstants.TRANSPORTATION_PRICING_METHOD_KG) { } #endregion else { throw new BusinessErrorException("Transportation.PricingMethod.Empty"); } actBill.UnitPrice = priceListDetail.UnitPrice; // actBill.BillAmount = actBill.UnitPrice * actBill.BillQty; actBill.Currency = priceListDetail.Currency; actBill.IsIncludeTax = priceListDetail.IsIncludeTax; actBill.Currency = priceListDetail.Currency; actBill.IsProvisionalEstimate = priceListDetail.IsProvisionalEstimate; actBill.PricingMethod = order.PricingMethod; actBill.PriceList = priceListDetail.TransportPriceList; actBill.PriceListDetail = priceListDetail; actBill.VehicleType = priceListDetail.VehicleType; if (order.TransportationRoute != null) { actBill.ShipFrom = order.TransportationRoute.ShipFrom; actBill.ShipTo = order.TransportationRoute.ShipTo; } } actBill.OrderNo = order.OrderNo; actBill.BillAddress = order.CarrierBillAddress; actBill.EffectiveDate = DateTime.Parse(order.CreateDate.ToString("yyyy-MM-dd")); actBill.Status = BusinessConstants.CODE_MASTER_STATUS_VALUE_CREATE; actBill.TransType = BusinessConstants.TRANSPORTATION_PRICELIST_DETAIL_TYPE_TRANSPORTATION; actBill.CreateDate = DateTime.Now; actBill.CreateUser = user; actBill.LastModifyDate = DateTime.Now; actBill.LastModifyUser = user; actBill.TransportMethod = order.TransportMethod; this.CreateTransportationActBill(actBill); return(actBill); }
public TransportationBillDetail TransferTransportationActBill2TransportationBillDetail(TransportationActBill transportationActBill) { EntityPreference entityPreference = this.entityPreferenceMgr.LoadEntityPreference( BusinessConstants.ENTITY_PREFERENCE_CODE_AMOUNT_DECIMAL_LENGTH); int amountDecimalLength = int.Parse(entityPreference.Value); TransportationBillDetail transportationBillDetail = new TransportationBillDetail(); transportationBillDetail.ActBill = transportationActBill; transportationBillDetail.TransType = transportationActBill.TransType; transportationBillDetail.Currency = transportationActBill.Currency; transportationBillDetail.IsIncludeTax = transportationActBill.IsIncludeTax; transportationBillDetail.TaxCode = transportationActBill.TaxCode; /* * * 1.TransType=Transportation 价格单明细(承运商) 或 短拨费(区域)时 * a.PricingMethod=M3或KG 按数量 * b.SHIPT 按金额 * 2.TransType=WarehouseLease(固定费用) 按金额 * 3.TransType=Operation(操作费) 按数量 */ if (transportationActBill.TransType == BusinessConstants.TRANSPORTATION_PRICELIST_DETAIL_TYPE_OPERATION || (transportationActBill.TransType == BusinessConstants.TRANSPORTATION_PRICELIST_DETAIL_TYPE_TRANSPORTATION && (transportationActBill.PricingMethod == BusinessConstants.TRANSPORTATION_PRICING_METHOD_M3 || transportationActBill.PricingMethod == BusinessConstants.TRANSPORTATION_PRICING_METHOD_KG) ) ) { transportationBillDetail.UnitPrice = transportationActBill.UnitPrice; transportationBillDetail.BilledQty = transportationActBill.CurrentBillQty; transportationBillDetail.Discount = transportationActBill.CurrentDiscount; if (transportationActBill.CurrentBillQty != (transportationActBill.BillQty - transportationActBill.BilledQty)) { //本次开票数量大于剩余数量 if (transportationActBill.CurrentBillQty > (transportationActBill.BillQty - transportationActBill.BilledQty)) { throw new BusinessErrorException("TransportationActBill.Error.CurrentBillQtyGeRemainQty"); } //本次开票数量小于剩余数量 transportationBillDetail.Amount = Math.Round((transportationActBill.BillAmount / transportationActBill.BillQty * transportationActBill.CurrentBillQty), amountDecimalLength, MidpointRounding.AwayFromZero); } else { //本次开票数量等于剩余数量 transportationBillDetail.Amount = transportationActBill.BillAmount - transportationActBill.BilledAmount; } } else { transportationBillDetail.UnitPrice = transportationActBill.CurrentBillAmount; transportationBillDetail.BilledQty = 1; transportationBillDetail.Discount = transportationActBill.CurrentDiscount; if (transportationActBill.CurrentBillAmount != (transportationActBill.BillAmount - transportationActBill.BilledAmount)) { //本次开票金额大于剩余金额 if (transportationActBill.CurrentBillAmount > (transportationActBill.BillAmount - transportationActBill.BilledAmount)) { throw new BusinessErrorException("TransportationActBill.Error.CurrentBillAmountGeRemainAmount"); } //本次开票金额小于剩余金额 transportationBillDetail.Amount = transportationActBill.CurrentBillAmount; } else { //本次开票金额等于剩余金额 transportationBillDetail.Amount = transportationActBill.BillAmount - transportationActBill.BilledAmount; } } return(transportationBillDetail); }
protected void createTBill() { TransportationOrder to = TheTransportationOrderMgr.LoadTransportationOrder(OrderNo); if (to.Status == "In-Process") { TransportationActBill tb = new TransportationActBill(); tb.BillAddress = TheBillAddressMgr.LoadBillAddress(((Controls_TextBox)(this.FV_Order.FindControl("tbCarrierBillAddress"))).Text); tb.Currency = TheCurrencyMgr.LoadCurrency("RMB"); tb.Status = "Create"; tb.IsIncludeTax = false; tb.OrderNo = this.OrderNo; tb.TransType = "Transportation"; tb.EffectiveDate = DateTime.Now; tb.CreateDate = DateTime.Now; tb.CreateUser = CurrentUser; tb.LastModifyUser = CurrentUser; tb.LastModifyDate = DateTime.Now; tb.IsProvisionalEstimate = false; string carrier = string.Empty; tb.PricingMethod = ((com.Sconit.Control.CodeMstrDropDownList)(this.FV_Order.FindControl("ddlPricingMethod"))).SelectedValue; carrier = ((Controls_TextBox)(this.FV_Order.FindControl("tbCarrier"))).Text + "WL"; string vchtype = ((DropDownList)(this.FV_Order.FindControl("ddlType"))).SelectedValue; int shipto = (TheTransportationOrderMgr.LoadTransportationOrder(this.OrderNo)).TransportationRoute.ShipTo.Id; int shipfrom = (TheTransportationOrderMgr.LoadTransportationOrder(this.OrderNo)).TransportationRoute.ShipFrom.Id; DataSet ds = SqlHelper.ExecuteDataset(connstring, CommandType.Text, "select id from TPriceListDet where Tpricelist='" + carrier + "' and startdate<'" + to.CreateDate.ToShortDateString() + "' and enddate >'" + to.CreateDate.ToShortDateString() + "' and currency='RMB' and pricingmethod='" + tb.PricingMethod + "' and vehicletype='" + vchtype + "' and shipto='" + shipto + "' and shipfrom='" + shipfrom + "' "); if (ds.Tables[0].Rows.Count == 0) { throw new BusinessErrorException("没有找到该类型的价格单"); } int _id = Convert.ToInt32(ds.Tables[0].Rows[0][0]); tb.PriceListDetail = TheTransportPriceListDetailMgr.LoadTransportPriceListDetail(_id); tb.PriceList = TheTransportPriceListMgr.LoadTransportPriceList(carrier); tb.UnitPrice = tb.PriceListDetail.UnitPrice; tb.ShipFrom = tb.PriceListDetail.ShipFrom; tb.ShipTo = tb.PriceListDetail.ShipTo; tb.VehicleType = tb.PriceListDetail.VehicleType; if (tb.PricingMethod != "SHIPT") { decimal qty = 0; foreach (DataRow dr in ds_ip.Tables[0].Rows) { qty += Convert.ToDecimal((TheInProcessLocationMgr.LoadInProcessLocation(dr["ipno"].ToString())).CompleteLatency); } tb.BillQty = qty; tb.BilledQty = 0; if (qty < tb.PriceListDetail.MinVolume) { tb.BillAmount = tb.PriceListDetail.MinVolume * tb.UnitPrice; } else { tb.BillAmount = qty * tb.UnitPrice; } tb.BilledAmount = 0; } else { tb.BillQty = 1; tb.BilledQty = 0; tb.BillAmount = tb.PriceListDetail.UnitPrice; tb.BilledAmount = 0; } TheTransportationActBillMgr.CreateTransportationActBill(tb); } else { return; } }
public IList <TransportationBill> CreateTransportationBill(IList <TransportationActBill> transportationActBillList, 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 (transportationActBillList == null || transportationActBillList.Count == 0) { throw new BusinessErrorException("TransportationBill.Error.EmptyBillDetails"); } DateTime dateTimeNow = DateTime.Now; IList <TransportationBill> transportationBillList = new List <TransportationBill>(); foreach (TransportationActBill transportationActBill in transportationActBillList) { TransportationActBill oldTransportationActBill = this.transportationActBillMgr.LoadTransportationActBill(transportationActBill.Id); oldTransportationActBill.CurrentBillQty = transportationActBill.CurrentBillQty; oldTransportationActBill.CurrentBillAmount = transportationActBill.CurrentBillAmount; oldTransportationActBill.CurrentDiscount = transportationActBill.CurrentDiscount; TransportationBill transportationBill = null; #region 查找和待开明细的billAddress、currency一致的TransportationBillMstr foreach (TransportationBill thisTransportationBill in transportationBillList) { if (thisTransportationBill.BillAddress.Code == oldTransportationActBill.BillAddress.Code && thisTransportationBill.Currency.Code == oldTransportationActBill.Currency.Code) { transportationBill = thisTransportationBill; break; } } #endregion #region 没有找到匹配的TransportationBill,新建 if (transportationBill == null) { #region 检查权限 bool hasPermission = false; foreach (Permission permission in user.OrganizationPermission) { if (permission.Code == oldTransportationActBill.BillAddress.Party.Code) { hasPermission = true; break; } } if (!hasPermission) { throw new BusinessErrorException("TransportationBill.Create.Error.NoAuthrization", oldTransportationActBill.BillAddress.Party.Code); } #endregion #region 创建TransportationBill transportationBill = new TransportationBill(); transportationBill.BillNo = numberControlMgr.GenerateNumber(BusinessConstants.CODE_PREFIX_TRANSPORTATIONBILL); transportationBill.Status = status; transportationBill.BillAddress = oldTransportationActBill.BillAddress; transportationBill.Currency = oldTransportationActBill.Currency; transportationBill.Discount = discount; //可能有问题 transportationBill.BillType = BusinessConstants.CODE_TRANSPORTATION_TRANSPORTATIONBILL_TYPE_VALUE_NORMAL; transportationBill.CreateDate = dateTimeNow; transportationBill.CreateUser = user; transportationBill.LastModifyDate = dateTimeNow; transportationBill.LastModifyUser = user; this.CreateTransportationBill(transportationBill); transportationBillList.Add(transportationBill); #endregion } #endregion TransportationBillDetail transportationBillDetail = this.transportationBillDetailMgr.TransferTransportationActBill2TransportationBillDetail(oldTransportationActBill); transportationBillDetail.Bill = transportationBill; transportationBill.AddTransportationBillDetail(transportationBillDetail); this.transportationBillDetailMgr.CreateTransportationBillDetail(transportationBillDetail); //扣减TransportationActBill数量和金额 this.transportationActBillMgr.ReverseUpdateTransportationActBill(null, transportationBillDetail, user); } return(transportationBillList); }