示例#1
0
        private void buttonCreditCommiteeSaveDecision_Click(object sender, EventArgs e)
        {
            if (buttonCreditCommiteeSaveDecision.Text.Equals(GetString("update")))
            {
                EnableBoxCreditCommitteeComponents(true);
                buttonCreditCommiteeSaveDecision.Enabled = true;
                buttonCreditCommiteeSaveDecision.Text = GetString("save");
            }
            else
            {
                OContractStatus currentCreditStatus = OContractStatus.Pending;
                OContractStatus currentGuaranteeStatus = OContractStatus.Pending;

                try
                {
                    if (_credit != null)
                    {
                        OContractStatus newStatus = GetNewStatusAndValidate(ref currentCreditStatus);

                        _credit.ContractStatus = newStatus;
                        _credit.CreditCommiteeComment = textBoxCreditCommiteeComment.Text;
                        _credit.CreditCommiteeDate = dateTimePickerCreditCommitee.Value;
                        _credit.CreditCommitteeCode = tBCreditCommitteeCode.Text;

                        IClient client = null;
                        if (_oClientType == OClientTypes.Corporate) client = _corporateUserControl.Corporate;
                        if (_oClientType == OClientTypes.Person) client = _personUserControl.Person;
                        if (_oClientType == OClientTypes.Group) client = _groupUserControl.Group;

                        if (OContractStatus.Refused == newStatus
                            || OContractStatus.Abandoned == newStatus
                            || OContractStatus.Closed == newStatus
                            || OContractStatus.Deleted == newStatus)
                        {
                            _credit.Closed = true;
                            if (client != null)
                            {
                                if (client.ActiveLoans != null)
                                {
                                    if (client.ActiveLoans.Count == 0)
                                    {
                                        client.Active = false;
                                        client.Status = OClientStatus.Inactive;
                                    }
                                }
                            }
                            // updating guarantor status
                            if (_listGuarantors != null && _listGuarantors.Count > 0)
                            {
                                foreach (Guarantor guarantor in _listGuarantors)
                                {
                                    guarantor.Tiers.Active = false;
                                    guarantor.Tiers.Status = OClientStatus.Inactive;
                                    ServicesProvider.GetInstance().GetClientServices().UpdateClientStatus(guarantor.Tiers);
                                }
                            }
                        }
                        else
                        {
                            _credit.Closed = false;
                            if (client != null)
                            {
                                client.Active = true;
                                client.Status = OClientStatus.Active;
                            }
                        }

                        _credit = ServicesProvider.GetInstance().GetContractServices().
                            UpdateContractStatus(_credit, _project, client, currentCreditStatus == OContractStatus.Validated);

                        DisableCommitteeDecision(OContractStatus.Validated);

                        if (_credit.ContractStatus != OContractStatus.Validated)
                        {
                            var pendingOrPostponed = _credit.PendingOrPostponed();
                            if (!pendingOrPostponed)
                                ServicesProvider.GetInstance().GetContractServices().UpdateTiersStatus(_credit, client);

                            SetGuarantorsEnabled(pendingOrPostponed);
                            InitializeTabPageGuaranteesDetailsButtons(_credit.Product.UseGuarantorCollateral);
                        }
                        else
                        {
                            btnEditSchedule.Enabled = false;
                            InitializeTabPageGuaranteesDetailsButtons(_credit.Product.UseGuarantorCollateral);
                            DisableContractDetails(OContractStatus.Validated);
                        }
                        InitLoanDetails(false, _credit.Disbursed, _credit.ContractStatus == OContractStatus.Validated);
                        tabPageLoansDetails.Enabled = true;

                        if (_credit.PendingOrPostponed())
                        {
                            // Enable loan details components
                            InitializeAmount(_credit, false);
                            InitializePackageInterestRate(_credit, false);
                            InitializePackageGracePeriod(_credit.Product, false);
                            InitializePackageNumberOfInstallments(_credit, false);
                            cmbLoanOfficer.Enabled = true;
                            textBoxLoanPurpose.Enabled = true;
                            textBoxComments.Enabled = true;
                            comboBoxLoanFundingLine.Enabled = true;
                            // Advanced settings tab
                            EnableLocAmountTextBox(_credit);
                            EnableInsuranceTextBox(_credit);
                            groupBoxEntryFees.Enabled = true;
                            btnEditSchedule.Enabled = true;
                            InitializePackageAnticipatedTotalRepaymentsPenalties(_credit.Product, false);
                            InitializePackageAnticipatedPartialRepaymentsPenalties(_credit.Product, false);
                            InitializePackageNonRepaymentPenalties(_credit.Product, false);

                            //if (_credit != null && _credit.Id > 0)
                            //    InitializeCustomizableFields(OCustomizableFieldEntities.Loan, _credit.Id, false);
                            //else
                            //    InitializeCustomizableFields(OCustomizableFieldEntities.Loan, null, false);
                        }
                        InitializePackageLoanCompulsorySavings(_credit.Product, false);

                        DisplayContracts(_project.Credits);

                        DisableContractDetails(newStatus);
                        if (_credit.Product.InterestRate.HasValue)
                        {
                            nudInterestRate.Enabled = false;
                        }

                    }

                    ((LotrasmicMainWindowForm)_mdiParent).ReloadAlertsSync();

                }
                catch (Exception ex)
                {
                    if (_credit != null) _credit.ContractStatus = currentCreditStatus;
                    if (_guarantee != null) _guarantee.ContractStatus = currentGuaranteeStatus;
                    new frmShowError(CustomExceptionHandler.ShowExceptionText(ex)).ShowDialog();
                }
            }
        }
示例#2
0
        /// <summary>
        /// The method initializes values of controls of the Details tab when a contract is creating
        /// </summary>
        /// <param name="pPackage">Loan product</param>
        private void InitializeTabPageLoansDetails(LoanProduct pPackage)
        {
            _credit = new Loan(User.CurrentUser, ServicesProvider.GetInstance().GetGeneralSettings(),
                ServicesProvider.GetInstance().GetNonWorkingDate(),
                CoreDomainProvider.GetInstance().GetProvisioningTable(),
                CoreDomainProvider.GetInstance().GetChartOfAccounts());
            _credit.Product = pPackage;

            nudLoanAmount.Text = string.Empty;
            textBoxLoanContractCode.Text = string.Empty;
            ReInitializeListViewInstallment();
            pnlCCStatus.Enabled = true;

            InitializeFundingLine();
            InitializeInstallmentTypes();
            InitializeLoanOfficer();
            DisableContractDetails(_credit.ContractStatus);
            SetPackageValuesForLoanDetails(_credit, true);
            SetSecurityForTabPageLoansDetails(true);
            InitLoanDetails(true, false, false);
            InitializeTabPageGuaranteesDetailsButtons(_credit.Product.UseGuarantorCollateral);
            cmbLoanOfficer.Enabled = true;
            textBoxLoanPurpose.Enabled = true;
            textBoxComments.Enabled = true;
            listViewLoanInstallments.Items.Clear();
            listViewGuarantors.Items.Clear();
            lblCreditCurrency.Text = MultiLanguageStrings.GetString(Ressource.ClientForm, "Currency.Text") + pPackage.Currency.Name;
            lbCompulsorySavings.Enabled = false;
            InitializePackageLoanCompulsorySavings(pPackage, true);

            btnEditSchedule.Visible = _credit.Product.AllowFlexibleSchedule;
            btnEditSchedule.Enabled = ((_credit.ContractStatus == 0 || _credit.PendingOrPostponed()) && !_credit.Disbursed);
            try
            {
                ServiceProvider.GetContractServices().ManualScheduleBeforeDisbursement();
            }
            catch (Exception)
            {
                btnEditSchedule.Enabled = false;
            }
            EnableLocAmountTextBox(_credit);
            EnableInsuranceTextBox(_credit);
            InitializeTabPageAdvancedSettings();

            bool active = _credit != null && _credit.ContractStatus == OContractStatus.Active;
            numCompulsoryAmountPercent.BackColor = pPackage.UseCompulsorySavings ? Color.White : Color.LightGray;
            //InitializeCustomizableFields(OCustomizableFieldEntities.Loan, _credit.Id, active);
        }
示例#3
0
        private void InitializeTabPageLoansDetails(Loan pCredit)
        {
            InitializeContractStatus(pCredit);

            gbxLoanDetails.Text = string.Format("{0}{1}  {2}{3}",
                    MultiLanguageStrings.GetString(Ressource.CreditContractForm, "contractCode.Text"), pCredit.Code,
                    MultiLanguageStrings.GetString(Ressource.CreditContractForm, "LoanType.Text"), pCredit.Product.Name);

            InitLoanDetails(false, pCredit.Disbursed, pCredit.ContractStatus == OContractStatus.Validated);
            InitializeTabPageGuaranteesDetailsButtons(pCredit.Product.UseGuarantorCollateral);
            InitializeFundingLine();
            InitializeInstallmentTypes();
            InitializeLoanOfficer();
            SetPackageValuesForLoanDetails(pCredit, false);
            DisableContractDetails(pCredit.ContractStatus);

            DisableCommitteeDecision(pCredit.ContractStatus);

            nudInterestRate.Text = (pCredit.InterestRate * 100).ToString();

            if (pCredit.Product.InterestRate.HasValue)
            {
                nudInterestRate.Enabled = false;
            }

            numericUpDownLoanGracePeriod.Value = (pCredit.GracePeriod.Value);

            btnEditSchedule.Visible = pCredit.Product.AllowFlexibleSchedule;
            btnEditSchedule.Enabled = (pCredit.PendingOrPostponed() && !pCredit.Disbursed);

            textBoxLoanAnticipatedTotalFees.Text = (pCredit.AnticipatedTotalRepaymentPenalties * 100).ToString();
            tbLoanAnticipatedPartialFees.Text = (pCredit.AnticipatedPartialRepaymentPenalties * 100).ToString();

            if (pCredit.Product.AnticipatedTotalRepaymentPenaltiesBase == OAnticipatedRepaymentPenaltiesBases.RemainingOLB)
            {
                lblEarlyTotalRepaimentBase.Text = MultiLanguageStrings.GetString(Ressource.ClientForm, "lblEarlyRepaimentBaseOLB.Text");
            }
            else
            {
                lblEarlyTotalRepaimentBase.Text = MultiLanguageStrings.GetString(Ressource.ClientForm, "lblEarlyRepaimentBaseInterest.Text");
            }

            if (pCredit.Product.AnticipatedPartialRepaymentPenaltiesBase == OAnticipatedRepaymentPenaltiesBases.RemainingOLB)
            {
                lblEarlyPartialRepaimentBase.Text = MultiLanguageStrings.GetString(Ressource.ClientForm, "lblEarlyRepaimentBaseOLB.Text");
            }
            else if (pCredit.Product.AnticipatedPartialRepaymentPenaltiesBase == OAnticipatedRepaymentPenaltiesBases.RemainingInterest)
            {
                lblEarlyPartialRepaimentBase.Text = MultiLanguageStrings.GetString(Ressource.ClientForm, "lblEarlyRepaimentBaseInterest.Text");
            }
            else if (pCredit.Product.AnticipatedPartialRepaymentPenaltiesBase == OAnticipatedRepaymentPenaltiesBases.PrepaidPrincipal)
            {
                lblEarlyPartialRepaimentBase.Text = MultiLanguageStrings.GetString(Ressource.ClientForm, "lblEarlyRepaimentBasePrincipal.Text");
            }

            if (pCredit.AmountUnderLoc.HasValue)
                tbLocAmount.Text = ServicesHelper.ConvertDecimalToString(pCredit.AmountUnderLoc.Value);

            textBoxLoanLateFeesOnAmount.Text = (pCredit.NonRepaymentPenalties.InitialAmount * 100).ToString();
            textBoxLoanLateFeesOnOLB.Text = (pCredit.NonRepaymentPenalties.OLB * 100).ToString();
            textBoxLoanLateFeesOnOverdueInterest.Text = (pCredit.NonRepaymentPenalties.OverDueInterest * 100).ToString();
            textBoxLoanLateFeesOnOverduePrincipal.Text = (pCredit.NonRepaymentPenalties.OverDuePrincipal * 100).ToString();

            groupBoxLoanLateFees.Text = MultiLanguageStrings.GetString(Ressource.ClientForm, "LateFeesGracePeriod.Text") + @" (" + pCredit.GracePeriodOfLateFees + @")";

            comboBoxLoanInstallmentType.Text = pCredit.InstallmentType.Name;

            nudLoanNbOfInstallments.Value = pCredit.NbOfInstallments;
            dateLoanStart.Value = pCredit.StartDate;
            _oldDisbursmentDate = dateLoanStart.Value;
            _oldFirstInstalmentDate = dtpDateOfFirstInstallment.Value;
            cmbLoanOfficer.Text = pCredit.LoanOfficer != null ? pCredit.LoanOfficer.Name : string.Empty;

            textBoxLoanPurpose.Text = pCredit.LoanPurpose ?? string.Empty;
            textBoxComments.Text = pCredit.Comments ?? string.Empty;

            SetSecurityForTabPageLoansDetails(false);

            DisplayInstallments(ref pCredit);

            _listGuarantors = _credit.Guarantors;
            _collaterals = _credit.Collaterals;
            lblCreditCurrency.Text = MultiLanguageStrings.GetString(Ressource.ClientForm, "Currency.Text") + _credit.Product.Currency.Name;
            DisplayCollateral();
            DisplayGuarantors(pCredit.Guarantors, pCredit.Amount);
            textBoxCreditCommiteeComment.Text = pCredit.CreditCommiteeComment;
            tBCreditCommitteeCode.Text = pCredit.CreditCommitteeCode;

            if (pCredit.CreditCommiteeDate.HasValue)
                dateTimePickerCreditCommitee.Text = pCredit.CreditCommiteeDate.Value.ToShortDateString();
            SetCreditStatus(pCredit.ContractStatus);
            if (pCredit.Code != null)
                textBoxLoanContractCode.Text = pCredit.Code;

            Text = string.Format("{0} - {1}", _title, pCredit.Code);
            InitLoanDetails(false, pCredit.Disbursed,
                            (pCredit.ContractStatus == OContractStatus.Validated) ||
                            (pCredit.ContractStatus == OContractStatus.Active));
        }
示例#4
0
        private void EnableLocAmountTextBox(Loan credit)
        {
            if ((credit.PendingOrPostponed() || credit.ContractStatus == 0 || credit.Disbursed
                || credit.ContractStatus == OContractStatus.Validated) &&
                (credit.Product.AmountUnderLocMin.HasValue && credit.Product.AmountUnderLocMax.HasValue))
                tbLocAmount.Enabled = true;
            else
                tbLocAmount.Enabled = false;

            if (credit.Product.AmountUnderLocMin.HasValue && credit.Product.AmountUnderLocMax.HasValue)
            {
                labelLocMaxAmount.Text = ServicesHelper.ConvertDecimalToString(credit.Product.AmountUnderLocMax.Value);
                labelLocMinAmount.Text = ServicesHelper.ConvertDecimalToString(credit.Product.AmountUnderLocMin.Value);
                if (!credit.AmountUnderLoc.HasValue)
                    tbLocAmount.Text = credit.Product.AmountUnderLocMax.GetFormatedValue(credit.UseCents);
                lblLocCurrencyMin.Text = _credit.Product.Currency.Name;
                lblLocCurrencyMax.Text = _credit.Product.Currency.Name;
                lblLocCurrencyMin.Visible = true;
                lblLocCurrencyMax.Visible = true;
                labelLocMinAmount.Visible = true;
                labelLocMaxAmount.Visible = true;
                labelLocMin.Visible = true;
                labelLocMax.Visible = true;
            }
            else if (credit.Product.AmountUnderLoc.HasValue)
            {
                tbLocAmount.Text = credit.Product.AmountUnderLoc.GetFormatedValue(credit.UseCents);
                labelLocMaxAmount.Text = ServicesHelper.ConvertDecimalToString(credit.Product.AmountUnderLoc.Value);
                labelLocMinAmount.Text = ServicesHelper.ConvertDecimalToString(credit.Product.AmountUnderLoc.Value);
                lblLocCurrencyMin.Text = _credit.Product.Currency.Name;
                lblLocCurrencyMax.Text = _credit.Product.Currency.Name;
                lblLocCurrencyMin.Visible = true;
                lblLocCurrencyMax.Visible = true;
                labelLocMinAmount.Visible = true;
                labelLocMaxAmount.Visible = true;
                labelLocMin.Visible = true;
                labelLocMax.Visible = true;

            }
            else
            {
                tbLocAmount.Enabled = false;
                tbLocAmount.Text = "0";
            }
        }
示例#5
0
 private void EnableInsuranceTextBox(Loan credit)
 {
     if (credit.PendingOrPostponed() || credit.ContractStatus == 0)
     {
         if (credit.Product.CreditInsuranceMin == credit.Product.CreditInsuranceMax)
             tbInsurance.Enabled = false;
         else tbInsurance.Enabled = true;
     }
     else
         tbInsurance.Enabled = false;
 }
示例#6
0
        private void SaveLoanApproval()
        {
            var currentCreditStatus = OContractStatus.Pending;
            var currentGuaranteeStatus = OContractStatus.Pending;

            try
            {
                if (_credit != null)
                {
                    OContractStatus newStatus = _loanApprovalControl.Status;

                    _credit.ContractStatus = newStatus;
                    _credit.CreditCommiteeComment = _loanApprovalControl.Comment;
                    _credit.CreditCommiteeDate = _loanApprovalControl.Date;
                    _credit.CreditCommitteeCode = _loanApprovalControl.Code;

                    IClient client = null;
                    if (_oClientType == OClientTypes.Corporate) client = _corporateUserControl.Corporate;
                    if (_oClientType == OClientTypes.Person) client = _personUserControl.Person;
                    if (_oClientType == OClientTypes.Group) client = _groupUserControl.Group;

                    if (OContractStatus.Refused == newStatus
                        || OContractStatus.Abandoned == newStatus
                        || OContractStatus.Closed == newStatus
                        || OContractStatus.Deleted == newStatus)
                    {
                        _credit.Closed = true;
                        if (client != null)
                        {
                            if (client.ActiveLoans != null)
                            {
                                if (client.ActiveLoans.Count == 0)
                                {
                                    client.Active = false;
                                    client.Status = OClientStatus.Inactive;
                                }
                            }
                        }
                        // updating guarantor status
                        if (_listGuarantors != null && _listGuarantors.Count > 0)
                        {
                            foreach (Guarantor guarantor in _listGuarantors)
                            {
                                guarantor.Tiers.Active = false;
                                guarantor.Tiers.Status = OClientStatus.Inactive;
                                ServicesProvider.GetInstance().GetClientServices().UpdateClientStatus(guarantor.Tiers);
                            }
                        }
                    }
                    else
                    {
                        _credit.Closed = false;
                        if (client != null)
                        {
                            client.Active = true;
                            client.Status = OClientStatus.Active;
                        }
                    }

                    _credit = ServicesProvider.GetInstance().GetContractServices().
                        UpdateContractStatus(_credit, _project, client, _credit.ContractStatus != OContractStatus.Validated);

                    if (_credit.ContractStatus != OContractStatus.Validated)
                    {
                        var pendingOrPostponed = _credit.PendingOrPostponed();
                        if (!pendingOrPostponed)
                            ServicesProvider.GetInstance().GetContractServices().UpdateTiersStatus(_credit, client);

                        SetGuarantorsEnabled(pendingOrPostponed);
                        InitializeTabPageGuaranteesDetailsButtons(_credit.Product.UseGuarantorCollateral);
                    }
                    else
                    {
                        btnEditSchedule.Enabled = false;
                        InitializeTabPageGuaranteesDetailsButtons(_credit.Product.UseGuarantorCollateral);
                        DisableContractDetails(OContractStatus.Validated);
                    }
                    InitLoanDetails(false, _credit.Disbursed, _credit.ContractStatus == OContractStatus.Validated);
                    tabPageLoansDetails.Enabled = true;

                    if (_credit.PendingOrPostponed())
                    {
                        // Enable loan details components
                        InitializeAmount(_credit, false);
                        InitializePackageInterestRate(_credit, false);
                        InitializePackageGracePeriod(_credit.Product, false);
                        InitializePackageNumberOfInstallments(_credit, false);
                        _loanOfficerComboBox.Enabled = true;
                        textBoxLoanPurpose.Enabled = true;
                        textBoxComments.Enabled = true;
                        comboBoxLoanFundingLine.Enabled = true;
                        // Advanced settings tab
                        EnableLocAmountTextBox(_credit);
                        EnableInsuranceTextBox(_credit);
                        groupBoxEntryFees.Enabled = true;
                        btnEditSchedule.Enabled = true;
                        InitializePackageAnticipatedTotalRepaymentsPenalties(_credit.Product, false);
                        InitializePackageAnticipatedPartialRepaymentsPenalties(_credit.Product, false);
                        InitializePackageNonRepaymentPenalties(_credit.Product, false);
                    }
                    InitializePackageLoanCompulsorySavings(_credit.Product, false);

                    DisplayContracts(_project.Credits);

                    DisableContractDetails(newStatus);
                    if (_credit.Product.InterestRate.HasValue)
                    {
                        nudInterestRate.Enabled = false;
                    }

                    if (newStatus == OContractStatus.Validated)
                    {
                        tabControlPerson.SelectTab(tabPageLoansDetails);
                    }
                }

                //((MainView)_mdiParent).ReloadAlertsSync();

            }
            catch (Exception ex)
            {
                if (_credit != null) _credit.ContractStatus = currentCreditStatus;
                if (_guarantee != null) _guarantee.ContractStatus = currentGuaranteeStatus;
                new frmShowError(CustomExceptionHandler.ShowExceptionText(ex)).ShowDialog();
            }
        }