private static ProvisioningRate GetProvisionningRate(OpenCbsReader reader) { return(new ProvisioningRate { Number = reader.GetInt("id"), NbOfDaysMin = reader.GetInt("number_of_days_min"), NbOfDaysMax = reader.GetInt("number_of_days_max"), ProvisioningValue = reader.GetDouble("provisioning_value"), ProvisioningInterest = reader.GetDouble("provisioning_interest"), ProvisioningPenalty = reader.GetDouble("provisioning_penalty") }); }
public ExchangeRate Select(DateTime pDate, Currency pCurrency) { const string q = @"SELECT exchange_date, exchange_rate, currency_id FROM ExchangeRates WHERE DATEADD(dd, 0, DATEDIFF(dd, 0, exchange_date)) = @date AND currency_id = @currency"; using (SqlConnection conn = GetConnection()) using (OpenCbsCommand c = new OpenCbsCommand(q, conn)) { c.AddParam("@date", pDate.Date); c.AddParam("@currency", pCurrency.Id); using (OpenCbsReader r = c.ExecuteReader()) { if (r.Empty) { return(null); } r.Read(); return(new ExchangeRate { Date = pDate, Rate = r.GetDouble("exchange_rate"), Currency = pCurrency }); } } }
public List <ExchangeRate> SelectRatesByDate(DateTime beginDate, DateTime endDate) { const string q = @"SELECT exchange_date, exchange_rate, currency_id, is_pivot, is_swapped, name, code FROM ExchangeRates INNER JOIN Currencies ON ExchangeRates.currency_id = Currencies.id WHERE exchange_date BETWEEN @beginDate AND @endDate"; List <ExchangeRate> rates; using (SqlConnection conn = GetConnection()) using (OpenCbsCommand c = new OpenCbsCommand(q, conn)) { c.AddParam("@beginDate", beginDate.Date); c.AddParam("@endDate", endDate.Date); using (OpenCbsReader r = c.ExecuteReader()) { if (r == null || r.Empty) { return(null); } rates = new List <ExchangeRate>(); while (r.Read()) { ExchangeRate newRate = new ExchangeRate { Date = r.GetDateTime("exchange_date"), Rate = r.GetDouble("exchange_rate"), Currency = new Currency { Id = r.GetInt("currency_id"), IsPivot = r.GetBool("is_pivot"), IsSwapped = r.GetBool("is_swapped"), Name = r.GetString("name"), Code = r.GetString("code") } }; rates.Add(newRate); } } } return(rates); }
private static ProvisioningRate GetProvisionningRate(OpenCbsReader reader) { return new ProvisioningRate { Number = reader.GetInt("id"), NbOfDaysMin = reader.GetInt("number_of_days_min"), NbOfDaysMax = reader.GetInt("number_of_days_max"), ProvisioningValue = reader.GetDouble("provisioning_value"), ProvisioningInterest = reader.GetDouble("provisioning_interest"), ProvisioningPenalty = reader.GetDouble("provisioning_penalty") }; }
private SavingBookContract GetSavingFromReader(OpenCbsReader pReader) { var savingContract = new SavingBookContract( ApplicationSettings.GetInstance(_user.Md5), _user); savingContract.Product = new SavingsBookProduct { Id = pReader.GetInt("product_id") }; savingContract.Id = pReader.GetInt("id"); savingContract.Code = pReader.GetString("code"); savingContract.Status = (OSavingsStatus)pReader.GetSmallInt("status"); savingContract.CreationDate = pReader.GetDateTime("creation_date"); savingContract.ClosedDate = pReader.GetNullDateTime("closed_date"); savingContract.InterestRate = pReader.GetDouble("interest_rate"); savingContract.SavingsOfficer = new User { Id = pReader.GetInt("savings_officer_id") , FirstName = pReader.GetString("so_first_name") , LastName = pReader.GetString("so_last_name") }; savingContract.InitialAmount = pReader.GetMoney("initial_amount"); savingContract.EntryFees = pReader.GetMoney("entry_fees"); savingContract.NsgID = pReader.GetNullInt("nsg_id"); return savingContract; }
private Loan _GetLoan(OpenCbsReader r) { return new Loan(_user, ApplicationSettings.GetInstance(_user.Md5), NonWorkingDateSingleton.GetInstance(_user.Md5), ProvisionTable.GetInstance(_user), ChartOfAccounts.GetInstance(_user)) { Id = r.GetInt("credit_id"), ClientType = r.GetChar("client_type_code") == 'I' ? OClientTypes.Person : r.GetChar("client_type_code") == 'G' ? OClientTypes.Group : OClientTypes.Corporate, ContractStatus = (OContractStatus) r.GetSmallInt("status"), CreditCommiteeDate = r.GetNullDateTime("credit_commitee_date"), CreditCommiteeComment = r.GetString("credit_commitee_comment"), CreditCommitteeCode = r.GetString("credit_commitee_code"), Amount = r.GetMoney("amount"), InterestRate = r.GetDecimal("interest_rate"), NbOfInstallments = r.GetInt("nb_of_installment"), NonRepaymentPenalties = new NonRepaymentPenalties { InitialAmount = r.GetDouble("non_repayment_penalties_based_on_initial_amount"), OLB = r.GetDouble("non_repayment_penalties_based_on_olb"), OverDueInterest = r.GetDouble("non_repayment_penalties_based_on_overdue_interest"), OverDuePrincipal = r.GetDouble("non_repayment_penalties_based_on_overdue_principal") }, AnticipatedTotalRepaymentPenalties = r.GetDouble("anticipated_total_repayment_penalties"), AnticipatedPartialRepaymentPenalties = r.GetDouble("anticipated_partial_repayment_penalties"), AnticipatedPartialRepaymentPenaltiesBase = (OAnticipatedRepaymentPenaltiesBases) r.GetSmallInt("anticipated_partial_repayment_base"), AnticipatedTotalRepaymentPenaltiesBase =(OAnticipatedRepaymentPenaltiesBases) r.GetSmallInt("anticipated_total_repayment_base"), Disbursed = r.GetBool("disbursed"), GracePeriod = r.GetNullInt("grace_period"), GracePeriodOfLateFees = r.GetNullInt("grace_period_of_latefees"), WrittenOff = r.GetBool("written_off"), Rescheduled = r.GetBool("rescheduled"), Code = r.GetString("contract_code"), BranchCode = r.GetString("branch_code"), CreationDate = r.GetDateTime("creation_date"), StartDate = r.GetDateTime("start_date"), AlignDisbursementDate = r.GetDateTime("align_disbursed_date"), CloseDate = r.GetDateTime("close_date"), Closed = r.GetBool("closed"), BadLoan = r.GetBool("bad_loan"), Synchronize = r.GetBool("synchronize"), ScheduleChangedManually = r.GetBool("schedule_changed"), AmountUnderLoc = r.GetMoney("amount_under_loc"), CompulsorySavingsPercentage = r.GetNullInt("loan_percentage"), LoanPurpose = r.GetString("loan_purpose"), Comments = r.GetString("comments"), AmountMin = r.GetMoney("amount_min"), AmountMax = r.GetMoney("amount_max"), InterestRateMin = r.GetNullDecimal("ir_min"), InterestRateMax = r.GetNullDecimal("ir_max"), NmbOfInstallmentsMin = r.GetNullInt("nmb_of_inst_min"), NmbOfInstallmentsMax = r.GetNullInt("nmb_of_inst_max"), LoanCycle = r.GetNullInt("loan_cycle"), Insurance = r.GetDecimal("insurance"), NsgID = r.GetNullInt("nsg_id"), EconomicActivityId = r.GetInt("activity_id"), FirstInstallmentDate = r.GetDateTime("preferred_first_installment_date"), }; }
private static Booking GetBooking(OpenCbsReader reader) { return new Booking { Id = reader.GetInt("id"), Amount = reader.GetMoney("amount"), IsExported = reader.GetBool("is_exported"), DebitAccount = new Account { Id = reader.GetInt("debit_account_number_id") }, CreditAccount = new Account { Id = reader.GetInt("credit_account_number_id") }, EventId = reader.GetInt("event_id"), ContractId = reader.GetInt("contract_id"), Date = reader.GetDateTime("transaction_date"), Currency = new Currency {Id = reader.GetInt("currency_id")}, ExchangeRate = reader.GetDouble("exchange_rate"), Description = reader.GetString("description"), Branch = new Branch {Id = reader.GetInt("branch_id")} }; }
private static ExoticInstallment _GetExoticInstallment(OpenCbsReader r) { return new ExoticInstallment { Number = r.GetInt("number"), PrincipalCoeff = r.GetDouble("principal_coeff"), InterestCoeff =r.GetNullDouble("interest_coeff") }; }