public override void Initialize() { Schedule localAccrualSchedule = new Schedule(); localAccrualSchedule.ScheduleType = "AccrualSchedule"; localAccrualSchedule.BusinessDayCalculator = Account.BusinessDayCalculator; SetAccrualScheduleCalculatedProperties(localAccrualSchedule); Account.Schedules.Add(localAccrualSchedule); Schedule localInterestSchedule = new Schedule(); localInterestSchedule.ScheduleType = "InterestSchedule"; localInterestSchedule.BusinessDayCalculator = Account.BusinessDayCalculator; SetInterestScheduleDefaultProperties(localInterestSchedule); Account.Schedules.Add(localInterestSchedule); Schedule localRedemptionSchedule = new Schedule(); localRedemptionSchedule.ScheduleType = "RedemptionSchedule"; localRedemptionSchedule.BusinessDayCalculator = Account.BusinessDayCalculator; SetRedemptionScheduleDefaultProperties(localRedemptionSchedule); Account.Schedules.Add(localRedemptionSchedule); OptionValue localAccrualOption = new OptionValue(); localAccrualOption.OptionType = "AccrualOption"; localAccrualOption.OptionValues = TransactRules.Calculations.AccrualCalculation.AccrualOptions(); Account.Options.Add(localAccrualOption); RateValue localInterestRate = new RateValue(); localInterestRate.RateType = "InterestRate"; Account.Rates.Add(localInterestRate); }
private static void InsertNewRate(string usdCurrencyName, decimal usdRateValue) { using (var dbContext = new CurrencyConverterContext()) { var usdRate = new RateValue { RateValueId = 1, Currency = usdCurrencyName, Value = usdRateValue }; dbContext.Rates.Add(usdRate); dbContext.SaveChanges(); } }
public Task <RateValue> GetRate(string rateCode, DateTime dateTime) { RateValue rateValue = new RateValue(); switch (rateCode) { case "EURIBOR-3M": rateValue = new RateValue() { Value = (decimal) - 1.5, RateCode = rateCode, EffectiveDate = dateTime }; break; case "EURIBOR-4M": rateValue = new RateValue() { Value = 2, RateCode = rateCode, EffectiveDate = dateTime }; break; case "EURIBOR-6M": rateValue = new RateValue() { Value = 0, RateCode = rateCode, EffectiveDate = dateTime }; break; case "BELIBOR-3M": rateValue = new RateValue() { Value = (decimal) - 2.5, RateCode = rateCode, EffectiveDate = dateTime }; break; case "EARLY-EUR": rateValue = new RateValue() { Value = (decimal)1.5, RateCode = rateCode, EffectiveDate = dateTime }; break; } return(Task.FromResult(rateValue)); }
static void Main(string[] args) { while (true) //программа работает бесконечно, обновляется раз в час (по идее надо продумать решение переполнения БД) { Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("Данные по курсу валюты обновляются каждый час"); Console.WriteLine("Курс выводится красным цветом если за час произошло его изменение"); Console.ResetColor(); string message = ""; RateValue rateDOL = new RateValue("доллар"); DB.Create <RateValue>(pathForDB, rateDOL, out message); var list = DB.GetCollection <RateValue>(pathForDB); DB.ShowLast(list); Thread.Sleep(3600000); Console.Clear(); } }
private void PreparePropertiesList() { ProjectProperties = new List <ProjectProperty>() { new ProjectProperty() { StandardType = StandardType.Standard, Type = Templates.Templates.PerfectMatch, PathInFile = Templates.Templates.PerfectMatchPathInFile }, new ProjectProperty() { StandardType = StandardType.Standard, Type = Templates.Templates.ContextMatch, PathInFile = Templates.Templates.ContextMatchPathInFile }, new ProjectProperty() { StandardType = StandardType.Standard, Type = Templates.Templates.Repetitions, PathInFile = Templates.Templates.RepetitionsPathInFile }, new ProjectProperty() { StandardType = StandardType.Standard, Type = Templates.Templates.Percent100, PathInFile = Templates.Templates.Percent100PathInFile }, new ProjectProperty() { StandardType = StandardType.Standard, Type = Templates.Templates.Percent95, PathInFile = Templates.Templates.Percent95PathInFile }, new ProjectProperty() { StandardType = StandardType.Standard, Type = Templates.Templates.Percent85, PathInFile = Templates.Templates.Percent85PathInFile }, new ProjectProperty() { StandardType = StandardType.Standard, Type = Templates.Templates.Percent75, PathInFile = Templates.Templates.Percent75PathInFile }, new ProjectProperty() { StandardType = StandardType.Standard, Type = Templates.Templates.Percent50, PathInFile = Templates.Templates.Percent50PathInFile }, new ProjectProperty() { StandardType = StandardType.Standard, Type = Templates.Templates.New, PathInFile = Templates.Templates.NewPathInFile }, new ProjectProperty() { StandardType = StandardType.Global, Type = Templates.Templates.RepsAnd100Percent, PathInFile = "" }, new ProjectProperty() { StandardType = StandardType.Global, Type = Templates.Templates.FuzzyMatches, PathInFile = "" }, new ProjectProperty() { StandardType = StandardType.Global, Type = Templates.Templates.NoMatch, PathInFile = "" }, new ProjectProperty() { StandardType = StandardType.Both, Type = Templates.Templates.Tags, PathInFile = Templates.Templates.TagsPathInFile } }; ProjectProperties = TemplateRates.FillRatesForProject(ProjectProperties); if (TemplateRates.AdditionalRates.Count > 0) { RateValue ratePerLine = TemplateRates.AdditionalRates.FirstOrDefault(rate => rate.Type == Templates.Templates.RatePerLine); if (ratePerLine != null) { RatePerLine = ratePerLine.Rate; } RateValue lineCharacters = TemplateRates.AdditionalRates.FirstOrDefault(rate => rate.Type == Templates.Templates.CharactersPerLine); if (lineCharacters != null) { LineCharacters = lineCharacters.Rate; } } }
public ActionResult ChangeRate(int id, int voteRate) { var selectedProduct = _context.Products.Find(id); selectedProduct.numberOfVotes++; _context.SaveChanges(); var RateValues = _context.RateValues.ToList(); bool check = _context.RateValues.Any(x => x.ProductId == id); InformationAboutVotesViewModel Infos = new InformationAboutVotesViewModel(); Infos.yourRate = voteRate; Infos.numberOfVotes = selectedProduct.numberOfVotes; if (check == false) { RateValue NewAdded = new RateValue(); NewAdded.ProductId = id; switch (voteRate) { case 1: NewAdded.RateNumberOne++; break; case 2: NewAdded.RateNumberTwo++; break; case 3: NewAdded.RateNumberThree++; break; case 4: NewAdded.RateNumberFour++; break; case 5: NewAdded.RateNumberFive++; break; } _context.RateValues.Add(NewAdded); selectedProduct.Rate = RateChanger(selectedProduct.numberOfVotes, NewAdded.RateNumberOne, NewAdded.RateNumberTwo, NewAdded.RateNumberThree, NewAdded.RateNumberFour, NewAdded.RateNumberFive); _context.SaveChanges(); Infos.actualRate = Math.Round(selectedProduct.Rate, 2); } if (check == true) { var FindFrom = _context.RateValues.Single(x => x.ProductId == id); switch (voteRate) { case 1: FindFrom.RateNumberOne++; break; case 2: FindFrom.RateNumberTwo++; break; case 3: FindFrom.RateNumberThree++; break; case 4: FindFrom.RateNumberFour++; break; case 5: FindFrom.RateNumberFive++; break; } selectedProduct.Rate = RateChanger(selectedProduct.numberOfVotes, FindFrom.RateNumberOne, FindFrom.RateNumberTwo, FindFrom.RateNumberThree, FindFrom.RateNumberFour, FindFrom.RateNumberFive); _context.SaveChanges(); Infos.actualRate = Math.Round(selectedProduct.Rate, 2); } return(View(Infos)); }
private async Task UpdateInvoiceSell(InvoiceSell dbInv, TransportOfferDTO dto) { var tradeInfoDTO = dto.TradeInfo; if (dbInv.Buyer == null || dbInv.BuyerId != tradeInfoDTO.Company.CompanyId) { //dbInv.Buyer = await this._db.Company.FirstOrDefaultAsync(f => f.CompanyId == tradeInfoDTO.Company.CompanyId); dbInv.Buyer = await this._companyService.CompanyMapper(dbInv.Buyer, dto.TradeInfo.Company); } if (dto.InvoiceInPLN) { dbInv.Currency = this._invoiceService._currencyList.FirstOrDefault(f => f.Name == "PLN"); } else { dbInv.Currency = this._invoiceService._currencyList.FirstOrDefault(f => f.CurrencyId == tradeInfoDTO.Price.Currency.CurrencyId); } dbInv.DateOfIssue = DateTime.Now; var extraInfo = dbInv.ExtraInfo ?? new InvoiceExtraInfo(); extraInfo.LoadNo = dto.OfferNo; if (dbInv.ExtraInfo == null) { extraInfo.InvoiceSell = dbInv; this._db.Entry(extraInfo).State = EntityState.Added; } dbInv.InvoiceNo = await this._invoiceService.GetNextInvoiceNo(dto.TradeInfo.Date); //invoice pos var price = dto.InvoiceInPLN ? tradeInfoDTO.Price.PlnValue: tradeInfoDTO.Price.Price; var brutto = Math.Round(price * 1.23, 2); var itemName = $"Usługa transportowa ({dto.Load.PostalCode} - {dto.Unload.PostalCode})"; var dbPos = new InvoicePos(); var posDTO = new InvoiceLineDTO { Brutto_value = brutto, Measurement_unit = "szt", //Name = $"Usługa transportowa", Name = itemName, Netto_value = price, Quantity = 1, Unit_price = price, Vat_rate = "23", Vat_unit_value = brutto - price, Vat_value = brutto - price }; this._invoiceService.MapperLine(dbPos, posDTO); if (dbInv.InvoicePosList == null || dbInv.InvoicePosList.Count == 0) { dbPos.InvoiceSell = dbInv; this._db.Entry(dbPos).State = EntityState.Added; } else { dbPos = dbInv.InvoicePosList.FirstOrDefault(); this._invoiceService.MapperLine(dbPos, posDTO); } var dbTotal = dbInv.InvoiceTotal ?? new InvoiceTotal(); dbTotal.TotalBrutto = brutto; dbTotal.TotalNetto = price; dbTotal.TotalTax = brutto - price; if (dbInv.InvoiceTotal == null) { dbTotal.InvoiceSell = dbInv; this._db.Entry(dbTotal).State = EntityState.Added; } var dbPaymentTerms = dbInv.PaymentTerms ?? new PaymentTerms(); this._invoiceService.MapperPaymentTerms(dbPaymentTerms, tradeInfoDTO.PaymentTerms); if (dbInv.PaymentTerms == null) { dbPaymentTerms.InvoiceSell = dbInv; this._db.Entry(dbPaymentTerms).State = EntityState.Added; } if (dbInv.RatesValuesList == null || dbInv.RatesValuesList.Count == 0) { var dbRate = new RateValue(); dbRate.BruttoValue = brutto; dbRate.NettoValue = price; dbRate.VatRate = "23"; dbRate.VatValue = brutto - price; dbRate.InvoiceSell = dbInv; this._db.Entry(dbRate).State = EntityState.Added; } else { var dbRate = dbInv.RatesValuesList.FirstOrDefault(); dbRate.BruttoValue = brutto; dbRate.NettoValue = price; dbRate.VatRate = "23"; dbRate.VatValue = brutto - price; } if (dbInv.Seller == null) { dbInv.Seller = await this._companyService.Owner(); } dbInv.SellingDate = dto.TradeInfo.Date; var dbInvTotal = dbInv.InvoiceTotal ?? new InvoiceTotal(); dbInvTotal.TotalBrutto = brutto; dbInvTotal.TotalNetto = tradeInfoDTO.Price.Price; dbInvTotal.TotalTax = brutto - tradeInfoDTO.Price.Price; if (dbInv.InvoiceTotal == null) { dbInvTotal.InvoiceSell = dbInv; this._db.Entry(dbInvTotal).State = EntityState.Added; } }
public Rate(RateValue value = RateValue.Unknown) => _value = value;