public void AddItem(ProductSkuInfo productSkuInfo, decimal quantity, decimal weight, decimal price, string productNumber, Guid positionID, string remark = "", Guid?purchaseOrderItemID = null) { if (productNumber == null) { productNumber = string.Empty; } DeliveryVoucherItem newDeliveryVoucherItem = new DeliveryVoucherItem(); newDeliveryVoucherItem.DeliveryVoucher = this; newDeliveryVoucherItem.DeliveryVoucherID = this.ID; newDeliveryVoucherItem.Remark = remark; newDeliveryVoucherItem.ProductSkuInfo = productSkuInfo; newDeliveryVoucherItem.Quantity = quantity; newDeliveryVoucherItem.Weight = weight; newDeliveryVoucherItem.Price = price; if (productSkuInfo.PricingMethod == PricingMethod.PricingByQuantity) { newDeliveryVoucherItem.Amount = quantity * price; } else { newDeliveryVoucherItem.Amount = weight * price; } newDeliveryVoucherItem.ProductNumber = productNumber; newDeliveryVoucherItem.PositionID = positionID; newDeliveryVoucherItem.PurchaseOrderItemID = purchaseOrderItemID; RefreshAmount(newDeliveryVoucherItem); Items.Add(newDeliveryVoucherItem); }
public void UpdateItem(Guid itemID, ProductSkuInfo productSkuInfo, decimal quantity, decimal weight, decimal price, string productNumber, Guid positionID, string remark = "", Guid?purchaseOrderItemID = null) { DeliveryVoucherItem item = this.Items.FirstOrDefault(p => p.ID == itemID); if (item != null) { if (productNumber == null) { productNumber = string.Empty; } //item.Product = product; item.ProductSkuInfo = productSkuInfo; item.Remark = remark; item.Quantity = quantity; item.Weight = weight; item.ProductNumber = productNumber; item.PositionID = positionID; item.Price = price; //item.Amount = price * pricingQuantity; item.PurchaseOrderItemID = purchaseOrderItemID; RefreshAmount(item); } else { throw new DomainException("无此ID"); } }
public void RemoveItem(Guid itemID) { DeliveryVoucherItem item = Items.FirstOrDefault(p => p.ID == itemID); if (item == null) { throw new DomainException("无此ID"); } Items.Remove(item); }
private void RefreshAmount(DeliveryVoucherItem item) { this.TotalAmount = this.TotalAmount - item.Amount; if (item.ProductSkuInfo.PricingMethod == PricingMethod.PricingByQuantity) { item.Amount = item.Quantity * item.Price; } else { item.Amount = item.Weight * item.Price; } this.TotalAmount = this.TotalAmount + item.Amount; }
private void RefreshAmount(DeliveryVoucherItem item) { this.TotalAmount = this.TotalAmount - item.Amount; if (item.ProductSkuInfo.PricingMethod == PricingMethod.PricingByQuantity) item.Amount = item.Quantity * item.Price; else item.Amount = item.Weight * item.Price; this.TotalAmount = this.TotalAmount + item.Amount; }
public void AddItem(ProductSkuInfo productSkuInfo, decimal quantity, decimal weight, decimal price, string productNumber, Guid positionID, string remark = "", Guid? purchaseOrderItemID = null) { if (productNumber == null) productNumber = string.Empty; DeliveryVoucherItem newDeliveryVoucherItem = new DeliveryVoucherItem(); newDeliveryVoucherItem.DeliveryVoucher = this; newDeliveryVoucherItem.DeliveryVoucherID = this.ID; newDeliveryVoucherItem.Remark = remark; newDeliveryVoucherItem.ProductSkuInfo = productSkuInfo; newDeliveryVoucherItem.Quantity = quantity; newDeliveryVoucherItem.Weight = weight; newDeliveryVoucherItem.Price = price; if (productSkuInfo.PricingMethod == PricingMethod.PricingByQuantity) newDeliveryVoucherItem.Amount = quantity * price; else newDeliveryVoucherItem.Amount = weight * price; newDeliveryVoucherItem.ProductNumber = productNumber; newDeliveryVoucherItem.PositionID = positionID; newDeliveryVoucherItem.PurchaseOrderItemID = purchaseOrderItemID; RefreshAmount(newDeliveryVoucherItem); Items.Add(newDeliveryVoucherItem); }