本文整理汇总了C#中ISavingsContract.CancelLastEvent方法的典型用法代码示例。如果您正苦于以下问题:C# ISavingsContract.CancelLastEvent方法的具体用法?C# ISavingsContract.CancelLastEvent怎么用?C# ISavingsContract.CancelLastEvent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISavingsContract
的用法示例。
在下文中一共展示了ISavingsContract.CancelLastEvent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CancelLastEvent
public SavingEvent CancelLastEvent(ISavingsContract saving, User user, string pDescription)
{
if (string.IsNullOrEmpty(pDescription))
throw new OpenCbsSavingException(OpenCbsSavingExceptionEnum.SavingsEventCommentIsEmpty);
Debug.Assert(_ePS != null, "Event processor is null");
SavingEvent lastSavingEvent = saving.GetCancelableEvent();
if (null == lastSavingEvent) return null;
// check for compulsory
if (saving is SavingBookContract)
{
if (lastSavingEvent is SavingDepositEvent)
{
if (((SavingBookContract)saving).Loans != null && ((SavingBookContract)saving).Loans.Count > 0)
{
if (!IsCompulsorySavingBalanceOk(saving, lastSavingEvent.Amount))
throw new OpenCbsSavingException(OpenCbsSavingExceptionEnum.SavingsEventCannotBeCanceled);
}
}
}
//reversal transaction in accounting
if (lastSavingEvent is SavingCreditOperationEvent || lastSavingEvent is SavingDebitOperationEvent)
{
if (((SavingBookContract)saving).Loans != null && ((SavingBookContract)saving).Loans.Count > 0)
{
if (!IsCompulsorySavingBalanceOk(saving, lastSavingEvent.Amount))
throw new OpenCbsSavingException(OpenCbsSavingExceptionEnum.SavingsEventCannotBeCanceled);
}
Booking booking = ServicesProvider.GetInstance().GetAccountingServices().SelectBookingByEventId(lastSavingEvent.Id);
Booking reversalBooking = new Booking
{
Currency = booking.Currency,
User = User.CurrentUser,
Amount = booking.Amount,
Description = booking.Description,
DebitAccount = booking.CreditAccount,
CreditAccount = booking.DebitAccount,
Date = TimeProvider.Now,
EventId = lastSavingEvent.Id,
ExchangeRate = booking.ExchangeRate,
Branch = saving.Branch
};
ServicesProvider.GetInstance().GetAccountingServices().BookManualEntry(reversalBooking, User.CurrentUser);
}
// Cancelling event
lastSavingEvent.Description = pDescription;
lastSavingEvent = saving.CancelLastEvent();
_savingEventManager.UpdateEventDescription(lastSavingEvent.Id, pDescription);
lastSavingEvent.CancelDate = new DateTime(
TimeProvider.Now.Year,
TimeProvider.Now.Month,
TimeProvider.Now.Day,
TimeProvider.Now.Hour,
TimeProvider.Now.Minute,
TimeProvider.Now.Second
);
_ePS.CancelFireEvent(lastSavingEvent, saving.Product.Currency.Id);
SavingEvent savingEvent = lastSavingEvent;
if (lastSavingEvent.PendingEventId != null)
{
savingEvent.Code = "SPDE";
savingEvent.Id = (int)lastSavingEvent.PendingEventId;
_ePS.CancelFireEvent(savingEvent, saving.Product.Currency.Id);
}
return savingEvent;
}