本文整理汇总了C#中OpenCBS.CoreDomain.Contracts.Loans.Loan.GetLastNonDeletedEvent方法的典型用法代码示例。如果您正苦于以下问题:C# Loan.GetLastNonDeletedEvent方法的具体用法?C# Loan.GetLastNonDeletedEvent怎么用?C# Loan.GetLastNonDeletedEvent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenCBS.CoreDomain.Contracts.Loans.Loan
的用法示例。
在下文中一共展示了Loan.GetLastNonDeletedEvent方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CancelLastEvent
/// <summary>
/// Cancels last event from given contract, restores associated installment status.
/// and restores Client(individual, corporate) status
/// </summary>
/// <param name="contract">Contract</param>
/// <param name="pClient"></param>
/// <param name="comment"> </param>
/// <returns>Cancelled event</returns>
public Event CancelLastEvent(Loan contract, IClient pClient, string comment)
{
using (SqlConnection conn = _loanManager.GetConnection())
using (SqlTransaction sqlTransaction = conn.BeginTransaction())
{
Event cancelledEvent;
try
{
Event evnt = contract.GetLastNonDeletedEvent();
if (null == evnt)
throw new OpenCbsContractSaveException(OpenCbsContractSaveExceptionEnum.EventIsNull);
if (!evnt.Cancelable)
throw new OpenCbsContractSaveException(OpenCbsContractSaveExceptionEnum.EventNotCancelable);
if (string.IsNullOrEmpty(comment))
throw new OpenCbsContractSaveException(OpenCbsContractSaveExceptionEnum.EventCommentIsEmpty);
if (pClient is Person)
evnt.ClientType = OClientTypes.Person;
else if (pClient is Group)
evnt.ClientType = OClientTypes.Group;
else if (pClient is Corporate)
evnt.ClientType = OClientTypes.Corporate;
else if (pClient is Village)
evnt.ClientType = OClientTypes.Village;
var evntCopy = evnt.Copy();
evntCopy.Id = evnt.ParentId ?? evnt.Id;
CallInterceptor(new Dictionary<string, object>
{
{"Loan", contract},
{"Event", evntCopy},
{"Deleted", true},
{"SqlTransaction", sqlTransaction}
});
if (ApplicationSettings.GetInstance(User.CurrentUser.Md5).UseMandatorySavingAccount)
{
var id = 0;
if (int.TryParse(evnt.Comment, out id))
ServicesProvider.GetInstance()
.GetSavingServices()
.DeleteEvent(new SavingWithdrawEvent()
{
Id = id,
CancelDate = TimeProvider.Today
});
}
evnt.Comment = comment;
evnt.CancelDate = TimeProvider.Now;
// if event is loan close event, we delete it first
if (evnt is LoanCloseEvent)
{
_ePs.CancelFireEvent(evnt, sqlTransaction, contract, contract.Product.Currency.Id);
evnt.Deleted = true;
evnt = contract.GetLastNonDeletedEvent();
if (pClient is Person)
evnt.ClientType = OClientTypes.Person;
else if (pClient is Group)
evnt.ClientType = OClientTypes.Group;
else if (pClient is Corporate)
evnt.ClientType = OClientTypes.Corporate;
else if (pClient is Village)
evnt.ClientType = OClientTypes.Village;
evnt.Comment = comment;
evnt.CancelDate = TimeProvider.Now;
}
_ePs.CancelFireEvent(evnt, sqlTransaction, contract, contract.Product.Currency.Id);
_ePs.UpdateCommentForLoanEvent(evnt, sqlTransaction);
evnt.Deleted = true;
//in case total repayment there could be several rep events
foreach (RepaymentEvent evt in contract.Events.GetRepaymentEvents())
{
if ((evt.ParentId == evnt.ParentId && evnt.ParentId != null) || (evt.Id == evnt.ParentId))
{
evt.Deleted = true;
evt.Comment = evnt.Comment;
_ePs.UpdateCommentForLoanEvent(evt, sqlTransaction);
}
}
if (evnt.Code == "ATR" || evnt.Code == "RBLE")
{
foreach (Event cie in contract.Events)
{
if (cie is CreditInsuranceEvent)
if (cie.Deleted == false && cie.Code == "LCIP")
{
_ePs.CancelFireEvent(cie, sqlTransaction, contract, contract.Product.Currency.Id);
//.........这里部分代码省略.........
示例2: UpdateLoan
public void UpdateLoan(Loan pLoan, SqlTransaction pSqlTransac)
{
string q = @"UPDATE Credit
SET loanofficer_id = @loanOfficerId,
fundingLine_id = @fundingLine_id,
disbursed = @disbursed,
rescheduled = @rescheduled,
nb_of_installment = @NbOfInstallment,
amount = @Amount,
interest_rate = @InterestRate,
grace_period = @GracePeriode,
anticipated_total_repayment_penalties = @AnticipatedTotalRepayment,
anticipated_partial_repayment_penalties = @AnticipatedPartialRepayment,
non_repayment_penalties_based_on_overdue_principal = @NRPBOOP,
non_repayment_penalties_based_on_initial_amount = @NRPBOIA,
non_repayment_penalties_based_on_olb = @NRPBOOLB,
non_repayment_penalties_based_on_overdue_interest = @NRPBOOI,
synchronize = @synchronize,
grace_period_of_latefees = @grace_period_of_latefees,
[number_of_drawings_loc] = @DrawingsNumber,
[amount_under_loc] = @AmountUnderLoc,
[maturity_loc] = @MaturityLoc,
[anticipated_partial_repayment_base] = @AnticipatedPartialRepaymentPenaltiesBase,
[anticipated_total_repayment_base] = @AnticipatedTotalRepaymentPenaltiesBase,
[schedule_changed] = @schedule_changed,
[written_off] = @written_off,
[insurance][email protected]
WHERE id = @id";
using(OpenCbsCommand c = new OpenCbsCommand(q, pSqlTransac.Connection, pSqlTransac))
{
SetLoanForUpdate(c, pLoan);
c.ExecuteNonQuery();
}
q = @"UPDATE Contracts
SET start_date = @startDate,
align_disbursed_date = @align_disbursed_date,
close_date = @closeDate,
closed = @closed,
status = @status,
loan_purpose = @loanPurpose,
comments = @comments,
activity_id = @activityId,
preferred_first_installment_date = @preferredFirstInstallmentDate
WHERE id = @id";
using(OpenCbsCommand c = new OpenCbsCommand(q, pSqlTransac.Connection, pSqlTransac))
{
c.AddParam("@startDate", pLoan.StartDate);
c.AddParam("@align_disbursed_date", pLoan.AlignDisbursementDate);
c.AddParam("@closeDate", pLoan.CloseDate);
c.AddParam("@closed", pLoan.Closed);
c.AddParam("@status", Convert.ToInt32(pLoan.ContractStatus));
c.AddParam("@id", pLoan.Id);
c.AddParam("@loanPurpose", pLoan.LoanPurpose);
c.AddParam("@comments", pLoan.Comments);
c.AddParam("@activityId", pLoan.EconomicActivityId);
c.AddParam("@preferredFirstInstallmentDate", pLoan.FirstInstallmentDate);
c.ExecuteNonQuery();
}
// Updating Tiers status to 'active'
if (pLoan.Project != null && pLoan.Project.Client != null)
{
q = @"UPDATE Tiers
SET active = @active
WHERE id = @id";
using (OpenCbsCommand c = new OpenCbsCommand(q, pSqlTransac.Connection, pSqlTransac))
{
c.AddParam("@active", pLoan.Project.Client.Active);
c.AddParam("@id", pLoan.Project.Client.Id);
c.ExecuteNonQuery();
}
}
if (pLoan.EscapedMember != null && pLoan.Project != null && pLoan.Project.Client != null)
{
//delete member from the group
_clientManager.UpdatePersonFromGroup(pLoan.EscapedMember.Tiers.Id, pLoan.Project.Client.Id, pSqlTransac);
q = @"UPDATE LoanShareAmounts
SET payment_date = @payment_date,
event_id = @event_id
WHERE person_id = @person_id
AND group_id = @group_id
AND contract_id = @contract_id";
using (OpenCbsCommand c = new OpenCbsCommand(q, pSqlTransac.Connection, pSqlTransac))
{
c.AddParam("@payment_date", pLoan.GetLastNonDeletedEvent().Date);
c.AddParam("@event_id", pLoan.GetLastNonDeletedEvent().Id);
c.AddParam("@person_id", pLoan.EscapedMember.Tiers.Id);
c.AddParam("@group_id", pLoan.Project.Client.Id);
c.AddParam("@contract_id", pLoan.Id);
c.ExecuteNonQuery();
}
//.........这里部分代码省略.........
示例3: WaiveFee
public void WaiveFee(ref Loan credit, ref IClient client)
{
Event foundEvent = credit.GetLastNonDeletedEvent();
if (foundEvent == null)
throw new OpenCbsContractSaveException(OpenCbsContractSaveExceptionEnum.EventIsNull);
if (!(foundEvent is RepaymentEvent))
throw new OpenCbsContractSaveException(OpenCbsContractSaveExceptionEnum.WrongEvent);
if (!foundEvent.Cancelable)
throw new OpenCbsContractSaveException(OpenCbsContractSaveExceptionEnum.EventNotCancelable);
if (((RepaymentEvent) foundEvent).Fees == 0)
throw new OpenCbsContractSaveException(OpenCbsContractSaveExceptionEnum.ZeroFee);
string fee = ((RepaymentEvent) foundEvent).Fees.GetFormatedValue(credit.UseCents);
String comment = "FEE WAIVED [" + fee.Replace("�", string.Empty) + "]";
//foundEvent.Comment = comment;
////EventProcessorServices eps = ServicesProvider.GetInstance().GetEventProcessorServices();
////eps.UpdateCommentForLoanEvent(foundEvent, null);
CancelLastEvent(credit, client, comment);
//update a loan for a client
foreach (Project prj in client.Projects)
{
foreach (Loan loan in prj.Credits)
{
if (loan.Code == credit.Code)
{
loan.Disbursed = credit.Disbursed;
}
}
}
OCurrency amount = ((RepaymentEvent) foundEvent).Principal +
((RepaymentEvent) foundEvent).Interests + ((RepaymentEvent) foundEvent).Fees;
comment = "ID[" + foundEvent.Id + "] FEE WAIVED [" + fee.Replace("�", string.Empty) + "]";
Loan l = Repay(credit,
client,
foundEvent.InstallmentNumber,
foundEvent.Date,
amount,
true,
0,
0,
false,
0,
true,
false,
foundEvent.PaymentMethod,
comment,
false);
credit.Events = l.Events;
}
示例4: ShowLoanInListView
private void ShowLoanInListView(VillageMember member, Loan loan)
{
Person person = (Person)member.Tiers;
ApplicationSettings dataParam = ApplicationSettings.GetInstance(string.Empty);
int decimalPlaces = dataParam.InterestRateDecimalPlaces;
ListViewItem item = new ListViewItem(person.Name) { Tag = member };
if (loan == null || _village.EstablishmentDate==null) return;
if (loan.CreationDate.Date >= _village.EstablishmentDate.Value.Date && _village.Id == loan.NsgID)
{
item.SubItems.Add(loan.ProductName);
item.SubItems.Add(loan.Code);
item.SubItems.Add(MultiLanguageStrings.GetString(Ressource.ClientForm, loan.ContractStatus + ".Text"));
item.SubItems.Add(loan.Amount.GetFormatedValue(loan.UseCents));
item.SubItems.Add(
loan.CalculateActualOlbBasedOnRepayments().GetFormatedValue(loan.UseCents));
item.SubItems.Add(loan.Product.Currency.Name);
item.SubItems.Add(Math.Round(loan.InterestRate*100m, decimalPlaces).ToString());
item.SubItems.Add(loan.InstallmentType.Name);
item.SubItems.Add(loan.NbOfInstallments.ToString());
item.SubItems.Add(loan.AlignDisbursementDate.ToShortDateString());
if (loan.GetLastNonDeletedEvent() != null) item.SubItems.Add(loan.GetLastNonDeletedEvent().Date.ToShortDateString());
else item.SubItems.Add("-");
if (loan.NextInstallment != null)
{
item.SubItems.Add(loan.NextInstallment.ExpectedDate.ToShortDateString());
item.SubItems.Add(
ServicesHelper.ConvertDecimalToString(loan.NextInstallment.Amount.Value));
}
else
{
item.SubItems.Add("-");
item.SubItems.Add("-");
}
item.SubItems.Add(loan.CloseDate.ToShortDateString());
if (member.LeftDate != null)
item.BackColor = Color.Red;
listViewLoans.Items.Add(item);
}
}