Пример #1
0
        private void Calculate(Invoice invoice, IEnumerable<ParkingTimeInfo> parkingTimes, decimal timeRangePriceDay, decimal timeRangePriceNight)
        {
            foreach (var parkingTime in parkingTimes)
            {
                var currentTime = parkingTime.StartTime;
                var parkingInfo = new InvoiceParkingInfo();
                parkingInfo.StartTime = parkingTime.StartTime;
                do
                {
                    if (currentTime.Hour >= DAYSTARTHOUR && currentTime.Hour < NIGHTSTARTHOUR)
                    {
                        invoice.Price += timeRangePriceDay;
                        parkingInfo.BillableAmount++;
                        parkingInfo.Price += timeRangePriceDay;
                    }
                    else
                    {
                        invoice.Price += timeRangePriceNight;
                        parkingInfo.BillableAmount++;
                        parkingInfo.Price += timeRangePriceNight;

                    }
                    currentTime = currentTime.AddMinutes(PARKINGMINTIMERANGE);
                } while (currentTime < parkingTime.EndTime);
                parkingInfo.EndTime = parkingTime.EndTime;
                parkingTime.Calculated = true;
                invoice.parkingInfo.Add(parkingInfo);
                
            }
        }
Пример #2
0
        private Invoice CalculateInvoice(RegularClient client, IList<ParkingTimeInfo> parkingTimes)
        {
            decimal timeRangePriceDay = (decimal)1.5;
            decimal timeRangePriceNight = (decimal)1.0;
            var invoice = new Invoice(client.Id);
            
            Calculate(invoice, parkingTimes, timeRangePriceDay, timeRangePriceNight);

            return invoice;

        }
Пример #3
0
        private Invoice CalculateInvoice(PremiumClient premiumClient, IList<ParkingTimeInfo> parkingTimes)
        {
            decimal MaxInvoice = 300.0m;
            decimal monthlyFee = 20.0m;
            decimal timeRangePriceDay = 1.0m;
            decimal timeRangePriceNight = 0.75m;
            var invoice = new Invoice(premiumClient.Id);
            Calculate(invoice, parkingTimes, timeRangePriceDay, timeRangePriceNight);

            invoice.Price += monthlyFee;

            if (invoice.Price > MaxInvoice)
                invoice.Price = MaxInvoice;
            return invoice;
        }
Пример #4
0
 public void Save(Invoice invoice)
 {
     invoice.Id = _invoiceSeq++;
     _invoices.Add(invoice);
 }