/// <summary> /// Initializes a new instance of the <see cref="T:B4F.TotalGiro.Accounts.Instructions.CashWithdrawalInstruction">CashWithdrawalInstruction</see> class. /// </summary> /// <param name="account">The account the withdrawal will belong to</param> /// <param name="executionDate">The day from which the instruction should be taken into account</param> /// <param name="withdrawalDate">The day that the money should be withdrawn</param> /// <param name="amount">The relevant amount</param> /// <param name="counterAccount">The account the money should go to</param> /// <param name="rule">The rule that is responsible for this periodic instruction</param> /// <param name="doNotChargeCommission">The instruction is without any charges</param> internal CashWithdrawalInstruction(IAccountTypeCustomer account, DateTime executionDate, DateTime withdrawalDate, Money amount, ICounterAccount counterAccount, IWithdrawalRule rule, string transferDescription, bool doNotChargeCommission) : base(account, executionDate, doNotChargeCommission) { this.Account = account; this.WithdrawalDate = withdrawalDate; this.Amount = amount; this.CounterAccount = counterAccount; this.Rule = rule; this.TransferDescription = transferDescription; this.status = CashWithdrawalInstructionStati.New; if (rule != null) this.IsPeriodic = true; }
public static void Update(IDalSession session, IWithdrawalRule obj) { session.InsertOrUpdate(obj); }
/// <summary> /// This is the method where a new withdrawal instruction is created for the account. /// </summary> /// <param name="executionDate">The day from which the instruction should be taken into account</param> /// <param name="withdrawalDate">The day that the money should be there</param> /// <param name="withdrawalAmount">The relevant amount</param> /// <param name="counterAccount">The account the money should go to</param> /// <param name="rule">The rule that is responsible for this periodic instruction</param> /// <param name="doNotChargeCommission">The instruction is without any charges</param> /// <returns>A new <see cref="T:B4F.TotalGiro.Accounts.Instructions.Instruction">instruction</see></returns> public ICashWithdrawalInstruction CreateWithdrawalInstruction(DateTime executionDate, DateTime withdrawalDate, Money withdrawalAmount, ICounterAccount counterAccount, IWithdrawalRule rule, string transferDescription, bool doNotChargeCommission) { if (withdrawalAmount == null || withdrawalAmount.IsGreaterThanZero) throw new ApplicationException("The withdrawal amount is mandatory and can not be positive"); if (counterAccount == null && this.CounterAccount == null) throw new ApplicationException("There should be at least a counter account on the rule or on the account."); ICashWithdrawalInstruction instruct = new CashWithdrawalInstruction(this, executionDate, withdrawalDate, withdrawalAmount, counterAccount, rule, transferDescription, doNotChargeCommission); if (instruct != null && instruct.Validate()) { AccountInstructions.Add(instruct); ActiveAccountInstructions.Add(instruct); } return instruct; }
public static void Delete(IDalSession session, IWithdrawalRule obj) { session.Delete(obj); }
private static bool checkDeactivateRule(IWithdrawalRule rule, DateTime endDateWithdrawal, bool isActive) { if (Util.IsNotNullDate(endDateWithdrawal) && Util.IsNullDate(rule.EndDateWithdrawal) || (!isActive && rule.IsActive)) { if (!isActive && rule.IsActive) { if (Util.IsNullDate(endDateWithdrawal)) endDateWithdrawal = DateTime.Today; if (rule.FirstDateWithdrawal > endDateWithdrawal) endDateWithdrawal = rule.FirstDateWithdrawal; rule.EndDateWithdrawal = endDateWithdrawal; } rule.IsActive = isActive; int instructionsToBeCancelled = 0; foreach (ICashWithdrawalInstruction instruction in rule.WithdrawalInstructions) { if (instruction.IsActive && instruction.WithdrawalDate >= rule.EndDateWithdrawal) instructionsToBeCancelled++; } if (instructionsToBeCancelled > 0) throw new ApplicationException(string.Format("The end date/active flag of the rule can not be set since {0} withdrawal instructions exist with a withdrawal date after {1}. Please cancel the instruction(s) in 'Withdrawal Instruction Management'.", instructionsToBeCancelled, rule.EndDateWithdrawal.ToString("yyyy-MM-dd"))); } return true; }