public ExchangeRate(Currency sourceCurrency, Currency targetCurrency, ExchangeRateType rateType, decimal value) { SourceCurrency = sourceCurrency; TargetCurrency = targetCurrency; RateType = rateType; Value = value; }
public static ExchangeRateType CreateExchangeRateType(string name) { ExchangeRateType exchangeRateType = new ExchangeRateType(); exchangeRateType.Name = name; return(exchangeRateType); }
public void Update(ExchangeRateType item) { var todoItem = Find(item.Code); var index = _todoList.IndexOf(todoItem); _todoList.RemoveAt(index); _todoList.Insert(index, item); }
public void UpdateData(ExchangeRateType item) { if (item == null) { throw new ArgumentNullException("item"); } _repository.Update(item); }
public static string GetStringValue(this ExchangeRateType exchangeRateType) { switch (exchangeRateType) { case ExchangeRateType.Positive: return(positiveExchangeRateText); case ExchangeRateType.Negative: return(negativeExchangeRateText); default: throw new ArgumentOutOfRangeException($"Brak wartości {nameof(exchangeRateType)} dla typu wyliczeniowego {nameof(ExchangeRateType)}."); } }
public CreditNoteType() { this._creditNoteLine = new List <CreditNoteLineType>(); this._legalMonetaryTotal = new MonetaryTotalType(); this._taxTotal = new List <TaxTotalType>(); this._allowanceCharge = new List <AllowanceChargeType>(); this._paymentAlternativeExchangeRate = new ExchangeRateType(); this._paymentExchangeRate = new ExchangeRateType(); this._pricingExchangeRate = new ExchangeRateType(); this._taxExchangeRate = new ExchangeRateType(); this._paymentTerms = new List <PaymentTermsType>(); this._paymentMeans = new List <PaymentMeansType>(); this._deliveryTerms = new List <DeliveryTermsType>(); this._delivery = new List <DeliveryType>(); this._taxRepresentativeParty = new PartyType(); this._sellerSupplierParty = new SupplierPartyType(); this._buyerCustomerParty = new CustomerPartyType(); this._payeeParty = new PartyType(); this._accountingCustomerParty = new CustomerPartyType(); this._accountingSupplierParty = new SupplierPartyType(); this._signature = new List <SignatureType>(); this._originatorDocumentReference = new List <DocumentReferenceType>(); this._statementDocumentReference = new List <DocumentReferenceType>(); this._additionalDocumentReference = new List <DocumentReferenceType>(); this._contractDocumentReference = new List <DocumentReferenceType>(); this._receiptDocumentReference = new List <DocumentReferenceType>(); this._despatchDocumentReference = new List <DocumentReferenceType>(); this._billingReference = new List <BillingReferenceType>(); this._orderReference = new OrderReferenceType(); this._discrepancyResponse = new List <ResponseType>(); this._invoicePeriod = new List <PeriodType>(); this._buyerReference = new BuyerReferenceType(); this._lineCountNumeric = new LineCountNumericType(); this._accountingCost = new AccountingCostType(); this._accountingCostCode = new AccountingCostCodeType(); this._paymentAlternativeCurrencyCode = new PaymentAlternativeCurrencyCodeType(); this._paymentCurrencyCode = new PaymentCurrencyCodeType(); this._pricingCurrencyCode = new PricingCurrencyCodeType(); this._taxCurrencyCode = new TaxCurrencyCodeType(); this._documentCurrencyCode = new DocumentCurrencyCodeType(); this._note = new List <NoteType>(); this._creditNoteTypeCode = new CreditNoteTypeCodeType(); this._taxPointDate = new TaxPointDateType(); this._issueTime = new IssueTimeType(); this._issueDate = new IssueDateType(); this._uUID = new UUIDType(); this._copyIndicator = new CopyIndicatorType(); this._id = new IDType(); this._profileExecutionID = new ProfileExecutionIDType(); this._profileID = new ProfileIDType(); this._customizationID = new CustomizationIDType(); this._uBLVersionID = new UBLVersionIDType(); this._uBLExtensions = new List <UBLExtensionType>(); }
static internal FixedList <ExchangeRate> GetExchangeRates(ExchangeRateType exchangeRateType, DateTime date) { var sql = "SELECT * FROM AO_EXCHANGE_RATES " + $"WHERE EXCHANGE_RATE_TYPE_ID = {exchangeRateType.Id} " + $"AND FROM_DATE = '{CommonMethods.FormatSqlDate(date)}' " + $"ORDER BY TO_CURRENCY_ID"; var dataOperation = DataOperation.Parse(sql); return(DataReader.GetFixedList <ExchangeRate>(dataOperation)); }
public DebitNoteType() { this.debitNoteLineField = new ObservableCollection <DebitNoteLineType>(); this.requestedMonetaryTotalField = new MonetaryTotalType(); this.taxTotalField = new ObservableCollection <TaxTotalType>(); this.paymentAlternativeExchangeRateField = new ExchangeRateType(); this.paymentExchangeRateField = new ExchangeRateType(); this.pricingExchangeRateField = new ExchangeRateType(); this.taxExchangeRateField = new ExchangeRateType(); this.paymentTermsField = new ObservableCollection <PaymentTermsType>(); this.paymentMeansField = new ObservableCollection <PaymentMeansType>(); this.deliveryTermsField = new ObservableCollection <DeliveryTermsType>(); this.deliveryField = new ObservableCollection <DeliveryType>(); this.allowanceChargeField = new ObservableCollection <AllowanceChargeType>(); this.prepaidPaymentField = new ObservableCollection <PaymentType>(); this.taxRepresentativePartyField = new PartyType(); this.sellerSupplierPartyField = new SupplierPartyType(); this.buyerCustomerPartyField = new CustomerPartyType(); this.payeePartyField = new PartyType(); this.accountingCustomerPartyField = new CustomerPartyType(); this.accountingSupplierPartyField = new SupplierPartyType(); this.signatureField = new ObservableCollection <SignatureType>(); this.additionalDocumentReferenceField = new ObservableCollection <DocumentReferenceType>(); this.contractDocumentReferenceField = new ObservableCollection <DocumentReferenceType>(); this.statementDocumentReferenceField = new ObservableCollection <DocumentReferenceType>(); this.receiptDocumentReferenceField = new ObservableCollection <DocumentReferenceType>(); this.despatchDocumentReferenceField = new ObservableCollection <DocumentReferenceType>(); this.billingReferenceField = new ObservableCollection <BillingReferenceType>(); this.orderReferenceField = new OrderReferenceType(); this.discrepancyResponseField = new ObservableCollection <ResponseType>(); this.invoicePeriodField = new ObservableCollection <PeriodType>(); this.lineCountNumericField = new LineCountNumericType(); this.accountingCostField = new AccountingCostType(); this.accountingCostCodeField = new AccountingCostCodeType(); this.paymentAlternativeCurrencyCodeField = new PaymentAlternativeCurrencyCodeType(); this.paymentCurrencyCodeField = new PaymentCurrencyCodeType(); this.pricingCurrencyCodeField = new PricingCurrencyCodeType(); this.taxCurrencyCodeField = new TaxCurrencyCodeType(); this.documentCurrencyCodeField = new DocumentCurrencyCodeType(); this.taxPointDateField = new TaxPointDateType(); this.noteField = new ObservableCollection <NoteType>(); this.issueTimeField = new IssueTimeType(); this.issueDateField = new IssueDateType(); this.uUIDField = new UUIDType(); this.copyIndicatorField = new CopyIndicatorType(); this.idField = new IDType(); this.profileExecutionIDField = new ProfileExecutionIDType(); this.profileIDField = new ProfileIDType(); this.customizationIDField = new CustomizationIDType(); this.uBLVersionIDField = new UBLVersionIDType(); this.uBLExtensionsField = new ObservableCollection <UBLExtensionType>(); }
public OrderType() { this.orderLineField = new ObservableCollection <OrderLineType>(); this.anticipatedMonetaryTotalField = new MonetaryTotalType(); this.taxTotalField = new ObservableCollection <TaxTotalType>(); this.destinationCountryField = new CountryType(); this.paymentExchangeRateField = new ExchangeRateType(); this.pricingExchangeRateField = new ExchangeRateType(); this.taxExchangeRateField = new ExchangeRateType(); this.allowanceChargeField = new ObservableCollection <AllowanceChargeType>(); this.transactionConditionsField = new TransactionConditionsType(); this.paymentTermsField = new ObservableCollection <PaymentTermsType>(); this.paymentMeansField = new ObservableCollection <PaymentMeansType>(); this.deliveryTermsField = new ObservableCollection <DeliveryTermsType>(); this.deliveryField = new ObservableCollection <DeliveryType>(); this.accountingCustomerPartyField = new CustomerPartyType(); this.freightForwarderPartyField = new PartyType(); this.originatorCustomerPartyField = new CustomerPartyType(); this.sellerSupplierPartyField = new SupplierPartyType(); this.buyerCustomerPartyField = new CustomerPartyType(); this.signatureField = new ObservableCollection <SignatureType>(); this.projectReferenceField = new ObservableCollection <ProjectReferenceType>(); this.contractField = new ObservableCollection <ContractType>(); this.additionalDocumentReferenceField = new ObservableCollection <DocumentReferenceType>(); this.catalogueReferenceField = new CatalogueReferenceType(); this.originatorDocumentReferenceField = new DocumentReferenceType(); this.orderDocumentReferenceField = new ObservableCollection <DocumentReferenceType>(); this.quotationDocumentReferenceField = new DocumentReferenceType(); this.validityPeriodField = new ObservableCollection <PeriodType>(); this.lineCountNumericField = new LineCountNumericType(); this.accountingCostField = new AccountingCostType(); this.accountingCostCodeField = new AccountingCostCodeType(); this.customerReferenceField = new CustomerReferenceType(); this.taxCurrencyCodeField = new TaxCurrencyCodeType(); this.pricingCurrencyCodeField = new PricingCurrencyCodeType(); this.documentCurrencyCodeField = new DocumentCurrencyCodeType(); this.requestedInvoiceCurrencyCodeField = new RequestedInvoiceCurrencyCodeType(); this.noteField = new ObservableCollection <NoteType>(); this.orderTypeCodeField = new OrderTypeCodeType(); this.issueTimeField = new IssueTimeType(); this.issueDateField = new IssueDateType(); this.uUIDField = new UUIDType(); this.copyIndicatorField = new CopyIndicatorType(); this.salesOrderIDField = new SalesOrderIDType(); this.idField = new IDType(); this.profileExecutionIDField = new ProfileExecutionIDType(); this.profileIDField = new ProfileIDType(); this.customizationIDField = new CustomizationIDType(); this.uBLVersionIDField = new UBLVersionIDType(); this.uBLExtensionsField = new ObservableCollection <UBLExtensionType>(); }
public void Should_Get_A_List_Of_Exchange_Rates_For_Type_In_A_Date() { FixedList <ExchangeRateType> exchangeRateTypes = ExchangeRateType.GetList(); var EXCHANGE_RATE_TYPE = exchangeRateTypes[0]; DateTime DATE = new DateTime(2017, 08, 31); FixedList <ExchangeRate> list = ExchangeRate.GetList(EXCHANGE_RATE_TYPE, DATE); Assert.NotEmpty(list); Assert.All(list, x => { Assert.Equal(DATE, x.Date); }); Assert.All(list, x => { Assert.Equal(EXCHANGE_RATE_TYPE, x.ExchangeRateType); }); Assert.All(list, x => { Assert.True(x.Value > 0); }); }
internal FixedList <TrialBalanceEntry> ValuateToExchangeRate(FixedList <TrialBalanceEntry> entries, TrialBalanceCommandPeriod commandPeriod) { var exchangeRateType = ExchangeRateType.Parse(commandPeriod.ExchangeRateTypeUID); FixedList <ExchangeRate> exchageRates = ExchangeRate.GetList(exchangeRateType, commandPeriod.ExchangeRateDate); foreach (var entry in entries.Where(a => a.Currency.Code != "01")) { var exchangeRate = exchageRates.FirstOrDefault(a => a.FromCurrency.Code == commandPeriod.ValuateToCurrrencyUID && a.ToCurrency.Code == entry.Currency.Code); Assertion.AssertObject(exchangeRate, $"No hay tipo de cambio para la moneda {entry.Currency.FullName}."); entry.MultiplyBy(exchangeRate.Value); } return(entries); }
public ReminderType() { this.reminderLineField = new ObservableCollection <ReminderLineType>(); this.legalMonetaryTotalField = new MonetaryTotalType(); this.taxTotalField = new ObservableCollection <TaxTotalType>(); this.paymentAlternativeExchangeRateField = new ExchangeRateType(); this.paymentExchangeRateField = new ExchangeRateType(); this.pricingExchangeRateField = new ExchangeRateType(); this.taxExchangeRateField = new ExchangeRateType(); this.allowanceChargeField = new ObservableCollection <AllowanceChargeType>(); this.prepaidPaymentField = new ObservableCollection <PaymentType>(); this.paymentTermsField = new ObservableCollection <PaymentTermsType>(); this.paymentMeansField = new ObservableCollection <PaymentMeansType>(); this.taxRepresentativePartyField = new PartyType(); this.payeePartyField = new PartyType(); this.accountingCustomerPartyField = new CustomerPartyType(); this.accountingSupplierPartyField = new SupplierPartyType(); this.signatureField = new ObservableCollection <SignatureType>(); this.additionalDocumentReferenceField = new ObservableCollection <DocumentReferenceType>(); this.reminderPeriodField = new ObservableCollection <PeriodType>(); this.lineCountNumericField = new LineCountNumericType(); this.accountingCostField = new AccountingCostType(); this.accountingCostCodeField = new AccountingCostCodeType(); this.paymentAlternativeCurrencyCodeField = new PaymentAlternativeCurrencyCodeType(); this.paymentCurrencyCodeField = new PaymentCurrencyCodeType(); this.pricingCurrencyCodeField = new PricingCurrencyCodeType(); this.taxCurrencyCodeField = new TaxCurrencyCodeType(); this.documentCurrencyCodeField = new DocumentCurrencyCodeType(); this.taxPointDateField = new TaxPointDateType(); this.noteField = new ObservableCollection <NoteType>(); this.reminderSequenceNumericField = new ReminderSequenceNumericType(); this.reminderTypeCodeField = new ReminderTypeCodeType(); this.issueTimeField = new IssueTimeType(); this.issueDateField = new IssueDateType(); this.uUIDField = new UUIDType(); this.copyIndicatorField = new CopyIndicatorType(); this.idField = new IDType(); this.profileExecutionIDField = new ProfileExecutionIDType(); this.profileIDField = new ProfileIDType(); this.customizationIDField = new CustomizationIDType(); this.uBLVersionIDField = new UBLVersionIDType(); this.uBLExtensionsField = new ObservableCollection <UBLExtensionType>(); }
public FixedList <NamedEntityDto> GetExchangeRatesTypes() { var list = ExchangeRateType.GetList(); return(list.MapToNamedEntityList()); }
public SUNATRetentionDocumentReferenceType[] getSUNATRetentionDocumentReference() { SUNATRetentionDocumentReferenceType[] DocumentReference = new SUNATRetentionDocumentReferenceType[VD.it]; for (int i = 0; i < VD.it; ++i) { int j = i + 1; DocumentReference[i] = new SUNATRetentionDocumentReferenceType() { ID = new IDType() { schemeID = Interface["TpoDocRelac" + j], Value = Interface["NumDocRelac" + j] }, IssueDate = new IssueDateType() { Value = DateTime.Parse(Interface["FEmisDocRelac" + j]) }, TotalInvoiceAmount = new TotalInvoiceAmountType() { currencyID = Interface["MDocRelac" + j], Value = Interface["ITotDocRelac" + j] }, Payment = new PaymentType() { ID = new IDType() { Value = Interface["NumMovi" + j] }, PaidAmount = new PaidAmountType() { currencyID = Interface["MonMovi" + j], Value = Interface["ImpSOperMov" + j] }, PaidDate = new PaidDateType() { Value = DateTime.Parse(Interface["FecMovi" + j]) } }, SUNATRetentionInformation = new SUNATRetentionInformationType() { SUNATRetentionAmount = new AmountType1() { currencyID = Interface["MonImpOper" + j], Value = Interface["ImpOper" + j] }, SUNATRetentionDate = new SUNATRetentionDateType() { Value = DateTime.Parse(Interface["FecOper" + j]) }, SUNATNetTotalPaid = new AmountType1() { currencyID = Interface["MonOper" + j], Value = Interface["ImpTotOper" + j] } } }; if (Interface["MonRefeTC" + j] != "" || Interface["MonDestTC" + j] != "" || Interface["FactorTC" + j] != "" || Interface["FechaTC" + j] != "") { ExchangeRateType EXRT = new ExchangeRateType(); if (Interface["MonRefeTC" + j] != "") { EXRT.SourceCurrencyCode = new SourceCurrencyCodeType() { Value = Interface["MonRefeTC" + j] }; } if (Interface["MonDestTC" + j] != "") { EXRT.TargetCurrencyCode = new TargetCurrencyCodeType() { Value = Interface["MonDestTC" + j] }; } if (Interface["FactorTC" + j] != "") { if (isDecimal(Interface["FactorTC" + j])) { EXRT.CalculationRate = new CalculationRateType() { Value = Interface["FactorTC" + j] } } ; } if (Interface["FechaTC" + j] != "") { if (isDate(Interface["FechaTC" + j])) { EXRT.Date = new DateType() { Value = DateTime.Parse(Interface["FechaTC" + j]) } } ; } DocumentReference[i].SUNATRetentionInformation.ExchangeRate = EXRT; } } return(DocumentReference); }
public void FillData() { /*if (!context.TypeOfDocuments.Any()) * { * TypeOfDocument pasport = new TypeOfDocument { Name = "Паспорт" }; * TypeOfDocument pasport1 = new TypeOfDocument { Name = "ВоенныйБилет" }; * TypeOfDocument pasport2 = new TypeOfDocument { Name = "СвидетельствоОрождении" }; * context.TypeOfDocuments.AddRange(pasport, pasport1, pasport2); * context.SaveChanges(); * } * * if (!context.Countries.Any()) * { * Country country = new Country { CountryName = "Кыргызстан" }; * Country country1 = new Country { CountryName = "Таджикистан" }; * Country country2 = new Country { CountryName = "Казахстан" }; * context.Countries.AddRange(country, country1, country2); * context.SaveChanges(); * } * if (!context.LegalForms.Any()) * { * LegalForm legalForm = new LegalForm { LegalFormName = "ОсОО" }; * LegalForm legalForm1 = new LegalForm { LegalFormName = "ОАО" }; * LegalForm legalForm2 = new LegalForm { LegalFormName = "ЗАО" }; * context.LegalForms.AddRange(legalForm, legalForm1, legalForm2); * context.SaveChanges(); * } * if (!context.PropertyTypes.Any()) * { * PropertyType propertyType = new PropertyType { PropertyTypeName = "Государственная" }; * PropertyType propertyType1 = new PropertyType { PropertyTypeName = "Частная" }; * PropertyType propertyType2 = new PropertyType { PropertyTypeName = "Смешанная" }; * context.PropertyTypes.AddRange(propertyType, propertyType1, propertyType2); * context.SaveChanges(); * } * if (!context.Residencies.Any()) * { * Residency residency = new Residency { ResidencyName = "Резидент" }; * Residency residency1 = new Residency { ResidencyName = "НеРезидент" }; * * context.Residencies.AddRange(residency, residency1); * context.SaveChanges(); * } * if (!context.TaxInspections.Any()) * { * TaxInspection taxInspection = new TaxInspection { TaxInspectionName = "Ленинский" }; * TaxInspection taxInspection1 = new TaxInspection { TaxInspectionName = "Свердловский" }; * TaxInspection taxInspection2 = new TaxInspection { TaxInspectionName = "Октябрьский" }; * context.TaxInspections.AddRange(taxInspection, taxInspection1, taxInspection2); * context.SaveChanges(); * }*/ if (!context.TransactionTypes.Any()) { List <TransactionType> transactions = new List <TransactionType>(); transactions.Add(TransactionType.Create(TransactionTypesEnum.Debit)); transactions.Add(TransactionType.Create(TransactionTypesEnum.Credit)); context.TransactionTypes.AddRange(transactions); context.SaveChanges(); } if (!context.ExchangeRateTypes.Any()) { ExchangeRateType exchangeRateType = ExchangeRateType.Create(ExchangeRateTypesEnum.NBKR); ExchangeRateType exchangeRateType1 = ExchangeRateType.Create(ExchangeRateTypesEnum.Market); context.ExchangeRateTypes.AddRange(exchangeRateType, exchangeRateType1); context.SaveChanges(); } if (!context.TransferStates.Any()) { context.AddRange( TransferState.Create(TransferStatesEnum.Confirmed), TransferState.Create(TransferStatesEnum.NotConfirmed), TransferState.Create(TransferStatesEnum.Canceled), TransferState.Create(TransferStatesEnum.BalanceNotEnough), TransferState.Create(TransferStatesEnum.AccountIsLocked)); context.SaveChanges(); } if (!context.TypeOfTransfers.Any()) { context.AddRange( TypeOfTransfer.Create(TypeOfTransfersEnum.InnerTransfer), TypeOfTransfer.Create(TypeOfTransfersEnum.InterBankTransfer), TypeOfTransfer.Create(TypeOfTransfersEnum.Conversion)); context.SaveChanges(); } if (!context.Currencies.Any()) { context.Currencies.Add ( new Currency { Code = "123", Name = "SOM", IsNativeCurrency = true } ); context.SaveChanges(); } if (!context.OurBank.Any()) { Currency currency = context.Currencies.FirstOrDefault(n => n.IsNativeCurrency == true); Account bankAccount = new Account { Locked = false, CurrencyId = currency.Id, Number = "1234567890123456" }; context.Accounts.Add(bankAccount); context.SaveChanges(); BankInfo bank = new BankInfo { BankName = "OurBank", Email = "*****@*****.**" }; context.BankInfos.Add(bank); OurBank ourBank = new OurBank { BIK = "123", AccountId = bankAccount.Id, BankInfoId = bank.Id }; context.OurBank.Add(ourBank); context.SaveChanges(); } if (!context.IntervalTypes.Any()) { List <IntervalType> intervalTypes = new List <IntervalType>(); intervalTypes.Add(IntervalType.Create(IntervalTypesEnum.OnceADay)); intervalTypes.Add(IntervalType.Create(IntervalTypesEnum.OnceAWeek)); intervalTypes.Add(IntervalType.Create(IntervalTypesEnum.OnceInTwoWeeks)); intervalTypes.Add(IntervalType.Create(IntervalTypesEnum.OnceAMonth)); intervalTypes.Add(IntervalType.Create(IntervalTypesEnum.OnceAQuarter)); intervalTypes.Add(IntervalType.Create(IntervalTypesEnum.OnceAHalfYear)); intervalTypes.Add(IntervalType.Create(IntervalTypesEnum.OnceAYear)); context.IntervalTypes.AddRange(intervalTypes); context.SaveChanges(); } if (!context.AddressTypes.Any()) { List <AddressType> addressTypes = new List <AddressType> { AddressType.Create(AddressTypesEnum.FactAddress), AddressType.Create(AddressTypesEnum.LegalAddress), AddressType.Create(AddressTypesEnum.BirthAddress) }; context.AddRange(addressTypes); context.SaveChanges(); } }
public static void FillData(ApplicationContext context, UserManager <User> _userManager) { if (!context.TypeOfDocuments.Any()) { TypeOfDocument pasport = new TypeOfDocument { Name = "Паспорт" }; TypeOfDocument pasport1 = new TypeOfDocument { Name = "ВоенныйБилет" }; TypeOfDocument pasport2 = new TypeOfDocument { Name = "СвидетельствоОрождении" }; context.TypeOfDocuments.AddRange(pasport, pasport1, pasport2); context.SaveChanges(); } if (!context.Countries.Any()) { Country country = new Country { CountryName = "Кыргызстан" }; Country country1 = new Country { CountryName = "Таджикистан" }; Country country2 = new Country { CountryName = "Казахстан" }; context.Countries.AddRange(country, country1, country2); context.SaveChanges(); } if (!context.LegalForms.Any()) { LegalForm legalForm = new LegalForm { LegalFormName = "ОсОО" }; LegalForm legalForm1 = new LegalForm { LegalFormName = "ОАО" }; LegalForm legalForm2 = new LegalForm { LegalFormName = "ЗАО" }; context.LegalForms.AddRange(legalForm, legalForm1, legalForm2); context.SaveChanges(); } if (!context.PropertyTypes.Any()) { PropertyType propertyType = new PropertyType { PropertyTypeName = "Государственная" }; PropertyType propertyType1 = new PropertyType { PropertyTypeName = "Частная" }; PropertyType propertyType2 = new PropertyType { PropertyTypeName = "Смешанная" }; context.PropertyTypes.AddRange(propertyType, propertyType1, propertyType2); context.SaveChanges(); } if (!context.Residencies.Any()) { Residency residency = new Residency { ResidencyName = "Резидент" }; Residency residency1 = new Residency { ResidencyName = "НеРезидент" }; context.Residencies.AddRange(residency, residency1); context.SaveChanges(); } if (!context.TaxInspections.Any()) { TaxInspection taxInspection = new TaxInspection { TaxInspectionName = "Ленинский" }; TaxInspection taxInspection1 = new TaxInspection { TaxInspectionName = "Свердловский" }; TaxInspection taxInspection2 = new TaxInspection { TaxInspectionName = "Октябрьский" }; context.TaxInspections.AddRange(taxInspection, taxInspection1, taxInspection2); context.SaveChanges(); } if (!context.TransactionTypes.Any()) { List <TransactionType> transactions = new List <TransactionType>(); transactions.Add(TransactionType.Create(TransactionTypesEnum.Debit)); transactions.Add(TransactionType.Create(TransactionTypesEnum.Credit)); context.TransactionTypes.AddRange(transactions); context.SaveChanges(); } if (!context.ExchangeRateTypes.Any()) { ExchangeRateType exchangeRateType = ExchangeRateType.Create(ExchangeRateTypesEnum.NBKR); ExchangeRateType exchangeRateType1 = ExchangeRateType.Create(ExchangeRateTypesEnum.Market); context.ExchangeRateTypes.AddRange(exchangeRateType, exchangeRateType1); context.SaveChanges(); } if (!context.TransferStates.Any()) { context.AddRange( TransferState.Create(TransferStatesEnum.Confirmed), TransferState.Create(TransferStatesEnum.NotConfirmed), TransferState.Create(TransferStatesEnum.Canceled), TransferState.Create(TransferStatesEnum.BalanceNotEnough), TransferState.Create(TransferStatesEnum.AccountIsLocked)); context.SaveChanges(); } if (!context.TypeOfTransfers.Any()) { context.AddRange( TypeOfTransfer.Create(TypeOfTransfersEnum.InnerTransfer), TypeOfTransfer.Create(TypeOfTransfersEnum.InterBankTransfer), TypeOfTransfer.Create(TypeOfTransfersEnum.Conversion)); context.SaveChanges(); } if (!context.Currencies.Any()) { context.Currencies.Add ( new Currency { Code = "123", Name = "SOM", IsNativeCurrency = true } ); context.SaveChanges(); } if (!context.OurBank.Any()) { Currency currency = context.Currencies.FirstOrDefault(n => n.IsNativeCurrency == true); Account bankAccount = new Account { Locked = false, CurrencyId = currency.Id, Number = "1234567890123456" }; context.Accounts.Add(bankAccount); context.SaveChanges(); BankInfo bank = new BankInfo { BankName = "OurBank", Email = "*****@*****.**" }; context.BankInfos.Add(bank); OurBank ourBank = new OurBank { BIK = "123", AccountId = bankAccount.Id, BankInfoId = bank.Id }; context.OurBank.Add(ourBank); context.SaveChanges(); } if (!context.IntervalTypes.Any()) { List <IntervalType> intervalTypes = new List <IntervalType>(); intervalTypes.Add(IntervalType.Create(IntervalTypesEnum.OnceADay)); intervalTypes.Add(IntervalType.Create(IntervalTypesEnum.OnceAWeek)); intervalTypes.Add(IntervalType.Create(IntervalTypesEnum.OnceInTwoWeeks)); intervalTypes.Add(IntervalType.Create(IntervalTypesEnum.OnceAMonth)); intervalTypes.Add(IntervalType.Create(IntervalTypesEnum.OnceAQuarter)); intervalTypes.Add(IntervalType.Create(IntervalTypesEnum.OnceAHalfYear)); intervalTypes.Add(IntervalType.Create(IntervalTypesEnum.OnceAYear)); context.IntervalTypes.AddRange(intervalTypes); context.SaveChanges(); } if (!context.Roles.Any()) { context.Roles.AddRange ( new IdentityRole { Name = "admin", NormalizedName = "ADMIN" }, new IdentityRole { Name = "user", NormalizedName = "USER" } ); context.SaveChanges(); } if (context.Users.FirstOrDefault(u => u.UserName == "Admin") == null) { var result = _userManager.CreateAsync(new User { UserName = "******", Email = "*****@*****.**", IsTwoFactorOn = false, IsPasswordChanged = true, }, "Admin123@"); if (result.Result.Succeeded) { User user = context.Users.FirstOrDefault(u => u.UserName == "Admin"); IdentityRole role = context.Roles.FirstOrDefault(r => r.Name == "Admin"); context.UserRoles.Add(new IdentityUserRole <string> { RoleId = role.Id, UserId = user.Id }); context.SaveChanges(); } } if (!context.AddressTypes.Any()) { List <AddressType> addressTypes = new List <AddressType> { AddressType.Create(AddressTypesEnum.FactAddress), AddressType.Create(AddressTypesEnum.LegalAddress), AddressType.Create(AddressTypesEnum.BirthAddress) }; context.AddRange(addressTypes); context.SaveChanges(); //List<Address> adresses = context.Addresses.ToList(); //AddressType factaddress = // context.AddressTypes.FirstOrDefault(a => a.TypeName == AddressTypesEnum.FactAddress.ToString()); //AddressType legaladdress = // context.AddressTypes.FirstOrDefault(a => a.TypeName == AddressTypesEnum.LegalAddress.ToString()); //AddressType birthaddress = // context.AddressTypes.FirstOrDefault(a => a.TypeName == AddressTypesEnum.BirthAddress.ToString()); //foreach (Address address in adresses) //{ // switch (address.TypeOfAddress) // { // case "factaddress": address.AddressType = factaddress; // break; // case "legaladdress": address.AddressType = legaladdress; // break; // case "birthaddress": address.AddressType = birthaddress; // break; // } //} //context.UpdateRange(adresses); //context.SaveChanges(); } }
public void Should_Parse_The_Empty_Exchange_Rate_Type() { ExchangeRateType empty = ExchangeRateType.Empty; Assert.NotNull(empty); }
public void Should_Get_The_List_Of_Exchange_Rate_Types() { FixedList <ExchangeRateType> list = ExchangeRateType.GetList(); Assert.NotEmpty(list); }
public IEnumerable <ExchangeRate> GetExchangeRates(IEnumerable <Currency> currencies, ExchangeRateType rateType) { string[] lines = File.ReadAllText(ExchangeRateFile).Split('\n'); var rates = new List <ExchangeRate>(); var sourceCurrency = new Currency(ExchangeRateSourceCurrency); foreach (var row in lines.Skip(2)) { var fields = row.Split(';'); string currency = fields[0].Trim().ToUpper(); if (currencies.Any(x => x.Code == currency)) { var targetCurency = new Currency(currency); decimal value = 0; switch (rateType) { case ExchangeRateType.BuyInCash: { decimal.TryParse(fields[1].Trim(), out value); break; } case ExchangeRateType.SellInCash: { decimal.TryParse(fields[2].Trim(), out value); break; } case ExchangeRateType.MiddleInCash: { decimal value1 = 0; decimal value2 = 0; decimal.TryParse(fields[1].Trim(), out value1); decimal.TryParse(fields[2].Trim(), out value2); value = (value1 + value2) / 2; break; } case ExchangeRateType.BuyTransfer: { decimal.TryParse(fields[3].Trim(), out value); break; } case ExchangeRateType.SellTransfer: { decimal.TryParse(fields[3].Trim(), out value); break; } case ExchangeRateType.MiddleTransfer: { decimal value1 = 0; decimal value2 = 0; decimal.TryParse(fields[3].Trim(), out value1); decimal.TryParse(fields[4].Trim(), out value2); value = (value1 + value2) / 2; break; } case ExchangeRateType.CentralBank: { decimal.TryParse(fields[5].Trim(), out value); break; } default: { break; } } var rate = new ExchangeRate(sourceCurrency, targetCurency, rateType, value); rates.Add(rate); } } return(rates.ToArray()); }
public void Insert(ExchangeRateType item) { _todoList.Add(item); }