Esempio n. 1
0
        public List <PriceComponent> CalculatePrice(PlaceInRun placeInRun /*,ServicesContext requestedServices*/)
        {
            var components = new List <PriceComponent>();

            //if (requestedServices.Tee)
            //{
            // тут какая то логика. много.
            // обращения к сервисам

            var beveragesPriceComponent = new PriceComponent()
            {
                Name  = "Beverages",
                Value = 3
            };

            components.Add(beveragesPriceComponent);
            //}

            var domesticsPriceComponent = new PriceComponent()
            {
                Name  = "Domestics",
                Value = 2
            };

            components.Add(domesticsPriceComponent);

            return(components);
        }
        public List <PriceComponent> CalculatePrice(PlaceAtMatch placeInRun)
        {
            var components = new List <PriceComponent>();

            var match   = _matchRepository.Get(placeInRun.Match.Id);
            var stadium = _stadiumRepository.Get(match.StadiumId);
            var place   =
                stadium.Sectors
                .Select(s => s.Places.SingleOrDefault(pl =>
                                                      pl.Number == placeInRun.Number &&
                                                      s.Number == placeInRun.SectorNumber))
                .SingleOrDefault(x => x != null);

            var placeComponent = new PriceComponent()
            {
                Name = "Main price"
            };

            placeComponent.Value = place.Sector.DefaultPrice * place.PriceMultiplier;
            components.Add(placeComponent);


            if (placeComponent.Value > 30)
            {
                var cashDeskComponent = new PriceComponent()
                {
                    Name  = "Cash desk service tax",
                    Value = placeComponent.Value * 0.2m
                };
                components.Add(cashDeskComponent);
            }

            return(components);
        }
Esempio n. 3
0
        public static void Tariff0003()
        {
            var tariff = new Tariff(Tariff_Id.Parse("12"),
                                    Currency.EUR,
                                    TariffUrl:      new Uri("https://company.com/tariffs/12"),
                                    TariffElements: Enumeration.Create(
                                        new TariffElement(
                                            PriceComponent.ChargingTime(2.00M, TimeSpan.FromSeconds(300))
                                            )
                                        )
                                    );

            var expected = new JObject(new JProperty("id", "12"),
                                       new JProperty("currency", "EUR"),
                                       new JProperty("tariff_alt_url", "https://company.com/tariffs/12"),
                                       new JProperty("elements", new JArray(
                                                         new JObject(
                                                             new JProperty("price_components", new JArray(
                                                                               new JObject(
                                                                                   new JProperty("type", "TIME"),
                                                                                   new JProperty("price", "2.00"),
                                                                                   new JProperty("step_size", 300)
                                                                                   )))
                                                             )
                                                         )));

            Assert.AreEqual(expected.ToString(), tariff.ToJSON().ToString());
        }
        public List <PriceComponent> CalculatePrice(PlaceInRun placeInRun)
        {
            var components = new List <PriceComponent>();
            var runDate    = placeInRun.Run.Date;

            foreach (Holiday holiday in _holidayRepository.GetHolidaysList())
            {
                if (runDate.Day == holiday.Date.Day && runDate.Month == holiday.Date.Month && runDate.Year == holiday.Date.Year)
                {
                    var HolidayComponent = new PriceComponent()
                    {
                        Name  = $"Holiday service tax for {holiday.Name}",
                        Value = 10000m
                    };
                    components.Add(HolidayComponent);
                    return(components);
                }
            }
            if (runDate.DayOfWeek == DayOfWeek.Saturday || runDate.DayOfWeek == DayOfWeek.Sunday)
            {
                var WeekendComponent = new PriceComponent()
                {
                    Name  = "Weekend service tax",
                    Value = 5000m
                };
                components.Add(WeekendComponent);
            }
            else
            {
                components = null;
            }
            return(components);
        }
Esempio n. 5
0
        public List <PriceComponent> CalculatePrice(PlaceInRun placeInRun)
        {
            var components = new List <PriceComponent>();

            var run    = _runRepository.GetRunDetails(placeInRun.RunId);
            var train  = _trainRepository.GetTrainDetails(run.TrainId);
            var agency = _agenciesRepository.GetAgencyDetails(train.AgencyId);
            var place  =
                train.Carriages
                .Select(car => car.Places.SingleOrDefault(pl =>
                                                          pl.Number == placeInRun.Number &&
                                                          car.Number == placeInRun.CarriageNumber))
                .SingleOrDefault(x => x != null);

            var placeComponent = new PriceComponent()
            {
                Name = "Main price: " + Convert.ToString(place.Carriage.DefaultPrice) + "$ AgencyTax: " + Convert.ToString(((agency.AgencyPay) - 1) * 100) + "%" + " Full Price:"
            };

            placeComponent.Value = place.Carriage.DefaultPrice * agency.AgencyPay;
            components.Add(placeComponent);
            var AgencyInfo = new PriceComponent()
            {
                Name  = "Agency Tax provided by " + agency.Name,
                Value = place.Carriage.DefaultPrice * ((agency.AgencyPay) - 1)
            };

            components.Add(AgencyInfo);

            return(components);
        }
        public List <PriceComponent> CalculatePrice(PlaceInRun placeInRun)
        {
            var components = new List <PriceComponent>();

            var run   = _runRepository.GetRunDetails(placeInRun.RunId);
            var train = _trainRepository.GetTrainDetails(run.TrainId);
            var place =
                train.Carriages
                .Select(car => car.Places.SingleOrDefault(pl =>
                                                          pl.Number == placeInRun.Number &&
                                                          car.Number == placeInRun.CarriageNumber))
                .SingleOrDefault(x => x != null);

            var placeComponent = new PriceComponent()
            {
                Name = "Main price"
            };

            placeComponent.Value = place.Carriage.DefaultPrice * place.PriceMultiplier;
            components.Add(placeComponent);


            if (placeComponent.Value > 30)
            {
                var cashDeskComponent = new PriceComponent()
                {
                    Name  = "Cash desk service tax",
                    Value = placeComponent.Value * 0.2m
                };
                components.Add(cashDeskComponent);
            }


            return(components);
        }
Esempio n. 7
0
        public static void AppsOnDerive(this PriceComponent @this, ObjectOnDerive method)
        {
            var derivation = method.Derivation;

            var internalOrganisations = new Organisations(@this.Strategy.Session).Extent().Where(v => Equals(v.IsInternalOrganisation, true)).ToArray();

            if ([email protected] && internalOrganisations.Count() == 1)
            {
                @this.PricedBy = internalOrganisations.First();
            }
        }
Esempio n. 8
0
        public List <PriceComponent> CalculatePrice(PlaceInRun placeInRun)
        {
            var components  = new List <PriceComponent>();
            var holidayList = _holidayRepository.GetAllHolidays();
            var run         = _runRepository.GetRunDetails(placeInRun.RunId);
            var train       = _trainRepository.GetTrainDetails(run.TrainId);
            var place       =
                train.Carriages
                .Select(car => car.Places.SingleOrDefault(pl =>
                                                          pl.Number == placeInRun.Number &&
                                                          car.Number == placeInRun.CarriageNumber))
                .SingleOrDefault(x => x != null);

            var placeComponent = new PriceComponent()
            {
                Name = "Main price"
            };

            placeComponent.Value = place.Carriage.DefaultPrice * place.PriceMultiplier;
            components.Add(placeComponent);
            if (run.Date.DayOfWeek == (DayOfWeek)0 || run.Date.DayOfWeek == (DayOfWeek)6)
            {
                var cashDeskComponent = new PriceComponent()
                {
                    Name  = "Holiday tax",
                    Value = placeComponent.Value * 1.25m
                };
                components.Add(cashDeskComponent);
            }
            for (int i = 1; i < holidayList.Count; i++)
            {
                if (run.Date.Day == holidayList[i].Day && run.Date.Month == holidayList[i].Month)
                {
                    var cashDeskComponent = new PriceComponent()
                    {
                        Name  = "Holiday tax",
                        Value = placeComponent.Value * 1.25m
                    };
                    components.Add(cashDeskComponent);
                    break;
                }
            }
            if (placeComponent.Value > 30)
            {
                var cashDeskComponent = new PriceComponent()
                {
                    Name  = "Cash desk service tax",
                    Value = placeComponent.Value * 0.2m
                };
                components.Add(cashDeskComponent);
            }

            return(components);
        }
Esempio n. 9
0
        public List <PriceComponent> CalculatePrice(PriceCalculationParameters parameters)
        {
            var components = new List <PriceComponent>();

            var gun            = _gunRepository.GetGun(parameters.gun.Id);
            var placeComponent = new PriceComponent()
            {
                Name = "Main price"
            };

            placeComponent.Value = gun.Price;
            components.Add(placeComponent);
            return(components);
        }
Esempio n. 10
0
        public List <PriceComponent> CalculatePrice(PlaceInRun placeInRun)
        {
            var components = new List <PriceComponent>();

            var teaComponent = new PriceComponent()
            {
                Name  = "Price for " + _name,
                Value = _price
            };

            components.Add(teaComponent);

            return(components);
        }
Esempio n. 11
0
 public AddPriceResponse Add(AddPriceRequest request)
 {
     try
     {
         var response = new AddPriceResponse();
         var bc       = new PriceComponent();
         response.Result = bc.Add(request.Price);
         return(response);
     }
     catch (Exception ex)
     {
         var httpError = new HttpResponseMessage()
         {
             StatusCode   = (HttpStatusCode)422,
             ReasonPhrase = ex.Message
         };
         throw new HttpResponseException(httpError);
     }
 }
Esempio n. 12
0
 public GetPriceResponse GetById(int id, DateTime date)
 {
     try
     {
         var response = new GetPriceResponse();
         var bc       = new PriceComponent();
         response.Result = bc.Find(id, date);
         return(response);
     }
     catch (Exception ex)
     {
         var httpError = new HttpResponseMessage()
         {
             StatusCode   = (HttpStatusCode)422,
             ReasonPhrase = ex.Message
         };
         throw new HttpResponseException(httpError);
     }
 }
Esempio n. 13
0
        internal static decimal SetUnitDiscount(this Priceable @this, PriceComponent priceComponent, decimal revenueBreakDiscount)
        {
            if (priceComponent.Strategy.Class.Equals(DiscountComponents.Meta.ObjectType))
            {
                var discountComponent = (DiscountComponent)priceComponent;
                decimal discount;

                if (discountComponent.Price.HasValue)
                {
                    discount = discountComponent.Price.Value;
                    @this.UnitDiscount += discount;
                }
                else
                {
                    var percentage = discountComponent.Percentage ?? 0;
                    discount = decimal.Round((@this.UnitBasePrice * percentage) / 100, 2);
                    @this.UnitDiscount += discount;
                }

                ////Revenuebreaks on quantity and value are mutually exclusive.
                if (priceComponent.ExistRevenueQuantityBreak || priceComponent.ExistRevenueValueBreak)
                {
                    if (revenueBreakDiscount == 0)
                    {
                        revenueBreakDiscount = discount;
                    }
                    else
                    {
                        ////Apply highest of the two. Revert the other one.
                        if (discount > revenueBreakDiscount)
                        {
                            @this.UnitDiscount -= revenueBreakDiscount;
                        }
                        else
                        {
                            @this.UnitDiscount -= discount;
                        }
                    }
                }
            }

            return revenueBreakDiscount;
        }
Esempio n. 14
0
        public static decimal SetUnitSurcharge(this Priceable @this, PriceComponent priceComponent, decimal revenueBreakSurcharge)
        {
            if (priceComponent.Strategy.Class.Equals(SurchargeComponents.Meta.ObjectType))
            {
                var surchargeComponent = (SurchargeComponent)priceComponent;
                decimal surcharge;

                if (surchargeComponent.Price.HasValue)
                {
                    surcharge = surchargeComponent.Price.Value;
                    @this.UnitSurcharge += surcharge;
                }
                else
                {
                    var percentage = surchargeComponent.Percentage ?? 0;
                    surcharge = decimal.Round((@this.UnitBasePrice * percentage) / 100, 2);
                    @this.UnitSurcharge += surcharge;
                }

                ////Revenuebreaks on quantity and value are mutually exclusive.
                if (priceComponent.ExistRevenueQuantityBreak || priceComponent.ExistRevenueValueBreak)
                {
                    if (revenueBreakSurcharge == 0)
                    {
                        revenueBreakSurcharge = surcharge;
                    }
                    else
                    {
                        ////Apply highest of the two. Revert the other one.
                        if (surcharge > revenueBreakSurcharge)
                        {
                            @this.UnitSurcharge -= revenueBreakSurcharge;
                        }
                        else
                        {
                            @this.UnitSurcharge -= surcharge;
                        }
                    }
                }
            }

            return revenueBreakSurcharge;
        }
        public List <PriceComponent> CalculatePrice(PlaceInRun placeInRun)
        {
            var train           = _trainRepository.GetTrainDetails(placeInRun.Run.TrainId);
            var priceComponents = new List <PriceComponent>();

            priceComponents.AddRange(_strategy.CalculatePrice(placeInRun));
            var sum = 0m;

            foreach (var p in priceComponents)
            {
                sum += p.Value;
            }
            var AgencyComponent = new PriceComponent {
                Name = "AgencyMargin", Value = train.CompanyMargin.Margin * sum
            };

            priceComponents.Add(AgencyComponent);
            return(priceComponents
                   );
        }
Esempio n. 16
0
        public List <PriceComponent> CalculatePrice(TicketParametersDTO parametrs)
        {
            var components = new List <PriceComponent>();

            var            defaultPrice = _priceCalculationStrategy.CalculatePrice(parametrs);
            PriceComponent mainPrice    = defaultPrice.Find(p => p.Name == "Main price");

            if (parametrs.Code != null)
            {
                components.Add(new PriceComponent
                {
                    Name     = "Code markup price",
                    Ticket   = parametrs.Ticket,
                    TicketId = parametrs.Ticket.Id,
                    Value    = _bookingAgencies.GetMarkup(parametrs.Code)
                });
            }

            return(components);
        }
        public List<PriceComponent> CalculatePrice(PlaceInRun placeInRun)
        {
            var components = new List<PriceComponent>();

            var run = _runRepository.GetRunDetails(placeInRun.RunId);
            var train = _trainRepository.GetTrainDetails(run.TrainId);
            var place =
                train.Carriages
                    .Select(car => car.Places.FirstOrDefault(pl =>
                        pl.Number == placeInRun.Number &&
                        car.Number == placeInRun.CarriageNumber))
                    .SingleOrDefault(x => x != null);

            var cashDeskComponent = new PriceComponent()
            {
                Name = "Booking service tax",
                Value = place.Carriage.DefaultPrice * place.PriceMultiplier * Convert.ToDecimal(train.Booking.OverPrice)
            };
            components.Add(cashDeskComponent);

            return components;
        }
Esempio n. 18
0
        public List <PriceComponent> CalculatePrice(PlaceInRun placeInRun)
        {
            var priceComponents = new List <PriceComponent>();

            priceComponents.AddRange(_strategy.CalculatePrice(placeInRun));
            var teaComponent = new PriceComponent {
                Name = "Tea price", Value = PriceList.TEA * _teaCount
            };

            priceComponents.Add(teaComponent);
            var coffeeComponent = new PriceComponent {
                Name = "Coffee price", Value = PriceList.COFFEE * _coffeeCount
            };

            priceComponents.Add(coffeeComponent);
            var cookiesComponent = new PriceComponent {
                Name = "Cookies price", Value = PriceList.COOKIES * _cookiesCount
            };

            priceComponents.Add(cookiesComponent);
            return(priceComponents);
        }
        internal static decimal SetUnitDiscount(this Priceable @this, PriceComponent priceComponent, decimal revenueBreakDiscount)
        {
            if (priceComponent.Strategy.Class.Equals(M.DiscountComponent.ObjectType))
            {
                var     discountComponent = (DiscountComponent)priceComponent;
                decimal discount;

                if (discountComponent.Price.HasValue)
                {
                    discount = discountComponent.Price.Value;
                    @this.DerivedRoles.UnitDiscount += discount;
                }
                else
                {
                    var percentage = discountComponent.Percentage ?? 0;
                    discount = Math.Round(@this.UnitBasePrice * percentage / 100, 2);
                    @this.DerivedRoles.UnitDiscount += discount;
                }
            }

            return(revenueBreakDiscount);
        }
        public static decimal SetUnitSurcharge(this Priceable @this, PriceComponent priceComponent, decimal revenueBreakSurcharge)
        {
            if (priceComponent.Strategy.Class.Equals(M.SurchargeComponent.ObjectType))
            {
                var     surchargeComponent = (SurchargeComponent)priceComponent;
                decimal surcharge;

                if (surchargeComponent.Price.HasValue)
                {
                    surcharge = surchargeComponent.Price.Value;
                    @this.DerivedRoles.UnitSurcharge += surcharge;
                }
                else
                {
                    var percentage = surchargeComponent.Percentage ?? 0;
                    surcharge = Math.Round(@this.UnitBasePrice * percentage / 100, 2);
                    @this.DerivedRoles.UnitSurcharge += surcharge;
                }
            }

            return(revenueBreakSurcharge);
        }
Esempio n. 21
0
        public List <PriceComponent> CalculatePrice(PriceCalculationParametersDTO PriceCalculationParameters)
        {
            var components = new List <PriceComponent>();

            components.AddRange(_priceCalculationStrategy.CalculatePrice(PriceCalculationParameters));
            if (PriceCalculationParameters.IsTea == true)
            {
                var cashForTea = new PriceComponent()
                {
                    Name  = "Pay for tea",
                    Value = 7,
                };
                components.Add(cashForTea);
            }

            if (PriceCalculationParameters.IsCoffee == true)
            {
                var cashForCoffee = new PriceComponent()
                {
                    Name  = "Pay for Coffee",
                    Value = 8
                };
                components.Add(cashForCoffee);
            }

            if (PriceCalculationParameters.IsBed == true)
            {
                var cashForBed = new PriceComponent()
                {
                    Name  = "Pay for Bed",
                    Value = 15
                };
                components.Add(cashForBed);
            }
            return(components);
        }
Esempio n. 22
0
        public static void CDR_SerializeDeserialize_Test01()
        {
            #region Defined CDR1

            var CDR1 = new CDR(CountryCode.Parse("DE"),
                               Party_Id.Parse("GEF"),
                               CDR_Id.Parse("CDR0001"),
                               DateTime.Parse("2020-04-12T18:20:19Z"),
                               DateTime.Parse("2020-04-12T22:20:19Z"),
                               new CDRToken(
                                   Token_Id.Parse("1234"),
                                   TokenTypes.RFID,
                                   Contract_Id.Parse("C1234")
                                   ),
                               AuthMethods.AUTH_REQUEST,
                               new CDRLocation(
                                   Location_Id.Parse("LOC0001"),
                                   "Biberweg 18",
                                   "Jena",
                                   "Deutschland",
                                   GeoCoordinate.Parse(10, 20),
                                   EVSE_UId.Parse("DE*GEF*E*LOC0001*1"),
                                   EVSE_Id.Parse("DE*GEF*E*LOC0001*1"),
                                   Connector_Id.Parse("1"),
                                   ConnectorTypes.IEC_62196_T2,
                                   ConnectorFormats.SOCKET,
                                   PowerTypes.AC_3_PHASE,
                                   "Name?",
                                   "07749"
                                   ),
                               Currency.EUR,

                               new ChargingPeriod[] {
                new ChargingPeriod(
                    DateTime.Parse("2020-04-12T18:21:49Z"),
                    new CDRDimension[] {
                    new CDRDimension(
                        CDRDimensions.ENERGY,
                        1.33M
                        )
                },
                    Tariff_Id.Parse("DE*GEF*T0001")
                    ),
                new ChargingPeriod(
                    DateTime.Parse("2020-04-12T18:21:50Z"),
                    new CDRDimension[] {
                    new CDRDimension(
                        CDRDimensions.TIME,
                        5.12M
                        )
                },
                    Tariff_Id.Parse("DE*GEF*T0002")
                    )
            },

                               // Total costs
                               new Price(
                                   10.00,
                                   11.60
                                   ),

                               // Total Energy
                               50.00M,

                               // Total time
                               TimeSpan.FromMinutes(30),

                               Session_Id.Parse("0815"),
                               AuthorizationReference.Parse("Auth0815"),
                               Meter_Id.Parse("Meter0815"),

                               // OCPI Computer Science Extentions
                               new EnergyMeter(
                                   Meter_Id.Parse("Meter0815"),
                                   "EnergyMeter Model #1",
                                   "hw. v1.80",
                                   "fw. v1.20",
                                   "Energy Metering Services",
                                   null,
                                   null
                                   ),

                               // OCPI Computer Science Extentions
                               new TransparencySoftware[] {
                new TransparencySoftware(
                    "Chargy Transparency Software Desktop Application",
                    "v1.00",
                    LegalStatus.LegallyBinding,
                    OpenSourceLicenses.GPL3,
                    "GraphDefined GmbH",
                    URL.Parse("https://open.charging.cloud/logo.svg"),
                    URL.Parse("https://open.charging.cloud/Chargy/howto"),
                    URL.Parse("https://open.charging.cloud/Chargy"),
                    URL.Parse("https://github.com/OpenChargingCloud/ChargyDesktopApp")
                    ),
                new TransparencySoftware(
                    "Chargy Transparency Software Mobile Application",
                    "v1.00",
                    LegalStatus.ForInformationOnly,
                    OpenSourceLicenses.GPL3,
                    "GraphDefined GmbH",
                    URL.Parse("https://open.charging.cloud/logo.svg"),
                    URL.Parse("https://open.charging.cloud/Chargy/howto"),
                    URL.Parse("https://open.charging.cloud/Chargy"),
                    URL.Parse("https://github.com/OpenChargingCloud/ChargyMobileApp")
                    )
            },

                               new Tariff[] {
                new Tariff(
                    CountryCode.Parse("DE"),
                    Party_Id.Parse("GEF"),
                    Tariff_Id.Parse("TARIFF0001"),
                    Currency.EUR,
                    new TariffElement[] {
                    new TariffElement(
                        new PriceComponent[] {
                        PriceComponent.ChargingTime(
                            TimeSpan.FromSeconds(300),
                            2.00M,
                            0.10M
                            )
                    },
                        new TariffRestrictions [] {
                        new TariffRestrictions(
                            Time.FromHourMin(08, 00),                                 // Start time
                            Time.FromHourMin(18, 00),                                 // End time
                            DateTime.Parse("2020-12-01"),                             // Start timestamp
                            DateTime.Parse("2020-12-31"),                             // End timestamp
                            1.12M,                                                    // MinkWh
                            5.67M,                                                    // MaxkWh
                            1.34M,                                                    // MinCurrent
                            8.89M,                                                    // MaxCurrent
                            1.49M,                                                    // MinPower
                            9.91M,                                                    // MaxPower
                            TimeSpan.FromMinutes(10),                                 // MinDuration
                            TimeSpan.FromMinutes(30),                                 // MaxDuration
                            new DayOfWeek[] {
                            DayOfWeek.Monday,
                            DayOfWeek.Tuesday
                        },
                            ReservationRestrictionTypes.RESERVATION
                            )
                    }
                        )
                },
                    TariffTypes.PROFILE_GREEN,
                    new DisplayText[] {
                    new DisplayText(Languages.de, "Hallo Welt!"),
                    new DisplayText(Languages.en, "Hello world!"),
                },
                    URL.Parse("https://open.charging.cloud"),
                    new Price(                    // Min Price
                        1.10,
                        1.26
                        ),
                    new Price(                    // Max Price
                        2.20,
                        2.52
                        ),
                    DateTime.Parse("2020-12-01"),                    // Start timestamp
                    DateTime.Parse("2020-12-31"),                    // End timestamp
                    new EnergyMix(
                        true,
                        new EnergySource[] {
                    new EnergySource(
                        EnergySourceCategories.SOLAR,
                        80
                        ),
                    new EnergySource(
                        EnergySourceCategories.WIND,
                        20
                        )
                },
                        new EnvironmentalImpact[] {
                    new EnvironmentalImpact(
                        EnvironmentalImpactCategories.CARBON_DIOXIDE,
                        0.1
                        )
                },
                        "Stadtwerke Jena-Ost",
                        "New Green Deal"
                        ),
                    DateTime.Parse("2020-09-22")
                    )
            },

                               new SignedData(
                                   EncodingMethod.GraphDefiened,
                                   new SignedValue[] {
                new SignedValue(
                    SignedValueNature.START,
                    "PlainStartValue",
                    "SignedStartValue"
                    ),
                new SignedValue(
                    SignedValueNature.INTERMEDIATE,
                    "PlainIntermediateValue",
                    "SignedIntermediateValue"
                    ),
                new SignedValue(
                    SignedValueNature.END,
                    "PlainEndValue",
                    "SignedEndValue"
                    )
            },
                                   1,     // Encoding method version
                                   null,  // Public key
                                   "https://open.charging.cloud/pools/1/stations/1/evse/1/publicKey"
                                   ),

                               // Total Fixed Costs
                               new Price(
                                   20.00,
                                   23.10
                                   ),

                               // Total Energy Cost
                               new Price(
                                   20.00,
                                   23.10
                                   ),

                               // Total Time Cost
                               new Price(
                                   20.00,
                                   23.10
                                   ),

                               // Total Parking Time
                               TimeSpan.FromMinutes(120),

                               // Total Parking Cost
                               new Price(
                                   20.00,
                                   23.10
                                   ),

                               // Total Reservation Cost
                               new Price(
                                   20.00,
                                   23.10
                                   ),

                               "Remark!",
                               InvoiceReference_Id.Parse("Invoice:0815"),
                               true, // IsCredit
                               CreditReference_Id.Parse("Credit:0815"),

                               DateTime.Parse("2020-09-12")

                               );

            #endregion

            var JSON = CDR1.ToJSON();

            Assert.AreEqual("DE", JSON["country_code"].Value <String>());
            Assert.AreEqual("GEF", JSON["party_id"].Value <String>());
            Assert.AreEqual("CDR0001", JSON["id"].Value <String>());


            Assert.IsTrue(CDR.TryParse(JSON, out CDR CDR2, out String ErrorResponse));
            Assert.IsNull(ErrorResponse);

            Assert.AreEqual(CDR1.CountryCode, CDR2.CountryCode);
            Assert.AreEqual(CDR1.PartyId, CDR2.PartyId);
            Assert.AreEqual(CDR1.Id, CDR2.Id);

            Assert.AreEqual(CDR1.Start.ToIso8601(), CDR2.Start.ToIso8601());
            Assert.AreEqual(CDR1.End.ToIso8601(), CDR2.End.ToIso8601());
            Assert.AreEqual(CDR1.CDRToken, CDR2.CDRToken);
            Assert.AreEqual(CDR1.AuthMethod, CDR2.AuthMethod);
            Assert.AreEqual(CDR1.Location, CDR2.Location);
            Assert.AreEqual(CDR1.Currency, CDR2.Currency);
            Assert.AreEqual(CDR1.ChargingPeriods, CDR2.ChargingPeriods);
            Assert.AreEqual(CDR1.TotalCosts, CDR2.TotalCosts);
            Assert.AreEqual(CDR1.TotalEnergy, CDR2.TotalEnergy);
            Assert.AreEqual(CDR1.TotalTime, CDR2.TotalTime);

            Assert.AreEqual(CDR1.SessionId, CDR2.SessionId);
            Assert.AreEqual(CDR1.AuthorizationReference, CDR2.AuthorizationReference);
            Assert.AreEqual(CDR1.MeterId, CDR2.MeterId);
            Assert.AreEqual(CDR1.EnergyMeter, CDR2.EnergyMeter);
            Assert.AreEqual(CDR1.TransparencySoftwares, CDR2.TransparencySoftwares);
            Assert.AreEqual(CDR1.Tariffs, CDR2.Tariffs);
            Assert.AreEqual(CDR1.SignedData, CDR2.SignedData);
            Assert.AreEqual(CDR1.TotalFixedCosts, CDR2.TotalFixedCosts);
            Assert.AreEqual(CDR1.TotalEnergyCost, CDR2.TotalEnergyCost);
            Assert.AreEqual(CDR1.TotalTimeCost, CDR2.TotalTimeCost);
            Assert.AreEqual(CDR1.TotalParkingTime, CDR2.TotalParkingTime);
            Assert.AreEqual(CDR1.TotalParkingCost, CDR2.TotalParkingCost);
            Assert.AreEqual(CDR1.TotalReservationCost, CDR2.TotalReservationCost);
            Assert.AreEqual(CDR1.Remark, CDR2.Remark);
            Assert.AreEqual(CDR1.InvoiceReferenceId, CDR2.InvoiceReferenceId);
            Assert.AreEqual(CDR1.Credit, CDR2.Credit);
            Assert.AreEqual(CDR1.CreditReferenceId, CDR2.CreditReferenceId);

            Assert.AreEqual(CDR1.LastUpdated.ToIso8601(), CDR2.LastUpdated.ToIso8601());
        }
Esempio n. 23
0
 public double[] getMACD(TimeFrame timeFrame, PriceComponent priceComponent, int fastPeriod, int slowPeriod, int signalPeriod)
 {
     return getMACD(timeFrame, priceComponent, fastPeriod, slowPeriod, signalPeriod, 0);
 }
Esempio n. 24
0
 public double getLast(TimeFrame timeFrame, PriceComponent priceComponent, int offset)
 {
     List<double> ld = getList(timeFrame, priceComponent);
     if (offset > 0)
     {
         ld = getCopy(ld);
         ld.RemoveRange(ld.Count - offset, offset);
     }
     return ld.Last();
 }
Esempio n. 25
0
 public double getLast(string pair, TimeFrame timeFrame, PriceComponent priceComponent)
 {
     return AccumMgr.getAccum(pair, timeFrame, priceComponent).getLast();
 }
Esempio n. 26
0
 public double getSMA(TimeFrame timeFrame, PriceComponent priceComponent, int periods)
 {
     return getSMA(timeFrame, priceComponent, periods, 0);
 }
Esempio n. 27
0
 public List<double> getMACDasList(TimeFrame timeFrame, PriceComponent priceComponent, int fastPeriod, int slowPeriod, int signalPeriod)
 {
     double[] ad = getMACD(timeFrame, priceComponent, fastPeriod, slowPeriod, signalPeriod, 0);
     List<double> ld = new List<double>(ad);
     return ld;
 }
Esempio n. 28
0
 public Discount5WhenSpending20(PriceComponent component) : base(component)
 {
 }
Esempio n. 29
0
 public PriceDecorator(PriceComponent component)
 {
     this.component = component;
 }
Esempio n. 30
0
 public double getSMA(TimeFrame timeFrame, PriceComponent priceComponent, int periods, int offset)
 {
     if (!isEnoughData(timeFrame, priceComponent, periods + offset))
         return 0.0;
     List<double> ld = getAdjustedList(timeFrame, priceComponent, offset);
     return getSMA(periods, ld);
 }
Esempio n. 31
0
        public void AppsOnDerivePrices(IDerivation derivation, decimal quantityInvoiced, decimal totalBasePrice)
        {
            this.UnitBasePrice       = 0;
            this.UnitDiscount        = 0;
            this.UnitSurcharge       = 0;
            this.CalculatedUnitPrice = 0;
            decimal discountAdjustmentAmount  = 0;
            decimal surchargeAdjustmentAmount = 0;

            var internalOrganisation = this.Strategy.Session.GetSingleton();
            var customer             = this.SalesInvoiceWhereSalesInvoiceItem.BillToCustomer;
            var salesInvoice         = this.SalesInvoiceWhereSalesInvoiceItem;

            var baseprices = new PriceComponent[0];

            if (this.ExistProduct && this.Product.ExistBasePrices)
            {
                baseprices = this.Product.BasePrices;
            }

            if (this.ExistProductFeature && this.ProductFeature.ExistBasePrices)
            {
                baseprices = this.ProductFeature.BasePrices;
            }

            foreach (BasePrice priceComponent in baseprices)
            {
                if (priceComponent.FromDate <= this.SalesInvoiceWhereSalesInvoiceItem.InvoiceDate &&
                    (!priceComponent.ExistThroughDate || priceComponent.ThroughDate >= this.SalesInvoiceWhereSalesInvoiceItem.InvoiceDate))
                {
                    if (priceComponent.Strategy.Class.Equals(M.BasePrice.ObjectType))
                    {
                        if (PriceComponents.AppsIsEligible(new PriceComponents.IsEligibleParams
                        {
                            PriceComponent = priceComponent,
                            Customer = customer,
                            Product = this.Product,
                            SalesInvoice = salesInvoice,
                            QuantityOrdered = quantityInvoiced,
                            ValueOrdered = totalBasePrice
                        }))
                        {
                            if (priceComponent.ExistPrice)
                            {
                                if (priceComponent.Price.HasValue && (this.UnitBasePrice == 0 || priceComponent.Price < this.UnitBasePrice))
                                {
                                    this.UnitBasePrice = priceComponent.Price.Value;

                                    this.RemoveCurrentPriceComponents();
                                    this.AddCurrentPriceComponent(priceComponent);
                                }
                            }
                        }
                    }
                }
            }

            if (!this.ExistActualUnitPrice)
            {
                var priceComponents = this.GetPriceComponents();

                var revenueBreakDiscount  = 0M;
                var revenueBreakSurcharge = 0M;

                foreach (var priceComponent in priceComponents)
                {
                    if (priceComponent.Strategy.Class.Equals(M.DiscountComponent.ObjectType) || priceComponent.Strategy.Class.Equals(M.SurchargeComponent.ObjectType))
                    {
                        if (PriceComponents.AppsIsEligible(new PriceComponents.IsEligibleParams
                        {
                            PriceComponent = priceComponent,
                            Customer = customer,
                            Product = this.Product,
                            SalesInvoice = salesInvoice,
                            QuantityOrdered = quantityInvoiced,
                            ValueOrdered = totalBasePrice,
                        }))
                        {
                            this.AddCurrentPriceComponent(priceComponent);

                            revenueBreakDiscount  = this.SetUnitDiscount(priceComponent, revenueBreakDiscount);
                            revenueBreakSurcharge = this.SetUnitSurcharge(priceComponent, revenueBreakSurcharge);
                        }
                    }
                }

                var adjustmentBase = this.UnitBasePrice - this.UnitDiscount + this.UnitSurcharge;

                if (this.ExistDiscountAdjustment)
                {
                    if (this.DiscountAdjustment.Percentage.HasValue)
                    {
                        discountAdjustmentAmount = Math.Round((adjustmentBase * this.DiscountAdjustment.Percentage.Value) / 100, 2);
                    }
                    else
                    {
                        discountAdjustmentAmount = this.DiscountAdjustment.Amount.HasValue ? this.DiscountAdjustment.Amount.Value : 0;
                    }

                    this.UnitDiscount += discountAdjustmentAmount;
                }

                if (this.ExistSurchargeAdjustment)
                {
                    if (this.SurchargeAdjustment.Percentage.HasValue)
                    {
                        surchargeAdjustmentAmount = Math.Round((adjustmentBase * this.SurchargeAdjustment.Percentage.Value) / 100, 2);
                    }
                    else
                    {
                        surchargeAdjustmentAmount = this.SurchargeAdjustment.Amount.HasValue ? this.SurchargeAdjustment.Amount.Value : 0;
                    }

                    this.UnitSurcharge += surchargeAdjustmentAmount;
                }
            }

            var price = this.ActualUnitPrice.HasValue ? this.ActualUnitPrice.Value : this.UnitBasePrice;

            decimal vat = 0;

            if (this.ExistDerivedVatRate)
            {
                var vatRate = this.DerivedVatRate.Rate;
                var vatBase = price - this.UnitDiscount + this.UnitSurcharge;
                vat = Math.Round((vatBase * vatRate) / 100, 2);
            }

            this.UnitVat                = vat;
            this.TotalBasePrice         = price * this.Quantity;
            this.TotalDiscount          = this.UnitDiscount * this.Quantity;
            this.TotalSurcharge         = this.UnitSurcharge * this.Quantity;
            this.TotalInvoiceAdjustment = (0 - discountAdjustmentAmount + surchargeAdjustmentAmount) * this.Quantity;

            if (this.TotalBasePrice > 0)
            {
                this.TotalDiscountAsPercentage  = Math.Round((this.TotalDiscount / this.TotalBasePrice) * 100, 2);
                this.TotalSurchargeAsPercentage = Math.Round((this.TotalSurcharge / this.TotalBasePrice) * 100, 2);
            }

            if (this.ActualUnitPrice.HasValue)
            {
                this.CalculatedUnitPrice = this.ActualUnitPrice.Value;
            }
            else
            {
                this.CalculatedUnitPrice = this.UnitBasePrice - this.UnitDiscount + this.UnitSurcharge;
            }

            this.TotalVat    = this.UnitVat * this.Quantity;
            this.TotalExVat  = this.CalculatedUnitPrice * this.Quantity;
            this.TotalIncVat = this.TotalExVat + this.TotalVat;

            var toCurrency   = this.SalesInvoiceWhereSalesInvoiceItem.Currency;
            var fromCurrency = this.SalesInvoiceWhereSalesInvoiceItem.BilledFrom.PreferredCurrency;

            if (fromCurrency.Equals(toCurrency))
            {
                this.TotalBasePriceCustomerCurrency = this.TotalBasePrice;
                this.TotalDiscountCustomerCurrency  = this.TotalDiscount;
                this.TotalSurchargeCustomerCurrency = this.TotalSurcharge;
                this.TotalExVatCustomerCurrency     = this.TotalExVat;
                this.TotalVatCustomerCurrency       = this.TotalVat;
                this.TotalIncVatCustomerCurrency    = this.TotalIncVat;
            }
            else
            {
                this.TotalBasePriceCustomerCurrency = Currencies.ConvertCurrency(this.TotalBasePrice, fromCurrency, toCurrency);
                this.TotalDiscountCustomerCurrency  = Currencies.ConvertCurrency(this.TotalDiscount, fromCurrency, toCurrency);
                this.TotalSurchargeCustomerCurrency = Currencies.ConvertCurrency(this.TotalSurcharge, fromCurrency, toCurrency);
                this.TotalExVatCustomerCurrency     = Currencies.ConvertCurrency(this.TotalExVat, fromCurrency, toCurrency);
                this.TotalVatCustomerCurrency       = Currencies.ConvertCurrency(this.TotalVat, fromCurrency, toCurrency);
                this.TotalIncVatCustomerCurrency    = Currencies.ConvertCurrency(this.TotalIncVat, fromCurrency, toCurrency);
            }

            this.AppsOnDeriveMarkupAndProfitMargin(derivation);
        }
Esempio n. 32
0
 public double[] getStoch(TimeFrame timeFrame, PriceComponent priceComponentHi, PriceComponent priceComponentLow, PriceComponent priceComponentClose, int periods)
 {
     return getStoch(timeFrame, priceComponentHi, priceComponentLow, priceComponentClose, periods, 0);
 }
Esempio n. 33
0
 public double[] getStoch(TimeFrame timeFrame, PriceComponent priceComponentClose, int periods, int offset)
 {
     if (priceComponentClose == PriceComponent.BidClose)
         return getStoch(timeFrame, PriceComponent.BidHigh, PriceComponent.BidLow, priceComponentClose, periods, offset);
     else if (priceComponentClose == PriceComponent.AskClose)
         return getStoch(timeFrame, PriceComponent.AskHigh, PriceComponent.AskLow, priceComponentClose, periods, offset);
     else throw new Exception("Bad params in getADX");
 }
Esempio n. 34
0
 public double getSMATrend(TimeFrame timeFrame, PriceComponent priceComponent, int periods)
 {
     return 0.0;
 }
Esempio n. 35
0
 public double getADX(TimeFrame timeFrame, PriceComponent priceComponentClose, int periods)
 {
     return getADX(timeFrame, priceComponentClose, periods, 0);
 }
Esempio n. 36
0
 public IAccumulator getAccum(string pair, TimeFrame timeFrame, PriceComponent priceComponent)
 {
     return pairTimePriceMap[pair][timeFrame][priceComponent];
 }
Esempio n. 37
0
 public HolidayDiscount(PriceComponent component) : base(component)
 {
 }
Esempio n. 38
0
        private static decimal AppsCatalogPrice(
            SalesOrder salesOrder,
            SalesInvoice salesInvoice,
            Product product,
            DateTime date)
        {
            var productBasePrice = 0M;
            var productDiscount  = 0M;
            var productSurcharge = 0M;

            var baseprices = new PriceComponent[0];

            if (product.ExistBasePrices)
            {
                baseprices = product.BasePrices;
            }

            var party = salesOrder != null ? salesOrder.ShipToCustomer : salesInvoice != null ? salesInvoice.BillToCustomer : null;

            foreach (BasePrice priceComponent in baseprices)
            {
                if (priceComponent.FromDate <= date &&
                    (!priceComponent.ExistThroughDate || priceComponent.ThroughDate >= date))
                {
                    if (PriceComponents.AppsIsEligible(new PriceComponents.IsEligibleParams
                    {
                        PriceComponent = priceComponent,
                        Customer = party,
                        Product = product,
                        SalesOrder = salesOrder,
                        SalesInvoice = salesInvoice,
                    }))
                    {
                        if (priceComponent.ExistPrice)
                        {
                            if (productBasePrice == 0 || priceComponent.Price < productBasePrice)
                            {
                                productBasePrice = priceComponent.Price ?? 0;
                            }
                        }
                    }
                }
            }

            var priceComponents = GetPriceComponents(product, date);

            var revenueBreakDiscount  = 0M;
            var revenueBreakSurcharge = 0M;

            foreach (var priceComponent in priceComponents)
            {
                if (priceComponent.Strategy.Class.Equals(M.DiscountComponent.ObjectType) || priceComponent.Strategy.Class.Equals(M.SurchargeComponent.ObjectType))
                {
                    if (PriceComponents.AppsIsEligible(new PriceComponents.IsEligibleParams
                    {
                        PriceComponent = priceComponent,
                        Customer = party,
                        Product = product,
                        SalesOrder = salesOrder,
                        SalesInvoice = salesInvoice,
                    }))
                    {
                        if (priceComponent.Strategy.Class.Equals(M.DiscountComponent.ObjectType))
                        {
                            var     discountComponent = (DiscountComponent)priceComponent;
                            decimal discount;

                            if (discountComponent.Price.HasValue)
                            {
                                discount         = discountComponent.Price.Value;
                                productDiscount += discount;
                            }
                            else
                            {
                                var percentage = discountComponent.Percentage.HasValue ? discountComponent.Percentage.Value : 0;
                                discount         = Math.Round((productBasePrice * percentage) / 100, 2);
                                productDiscount += discount;
                            }
                        }

                        if (priceComponent.Strategy.Class.Equals(M.SurchargeComponent.ObjectType))
                        {
                            var     surchargeComponent = (SurchargeComponent)priceComponent;
                            decimal surcharge;

                            if (surchargeComponent.Price.HasValue)
                            {
                                surcharge         = surchargeComponent.Price.Value;
                                productSurcharge += surcharge;
                            }
                            else
                            {
                                var percentage = surchargeComponent.Percentage.HasValue ? surchargeComponent.Percentage.Value : 0;
                                surcharge         = Math.Round((productBasePrice * percentage) / 100, 2);
                                productSurcharge += surcharge;
                            }
                        }
                    }
                }
            }

            return(productBasePrice - productDiscount + productSurcharge);
        }
Esempio n. 39
0
        public static void Tariff0004()
        {
            var tariff = new Tariff(Tariff_Id.Parse("11"),
                                    Currency.EUR,
                                    TariffUrl:      new Uri("https://company.com/tariffs/11"),
                                    TariffElements: new List <TariffElement>()
            {
                // 2.50 euro start tariff
                new TariffElement(
                    PriceComponent.FlatRate(2.50M)
                    ),

                // 1.00 euro per hour charging tariff for less than 32A (paid per 15 minutes)
                new TariffElement(
                    PriceComponent.ChargingTime(1.00M, TimeSpan.FromSeconds(900)),
                    TariffRestriction.MaxPower(32M)
                    ),

                // 2.00 euro per hour charging tariff for more than 32A on weekdays (paid per 10 minutes)
                new TariffElement(
                    PriceComponent.ChargingTime(2.00M, TimeSpan.FromSeconds(600)),
                    new TariffRestriction(Power:      DecimalMinMax.FromMin(32M),
                                          DayOfWeek:  Enumeration.Create(
                                              DayOfWeek.Monday,
                                              DayOfWeek.Tuesday,
                                              DayOfWeek.Wednesday,
                                              DayOfWeek.Thursday,
                                              DayOfWeek.Friday
                                              ))
                    ),

                // 1.25 euro per hour charging tariff for more then 32A during the weekend (paid per 10 minutes)
                new TariffElement(
                    PriceComponent.ChargingTime(1.25M, TimeSpan.FromSeconds(600)),
                    new TariffRestriction(Power:      DecimalMinMax.FromMin(32M),
                                          DayOfWeek:  Enumeration.Create(
                                              DayOfWeek.Saturday,
                                              DayOfWeek.Sunday
                                              ))
                    ),


                // Parking on weekdays: between 09:00 and 18:00: 5 euro(paid per 5 minutes)
                new TariffElement(
                    PriceComponent.ParkingTime(5M, TimeSpan.FromSeconds(300)),
                    new TariffRestriction(Time:       TimeRange.From(9).To(18),
                                          DayOfWeek:  Enumeration.Create(
                                              DayOfWeek.Monday,
                                              DayOfWeek.Tuesday,
                                              DayOfWeek.Wednesday,
                                              DayOfWeek.Thursday,
                                              DayOfWeek.Friday
                                              ))
                    ),

                // Parking on saturday: between 10:00 and 17:00: 6 euro (paid per 5 minutes)
                new TariffElement(
                    PriceComponent.ParkingTime(6M, TimeSpan.FromSeconds(300)),
                    new TariffRestriction(Time:       TimeRange.From(10).To(17),
                                          DayOfWeek:  new DayOfWeek[] {
                    DayOfWeek.Saturday
                })
                    )
            }
                                    );

            var expected = new JObject(new JProperty("id", "11"),
                                       new JProperty("currency", "EUR"),
                                       new JProperty("tariff_alt_url", "https://company.com/tariffs/11"),
                                       new JProperty("elements", new JArray(

                                                         // 2.50 euro start tariff
                                                         new JObject(
                                                             new JProperty("price_components", new JArray(
                                                                               new JObject(
                                                                                   new JProperty("type", "FLAT"),
                                                                                   new JProperty("price", "2.50"),
                                                                                   new JProperty("step_size", 1)
                                                                                   )))
                                                             ),


                                                         // 1.00 euro per hour charging tariff for less than 32A (paid per 15 minutes)
                                                         new JObject(
                                                             new JProperty("price_components", new JArray(
                                                                               new JObject(
                                                                                   new JProperty("type", "TIME"),
                                                                                   new JProperty("price", "1.00"),
                                                                                   new JProperty("step_size", 900)
                                                                                   ))),
                                                             new JProperty("restrictions", new JArray(
                                                                               new JObject(
                                                                                   new JProperty("max_power", "32.00")
                                                                                   )
                                                                               ))
                                                             ),

                                                         // 2.00 euro per hour charging tariff for more than 32A on weekdays (paid per 10 minutes)
                                                         new JObject(
                                                             new JProperty("price_components", new JArray(
                                                                               new JObject(
                                                                                   new JProperty("type", "TIME"),
                                                                                   new JProperty("price", "2.00"),
                                                                                   new JProperty("step_size", 600)
                                                                                   ))),
                                                             new JProperty("restrictions", new JArray(
                                                                               new JObject(
                                                                                   new JProperty("min_power", "32.00"),
                                                                                   new JProperty("day_of_week", new JArray("MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY"))
                                                                                   )
                                                                               ))
                                                             ),

                                                         // 1.25 euro per hour charging tariff for more then 32A during the weekend (paid per 10 minutes)
                                                         new JObject(
                                                             new JProperty("price_components", new JArray(
                                                                               new JObject(
                                                                                   new JProperty("type", "TIME"),
                                                                                   new JProperty("price", "1.25"),
                                                                                   new JProperty("step_size", 600)
                                                                                   ))),
                                                             new JProperty("restrictions", new JArray(
                                                                               new JObject(
                                                                                   new JProperty("min_power", "32.00"),
                                                                                   new JProperty("day_of_week", new JArray("SATURDAY", "SUNDAY"))
                                                                                   )
                                                                               ))
                                                             ),

                                                         // Parking on weekdays: between 09:00 and 18:00: 5 euro(paid per 5 minutes)
                                                         new JObject(
                                                             new JProperty("price_components", new JArray(
                                                                               new JObject(
                                                                                   new JProperty("type", "PARKING_TIME"),
                                                                                   new JProperty("price", "5.00"),
                                                                                   new JProperty("step_size", 300)
                                                                                   ))),
                                                             new JProperty("restrictions", new JArray(
                                                                               new JObject(
                                                                                   new JProperty("start_time", "09:00"),
                                                                                   new JProperty("end_time", "18:00"),
                                                                                   new JProperty("day_of_week", new JArray("MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY"))
                                                                                   )
                                                                               ))
                                                             ),

                                                         // Parking on saturday: between 10:00 and 17:00: 6 euro (paid per 5 minutes)
                                                         new JObject(
                                                             new JProperty("price_components", new JArray(
                                                                               new JObject(
                                                                                   new JProperty("type", "PARKING_TIME"),
                                                                                   new JProperty("price", "6.00"),
                                                                                   new JProperty("step_size", 300)
                                                                                   ))),
                                                             new JProperty("restrictions", new JArray(
                                                                               new JObject(
                                                                                   new JProperty("start_time", "10:00"),
                                                                                   new JProperty("end_time", "17:00"),
                                                                                   new JProperty("day_of_week", new JArray("SATURDAY"))
                                                                                   )
                                                                               ))
                                                             )

                                                         )));

            Assert.AreEqual(expected.ToString(), tariff.ToJSON().ToString());
        }
Esempio n. 40
0
 public List<double> getList(TimeFrame timeFrame, PriceComponent priceComponent)
 {
     return Factory.FxUpdates.AccumMgr.getAccum(pair, timeFrame, priceComponent).getList();
 }
Esempio n. 41
0
        public static void Tariff_SerializeDeserialize_Test01()
        {
            var TariffA = new Tariff(
                CountryCode.Parse("DE"),
                Party_Id.Parse("GEF"),
                Tariff_Id.Parse("TARIFF0001"),
                Currency.EUR,
                new TariffElement[] {
                new TariffElement(
                    new PriceComponent[] {
                    PriceComponent.ChargingTime(
                        TimeSpan.FromSeconds(300),
                        2.00M,
                        0.10M
                        )
                },
                    new TariffRestrictions [] {
                    new TariffRestrictions(
                        Time.FromHourMin(08, 00),                            // Start time
                        Time.FromHourMin(18, 00),                            // End time
                        DateTime.Parse("2020-12-01"),                        // Start timestamp
                        DateTime.Parse("2020-12-31"),                        // End timestamp
                        1.12M,                                               // MinkWh
                        5.67M,                                               // MaxkWh
                        1.34M,                                               // MinCurrent
                        8.89M,                                               // MaxCurrent
                        1.49M,                                               // MinPower
                        9.91M,                                               // MaxPower
                        TimeSpan.FromMinutes(10),                            // MinDuration
                        TimeSpan.FromMinutes(30),                            // MaxDuration
                        new DayOfWeek[] {
                        DayOfWeek.Monday,
                        DayOfWeek.Tuesday
                    },
                        ReservationRestrictionTypes.RESERVATION
                        )
                }
                    )
            },
                TariffTypes.PROFILE_GREEN,
                new DisplayText[] {
                new DisplayText(Languages.de, "Hallo Welt!"),
                new DisplayText(Languages.en, "Hello world!"),
            },
                URL.Parse("https://open.charging.cloud"),
                new Price(               // Min Price
                    1.10,
                    1.26
                    ),
                new Price(               // Max Price
                    2.20,
                    2.52
                    ),
                DateTime.Parse("2020-12-01"),               // Start timestamp
                DateTime.Parse("2020-12-31"),               // End timestamp
                new EnergyMix(
                    true,
                    new EnergySource[] {
                new EnergySource(
                    EnergySourceCategories.SOLAR,
                    80
                    ),
                new EnergySource(
                    EnergySourceCategories.WIND,
                    20
                    )
            },
                    new EnvironmentalImpact[] {
                new EnvironmentalImpact(
                    EnvironmentalImpactCategories.CARBON_DIOXIDE,
                    0.1
                    )
            },
                    "Stadtwerke Jena-Ost",
                    "New Green Deal"
                    ),
                DateTime.Parse("2020-09-22")
                );

            var JSON = TariffA.ToJSON();

            Assert.AreEqual("DE", JSON["country_code"].Value <String>());
            Assert.AreEqual("GEF", JSON["party_id"].Value <String>());
            Assert.AreEqual("TARIFF0001", JSON["id"].Value <String>());

            Assert.IsTrue(Tariff.TryParse(JSON, out Tariff TariffB, out String ErrorResponse));
            Assert.IsNull(ErrorResponse);

            Assert.AreEqual(TariffA.CountryCode, TariffB.CountryCode);
            Assert.AreEqual(TariffA.PartyId, TariffB.PartyId);
            Assert.AreEqual(TariffA.Id, TariffB.Id);
            Assert.AreEqual(TariffA.Currency, TariffB.Currency);
            Assert.AreEqual(TariffA.TariffElements, TariffB.TariffElements);

            Assert.AreEqual(TariffA.TariffType, TariffB.TariffType);
            Assert.AreEqual(TariffA.TariffAltText, TariffB.TariffAltText);
            Assert.AreEqual(TariffA.TariffAltURL, TariffB.TariffAltURL);
            Assert.AreEqual(TariffA.MinPrice, TariffB.MinPrice);
            Assert.AreEqual(TariffA.MaxPrice, TariffB.MaxPrice);
            Assert.AreEqual(TariffA.Start, TariffB.Start);
            Assert.AreEqual(TariffA.End, TariffB.End);
            Assert.AreEqual(TariffA.EnergyMix, TariffB.EnergyMix);

            Assert.AreEqual(TariffA.LastUpdated.ToIso8601(), TariffB.LastUpdated.ToIso8601());
        }
Esempio n. 42
0
 public double[] getMACD(TimeFrame timeFrame, PriceComponent priceComponent, int fastPeriod, int slowPeriod, int signalPeriod, int offset)
 {
     if (!isEnoughData(timeFrame, priceComponent, fastPeriod + offset))
         return new double[] { 0.0, 0.0, 0.0 };
     List<double> ld = getAdjustedList(timeFrame, priceComponent, offset);
     return getMACD(fastPeriod, slowPeriod, signalPeriod, ld);
 }
Esempio n. 43
0
 public void create(string pair, TimeFrame timeFrame, PriceComponent priceComponent)
 {
     if (!pairTimePriceMap.ContainsKey(pair))
     {
         Dictionary<TimeFrame, Dictionary<PriceComponent, Accumulator>> m
             = new Dictionary<TimeFrame, Dictionary<PriceComponent, Accumulator>>();
         pairTimePriceMap.Add(pair, m);
     }
     if (!pairTimePriceMap[pair].ContainsKey(timeFrame))
     {
         pairTimePriceMap[pair].Add(timeFrame, new Dictionary<PriceComponent, Accumulator>());
     }
     Dictionary<PriceComponent, Accumulator> mp = pairTimePriceMap[pair][timeFrame];
     if (!mp.ContainsKey(priceComponent))
     {
         mp.Add(priceComponent, new Accumulator());
     }
 }
Esempio n. 44
0
        private static decimal BaseCatalogPrice(
            SalesOrder salesOrder,
            SalesInvoice salesInvoice,
            Product product,
            DateTime date)
        {
            var productBasePrice = 0M;
            var productDiscount  = 0M;
            var productSurcharge = 0M;

            var baseprices = new PriceComponent[0];

            if (product.ExistBasePrices)
            {
                baseprices = product.BasePrices;
            }

            var party = salesOrder != null ? salesOrder.ShipToCustomer : salesInvoice?.BillToCustomer;

            foreach (BasePrice priceComponent in baseprices)
            {
                if (priceComponent.FromDate <= date &&
                    (!priceComponent.ExistThroughDate || priceComponent.ThroughDate >= date))
                {
                    if (PriceComponents.BaseIsApplicable(new PriceComponents.IsApplicable
                    {
                        PriceComponent = priceComponent,
                        Customer = party,
                        Product = product,
                        SalesOrder = salesOrder,
                        SalesInvoice = salesInvoice,
                    }))
                    {
                        if (priceComponent.ExistPrice)
                        {
                            if (productBasePrice == 0 || priceComponent.Price < productBasePrice)
                            {
                                productBasePrice = priceComponent.Price ?? 0;
                            }
                        }
                    }
                }
            }

            var currentPriceComponents = new PriceComponents(product.Strategy.Session).CurrentPriceComponents(date);
            var priceComponents        = product.GetPriceComponents(currentPriceComponents);

            foreach (var priceComponent in priceComponents)
            {
                if (priceComponent.Strategy.Class.Equals(M.DiscountComponent.ObjectType) || priceComponent.Strategy.Class.Equals(M.SurchargeComponent.ObjectType))
                {
                    if (PriceComponents.BaseIsApplicable(new PriceComponents.IsApplicable
                    {
                        PriceComponent = priceComponent,
                        Customer = party,
                        Product = product,
                        SalesOrder = salesOrder,
                        SalesInvoice = salesInvoice,
                    }))
                    {
                        if (priceComponent.Strategy.Class.Equals(M.DiscountComponent.ObjectType))
                        {
                            var     discountComponent = (DiscountComponent)priceComponent;
                            decimal discount;

                            if (discountComponent.Price.HasValue)
                            {
                                discount         = discountComponent.Price.Value;
                                productDiscount += discount;
                            }
                            else
                            {
                                var percentage = discountComponent.Percentage ?? 0;
                                discount         = Rounder.RoundDecimal(productBasePrice * percentage / 100, 2);
                                productDiscount += discount;
                            }
                        }

                        if (priceComponent.Strategy.Class.Equals(M.SurchargeComponent.ObjectType))
                        {
                            var     surchargeComponent = (SurchargeComponent)priceComponent;
                            decimal surcharge;

                            if (surchargeComponent.Price.HasValue)
                            {
                                surcharge         = surchargeComponent.Price.Value;
                                productSurcharge += surcharge;
                            }
                            else
                            {
                                var percentage = surchargeComponent.Percentage ?? 0;
                                surcharge         = Rounder.RoundDecimal(productBasePrice * percentage / 100, 2);
                                productSurcharge += surcharge;
                            }
                        }
                    }
                }
            }

            return(productBasePrice - productDiscount + productSurcharge);
        }
Esempio n. 45
0
        public void AppsOnDerivePrices(IDerivation derivation, decimal quantityInvoiced, decimal totalBasePrice)
        {
            this.UnitBasePrice = 0;
            this.UnitDiscount = 0;
            this.UnitSurcharge = 0;
            this.CalculatedUnitPrice = 0;
            decimal discountAdjustmentAmount = 0;
            decimal surchargeAdjustmentAmount = 0;

            var internalOrganisation = this.SalesInvoiceWhereSalesInvoiceItem.BilledFromInternalOrganisation;
            var customer = this.SalesInvoiceWhereSalesInvoiceItem.BillToCustomer;
            var salesInvoice = this.SalesInvoiceWhereSalesInvoiceItem;

            var baseprices = new PriceComponent[0];
            if (this.ExistProduct && this.Product.ExistBasePrices)
            {
                baseprices = Product.BasePrices;
            }

            if (this.ExistProductFeature && this.ProductFeature.ExistBasePrices)
            {
                baseprices = ProductFeature.BasePrices;
            }

            foreach (BasePrice priceComponent in baseprices)
            {
                if (priceComponent.FromDate <= this.SalesInvoiceWhereSalesInvoiceItem.InvoiceDate &&
                    (!priceComponent.ExistThroughDate || priceComponent.ThroughDate >= this.SalesInvoiceWhereSalesInvoiceItem.InvoiceDate))
                {
                    if (priceComponent.Strategy.Class.Equals(M.BasePrice.ObjectType))
                    {
                        if (PriceComponents.AppsIsEligible(new PriceComponents.IsEligibleParams
                                                               {
                                                                   PriceComponent = priceComponent,
                                                                   Customer = customer,
                                                                   Product = this.Product,
                                                                   SalesInvoice = salesInvoice,
                                                                   QuantityOrdered = quantityInvoiced,
                                                                   ValueOrdered = totalBasePrice
                                                               }))
                        {
                            if (priceComponent.ExistPrice)
                            {
                                if (priceComponent.Price.HasValue && (this.UnitBasePrice == 0 || priceComponent.Price < this.UnitBasePrice))
                                {
                                    this.UnitBasePrice = priceComponent.Price.Value;

                                    this.RemoveCurrentPriceComponents();
                                    this.AddCurrentPriceComponent(priceComponent);
                                }
                            }
                        }
                    }
                }
            }

            if (!this.ExistActualUnitPrice)
            {
                var partyRevenueHistories = customer.PartyRevenueHistoriesWhereParty;
                partyRevenueHistories.Filter.AddEquals(M.PartyRevenueHistory.InternalOrganisation, internalOrganisation);
                var partyRevenueHistory = partyRevenueHistories.First;

                var partyProductCategoryRevenueHistoryByProductCategory = PartyProductCategoryRevenueHistories.PartyProductCategoryRevenueHistoryByProductCategory(internalOrganisation, customer);

                var partyPackageRevenuesHistories = customer.PartyPackageRevenueHistoriesWhereParty;
                partyPackageRevenuesHistories.Filter.AddEquals(M.PartyPackageRevenueHistory.InternalOrganisation, internalOrganisation);

                var priceComponents = this.GetPriceComponents(internalOrganisation);

                var revenueBreakDiscount = 0M;
                var revenueBreakSurcharge = 0M;

                foreach (var priceComponent in priceComponents)
                {
                    if (priceComponent.Strategy.Class.Equals(M.DiscountComponent.ObjectType) || priceComponent.Strategy.Class.Equals(M.SurchargeComponent.ObjectType))
                    {
                        if (PriceComponents.AppsIsEligible(new PriceComponents.IsEligibleParams
                                                               {
                                                                   PriceComponent = priceComponent,
                                                                   Customer = customer,
                                                                   Product = this.Product,
                                                                   SalesInvoice = salesInvoice,
                                                                   QuantityOrdered = quantityInvoiced,
                                                                   ValueOrdered = totalBasePrice,
                                                                   PartyPackageRevenueHistoryList = partyPackageRevenuesHistories,
                                                                   PartyRevenueHistory = partyRevenueHistory,
                                                                   PartyProductCategoryRevenueHistoryByProductCategory = partyProductCategoryRevenueHistoryByProductCategory
                                                               }))
                        {
                            this.AddCurrentPriceComponent(priceComponent);

                            revenueBreakDiscount = this.SetUnitDiscount(priceComponent, revenueBreakDiscount);
                            revenueBreakSurcharge = this.SetUnitSurcharge(priceComponent, revenueBreakSurcharge);
                        }
                    }
                }

                var adjustmentBase = this.UnitBasePrice - this.UnitDiscount + this.UnitSurcharge;

                if (this.ExistDiscountAdjustment)
                {
                    if (this.DiscountAdjustment.Percentage.HasValue)
                    {
                        discountAdjustmentAmount = decimal.Round((adjustmentBase * this.DiscountAdjustment.Percentage.Value) / 100, 2);
                    }
                    else
                    {
                        discountAdjustmentAmount = this.DiscountAdjustment.Amount.HasValue? this.DiscountAdjustment.Amount.Value : 0;
                    }

                    this.UnitDiscount += discountAdjustmentAmount;
                }

                if (this.ExistSurchargeAdjustment)
                {
                    if (this.SurchargeAdjustment.Percentage.HasValue)
                    {
                        surchargeAdjustmentAmount = decimal.Round((adjustmentBase * this.SurchargeAdjustment.Percentage.Value) / 100, 2);
                    }
                    else
                    {
                        surchargeAdjustmentAmount = this.SurchargeAdjustment.Amount.HasValue ? this.SurchargeAdjustment.Amount.Value : 0;
                    }

                    this.UnitSurcharge += surchargeAdjustmentAmount;
                }
            }

            var price = this.ActualUnitPrice.HasValue ? this.ActualUnitPrice.Value : this.UnitBasePrice;

            decimal vat = 0;
            if (this.ExistDerivedVatRate)
            {
                var vatRate = this.DerivedVatRate.Rate;
                var vatBase = price - this.UnitDiscount + this.UnitSurcharge;
                vat = decimal.Round((vatBase * vatRate) / 100, 2);
            }

            this.UnitVat = vat;
            this.TotalBasePrice = price * this.Quantity;
            this.TotalDiscount = this.UnitDiscount * this.Quantity;
            this.TotalSurcharge = this.UnitSurcharge * this.Quantity;
            this.TotalInvoiceAdjustment = (0 - discountAdjustmentAmount + surchargeAdjustmentAmount) * this.Quantity;

            if (this.TotalBasePrice > 0)
            {
                this.TotalDiscountAsPercentage = decimal.Round((this.TotalDiscount / this.TotalBasePrice) * 100, 2);
                this.TotalSurchargeAsPercentage = decimal.Round((this.TotalSurcharge / this.TotalBasePrice) * 100, 2);
            }

            if (this.ActualUnitPrice.HasValue)
            {
                this.CalculatedUnitPrice = this.ActualUnitPrice.Value;
            }
            else
            {
                this.CalculatedUnitPrice = this.UnitBasePrice - this.UnitDiscount + this.UnitSurcharge;
            }

            this.TotalVat = this.UnitVat * this.Quantity;
            this.TotalExVat = this.CalculatedUnitPrice * this.Quantity;
            this.TotalIncVat = this.TotalExVat + this.TotalVat;

            var toCurrency = this.SalesInvoiceWhereSalesInvoiceItem.CustomerCurrency;
            var fromCurrency = internalOrganisation.PreferredCurrency;

            if (fromCurrency.Equals(toCurrency))
            {
                this.TotalBasePriceCustomerCurrency = this.TotalBasePrice;
                this.TotalDiscountCustomerCurrency = this.TotalDiscount;
                this.TotalSurchargeCustomerCurrency = this.TotalSurcharge;
                this.TotalExVatCustomerCurrency = this.TotalExVat;
                this.TotalVatCustomerCurrency = this.TotalVat;
                this.TotalIncVatCustomerCurrency = this.TotalIncVat;
            }
            else
            {
                this.TotalBasePriceCustomerCurrency = Currencies.ConvertCurrency(this.TotalBasePrice, fromCurrency, toCurrency);
                this.TotalDiscountCustomerCurrency = Currencies.ConvertCurrency(this.TotalDiscount, fromCurrency, toCurrency);
                this.TotalSurchargeCustomerCurrency = Currencies.ConvertCurrency(this.TotalSurcharge, fromCurrency, toCurrency);
                this.TotalExVatCustomerCurrency = Currencies.ConvertCurrency(this.TotalExVat, fromCurrency, toCurrency);
                this.TotalVatCustomerCurrency = Currencies.ConvertCurrency(this.TotalVat, fromCurrency, toCurrency);
                this.TotalIncVatCustomerCurrency = Currencies.ConvertCurrency(this.TotalIncVat, fromCurrency, toCurrency);
            }

            this.AppsOnDeriveMarkupAndProfitMargin(derivation);
        }
Esempio n. 46
0
        private void rollDetail(string pair, int offset, TimeFrame baseTimeFrame, 
            IAccumulator accumHi, IAccumulator accumLo, PriceComponent highComp, PriceComponent lowComp)
        {
            double high = Double.NaN;
            double low = Double.NaN;

            IAccumulator accumHi2 = getAccum(pair, baseTimeFrame, highComp);
            IAccumulator accumLo2 = getAccum(pair, baseTimeFrame, lowComp);

            List<double> ldh = accumHi2.getList();
            if (ldh.Count >= offset)
            {
                List<double> ldh2 = ldh.GetRange(ldh.Count - offset, offset);
                high = ldh2.Max();
            }
            List<double> ldl = accumLo2.getList();
            if (ldl.Count >= offset)
            {
                List<double> ldl2 = ldh.GetRange(ldh.Count - offset, offset);
                low = ldl2.Min();
            }
            if (!Double.IsNaN(high))
                accumHi.addLast(high);
            if (!Double.IsNaN(low))
                accumLo.addLast(low);
        }
Esempio n. 47
0
 public double[] getStoch(TimeFrame timeFrame, PriceComponent priceComponentHi, PriceComponent priceComponentLow, PriceComponent priceComponentClose, int periods, int offset)
 {
     if (!isEnoughData(timeFrame, priceComponentClose, periods + offset))
         return new double[] { 0.0, 0.0 };
     List<double> ldh = getAdjustedList(timeFrame, PriceComponent.BidHigh, offset);
     List<double> ldl = getAdjustedList(timeFrame, PriceComponent.BidLow, offset);
     List<double> ldc = getAdjustedList(timeFrame, PriceComponent.BidClose, offset);
     return getStoch(periods, ldh, ldl, ldc);
 }
Esempio n. 48
0
        private static decimal AppsCatalogPrice(
            SalesOrder salesOrder,
            SalesInvoice salesInvoice,
            Product product,
            DateTime date)
        {
            var productBasePrice = 0M;
            var productDiscount = 0M;
            var productSurcharge = 0M;

            var baseprices = new PriceComponent[0];
            if (product.ExistBasePrices)
            {
                baseprices = product.BasePrices;
            }

            var party = salesOrder != null ? salesOrder.ShipToCustomer : salesInvoice != null ? salesInvoice.BillToCustomer : null;
            var internalOrganisation = salesOrder != null ? salesOrder.TakenByInternalOrganisation : salesInvoice != null ? salesInvoice.BilledFromInternalOrganisation : null;

            foreach (BasePrice priceComponent in baseprices)
            {
                if (priceComponent.FromDate <= date &&
                    (!priceComponent.ExistThroughDate || priceComponent.ThroughDate >= date))
                {
                    if (PriceComponents.AppsIsEligible(new PriceComponents.IsEligibleParams
                                                           {
                                                               PriceComponent = priceComponent,
                                                               Customer = party,
                                                               Product = product,
                                                               SalesOrder = salesOrder,
                                                               SalesInvoice = salesInvoice,
                                                           }))
                    {
                        if (priceComponent.ExistPrice)
                        {
                            if (productBasePrice == 0 || priceComponent.Price < productBasePrice)
                            {
                                productBasePrice = priceComponent.Price;
                            }
                        }
                    }
                }
            }

            var partyRevenueHistories = party.PartyRevenueHistoriesWhereParty;
            partyRevenueHistories.Filter.AddEquals(PartyRevenueHistories.Meta.InternalOrganisation, internalOrganisation);
            var partyRevenueHistory = partyRevenueHistories.First;

            var partyProductCategoryRevenueHistoryByProductCategory = PartyProductCategoryRevenueHistories.PartyProductCategoryRevenueHistoryByProductCategory(internalOrganisation, party);

            var partyPackageRevenuesHistories = party.PartyPackageRevenueHistoriesWhereParty;
            partyPackageRevenuesHistories.Filter.AddEquals(PartyPackageRevenueHistories.Meta.InternalOrganisation, internalOrganisation);

            var priceComponents = GetPriceComponents(internalOrganisation, product, date);

            var revenueBreakDiscount = 0M;
            var revenueBreakSurcharge = 0M;

            foreach (var priceComponent in priceComponents)
            {
                if (priceComponent.Strategy.Class.Equals(DiscountComponents.Meta.ObjectType) || priceComponent.Strategy.Class.Equals(SurchargeComponents.Meta.ObjectType))
                {
                    if (PriceComponents.AppsIsEligible(new PriceComponents.IsEligibleParams
                                                           {
                                                               PriceComponent = priceComponent,
                                                               Customer = party,
                                                               Product = product,
                                                               SalesOrder = salesOrder,
                                                               SalesInvoice = salesInvoice,
                                                               PartyPackageRevenueHistoryList = partyPackageRevenuesHistories,
                                                               PartyRevenueHistory = partyRevenueHistory,
                                                               PartyProductCategoryRevenueHistoryByProductCategory = partyProductCategoryRevenueHistoryByProductCategory,
                                                           }))
                    {
                        if (priceComponent.Strategy.Class.Equals(DiscountComponents.Meta.ObjectType))
                        {
                            var discountComponent = (DiscountComponent)priceComponent;
                            decimal discount;

                            if (discountComponent.Price.HasValue)
                            {
                                discount = discountComponent.Price.Value;
                                productDiscount += discount;
                            }
                            else
                            {
                                var percentage = discountComponent.Percentage.HasValue ? discountComponent.Percentage.Value : 0;
                                discount = decimal.Round(((productBasePrice * percentage) / 100), 2);
                                productDiscount += discount;
                            }

                            ////Revenuebreaks on quantity and value are mutually exclusive.
                            if (priceComponent.ExistRevenueQuantityBreak || priceComponent.ExistRevenueValueBreak)
                            {
                                if (revenueBreakDiscount == 0)
                                {
                                    revenueBreakDiscount = discount;
                                }
                                else
                                {
                                    ////Apply highest of the two. Revert the other one.
                                    if (discount > revenueBreakDiscount)
                                    {
                                        productDiscount -= revenueBreakDiscount;
                                    }
                                    else
                                    {
                                        productDiscount -= discount;
                                    }
                                }
                            }
                        }

                        if (priceComponent.Strategy.Class.Equals(SurchargeComponents.Meta.ObjectType))
                        {
                            var surchargeComponent = (SurchargeComponent)priceComponent;
                            decimal surcharge;

                            if (surchargeComponent.Price.HasValue)
                            {
                                surcharge = surchargeComponent.Price.Value;
                                productSurcharge += surcharge;
                            }
                            else
                            {
                                var percentage = surchargeComponent.Percentage.HasValue ? surchargeComponent.Percentage.Value : 0;
                                surcharge = decimal.Round(((productBasePrice * percentage) / 100), 2);
                                productSurcharge += surcharge;
                            }

                            ////Revenuebreaks on quantity and value are mutually exclusive.
                            if (priceComponent.ExistRevenueQuantityBreak || priceComponent.ExistRevenueValueBreak)
                            {
                                if (revenueBreakSurcharge == 0)
                                {
                                    revenueBreakSurcharge = surcharge;
                                }
                                else
                                {
                                    ////Apply highest of the two. Revert the other one.
                                    if (surcharge > revenueBreakSurcharge)
                                    {
                                        productSurcharge -= revenueBreakSurcharge;
                                    }
                                    else
                                    {
                                        productSurcharge -= surcharge;
                                    }
                                }
                            }
                        }
                    }
                }
            }

            return productBasePrice - productDiscount + productSurcharge;
        }
Esempio n. 49
0
 public bool isEnoughData(TimeFrame timeFrame, PriceComponent priceComponent, int periods)
 {
     return Factory.FxUpdates.AccumMgr.getAccum(pair, timeFrame, priceComponent).isEnoughData(periods);
 }
Esempio n. 50
0
 public void create(List<string> pairs, TimeFrame timeFrame, PriceComponent priceComponent)
 {
     foreach (string pair in pairs)
     {
         create(pair, timeFrame, priceComponent);
     }
 }