Beispiel #1
0
		private void CopyRebateTransaction() {
			if (LoanID == 0)
				return;

			MigrateLoanTransaction.LoanTransactionModel rebateTransaction = DB.FillFirst<MigrateLoanTransaction.LoanTransactionModel>(
				"select t.PostDate,t.Amount,t.Description,t.IP,t.PaypointId,c.Id as CardID from LoanTransaction t " +
				"join PayPointCard c on c.TransactionId = t.PaypointId " +
				"where Description='system-repay' " +
				"and Status='Done' " +
				"and Type ='PaypointTransaction' " +
				"and LoanId = @loanID " +
				"and DateDiff(d, t.PostDate, @dd) = 0 " +
				 "and LoanTransactionMethodId = @methodId",
				CommandSpecies.Text, new QueryParameter("@loanID", model.Loan.OldLoanID), new QueryParameter("@dd", DateTime.UtcNow.Date), new QueryParameter("@methodId", (int)NLLoanTransactionMethods.Auto)
			 );

			if (rebateTransaction == null || rebateTransaction.Amount == 0) {
				Log.Debug("rebate transaction for oldLoanID {0} not found", model.Loan.OldLoanID);
				NL_AddLog(LogType.Info, string.Format("rebate transaction for oldLoanID {0} not found", model.Loan.OldLoanID), this.strategyArgs, null, Error, null);
				return;
			}

			NL_AddLog(LogType.Info, "Addloan:rebate", new object[] { rebateTransaction }, Error, null, null);

			// call AddPayment 
			NL_Payments rebatePayment = new NL_Payments() {
				Amount = rebateTransaction.Amount,
				CreatedByUserID = 1,
				LoanID = LoanID,
				PaymentStatusID = (int)NLPaymentStatuses.Active,
				PaymentMethodID = (int)NLLoanTransactionMethods.Auto,
				CreationTime = nowTime,
				PaymentTime = nowTime.AddMilliseconds(60), // workaround: guarantee that "setup offset" payment (with PaymentTime=nowTime) will be recorded before rebate //rebateTransaction.PostDate,
				Notes = "rebate"
			};
			rebatePayment.PaypointTransactions.Add(new NL_PaypointTransactions() {
				Amount = rebateTransaction.Amount,
				IP = rebateTransaction.IP,
				Notes = rebateTransaction.Description,
				PaypointTransactionStatusID = (int)NLPaypointTransactionStatuses.Done,
				PaypointUniqueID = rebateTransaction.PaypointId,
				PaypointCardID = rebateTransaction.CardID,
				TransactionTime = rebateTransaction.PostDate
			});

			AddPayment p = new AddPayment(model.CustomerID, rebatePayment, 1);
			p.Execute();
		}
Beispiel #2
0
		}//Execute

		// 11. if setup fee - add payment to offset it
		private void SetupOffsetPayment() {
			if (LoanID == 0)
				return;

			var setupFee = model.Loan.Fees.FirstOrDefault(f => f.LoanFeeTypeID == (int)NLFeeTypes.SetupFee);

			Log.Debug("setup fee for offset: {0}", setupFee);

			if (setupFee != null) {
				NL_Payments setupfeeOffsetpayment = new NL_Payments {
					PaymentMethodID = (int)NLLoanTransactionMethods.SetupFeeOffset,
					Amount = setupFee.Amount,
					CreatedByUserID = 1,
					CreationTime = setupFee.CreatedTime,
					Notes = "setup fee offsetting",
					PaymentTime = nowTime.Date,
					PaymentStatusID = (int)NLPaymentStatuses.Active,
					LoanID = LoanID
				};
				AddPayment p = new AddPayment(model.CustomerID, setupfeeOffsetpayment, 1);
				p.Execute();
			}
		}