コード例 #1
0
        public double GetTotalAmountAfterDiscounts()
        {
            var cartTotal = LineItems.Sum(a => a.Product.UnitPrice * a.Quantity);

            var discountTotal = GetCampaignDiscount() + GetCouponDiscount();

            return(cartTotal - discountTotal);
        }
コード例 #2
0
 public TotalsMeta CalculateTotalsMeta()
 {
     return(new TotalsMeta
     {
         HighestDeposit = LineItems?.Where(x => x.Amount > 0)?.Max(x => x.Amount) ?? 0,
         HighestWithdrawal = LineItems?.Where(x => x.Amount < 0)?.Min(x => x.Amount) ?? 0,
         LowestDeposit = LineItems?.Where(x => x.Amount > 0)?.Min(x => x.Amount) ?? 0,
         LowestWithdrawal = LineItems?.Where(x => x.Amount < 0)?.Max(x => x.Amount) ?? 0,
         TotalsTally = LineItems?.Sum(x => x.Amount) == (EndingBalance - StartingBalance)
     });
 }
コード例 #3
0
        public double GetCouponDiscount()
        {
            if (AppliedCoupon == null)
            {
                return(default(double));
            }

            var cartTotal = LineItems.Sum(a => a.Product.UnitPrice * a.Quantity) - GetCampaignDiscount();

            return(_couponCalculator.CalculateFor(AppliedCoupon, cartTotal));
        }
コード例 #4
0
        /// <summary>
        /// adds line item to collection and recalculates totals
        /// </summary>
        /// <param name="line"></param>
        public void AddLineItem(LineItem item)
        {
            item.Discount  = _utilities.GetVolumeDiscount(item);
            item.ItemTotal = Math.Round(item.Bike.Price * item.Discount * item.Quantity, 2);
            this.LineItems.Add(item);

            this.SubTotal = Math.Round(LineItems.Sum(l => l.ItemTotal), 2);

            this.Tax   = Math.Round(SubTotal * _utilities.GetSalesTaxRate(this.Company.Address), 2);
            this.Total = Math.Round(SubTotal + Tax, 2);
        }
コード例 #5
0
        public decimal CalculateOrderPrice()
        {
            decimal totalDiscount = 0;
            decimal totalPrice = LineItems.Sum(i => i.UnitPrice * i.Quantity);
            foreach (var item in Promotions)
            {
                totalDiscount += item.GetDiscount(LineItems);
            }

            decimal finalPrice = totalPrice - totalDiscount;

            Console.WriteLine($"OrderID: {this.Id} => Total price: {totalPrice.ToString("0.00")} | Discount: {totalDiscount.ToString("0.00")} | Final price: {finalPrice.ToString("0.00")}");

            return finalPrice;
        }
コード例 #6
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (InvoiceId != null ? InvoiceId.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ InvoiceNumber;
         hashCode = (hashCode * 397) ^ (InvoiceNumberAsString != null ? InvoiceNumberAsString.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ Total.GetHashCode();
         hashCode = (hashCode * 397) ^ Subtotal.GetHashCode();
         hashCode = (hashCode * 397) ^ Tax.GetHashCode();
         hashCode = (hashCode * 397) ^ TaxPercentage.GetHashCode();
         hashCode = (hashCode * 397) ^ InvoiceDate.GetHashCode();
         hashCode = (hashCode * 397) ^ (ContractName != null ? ContractName.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ PeriodStartDate.GetHashCode();
         hashCode = (hashCode * 397) ^ PeriodEndDate.GetHashCode();
         hashCode = (hashCode * 397) ^ (Currency != null ? Currency.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (From != null ? From.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (To != null ? To.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (LineItems?.Sum(x => x.GetHashCode()) ?? 0);
         return(hashCode);
     }
 }
コード例 #7
0
ファイル: Order.cs プロジェクト: ucdavis/Purchasing
 public virtual decimal TotalWithTax()
 {
     return(LineItems.Sum(amt => amt.TotalWithTax()));
 }
コード例 #8
0
ファイル: Order.cs プロジェクト: ucdavis/Purchasing
 /// <summary>
 /// Total is sum of all line unit amts * quantities
 /// </summary>
 public virtual decimal Total()
 {
     return(LineItems.Sum(amt => amt.Quantity * amt.UnitPrice));
 }
コード例 #9
0
ファイル: HomeController.cs プロジェクト: anthrax3/MediaKit
 public void CalculateTotalPrice()
 {
     Price    = LineItems.Sum(i => i.Price * i.Quantity);
     SalesTax = Price * GetSalesTax();
 }
コード例 #10
0
 private void CalculateTotal()
 {
     Total = LineItems.Sum(l => l.DiscountedSubTotal);
 }
コード例 #11
0
ファイル: Invoice.cs プロジェクト: dgamma3/invoice
 /// <summary>
 /// GetTotal should return the sum of (Cost * Quantity) for each line item
 /// </summary>
 public decimal GetTotal()
 {
     return((decimal)LineItems.Sum(x => x.Cost * x.Quantity));
 }