Exemple #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();
		}
Exemple #2
0
		public void DirectQueryTest() {
			MigrateLoanTransaction.LoanTransactionModel rebateTransaction = this.m_oDB.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 = @LoanTransactionMethodId",
			   CommandSpecies.Text,
			   new QueryParameter("@LoanID", 2079), new QueryParameter("@dd", new DateTime(2015, 10, 23)), new QueryParameter("@LoanTransactionMethodId", (int)NLLoanTransactionMethods.Auto)
			);
			m_oLog.Debug(rebateTransaction.Amount);
			m_oLog.Debug(rebateTransaction.PostDate);
			m_oLog.Debug(rebateTransaction.PaypointId);
		}