Example #1
0
        //public static void GenerateBankExportsForBookingFeesToDate()
        //{
        //    DateTime startDateRange = Utilities.CardnetDelay(GetDateOfLastNonTicketFundsBankExport()).AddDays(1);
        //    DateTime endDateRange = Utilities.CardnetDelay().AddDays(1);
            
        //    Query untransferedBookingFeesQuery = new Query(new And(new Q(InvoiceItem.Columns.Type, InvoiceItem.Types.EventTicketsBookingFee),
        //                                                           new Q(InvoiceItem.Columns.RevenueStartDate, QueryOperator.GreaterThanOrEqualTo, startDateRange),
        //                                                           new Q(InvoiceItem.Columns.RevenueStartDate, QueryOperator.LessThan, endDateRange)));
        //    untransferedBookingFeesQuery.ExtraSelectElements.Add("SumBookingFeeAmounts", "SUM([InvoiceItem].[Total])");
        //    untransferedBookingFeesQuery.ExtraSelectElements.Add("TheDate", "dateadd(day, 0, datediff(day, 0, [InvoiceItem].[RevenueStartDate]))");
        //    untransferedBookingFeesQuery.GroupBy = new GroupBy("dateadd(day, 0, datediff(day, 0, [InvoiceItem].[RevenueStartDate]))");
        //    untransferedBookingFeesQuery.Columns = new ColumnSet();

        //    InvoiceItemSet untransferedBookingFeeItems = new InvoiceItemSet(untransferedBookingFeesQuery);
        //    foreach (InvoiceItem ii in untransferedBookingFeeItems)
        //    {
        //        GenerateBankExportForBookingFees(ii);
        //    }
        //}


		#region I this this sets up the transfers between the current and client accounts. I've disabled it.

		//public static void GenerateBankExportsForAllNonTicketFundsToDate()
		//{
		//    DateTime startDateRange = Utilities.CardnetDelay(GetDateOfLastNonTicketFundsBankExport()).AddDays(1);
		//    DateTime endDateRange = Utilities.CardnetDelay().AddDays(1);

		//    GenerateBankExportsForNonTicketFunds(startDateRange, endDateRange, true);
		//    GenerateBankExportsForNonTicketFunds(startDateRange, endDateRange, false);            
		//}

		//private static void GenerateBankExportsForNonTicketFunds(DateTime startDateRange, DateTime endDateRange, bool positiveCashFlow)
		//{
		//    startDateRange = Utilities.GetStartOfDay(startDateRange);
		//    endDateRange = Utilities.GetStartOfDay(endDateRange);

		//    Query nonTicketCardMoneyQuery = new Query(new And(new Q(Transfer.Columns.Method, Transfer.Methods.Card),
		//                                                      new Q(Transfer.Columns.Status, Transfer.StatusEnum.Success),
		//                                                      new Q(Transfer.Columns.DateTimeComplete, QueryOperator.GreaterThanOrEqualTo, startDateRange),
		//                                                      new Q(Transfer.Columns.DateTimeComplete, QueryOperator.LessThan, endDateRange)));
            
		//    nonTicketCardMoneyQuery.ExtraSelectElements.Add("SumAmounts", "SUM([Transfer].[Amount])");
		//    nonTicketCardMoneyQuery.ExtraSelectElements.Add("TheDate", "dateadd(day, 0, datediff(day, 0, [Transfer].[DateTimeComplete]))");
		//    nonTicketCardMoneyQuery.OrderBy = new OrderBy("dateadd(day, 0, datediff(day, 0, [Transfer].[DateTimeComplete]))");
		//    nonTicketCardMoneyQuery.GroupBy = new GroupBy("dateadd(day, 0, datediff(day, 0, [Transfer].[DateTimeComplete]))");
		//    nonTicketCardMoneyQuery.Columns = new ColumnSet();


		//    Query ticketCardMoneyQuery = new Query(new And(new Q(InvoiceItem.Columns.Type, InvoiceItem.Types.EventTickets),
		//                                                   new Q(InvoiceItem.Columns.RevenueStartDate, QueryOperator.GreaterThanOrEqualTo, startDateRange),
		//                                                   new Q(InvoiceItem.Columns.RevenueStartDate, QueryOperator.LessThan, endDateRange)));
		//    ticketCardMoneyQuery.ExtraSelectElements.Add("SumAmounts", "SUM([InvoiceItem].[Total])");
		//    ticketCardMoneyQuery.ExtraSelectElements.Add("TheDate", "dateadd(day, 0, datediff(day, 0, [InvoiceItem].[RevenueStartDate]))");
		//    ticketCardMoneyQuery.OrderBy = new OrderBy("dateadd(day, 0, datediff(day, 0, [InvoiceItem].[RevenueStartDate]))");
		//    ticketCardMoneyQuery.GroupBy = new GroupBy("dateadd(day, 0, datediff(day, 0, [InvoiceItem].[RevenueStartDate]))");
		//    ticketCardMoneyQuery.Columns = new ColumnSet();

		//    if(positiveCashFlow)
		//    {
		//        nonTicketCardMoneyQuery.QueryCondition = new And(nonTicketCardMoneyQuery.QueryCondition,
		//                                                         new Q(Transfer.Columns.Amount, QueryOperator.GreaterThan, 0));
		//        ticketCardMoneyQuery.QueryCondition = new And(ticketCardMoneyQuery.QueryCondition,
		//                                                      new Q(InvoiceItem.Columns.Total, QueryOperator.GreaterThan, 0));
		//    }
		//    else
		//    {
		//        nonTicketCardMoneyQuery.QueryCondition = new And(nonTicketCardMoneyQuery.QueryCondition,
		//                                                         new Q(Transfer.Columns.Amount, QueryOperator.LessThan, 0));
		//        ticketCardMoneyQuery.QueryCondition = new And(ticketCardMoneyQuery.QueryCondition,
		//                                                      new Q(InvoiceItem.Columns.Total, QueryOperator.LessThan, 0));
		//    }

		//    TransferSet nonTicketCardMoneyTransfers = new TransferSet(nonTicketCardMoneyQuery);
		//    InvoiceItemSet ticketCardMoneyItems = new InvoiceItemSet(ticketCardMoneyQuery);

		//    Hashtable hash = new Hashtable();
		//    foreach (Transfer t in nonTicketCardMoneyTransfers)
		//    {
		//        hash.Add(Convert.ToDateTime(t.ExtraSelectElements["TheDate"]).ToString("dd-MM-yyyy"), t.ExtraSelectElements["SumAmounts"]);
		//    }

		//    foreach (InvoiceItem ii in ticketCardMoneyItems)
		//    {
		//        if (hash.ContainsKey(Convert.ToDateTime(ii.ExtraSelectElements["TheDate"]).ToString("dd-MM-yyyy")))
		//            hash[Convert.ToDateTime(ii.ExtraSelectElements["TheDate"]).ToString("dd-MM-yyyy")] = ((double)(Convert.ToDouble(hash[Convert.ToDateTime(ii.ExtraSelectElements["TheDate"]).ToString("dd-MM-yyyy")]) - Convert.ToDouble(ii.ExtraSelectElements["SumAmounts"]))).ToString();
		//        else
		//            hash.Add(Convert.ToDateTime(ii.ExtraSelectElements["TheDate"]).ToString("dd-MM-yyyy"), ((double)(-1 * Convert.ToDouble(ii.ExtraSelectElements["SumAmounts"]))).ToString());
		//    }

		//    while (startDateRange < endDateRange)
		//    {
		//        if (hash.ContainsKey(startDateRange.ToString("dd-MM-yyyy")))
		//        {
		//            BankExport be = new BankExport();
		//            be.Amount = Math.Round(Convert.ToDecimal(hash[startDateRange.ToString("dd-MM-yyyy")]), 2);
		//            if (be.Amount != 0)
		//            {
		//                be.ReferenceDateTime = startDateRange;
		//                StringBuilder sb = new StringBuilder();
		//                sb.Append("Client account to current account: ");
		//                sb.Append(be.Amount.ToString("c"));
		//                sb.Append(" from ");
		//                sb.Append(be.ReferenceDateTime.ToString("ddd dd/MM/yyyy"));
		//                be.Details = sb.ToString();

		//                be.AddedDateTime = DateTime.Now;
		//                if (be.Amount > 0)
		//                {
		//                    be.BankAccountNumber = Vars.DSI_BANK_ACCOUNT_NUMBER;
		//                    be.BankAccountSortCode = Vars.DSI_BANK_SORT_CODE;
		//                    be.BankName = Vars.DSI_BANK_NAME;
		//                }
		//                else
		//                {
		//                    be.BankAccountNumber = Vars.DSI_CLIENT_BANK_ACCOUNT_NUMBER;
		//                    be.BankAccountSortCode = Vars.DSI_CLIENT_BANK_SORT_CODE;
		//                    be.BankName = Vars.DSI_CLIENT_BANK_NAME;
		//                }
		//                be.Amount = Math.Abs(be.Amount);

		//                be.Status = Statuses.Added;

		//                be.Type = Types.InternalTransferNonTicketFunds;

		//                be.Update();

		//                be.Validate();
		//            }
		//        }
		//        startDateRange = startDateRange.AddDays(1);
		//    }
		//}
		

		//private static void GenerateBankExportForBookingFees(InvoiceItem invoiceItem)
		//{
		//    BankExport be = new BankExport();

		//    be.Amount = Math.Round(Convert.ToDecimal(invoiceItem.ExtraSelectElements["SumBookingFeeAmounts"]), 2);
		//    if (be.Amount != 0)
		//    {
		//        be.ReferenceDateTime = (DateTime)invoiceItem.ExtraSelectElements["TheDate"];
		//        StringBuilder sb = new StringBuilder();
		//        sb.Append("Ticket booking fees of ");
		//        sb.Append(be.Amount.ToString("c"));
		//        sb.Append(" from ");
		//        sb.Append(be.ReferenceDateTime.ToString("ddd dd/MM/yyyy"));
		//        be.Details = sb.ToString();

		//        be.AddedDateTime = DateTime.Now;
		//        if (be.Amount > 0)
		//        {
		//            be.BankAccountNumber = Vars.DSI_BANK_ACCOUNT_NUMBER;
		//            be.BankAccountSortCode = Vars.DSI_BANK_SORT_CODE;
		//            be.BankName = Vars.DSI_BANK_NAME;
		//        }
		//        else
		//        {
		//            be.BankAccountNumber = Vars.DSI_CLIENT_BANK_ACCOUNT_NUMBER;
		//            be.BankAccountSortCode = Vars.DSI_CLIENT_BANK_SORT_CODE;
		//            be.BankName = Vars.DSI_CLIENT_BANK_NAME;
		//        }
		//        be.Amount = Math.Abs(be.Amount);

		//        be.Status = Statuses.Added;
 
		//        be.Type = Types.InternalTransferNonTicketFunds;

		//        be.Update();

		//        be.Validate();
		//    }
		//}
		#endregion

		public static void GenerateBankExportForRefundTransfer(Transfer refundTransfer)
        {
            BankExport be = new BankExport();
            be.AddedDateTime = DateTime.Now;
            be.Amount = Math.Abs(refundTransfer.Amount);
            be.BankName = Cambro.Misc.Utility.Snip(refundTransfer.BankName, 35);
            be.BankAccountNumber = refundTransfer.BankAccountNumber;
            be.BankAccountSortCode = refundTransfer.BankSortCode;
            be.PromoterK = refundTransfer.PromoterK;
            be.Status = BankExport.Statuses.Added;

			if (refundTransfer.TransferRefunded != null && refundTransfer.TransferRefunded.Method == Transfer.Methods.TicketSales)
            {
				//if (refundTransfer.BankName.ToUpper().Contains(Vars.DSI_BANK_NAME.ToUpper()))
				//    be.Type = BankExport.Types.InternalTransferTicketFundsToPromoter;
				//else
                    be.Type = BankExport.Types.ExternalBACSTicketFundsToPromoter;
            }
            else
            {
				//if (refundTransfer.BankName.ToUpper().Contains(Vars.DSI_BANK_NAME.ToUpper()))
				//    be.Type = BankExport.Types.InternalTransferRefundToPromoter;
				//else
                    be.Type = Types.ExternalBACSRefundToPromoter;
            }
            be.TransferK = refundTransfer.K;

            StringBuilder sb = new StringBuilder();
            sb.Append("Promoter ");
            sb.Append(refundTransfer.Promoter.Name);
            sb.Append(" requested a refund of ");
            sb.Append(refundTransfer.Amount.ToString("c"));
            sb.Append(".");
            sb.Append(refundTransfer.Promoter.AsHTML());
            sb.Append(refundTransfer.AsHTML());
            be.Details = sb.ToString();

            be.Update();

            be.Validate();
            refundTransfer.BankTransferReference = be.PaymentRef;
            refundTransfer.Update();
        }
Example #2
0
 protected void UpdateSearchGridViewStatusButton_Click(object sender, EventArgs e)
 {
     DropDownList BankExportStatusDDL = (DropDownList)SearchBankExportGridView.FooterRow.FindControl("BankExportStatusDropDownList");
     foreach (GridViewRow row in this.SearchBankExportGridView.Rows)
     {
         if (row.RowType == DataControlRowType.DataRow)
         {
             try
             {
                 if (((CheckBox)row.FindControl("BankExportSelectCheckBox")).Checked)
                 {
                     Bobs.BankExport be = new Bobs.BankExport(Convert.ToInt32(((TextBox)row.FindControl("BankExportKTextBox")).Text));
                     be.UpdateStatus((Bobs.BankExport.Statuses)Convert.ToInt32(BankExportStatusDDL.SelectedValue));
                 }
             }
             catch { }
         }
     }
     this.LoadGridViewOfSearchBankExport();
 }