/// <summary>
        /// Select all events for selected Funding Line
        /// </summary>
        /// <param name="fundingLine">funding line </param>
        /// <returns>list of Funding Line events</returns>
        public List <FundingLineEvent> SelectFundingLineEvents(FundingLine fundingLine)
        {
            List <FundingLineEvent> list = new List <FundingLineEvent>();

            const string sqlText =
                @"SELECT 
                        [id],
                        [code],
                        [amount],
                        [direction],
                        [fundingline_id],
                        [deleted],
                        [creation_date],
                        [type] 
                  FROM [FundingLineEvents] 
                  WHERE fundingline_id = @fundingline_id 
                  ORDER BY creation_date DESC, id DESC";

            using (SqlConnection conn = GetConnection())
                using (OpenCbsCommand cmd = new OpenCbsCommand(sqlText, conn))
                {
                    cmd.AddParam("@fundingline_id", fundingLine.Id);

                    using (OpenCbsReader reader = cmd.ExecuteReader())
                    {
                        if (reader == null || reader.Empty)
                        {
                            return(list);
                        }
                        {
                            while (reader.Read())
                            {
                                FundingLineEvent fundingLineEvent = new FundingLineEvent
                                {
                                    Id       = reader.GetInt("id"),
                                    Code     = reader.GetString("code"),
                                    Amount   = reader.GetMoney("amount"),
                                    Movement =
                                        ((OBookingDirections)
                                         reader.GetSmallInt("direction")),
                                    IsDeleted =
                                        reader.GetBool("deleted"),
                                    CreationDate =
                                        reader.GetDateTime("creation_date"),
                                    Type =
                                        ((OFundingLineEventTypes)
                                         reader.GetSmallInt("type")),
                                    FundingLine = fundingLine
                                };
                                list.Add(fundingLineEvent);
                            }
                        }
                    }
                    return(list);
                }
        }
예제 #2
0
        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);
        }
예제 #3
0
        public List <QueuedEmail> SelectAll()
        {
            List <QueuedEmail> qeuedEmails = new List <QueuedEmail>();
            const string       q           =
                @"SELECT * FROM dbo.QueuedEmails where Deleted <> 1";

            using (SqlConnection conn = GetConnection())
                using (OpenCbsCommand c = new OpenCbsCommand(q, conn))
                    using (OpenCbsReader r = c.ExecuteReader())
                    {
                        if (r.Empty)
                        {
                            return(qeuedEmails);
                        }

                        while (r.Read())
                        {
                            var queuedEmail = new QueuedEmail
                            {
                                Id             = r.GetInt("Id"),
                                Priority       = r.GetInt("Priority"),
                                From           = r.GetString("From"),
                                FromName       = r.GetString("FromName"),
                                To             = r.GetString("To"),
                                ToName         = r.GetString("ToName"),
                                ReplyTo        = r.GetString("ReplyTo"),
                                ReplyToName    = r.GetString("ReplyToName"),
                                CC             = r.GetString("CC"),
                                Bcc            = r.GetString("Bcc"),
                                Body           = r.GetString("Body"),
                                CreatedOnUtc   = r.GetDateTime("CreatedOnUtc"),
                                SentOnUtc      = r.GetNullDateTime("SentOnUtc"),
                                EmailAccountId = r.GetInt("EmailAccountId"),
                                SentTries      = r.GetInt("SentTries"),
                                Subject        = r.GetString("Subject"),
                                Deleted        = r.GetBool("Deleted"),
                            };

                            if (queuedEmail.EmailAccountId > 0)
                            {
                                EmailAccountManager _emailAccountManager = new EmailAccountManager(user);
                                queuedEmail.EmailAccount = _emailAccountManager.SelectById(queuedEmail.EmailAccountId);
                            }
                            qeuedEmails.Add(queuedEmail);
                        }
                    }
            return(qeuedEmails);
        }
예제 #4
0
        public List <QueuedSMS> SelectAll()
        {
            List <QueuedSMS> qeuedSMSs = new List <QueuedSMS>();
            const string     q         =
                @"SELECT * FROM dbo.QueuedSMS where Deleted <> 1";

            using (SqlConnection conn = GetConnection())
                using (OpenCbsCommand c = new OpenCbsCommand(q, conn))
                    using (OpenCbsReader r = c.ExecuteReader())
                    {
                        if (r.Empty)
                        {
                            return(qeuedSMSs);
                        }

                        while (r.Read())
                        {
                            var queuedSMS = new QueuedSMS
                            {
                                Id           = r.GetInt("Id"),
                                From         = r.GetString("From"),
                                Recipient    = r.GetString("Recipient"),
                                RecipientId  = r.GetNullInt("RecipientId"),
                                ContractId   = r.GetNullInt("ContractId"),
                                Charged      = r.GetNullBool("Charged"),
                                Message      = r.GetString("Message"),
                                CreatedOnUtc = r.GetDateTime("CreatedOnUtc"),
                                SentOnUtc    = r.GetNullDateTime("SentOnUtc"),
                                SentTries    = r.GetInt("SentTries"),
                                Response     = r.GetString("Response"),
                                Deleted      = r.GetBool("Deleted"),
                            };
                            qeuedSMSs.Add(queuedSMS);
                        }
                    }
            return(qeuedSMSs);
        }
예제 #5
0
        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;
        }
예제 #6
0
        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"),
            };
        }
예제 #7
0
 private static TrancheEvent GetTransh(OpenCbsReader r)
 {
     return new TrancheEvent
     {
         Number = r.GetInt("Number"),
         StartDate = r.GetDateTime("start_date"),
         Amount = r.GetMoney("amount"),
         Maturity = r.GetInt("countOfInstallments"),
         ApplyNewInterest = r.GetBool("ApplyNewInterest"),
         InterestRate = r.GetDecimal("interest_rate"),
         StartedFromInstallment = r.GetInt("started_from_installment"),
         Deleted = r.GetBool("is_deleted"),
         Id = r.GetInt("event_id")
     };
 }
예제 #8
0
        private static void SetSavingsEvent(OpenCbsReader r, SavingEvent e, ISavingProduct pProduct)
        {
            e.Id = r.GetInt("id");
            e.ContracId = r.GetInt("contract_id");
            e.Code = r.GetString("code");
            e.Amount = r.GetMoney("amount");
            e.Description = r.GetString("description");
            e.Deleted = r.GetBool("deleted");
            e.Date = r.GetDateTime("creation_date");
            e.Cancelable = r.GetBool("cancelable");
            e.IsFired = r.GetBool("is_fired");
            e.CancelDate = r.GetNullDateTime("cancel_date");

            if(pProduct != null)
                e.ProductType = pProduct.GetType();

            if (r.GetNullSmallInt("savings_method").HasValue)
                e.SavingsMethod = (OSavingsMethods)r.GetNullSmallInt("savings_method").Value;

            e.IsPending = r.GetBool("pending");
            e.PendingEventId = r.GetNullInt("pending_event_id");
            e.TellerId = r.GetNullInt("teller_id");
            e.LoanEventId = r.GetNullInt("loan_event_id");

            if (pProduct != null)
            {
                e.ProductType = pProduct.GetType();
            }

            if (e is SavingTransferEvent)
            {
                ((SavingTransferEvent)e).RelatedContractCode = r.GetString("related_contract_code");
            }

            if (e is ISavingsFees)
            {
                ((ISavingsFees) e).Fee = r.GetMoney("fees");
            }

            e.User = new User
                         {
                             Id = r.GetInt("user_id"),
                             UserName = r.GetString("user_name"),
                             Password = r.GetString("user_pass"),
                             LastName = r.GetString("last_name"),
                             FirstName = r.GetString("first_name")
                         };
            e.User.SetRole(r.GetString("role_code"));

            e.ClientType = OClientTypes.All;

            switch (r.GetString("client_type_code"))
            {
                case "I":
                    e.ClientType = OClientTypes.Person; break;
                case "C":
                    e.ClientType = OClientTypes.Corporate; break;
                case "G":
                    e.ClientType = OClientTypes.Group; break;
                case "V":
                    e.ClientType = OClientTypes.Village; break;
            }

            e.Branch = new Branch { Id = r.GetInt("branch_id") };
            e.Currency = new Currency
                             {
                                 Id = r.GetInt("currency_id"),
                                 Code = r.GetString("currency_code"),
                                 IsPivot = r.GetBool("is_pivot"),
                                 IsSwapped = r.GetBool("is_swapped")
                             };
            e.SavingProduct = new SavingsBookProduct { Id = r.GetInt("product_id") };
        }
 private static BookingToView GetBooking(Account pAccount, OpenCbsReader reader)
 {
     return new BookingToView
                {
                    Date = reader.GetDateTime("date"),
                    EventCode = reader.GetString("event_code"),
                    ExchangeRate = reader.GetNullDouble("exchange_rate"),
                    AmountInternal = reader.GetMoney("amount"),
                    ContractCode = reader.GetString("contract_code"),
                    Direction =
                        (reader.GetString("debit_local_account_number") == pAccount.Number
                             ? OBookingDirections.Debit
                             : OBookingDirections.Credit),
                    IsExported = reader.GetBool("is_exported")
                };
 }
        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")}

                       };
        }
예제 #11
0
        public List <Installment> SelectInstallment(DateTime pStartDate, DateTime pEndDate)
        {
            List <Installment> rows = new List <Installment>();

            const string sqlText = @"SELECT [credit].[id] AS contract_id 
                                           ,[expected_date] AS installment_date
	                                       ,[contract_code]
	                                       ,[number] AS installment_number
                                           ,[interest_repayment] + [capital_repayment] - [paid_capital] - [paid_interest] AS installment_amount
	                                       ,PersonalBank.[name] AS personal_bank_name
	                                       ,PersonalBank.[BIC] AS personal_bank_bic
                                           ,PersonalBank.[IBAN1] AS personal_bank_iban_1
                                           ,PersonalBank.[IBAN2] AS personal_bank_iban_2
                                           ,BusinessBank.[name] AS business_bank_name
                                           ,BusinessBank.[BIC] AS business_bank_bic
                                           ,BusinessBank.[IBAN1] AS business_bank_iban_1
                                           ,BusinessBank.[IBAN2] AS business_bank_iban_2
                                           ,Packages.code AS product_code
                                           ,Packages.Name AS product_name
                                           ,[Persons].[id] AS client_id
                                           ,[Persons].[first_name] + ' ' + [Persons].[last_name] AS client_name
                                     FROM [Installments] i
                                     INNER JOIN Contracts ON Contracts.id = contract_id
                                     INNER JOIN Credit ON Credit.id = contract_id
                                     INNER JOIN Projects ON Projects.id = project_id
                                     INNER JOIN Persons ON Persons.id = Projects.tiers_id
                                     INNER JOIN Banks AS PersonalBank ON PersonalBank.id = Persons.personalBank_id
                                     INNER JOIN Banks AS BusinessBank ON BusinessBank.id = Persons.businessBank_id
                                     INNER JOIN Packages ON Packages.id = Credit.package_id
                                     WHERE paid_date IS NULL
                                     AND ([interest_repayment] + [capital_repayment] - [paid_capital] - [paid_interest]) != 0
                                     AND Credit.disbursed = 1
                                     AND expected_date BETWEEN @startDate AND @endDate
                                     AND (SELECT COUNT(i2.number) 
                                          FROM Installments i2
	                                      WHERE i2.contract_id = i.contract_id
	                                      AND i2.number < i.number
	                                      AND ((i2.paid_date IS NULL AND (i2.interest_repayment + i2.capital_repayment - i2.paid_capital - paid_capital) > 0)
                                           OR (i2.paid_date IS NOT NULL AND i2.pending = 1))) = 0";

            using (SqlConnection connection = GetConnection())
                using (OpenCbsCommand cmd = new OpenCbsCommand(sqlText, connection))
                {
                    cmd.AddParam("@startDate", pStartDate);
                    cmd.AddParam("@endDate", pEndDate);

                    using (OpenCbsReader reader = cmd.ExecuteReader())
                    {
                        if (reader == null || reader.Empty)
                        {
                            return(rows);
                        }

                        while (reader.Read())
                        {
                            Installment row = new Installment
                            {
                                InstallmentDate   = reader.GetDateTime("installment_date"),
                                ContractId        = reader.GetInt("contract_id"),
                                ClientId          = reader.GetInt("client_id"),
                                ContractCode      = reader.GetString("contract_code"),
                                InstallmentNumber = reader.GetInt("installment_number"),
                                InstallmentAmount = reader.GetMoney("installment_amount"),
                                PersonalBankName  = reader.GetString("personal_bank_name"),
                                PersonalBankBic   = reader.GetString("personal_bank_bic"),
                                PersonalBankIban1 = reader.GetString("personal_bank_iban_1"),
                                PersonalBankIban2 = reader.GetString("personal_bank_iban_2"),
                                BusinessBankName  = reader.GetString("business_bank_name"),
                                BusinessBankBic   = reader.GetString("business_bank_bic"),
                                BusinessBankIban1 = reader.GetString("business_bank_iban_1"),
                                BusinessBankIban2 = reader.GetString("business_bank_iban_2"),
                                ProductCode       = reader.GetString("product_code"),
                                ProductName       = reader.GetString("product_name"),
                                ClientName        = reader.GetString("client_name")
                            };

                            rows.Add(row);
                        }
                    }
                }

            return(rows);
        }
예제 #12
0
 private static RescheduleLoanEvent GetReschedulingLoanEvent(OpenCbsReader r)
 {
     return new RescheduleLoanEvent{
         Id = r.GetInt("rle_id"),
         Amount = r.GetMoney("rle_amount"),
         NbOfMaturity = r.GetInt("rle_maturity"),
         PreferredFirstInstallmentDate = r.GetDateTime("rle_preferred_first_installment_date"),
          PreviousInterestRate = r.GetDecimal("rle_previous_interest_rate")
     };
 }
예제 #13
0
 private static TrancheEvent GetTrancheLoanEvent(OpenCbsReader r)
 {
     return new TrancheEvent{
         Id = r.GetInt("tranche_id"),
         Amount = r.GetMoney("tranche_amount"),
         InterestRate = r.GetMoney("tranche_interest_rate").Value,
         Maturity = r.GetInt("tranche_maturity"),
         StartDate = r.GetDateTime("tranche_start_date")
     };
 }
예제 #14
0
        private static void GetEvent(OpenCbsReader r, Event pEvent)
        {
            //abstract class Event attributes
            string eventType = r.GetString("event_type");
            pEvent.Code = eventType;
            pEvent.ContracId = r.GetInt("contract_id");
            pEvent.Date = r.GetDateTime("event_date");
            pEvent.EntryDate = r.GetDateTime("entry_date");
            pEvent.Deleted = r.GetBool("event_deleted");
            pEvent.IsFired = true;
            pEvent.Cancelable = true;
            pEvent.ExportedDate = DateTime.MinValue;
            pEvent.Comment = r.GetString("comment");
            pEvent.TellerId = r.GetNullInt("teller_id");
            pEvent.ParentId = r.GetNullInt("parent_id");
            pEvent.CancelDate = r.GetNullDateTime("cancel_date");
            pEvent.ClientType = OClientTypes.All;

            switch (r.GetString("client_type_code"))
            {
                case "I":
                    pEvent.ClientType = OClientTypes.Person;
                    break;
                case "C":
                    pEvent.ClientType = OClientTypes.Corporate;
                    break;
                case "G":
                    pEvent.ClientType = OClientTypes.Group;
                    break;
                case "V":
                    pEvent.ClientType = OClientTypes.Village;
                    break;
            }

            //User associated to the event
            pEvent.User = new User
                              {
                                  Id = r.GetInt("user_id"),
                                  UserName = r.GetString("user_username"),
                                  Password = r.GetString("user_password"),
                                  LastName = r.GetString("user_lastname"),
                                  FirstName = r.GetString("user_firstname")
                              };

            pEvent.Currency = new Currency
                                  {
                                      Id = r.GetInt("currency_id"),
                                      Code = r.GetString("currency_code"),
                                      IsPivot = r.GetBool("is_pivot"),
                                      IsSwapped = r.GetBool("is_swapped")
                                  };

            pEvent.Branch = new Branch { Id = r.GetInt("branch_id") };
            pEvent.LoanProduct = new LoanProduct { Id = r.GetInt("product_id") };

            pEvent.User.SetRole(r.GetString("user_role"));
            if (
                eventType.Equals("ULIE") ||
                eventType.Equals("ULOE")
                )
                return;

            if (r.HasColumn("contract_code"))
                pEvent.Description = r.GetString("contract_code");
        }
예제 #15
0
        private static void SetSavingsEvent(OpenCbsReader r, SavingEvent e, ISavingProduct pProduct)
        {
            e.Id          = r.GetInt("id");
            e.ContracId   = r.GetInt("contract_id");
            e.Code        = r.GetString("code");
            e.Amount      = r.GetMoney("amount");
            e.Description = r.GetString("description");
            e.Deleted     = r.GetBool("deleted");
            e.Date        = r.GetDateTime("creation_date");
            e.Cancelable  = r.GetBool("cancelable");
            e.IsFired     = r.GetBool("is_fired");
            e.CancelDate  = r.GetNullDateTime("cancel_date");

            if (pProduct != null)
            {
                e.ProductType = pProduct.GetType();
            }

            if (r.GetNullSmallInt("savings_method").HasValue)
            {
                e.SavingsMethod = (OSavingsMethods)r.GetNullSmallInt("savings_method").Value;
            }

            e.IsPending      = r.GetBool("pending");
            e.PendingEventId = r.GetNullInt("pending_event_id");
            e.TellerId       = r.GetNullInt("teller_id");
            e.LoanEventId    = r.GetNullInt("loan_event_id");

            if (pProduct != null)
            {
                e.ProductType = pProduct.GetType();
            }

            if (e is SavingTransferEvent)
            {
                ((SavingTransferEvent)e).RelatedContractCode = r.GetString("related_contract_code");
            }

            if (e is ISavingsFees)
            {
                ((ISavingsFees)e).Fee = r.GetMoney("fees");
            }

            e.User = new User
            {
                Id        = r.GetInt("user_id"),
                UserName  = r.GetString("user_name"),
                Password  = r.GetString("user_pass"),
                LastName  = r.GetString("last_name"),
                FirstName = r.GetString("first_name")
            };
            e.User.SetRole(r.GetString("role_code"));

            e.ClientType = OClientTypes.All;

            switch (r.GetString("client_type_code"))
            {
            case "I":
                e.ClientType = OClientTypes.Person; break;

            case "C":
                e.ClientType = OClientTypes.Corporate; break;

            case "G":
                e.ClientType = OClientTypes.Group; break;

            case "V":
                e.ClientType = OClientTypes.Village; break;
            }

            e.Branch = new Branch {
                Id = r.GetInt("branch_id")
            };
            e.Currency = new Currency
            {
                Id        = r.GetInt("currency_id"),
                Code      = r.GetString("currency_code"),
                IsPivot   = r.GetBool("is_pivot"),
                IsSwapped = r.GetBool("is_swapped")
            };
            e.SavingProduct = new SavingsBookProduct {
                Id = r.GetInt("product_id")
            };
        }
예제 #16
0
 private VillageMember GetMemberFromReader(OpenCbsReader r)
 {
     return new VillageMember
                {
                    Tiers = { Id = r.GetInt("person_id") },
                    JoinedDate = r.GetDateTime("joined_date"),
                    LeftDate = r.GetNullDateTime("left_date"),
                    IsLeader = r.GetBool("is_leader"),
                    CurrentlyIn = r.GetBool("currently_in"),
                };
 }
예제 #17
0
 private static TrancheEvent GetTrancheLoanEvent(OpenCbsReader r)
 {
     return new TrancheEvent{
         Id = r.GetInt("tranche_id"),
         Amount = r.GetMoney("tranche_amount"),
         InterestRate = r.GetMoney("tranche_interest_rate").Value,
         Maturity = r.GetInt("tranche_maturity"),
         StartDate = r.GetDateTime("tranche_start_date"),
         GracePeriod = r.GetInt("tranche_grace_period"),
         FirstRepaymentDate = r.GetDateTime("tranche_first_repayment_date"),
     };
 }
예제 #18
0
 private TrancheEvent GetTrancheLoanEvent(OpenCbsReader r)
 {
     return new TrancheEvent{
         Id = r.GetInt("tranche_id"),
         Amount = r.GetMoney("tranche_amount"),
         InterestRate = r.GetMoney("tranche_interest_rate").Value,
         Maturity = r.GetInt("tranche_maturity"),
         StartDate = r.GetDateTime("tranche_start_date"),
         GracePeriod = r.GetInt("tranche_grace_period"),
         FirstRepaymentDate = r.GetDateTime("tranche_first_repayment_date"),
         PaymentMethodId = r.GetNullInt("tranche_pm"),
         PaymentMethod = r.GetNullInt("tranche_pm") == null
                             ? null
                             : _paymentMethodManager.SelectPaymentMethodById(
                                 r.GetNullInt("tranche_pm").Value)
     };
 }