예제 #1
0
 protected void LoadMethod(object obj)
 {
     try
     {
         if (SelectedScheme != null)
         {
             IsPercentMode = SelectedScheme.DiscountPercent > 0;
             Scheme        = new DiscountScheme()
             {
                 SchemeId        = SelectedScheme.SchemeId,
                 SchemeName      = SelectedScheme.SchemeName,
                 ValidOnHolidays = SelectedScheme.ValidOnHolidays,
                 ValidOnWeekends = SelectedScheme.ValidOnWeekends,
                 ValidHours      = SelectedScheme.ValidHours,
                 DiscountAmount  = SelectedScheme.DiscountAmount,
                 DiscountPercent = SelectedScheme.DiscountPercent,
                 MinHrs          = SelectedScheme.MinHrs,
                 MaxHrs          = SelectedScheme.MaxHrs,
                 ExpiryDate      = SelectedScheme.ExpiryDate
             };
             SetAction(ButtonAction.Selected);
         }
     }
     catch (Exception ex)
     {
         while (ex.InnerException != null)
         {
             ex = ex.InnerException;
         }
         MessageBox.Show(ex.Message, MessageBoxCaption, MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
예제 #2
0
        public async Task OrderBidsFromCart(params int[] bidIds)
        {
            List <Bid> bids = await db.Bids
                              .Where(bid => bidIds.Contains(bid.BidId))
                              .ToListAsync();

            List <DiscountScheme> discountSchemes = await db.DiscountSchemes
                                                    .IncludeOptimized(ds => ds.Bids)
                                                    .ToListAsync();

            foreach (Bid bid in bids)
            {
                //1. For now, ignore validation whether the bids will exceed the bid limit imposed by the Discount Scheme
                //2. update the bidStatus that it is no longer in the cart

                //DiscountScheme has Bid property eager loaded
                DiscountScheme discountScheme = discountSchemes
                                                .FirstOrDefault(ds => ds.DiscountSchemeId == bid.DiscountSchemeId);

                int currentNumBids = GetNumberOfPendingBidsOfScheme(discountScheme);

                currentNumBids += bid.Quantity;

                //2. update the bidStatus that it is no longer in the cart
                bid.IsInCart = false;
                db.Bids.Update(bid);
                await db.SaveChangesAsync();

                // If the minOrderQuantity is reached, bid is successful ...
                if (currentNumBids >= discountScheme.MinOrderQnty)
                {
                    await SetBidSuccessDateAndDeliveryCharge(discountScheme);
                }
            }
        }
예제 #3
0
        public void UpdateAccount(
            string updatedByUri,
            DiscountScheme discountScheme,
            string turnoverBandUri,
            bool eligibleForGoodCredit,
            bool eligibleForRebate,
            bool growthPartner)
        {
            this.CheckUpdate(discountScheme, turnoverBandUri);

            if (discountScheme?.DiscountSchemeUri != this.DiscountSchemeUri)
            {
                this.UpdateDiscountScheme(new SalesAccountUpdateDiscountSchemeUriActivity(updatedByUri, discountScheme?.DiscountSchemeUri));
            }

            if (turnoverBandUri != this.TurnoverBandUri)
            {
                this.UpdateTurnoverBand(new SalesAccountUpdateTurnoverBandUriActivity(updatedByUri, turnoverBandUri));
            }

            if (eligibleForGoodCredit != this.EligibleForGoodCreditDiscount)
            {
                this.UpdateGoodCredit(new SalesAccountUpdateGoodCreditActivity(updatedByUri, eligibleForGoodCredit));
            }

            if (eligibleForRebate != this.EligibleForRebate)
            {
                this.UpdateRebate(new SalesAccountUpdateRebateActivity(updatedByUri, eligibleForRebate));
            }

            if (growthPartner != this.GrowthPartner)
            {
                this.UpdateGrowthPartner(new SalesAccountGrowthPartnerActivity(updatedByUri, growthPartner));
            }
        }
        public void SetUp()
        {
            this.salesAccountUpdateResource = new SalesAccountUpdateResource
            {
                TurnoverBandUri               = "/tb/10",
                DiscountSchemeUri             = "/ds/10",
                EligibleForGoodCreditDiscount = true
            };

            this.salesAccount = new SalesAccount(new SalesAccountCreateActivity("/employees/100", 1, "name"))
            {
                Id = 111
            };

            this.discountScheme = new DiscountScheme {
                DiscountSchemeUri = "/ds/10", TurnoverBandUris = new[] { "/tb/10" }
            };
            this.DiscountingService.GetDiscountScheme(this.salesAccountUpdateResource.DiscountSchemeUri)
            .Returns(this.discountScheme);
            this.SalesAccountRepository.GetById(111).Returns(this.salesAccount);

            this.Response = this.Browser.Put(
                "/sales/accounts/111",
                with =>
            {
                with.Header("Accept", "application/json");
                with.Header("Content-Type", "application/json");
                with.JsonBody(this.salesAccountUpdateResource);
            }).Result;
        }
예제 #5
0
        private static IDictionary <string, int> _SetAddressBidCountDict(DiscountScheme discountScheme)
        {
            IDictionary <string, int> addressBidCountDict = new Dictionary <string, int>()
            {
                { "AMK", 0 },
                { "BISHAN", 0 },
                { "SERANGOON", 0 }
            };

            if (discountScheme.Bids == null)
            {
                throw new NullReferenceException("Bids must be eagerly loaded");
            }

            foreach (Bid bid in discountScheme.Bids)
            {
                if (bid.BidSuccessDate != null || bid.IsInCart)
                {
                    continue;
                }

                if (addressBidCountDict.ContainsKey(bid.CollectionAddress))
                {
                    addressBidCountDict[bid.CollectionAddress] += 1;
                }
                else
                {
                    addressBidCountDict[bid.CollectionAddress] = 1;
                }
            }
            return(addressBidCountDict);
        }
예제 #6
0
        public void SetUp()
        {
            var discountScheme = new DiscountScheme {
                DiscountSchemeUri = "/ds/1", TurnoverBandUris = new[] { "/tb/1" }
            };

            this.Sut.UpdateAccount("/employees/100", discountScheme, string.Empty, true, true, true);
        }
예제 #7
0
        public void SetUp()
        {
            var discountScheme = new DiscountScheme {
                DiscountSchemeUri = "/ds/1", TurnoverBandUris = new[] { "/tb/2" }
            };

            this.action = () => this.Sut.UpdateAccount("/employees/100", discountScheme, "/tb/1", true, true, true);
        }
예제 #8
0
        public void SetUp()
        {
            this.updatedByUri = "/employees/100";
            var discountScheme = new DiscountScheme {
                DiscountSchemeUri = "/ds/1", TurnoverBandUris = new[] { "/tb/1" }
            };

            this.Sut.UpdateAccount(this.updatedByUri, discountScheme, "/tb/1", true, true, true);
        }
예제 #9
0
        public async Task <ActionResult <DiscountSchemeVM> > GetDiscountSchemeWithBid(int bidId)
        {
            DiscountScheme discountScheme = await discountSchemeService.GetDiscountSchemeWithBids(bidId);

            DiscountSchemeVM discountSchemeVM = new DiscountSchemeVM(discountScheme);

            discountSchemeVM.SetAddressBidCountDict(discountScheme);

            return(discountSchemeVM);
        }
예제 #10
0
        private void RemoveBidsFromSchemeThatAreInCart(DiscountScheme discountScheme)
        {
            if (discountScheme.Bids == null)
            {
                return;
            }
            List <Bid> bids = discountScheme.Bids.Where(bid => !bid.IsInCart).ToList();

            discountScheme.Bids = bids;
        }
예제 #11
0
        public async Task <DiscountScheme> DeleteDiscountScheme(int discountSchemeId)
        {
            DiscountScheme discountScheme = await db.DiscountSchemes
                                            .IncludeOptimized(ds => ds.Bids)
                                            .FirstOrDefaultAsync(ds => ds.DiscountSchemeId == discountSchemeId);

            db.DiscountSchemes.Remove(discountScheme);
            await db.SaveChangesAsync();

            return(discountScheme);
        }
예제 #12
0
 public DiscountSchemeVM(DiscountScheme discountScheme) : this()
 {
     DiscountSchemeId = discountScheme.DiscountSchemeId;
     MinOrderQnty     = discountScheme.MinOrderQnty;
     DiscountedPrice  = discountScheme.DiscountedPrice;
     ExpiryDate       = discountScheme.ExpiryDate;
     DeliveryCharge   = discountScheme.DeliveryCharge;
     ProductId        = discountScheme.ProductId;
     Product          = discountScheme.Product;
     Bids             = discountScheme.Bids;
 }
예제 #13
0
        public async Task <ActionResult <DiscountScheme> > CreateDiscountScheme(DiscountScheme ds)
        {
            DiscountScheme createdDiscountScheme = await discountSchemeService.CreateDiscountScheme(
                minOrderQnty : ds.MinOrderQnty,
                discountedPrice : ds.DiscountedPrice,
                expiryDate : ds.ExpiryDate,
                deliveryCharge : ds.DeliveryCharge,
                productId : ds.ProductId);

            return(Ok(createdDiscountScheme));
        }
예제 #14
0
        public void SetUp()
        {
            this.financialYear = "2018/19";
            this.account1      = new SalesAccount(new SalesAccountCreateActivity("/employees/100", 1, "one"))
            {
                DiscountSchemeUri = "/ds/1", TurnoverBandUri = "/tb/1"
            };
            this.account2 = new SalesAccount(new SalesAccountCreateActivity("/employees/100", 2, "two"))
            {
                DiscountSchemeUri = "/ds/2"
            };
            this.account3 = new SalesAccount(new SalesAccountCreateActivity("/employees/100", 3, "three"))
            {
                DiscountSchemeUri = "/ds/1", TurnoverBandUri = "/tb/1"
            };
            this.account4 = new SalesAccount(new SalesAccountCreateActivity("/employees/100", 4, "four"))
            {
                DiscountSchemeUri = "/ds/1", TurnoverBandUri = "/tb/1"
            };

            var discountScheme1 = new DiscountScheme {
                DiscountSchemeUri = "/ds/1", TurnoverBandSetUri = "/tbs/1"
            };
            var discountScheme2 = new DiscountScheme {
                DiscountSchemeUri = "/ds/2"
            };

            this.DiscountingService.GetDiscountScheme("/ds/1").Returns(discountScheme1);
            this.DiscountingService.GetDiscountScheme("/ds/2").Returns(discountScheme2);
            this.DiscountingService.GetTurnoverBandForTurnoverValue("/tbs/1", "GBP", 111).Returns("/tb/1");
            this.DiscountingService.GetTurnoverBandForTurnoverValue("/tbs/1", "EUR", 333).Returns("/tb/2");
            this.ProposedTurnoverBandRepository.GetAllForFinancialYear(this.financialYear)
            .Returns(new ProposedTurnoverBand[0]);
            this.SalesReportingService.GetSalesByAccount(this.financialYear)
            .Returns(new List <SalesDataDetail>
            {
                new SalesDataDetail {
                    Id = "1", CurrencyValue = 111, CurrencyCode = "GBP", BaseValue = 111
                },
                new SalesDataDetail {
                    Id = "2", CurrencyValue = 222, CurrencyCode = "GBP", BaseValue = 222
                },
                new SalesDataDetail {
                    Id = "3", CurrencyValue = 333, CurrencyCode = "EUR", BaseValue = 333
                },
                new SalesDataDetail {
                    Id = "4", CurrencyValue = 333, CurrencyCode = "NEW", BaseValue = 333
                }
            });
            this.SalesAccountRepository.GetAllOpenAccounts()
            .Returns(new[] { this.account1, this.account2, this.account3, this.account4 });
            this.result = this.Sut.CalculateProposedTurnoverBands(this.financialYear);
        }
예제 #15
0
        private int GetNumberOfPendingBidsOfScheme(DiscountScheme discountScheme)
        {
            if (discountScheme.Bids == null || discountScheme.Bids.Count == 0)
            {
                throw new NullReferenceException("discount scheme does not have any bids.\n Check that the bids are eagerly loaded");
            }

            int currentNumBids = discountScheme.Bids
                                 .Where(b => !b.IsInCart)
                                 .ToList()
                                 .Aggregate(0, (acc, b) => acc + b.Quantity);

            return(currentNumBids);
        }
        public void SetUp()
        {
            var discountScheme = new DiscountScheme {
                DiscountSchemeUri = "/ds/1", TurnoverBandUris = new[] { "/tb/1" }
            };

            this.Sut.UpdateAccount(
                "/employees/100",
                discountScheme,
                null,
                this.Sut.EligibleForGoodCreditDiscount,
                this.Sut.EligibleForRebate,
                this.Sut.GrowthPartner);
        }
예제 #17
0
        public static void Seed(this ModelBuilder modelBuilder)
        {
            Customer customer = new Customer
            {
                Id       = "1",
                UserName = "******",
                Address  = "",
                Email    = "*****@*****.**"
            };

            Product product = new Product
            {
                ProductId     = 1,
                Name          = "Awesome Shoes",
                Category      = "Shoe",
                Description   = "white shoe",
                OriginalPrice = 100,
            };

            DiscountScheme discountScheme = new DiscountScheme
            {
                DiscountSchemeId = 1,
                MinOrderQnty     = 5,
                DiscountedPrice  = 70,
                ExpiryDate       = DateTime.Now.AddMonths(1),
                DeliveryCharge   = 10,
                ProductId        = 1
            };

            Bid bid = new Bid
            {
                BidId             = 1,
                Quantity          = 2,
                CollectionAddress = "AMK MRT",
                CustomerId        = "1",
                DiscountSchemeId  = 1
            };

            Producer producer = new Producer
            {
                Id = "2"
            };

            modelBuilder.Entity <Customer>().HasData(customer);
            modelBuilder.Entity <Product>().HasData(product);
            modelBuilder.Entity <DiscountScheme>().HasData(discountScheme);
            modelBuilder.Entity <Bid>().HasData(bid);
            modelBuilder.Entity <Producer>().HasData(producer);
        }
예제 #18
0
        private int GetTotalPendingBids(int discountSchemeId, List <DiscountScheme> discountSchemes)
        {
            //The discountSchemes must have the Bid property eagerly loaded
            if (discountSchemes.Any(ds => ds.Bids == null))
            {
                throw new Exception("Bid property of discountScheme is not eagerly loaded");
            }

            DiscountScheme discountScheme = discountSchemes.Where(ds => ds.DiscountSchemeId == discountSchemeId).FirstOrDefault();
            int            currentBids    = discountScheme.Bids
                                            .Where(bid => !bid.IsInCart)
                                            .Aggregate(0, (accum, bid) => accum + bid.Quantity);

            return(currentBids);
        }
예제 #19
0
        public async Task <DiscountScheme> GetDiscountSchemeWithBids(int discountSchemeId)
        {
            if (!IsDiscountSchemeExist(discountSchemeId))
            {
                throw new EntityNotFoundException(discountSchemeId, typeof(DiscountScheme));
            }

            DiscountScheme discountScheme = await db.DiscountSchemes
                                            .Where(ds => ds.DiscountSchemeId == discountSchemeId)
                                            .IncludeOptimized(ds => ds.Bids)
                                            .IncludeOptimized(ds => ds.Product)
                                            .FirstOrDefaultAsync();

            return(discountScheme);
        }
예제 #20
0
        private async Task SetBidSuccessDateAndDeliveryCharge(DiscountScheme discountScheme)
        {
            if (discountScheme.Bids == null || discountScheme.Bids.Count == 0)
            {
                throw new NullReferenceException("discount scheme does not have any bids.\n Check that the bids are eagerly loaded");
            }

            discountScheme.Bids.ForEach(bid => bid.BidSuccessDate = DateTime.Now);

            double finalDeliveryCharge = discountScheme.DeliveryCharge / discountScheme.Bids.Count();

            discountScheme.Bids.ForEach(bid => bid.FinalDeliveryCharge = finalDeliveryCharge);

            db.DiscountSchemes.Update(discountScheme);
            await db.SaveChangesAsync();
        }
예제 #21
0
        public async Task <DiscountScheme> CreateDiscountScheme(int minOrderQnty, double discountedPrice, DateTime?expiryDate, double deliveryCharge, int productId)
        {
            DiscountScheme discountScheme = new DiscountScheme
            {
                MinOrderQnty    = minOrderQnty,
                DiscountedPrice = discountedPrice,
                ExpiryDate      = expiryDate,
                DeliveryCharge  = deliveryCharge,
                ProductId       = productId
            };

            db.DiscountSchemes.Add(discountScheme);
            await db.SaveChangesAsync();

            return(discountScheme);
        }
예제 #22
0
        public async Task <ActionResult <List <BidVM> > > GetBidsOfCustomerInCart(string customerId)
        {
            List <Bid> bids = await bidService.GetBidsOfCustomerInCart(customerId);

            int[]        dsIds  = bids.Select(bid => bid.DiscountSchemeId).ToArray();
            List <BidVM> bidVms = bids.Select(bid => new BidVM(bid)).ToList();

            List <DiscountScheme> discountSchemes = await discountSchemeService.GetAllDiscountSchemesWithBid();

            foreach (BidVM bidVm in bidVms)
            {
                bidVm.CurrentTotalBids = GetTotalPendingBids(bidVm.DiscountSchemeId, discountSchemes);
                DiscountScheme discountScheme = discountSchemes.FirstOrDefault(ds => ds.DiscountSchemeId == bidVm.DiscountSchemeId);
                bidVm.SetAddressBidCountDict(discountScheme);
            }
            return(Ok(bidVms));
        }
예제 #23
0
        public bool SetCurrentDiscountScheme(string discountSchemeName)
        {
            DiscountScheme discountScheme = null;

            if (discountSchemeName == "Single Highest Discount Scheme")
            {
                discountScheme = new SingleHighestDiscountScheme();
            }
            else if (discountSchemeName == "Multiple Discounts Scheme")
            {
                discountScheme = new MultipleDiscountsScheme();
            }

            var result = _iDiscountSchemeRepository.SetCurrentDiscountScheme(discountScheme);

            return(result);
        }
예제 #24
0
        private void CheckUpdate(DiscountScheme discountScheme, string turnoverBandUri)
        {
            if (string.IsNullOrEmpty(turnoverBandUri))
            {
                return;
            }

            if (discountScheme == null)
            {
                throw new InvalidTurnoverBandException($"Cannot use turnover band {turnoverBandUri} as no discount scheme specified");
            }

            if (!discountScheme.TurnoverBandUris.Contains(turnoverBandUri))
            {
                throw new InvalidTurnoverBandException($"Discount scheme {discountScheme.Name} does not contain turnover band {turnoverBandUri}");
            }
        }
예제 #25
0
 protected void UndoMethod(object obj)
 {
     try
     {
         SelectedScheme = null;
         IsPercentMode  = true;
         Scheme         = new DiscountScheme();
         SetAction(ButtonAction.Init);
     }
     catch (Exception ex)
     {
         while (ex.InnerException != null)
         {
             ex = ex.InnerException;
         }
         MessageBox.Show(ex.Message, MessageBoxCaption, MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
        public void SetUp()
        {
            var discountScheme = new DiscountScheme {
                DiscountSchemeUri = "/ds/1", TurnoverBandUris = new[] { "/tb/1" }
            };
            var address = new SalesAccountAddress("ln1", "ln2", string.Empty, string.Empty, "/countries/UK", "post");

            this.salesAccount = new SalesAccount(new SalesAccountCreateActivity("/employees/100", 1, "name", 4.May(2018)))
            {
                Id = 1
            };
            this.salesAccount.UpdateAccount("/employees/100", discountScheme, "/tb/1", true, true, true);
            this.salesAccount.UpdateNameAndAddress("/employees/100", "new name", address);
            this.salesAccount.CloseAccount(new SalesAccountCloseActivity("/employees/100", 17.April(2018)));

            this.SalesAccountRepository.GetById(1).Returns(this.salesAccount);

            this.Response = this.Browser.Get(
                "/sales/accounts/1/activities",
                with => { with.Header("Accept", "application/json"); }).Result;
        }
        public void SetUp()
        {
            this.financialYear = "2018/19";
            this.account1      = new SalesAccount(new SalesAccountCreateActivity("/employees/100", 1, "one"))
            {
                DiscountSchemeUri = "/ds/1",
                TurnoverBandUri   = "/tb/1"
            };

            var proposedTurnoverBands = new List <ProposedTurnoverBand>
            {
                new ProposedTurnoverBand
                {
                    SalesAccount              = this.account1,
                    FinancialYear             = this.financialYear,
                    AppliedToAccount          = true,
                    SalesValueCurrency        = 1,
                    ProposedTurnoverBandUri   = "/tb/100",
                    CalculatedTurnoverBandUri = "/tb/100"
                }
            };

            this.ProposedTurnoverBandRepository.GetAllForFinancialYear(this.financialYear)
            .Returns(proposedTurnoverBands);
            var discountScheme1 = new DiscountScheme {
                DiscountSchemeUri = "/ds/1", TurnoverBandSetUri = "/tbs/1"
            };

            this.DiscountingService.GetDiscountScheme("/ds/1").Returns(discountScheme1);
            this.DiscountingService.GetTurnoverBandForTurnoverValue("/tbs/1", "GBP", 111).Returns("/tb/1");
            this.SalesReportingService.GetSalesByAccount(this.financialYear)
            .Returns(new List <SalesDataDetail>
            {
                new SalesDataDetail {
                    Id = "1", CurrencyValue = 111, CurrencyCode = "GBP", BaseValue = 111
                }
            });
            this.SalesAccountRepository.GetAllOpenAccounts().Returns(new[] { this.account1 });
            this.results = this.Sut.CalculateProposedTurnoverBands(this.financialYear).ProposedTurnoverBands;
        }
예제 #28
0
        /// <summary>
        /// Gets details for an occupancy transaction
        /// </summary>
        public OccupancyDetailItem GetDetails(int cityId, long id)
        {
            var sensorpaymentitem = PemsEntities.SensorPaymentTransactions.FirstOrDefault(x => x.SensorPaymentTransactionID == id);
            var metermapitem      = sensorpaymentitem.ParkingSpace.Meter.MeterMaps.FirstOrDefault(x => x.Customerid == cityId && x.MeterId == sensorpaymentitem.ParkingSpace.MeterId);
            var area = PemsEntities.Areas.FirstOrDefault(x => x.CustomerID == cityId && x.AreaID == metermapitem.AreaId2);
            var occupancystatuses = PemsEntities.ParkingSpaceOccupancies.FirstOrDefault(x => x.ParkingSpaceId == sensorpaymentitem.ParkingSpaceId);

            int             lastmethodpaymenttypeid = sensorpaymentitem.LastTxPaymentMethod ?? 0;
            TransactionType lastpaymenttype         = PemsEntities.TransactionTypes.FirstOrDefault(x => x.TransactionTypeId == lastmethodpaymenttypeid);
            string          lastpaymentmethod       = "";

            if (lastpaymenttype != null)
            {
                lastpaymentmethod = lastpaymenttype.TransactionTypeDesc;
            }

            int             firstmethodpaymenttypeid = sensorpaymentitem.FirstTxPaymentMethod ?? 0;
            TransactionType firstpaymenttype         = PemsEntities.TransactionTypes.FirstOrDefault(x => x.TransactionTypeId == firstmethodpaymenttypeid);
            string          firstpaymentmethod       = "";

            if (firstpaymenttype != null)
            {
                firstpaymentmethod = firstpaymenttype.TransactionTypeDesc;
            }


            string         discounttype     = "";
            int            discountschemaid = sensorpaymentitem.DiscountSchema ?? 0;
            DiscountScheme ds = PemsEntities.DiscountSchemes.FirstOrDefault(x => x.DiscountSchemeID == discountschemaid);

            if (ds != null)
            {
                discounttype = ds.SchemeName;
            }
            var    spaceDetails = sensorpaymentitem.ParkingSpace.ParkingSpaceDetails.FirstOrDefault();
            string spacetype    = "";

            if (spaceDetails != null)
            {
                spacetype = spaceDetails.SpaceType1.SpaceTypeDesc;
            }
            string       suburb = "";
            CustomGroup1 cg     = PemsEntities.CustomGroup1.FirstOrDefault(x => x.CustomerId == cityId && x.CustomGroupId == metermapitem.CustomGroup1);

            if (cg != null)
            {
                suburb = cg.DisplayName;
            }
            long   sensorid = -1;
            Sensor sen      = sensorpaymentitem.ParkingSpace.Sensors.FirstOrDefault(x => x.CustomerID == cityId && x.ParkingSpaceId == sensorpaymentitem.ParkingSpaceId);

            if (sen != null)
            {
                sensorid = sen.SensorID;
            }
            OccupancyDetailItem ret = new OccupancyDetailItem()
            {
                SpaceId   = sensorpaymentitem.ParkingSpaceId,
                SpaceType = spacetype, //sensorpaymentitem.ParkingSpace.ParkingSpaceType.ToString(), // need to map
                Area      = area.AreaName,
                Zone      = metermapitem.Zone.ZoneName,
                Suburb    = suburb,
                //PemsEntities.CustomGroup1.FirstOrDefault(x=>x.CustomerId==cityId&&x.CustomGroupId==metermapitem.CustomGroup1).DisplayName,
                SensorId = sensorid,
                //sensorpaymentitem.ParkingSpace.Sensors.FirstOrDefault(x=>x.CustomerID==cityId&& x.ParkingSpaceId==sensorpaymentitem.ParkingSpaceId).SensorID,
                MeterId            = sensorpaymentitem.ParkingSpace.MeterId,
                Latitude           = metermapitem.Meter.Latitude ?? 0,
                Longitude          = metermapitem.Meter.Longitude ?? 0,
                DemandArea         = (metermapitem.Meter.DemandZone ?? 0),
                ArrivalTimestamp   = sensorpaymentitem.ArrivalTime,
                DepartureTimestamp = sensorpaymentitem.DepartureTime,
                TimeType1          = (sensorpaymentitem.TimeType1 != null
                                  ? PemsEntities.TimeTypes.FirstOrDefault(x => x.TimeTypeId == sensorpaymentitem.TimeType1).TimeTypeDesc
                                  : ""),
                TimeType2 = (sensorpaymentitem.TimeType2 != null
                                  ? PemsEntities.TimeTypes.FirstOrDefault(x => x.TimeTypeId == sensorpaymentitem.TimeType2).TimeTypeDesc
                                  : ""),
                TimeType3 = (sensorpaymentitem.TimeType3 != null
                                  ? PemsEntities.TimeTypes.FirstOrDefault(x => x.TimeTypeId == sensorpaymentitem.TimeType3).TimeTypeDesc
                                  : ""),
                TimeType4 = (sensorpaymentitem.TimeType4 != null
                                  ? PemsEntities.TimeTypes.FirstOrDefault(x => x.TimeTypeId == sensorpaymentitem.TimeType4).TimeTypeDesc
                                  : ""),
                TimeType5 = (sensorpaymentitem.TimeType5 != null
                                  ? PemsEntities.TimeTypes.FirstOrDefault(x => x.TimeTypeId == sensorpaymentitem.TimeType5).TimeTypeDesc
                                  : ""),
                ViolationMinutes      = sensorpaymentitem.ViolationMinute ?? 0,
                ViolationSegmentCount = sensorpaymentitem.ViolationSegmentCount ?? 0,
                OccupancyDuration     = sensorpaymentitem.TotalOccupiedMinute ?? 0,
                OccupancyStatus       = occupancystatuses != null ? occupancystatuses.OccupancyStatu.StatusDesc : "",

                OccupancyTimestamp = sensorpaymentitem.OccupancyDate,
                //OperationalStatus = ( sensorpaymentitem.ParkingSpace.OperationalStatu != null
                //                          ? sensorpaymentitem.ParkingSpace.OperationalStatu.OperationalStatusDesc
                //                          : "" ),
                OperationalStatus  = sensorpaymentitem.OperationalStatu.OperationalStatusDesc,
                NonCompliantStatus = (sensorpaymentitem.NonCompliantStatu != null ? sensorpaymentitem.NonCompliantStatu.NonCompliantStatusDesc : ""),
                UnusedPaidTime     = sensorpaymentitem.RemaingPaidTimeMinute ?? 0,
                TimeCleared        = sensorpaymentitem.ZeroOutTime,
                PaidTimeStart      = sensorpaymentitem.FirstTxStartTime,
                FreeParkingTime    = sensorpaymentitem.FreeParkingTime ?? 0,
                FirstPaymentTime   = sensorpaymentitem.FirstTxPaymentTime,
                FirstPaymentAmount = sensorpaymentitem.FirstTxAmountInCent ?? 0,
                FirstPaymentMethod = firstpaymentmethod,
                LastPaymentTime    = sensorpaymentitem.LastTxPaymentTime,
                LastPaymentAmount  = sensorpaymentitem.LastTxAmountInCent ?? 0,
                LastPaymentMethod  = lastpaymentmethod,
                TotalAmountPaid    = sensorpaymentitem.TotalAmountInCent ?? 0,
                TotalPaymentCount  = sensorpaymentitem.TotalNumberOfPayment ?? 0,
                DiscountType       = discounttype,
                PaidTimeEnd        = sensorpaymentitem.LastTxExpiryTime,
                PaidTimeDuration   = sensorpaymentitem.LastTxTimePaidMinute ?? 0,
                GracePeriodUsed    = sensorpaymentitem.GracePeriodMinute ?? 0,
                BayNumber          = sensorpaymentitem.ParkingSpace.BayNumber,
                BayName            = sensorpaymentitem.ParkingSpace.DisplaySpaceNum,
                Street             = metermapitem.Meter.Location,
                Zeroout            = sensorpaymentitem.Zeroout, //Changed On 11/11/2015
                Minuteresold       = sensorpaymentitem.Minuteresold
            };

            return(ret);
        }
예제 #29
0
        public void SetUp()
        {
            this.financialYear = "2018/19";
            this.account1      = new SalesAccount(new SalesAccountCreateActivity("/employees/100", 1, "one"))
            {
                DiscountSchemeUri = "/ds/1", TurnoverBandUri = "/tb/1"
            };
            this.account2 = new SalesAccount(new SalesAccountCreateActivity("/employees/100", 2, "two"))
            {
                DiscountSchemeUri = "/ds/1", TurnoverBandUri = "/tb/1"
            };
            this.account3 = new SalesAccount(new SalesAccountCreateActivity("/employees/100", 3, "three"))
            {
                DiscountSchemeUri = "/ds/1", TurnoverBandUri = "/tb/1"
            };
            this.account4 = new SalesAccount(new SalesAccountCreateActivity("/employees/100", 4, "four"))
            {
                DiscountSchemeUri = "/ds/1", TurnoverBandUri = "/tb/1"
            };
            this.account5 = new SalesAccount(new SalesAccountCreateActivity("/employees/100", 5, "closed"))
            {
                DiscountSchemeUri = "/ds/1", TurnoverBandUri = "/tb/1"
            };
            this.account5.CloseAccount(new SalesAccountCloseActivity("/employees/100", 1.May(2018)));

            this.proposedTurnoverBand5 = new ProposedTurnoverBand
            {
                SalesAccount       = this.account5,
                FinancialYear      = this.financialYear,
                SalesValueCurrency = 1
            };
            var proposedTurnoverBands = new List <ProposedTurnoverBand>
            {
                new ProposedTurnoverBand {
                    SalesAccount = this.account1, FinancialYear = this.financialYear, SalesValueCurrency = 1
                },
                new ProposedTurnoverBand {
                    SalesAccount = this.account2, FinancialYear = this.financialYear, SalesValueCurrency = 1
                },
                new ProposedTurnoverBand {
                    SalesAccount = this.account3, FinancialYear = this.financialYear, SalesValueCurrency = 1
                },
                this.proposedTurnoverBand5
            };

            this.ProposedTurnoverBandRepository.GetAllForFinancialYear(this.financialYear)
            .Returns(proposedTurnoverBands);
            var discountScheme1 = new DiscountScheme {
                DiscountSchemeUri = "/ds/1", TurnoverBandSetUri = "/tbs/1"
            };
            var discountScheme2 = new DiscountScheme {
                DiscountSchemeUri = "/ds/2"
            };

            this.DiscountingService.GetDiscountScheme("/ds/1").Returns(discountScheme1);
            this.DiscountingService.GetDiscountScheme("/ds/2").Returns(discountScheme2);
            this.DiscountingService.GetTurnoverBandForTurnoverValue("/tbs/1", "GBP", 111).Returns("/tb/1");
            this.DiscountingService.GetTurnoverBandForTurnoverValue("/tbs/1", "GBP", 222).Returns("/tb/1");
            this.DiscountingService.GetTurnoverBandForTurnoverValue("/tbs/1", "GBP", 333).Returns("/tb/2");
            this.DiscountingService.GetTurnoverBandForTurnoverValue("/tbs/1", "GBP", 444).Returns("/tb/2");
            this.SalesReportingService.GetSalesByAccount(this.financialYear)
            .Returns(new List <SalesDataDetail>
            {
                new SalesDataDetail {
                    Id = "1", CurrencyValue = 111, CurrencyCode = "GBP", BaseValue = 111
                },
                new SalesDataDetail {
                    Id = "2", CurrencyValue = 222, CurrencyCode = "GBP", BaseValue = 222
                },
                new SalesDataDetail {
                    Id = "4", CurrencyValue = 444, CurrencyCode = "GBP", BaseValue = 444
                },
                new SalesDataDetail {
                    Id = "5", CurrencyValue = 111, CurrencyCode = "GBP", BaseValue = 111
                }
            });
            this.SalesAccountRepository.GetAllOpenAccounts().Returns(new[] { this.account1, this.account2, this.account3, this.account4 });
            this.results = this.Sut.CalculateProposedTurnoverBands(this.financialYear).ProposedTurnoverBands;
        }
예제 #30
0
        public async Task <ActionResult <DiscountScheme> > DeleteDiscountScheme(int discountSchemeId)
        {
            DiscountScheme deletedDiscountScheme = await discountSchemeService.DeleteDiscountScheme(discountSchemeId);

            return(Ok(deletedDiscountScheme));
        }