private static void CompareInterests(ref UserComparison userComparison, ProfileData userProfile, ProfileData compUserProfile, InterestType typeToCompare) { IEnumerable<Interest> onlyProfile1Interests = userProfile.Interests.Where(x => x.type == typeToCompare).Except(compUserProfile.Interests); IEnumerable<Interest> onlyProfile2Interests = compUserProfile.Interests.Where(x => x.type == typeToCompare).Except(userProfile.Interests); IEnumerable<Interest> bothProfileInterests = userProfile.Interests.Where(x => x.type == typeToCompare).Except(onlyProfile1Interests); //For the interests Add instead of = (other interest types could have been already added) userComparison.EqualProfileData.Interests.AddRange(bothProfileInterests.ToList()); userComparison.OnlyUserProfileData.Interests.AddRange(onlyProfile1Interests.ToList()); //userComparison.OnlyCompUserProfileData.Interests.RemoveAll(x => x.Type == typeToCompare); userComparison.OnlyCompUserProfileData.Interests.AddRange(onlyProfile2Interests.ToList()); }
public StringChannelImpl(String channelId, MessageRouter router, InterestType interest) : base(channelId, router, interest) { InitBlock(); parser = new CLIPSParser(router.ReteEngine, (StreamReader) null); }
/// <summary> /// Opens the channel. /// </summary> /// <param name="channelName">Name of the channel.</param> /// <param name="inputStream">The input stream.</param> /// <param name="interestType">Type of the interest.</param> /// <returns></returns> public IStreamChannel openChannel(String channelName, TextReader inputStream, InterestType interestType) { IStreamChannel channel = new StreamChannelImpl(channelName + "_" + idCounter++, this, interestType); channel.init(inputStream); registerChannel(channel); return channel; }
/// <summary> /// Opens the channel. /// </summary> /// <param name="channelName">Name of the channel.</param> /// <param name="interestType">Type of the interest.</param> /// <returns></returns> public virtual ICommunicationChannel openChannel(String channelName, InterestType interestType) { ICommunicationChannel channel = new StringChannelImpl(channelName + "_" + idCounter++, this, interestType); registerChannel(channel); return channel; }
public static double calculateAccruedInterest(List <Transaction> transactions, DateTime currentDate, InterestType interestType) { double lastBalance = 0; DateTime lastTransactionDate = DateTime.MinValue; double totalInterest = 0; // Iterate over each transaction foreach (Transaction transaction in transactions) { // Save the transaction date (date part only) DateTime transactionDate = transaction.TransactionDate.Date; // Consider transactions prior to current date (current date may be changed in unit test simulations) if (transactionDate > currentDate.Date) { break; } // Whenever there is a date change in the transaction date, calculate the interest for the balance so far if (lastTransactionDate != DateTime.MinValue && transactionDate != lastTransactionDate) { // Calculate interest from last transaction to this transaction date (pro-rata as interest rate is in annual percent) // Pass the total interest accrued so far also, so that compounding can be done based on interest type totalInterest += calculateAccruedInterest(lastBalance, totalInterest, lastTransactionDate, transactionDate, interestType); } // Save last balance and transaction lastBalance = transaction.Balance; lastTransactionDate = transactionDate; } // Calculate the interest from the latest transaction's balance to current date totalInterest += calculateAccruedInterest(lastBalance, totalInterest, lastTransactionDate, currentDate, interestType); return(totalInterest); }
public async Task <List <LoanDetailModel> > CalculateInterest(int loanId, int loanDetailId, InterestType interestType, string username) { var _existingLoan = this._loanRepository.GetAllIncluding(e => e.LoanDetails).Where(x => x.Id == loanId).FirstOrDefault(); var _existingLoanDetail = _existingLoan.LoanDetails.FirstOrDefault(x => x.Id == loanDetailId); _existingLoanDetail.InterestType = interestType; _existingLoanDetail.UpdatedBy = username; _existingLoanDetail.UpdatedOn = DateTime.Now; var _futureLoanDetails = _existingLoan.LoanDetails.Where(x => x.Installment > _existingLoanDetail.Installment).OrderBy(o => o.Installment); var _balanceTakeForward = _existingLoan.CapitalOutstanding; var _previousLoanDetail = _existingLoan.LoanDetails.FirstOrDefault(x => x.Installment == _existingLoanDetail.Installment - 1); if (_previousLoanDetail != null) { if (_previousLoanDetail.InterestType == InterestType.CompoundInterest) { _balanceTakeForward = _previousLoanDetail.Balance; } else { _balanceTakeForward = _existingLoan.CapitalOutstanding; } } if (interestType == InterestType.CompoundInterest) { _existingLoanDetail.MonthlyInterest = _balanceTakeForward * _existingLoan.Interest / 100; } else if (interestType == InterestType.SimpleInterest && _previousLoanDetail.InterestType == InterestType.CompoundInterest) { _existingLoanDetail.MonthlyInterest = _balanceTakeForward * _existingLoan.Interest / 100; } else { _existingLoanDetail.MonthlyInterest = _existingLoan.CapitalOutstanding * _existingLoan.Interest / 100; } _existingLoanDetail.Balance = _existingLoan.CapitalOutstanding + _existingLoanDetail.MonthlyInterest; var _previousBalance = _existingLoanDetail.Balance; foreach (var _futureLoanDetail in _futureLoanDetails) { if (interestType == InterestType.CompoundInterest) { _futureLoanDetail.MonthlyInterest = _previousBalance * _existingLoan.Interest / 100; } else { _futureLoanDetail.MonthlyInterest = _existingLoan.CapitalOutstanding * _existingLoan.Interest / 100; } _futureLoanDetail.Balance = _previousBalance + _futureLoanDetail.MonthlyInterest; _futureLoanDetail.InterestType = interestType; _futureLoanDetail.UpdatedBy = username; _futureLoanDetail.UpdatedOn = DateTime.Now; _previousBalance = _futureLoanDetail.Balance; } var result = await this._loanRepository.UpdateAsyn(_existingLoan, loanId); return(await this.GetLoanDetails(loanId)); }
/// <summary> /// Opens the channel. /// </summary> /// <param name="channelName">Name of the channel.</param> /// <param name="inputStream">The input stream.</param> /// <param name="interestType">Type of the interest.</param> /// <returns></returns> public IStreamChannel openChannel(String channelName, TextReader inputStream, InterestType interestType) { IStreamChannel channel = new StreamChannelImpl(channelName + "_" + idCounter++, this, interestType); channel.init(inputStream); registerChannel(channel); return(channel); }
public IEnumerable <Interest> GetInterestByType(InterestType type) { var interestByType = _interests.Where(interestType => interestType.Type == type); return(interestByType); }
protected internal AbstractCommunicationChannel(String channelId, MessageRouter router, InterestType interest) { _channelId = channelId; _router = router; _interest = interest; }
public ItemOfInterest(string title, string owner, string stashName, string stashPos, InterestType interestType = InterestType.None, int preAccSortKey = 0, int preItemNameSortKey = 0, string extraLine = "") { Title = title; Owner = owner; StashName = stashName; StashPos = stashPos; PreAccSortKey = preAccSortKey; PreItemNameSortKey = preItemNameSortKey; Type = interestType; ExtraLine = extraLine; Visible = true; }
public InterestPromotionDecoration(InterestType pType) { this.itype = pType; }
public void setItype(InterestType itype) { this.itype = itype; }
public StreamChannelImpl(String channelId, MessageRouter router, InterestType interest) : base(channelId, router, interest) { parser = new CLIPSParser(router.ReteEngine, (StreamReader)null); }
public async Task <ActionResult> CalculateInterest(int loanId, int loanDetailId, InterestType interestType) { var result = await this._loanLoanService.CalculateInterest(loanId, loanDetailId, interestType, this.Username); return(Ok(result)); }