public bool IsReadyForProcessing(InvoiceItem.Types invoiceItemType, decimal price, decimal total)
		{
			if (VerifyPrice(invoiceItemType, price, total))
			{
				if (invoiceItemType.Equals(InvoiceItem.Types.UsrDonate) || invoiceItemType.Equals(InvoiceItem.Types.CharityDonation))
					return true;
				else
					throw new Exception("invalid invoice item type: " + Utilities.CamelCaseToString(invoiceItemType.ToString()));
			}
			else
				throw new DsiUserFriendlyException("price wrong!");
		}
Exemple #2
0
        /// <summary>
        /// Unprocesses the IBuyable Bob. For banners, it sets the event donation off, and updates the event.
        /// </summary>
        /// <param name="invoiceItemType">InvoiceItem.Type</param>
        /// <returns></returns>
        public bool Unprocess(InvoiceItem.Types invoiceItemType)
        {
            if (invoiceItemType.Equals(InvoiceItem.Types.EventTickets))
            {
                this.Unlock();
                this.TicketRun.CalculateSoldTicketsAndUpdate();

                return !IsProcessed(invoiceItemType);
            }
            else
                throw new Exception("invalid invoice item type: " + Utilities.CamelCaseToString(invoiceItemType.ToString()));
        }
Exemple #3
0
 /// <summary>
 /// Verifies if the IBuyable Bob has already been processed successfully.
 /// </summary>
 /// <param name="invoiceItemType">InvoiceItem.Type</param>
 /// <returns></returns>
 public bool IsProcessed(InvoiceItem.Types invoiceItemType)
 {
     if (invoiceItemType.Equals(InvoiceItem.Types.EventTickets))
     {
         return this.Enabled && this.K > 0 && this.Quantity > 0;
     }
     else if (invoiceItemType.Equals(InvoiceItem.Types.EventTicketsBookingFee))
     {
         return this.K > 0;
     }
     else
         throw new Exception("invalid invoice item type: " + Utilities.CamelCaseToString(invoiceItemType.ToString()));
 }
Exemple #4
0
        /// <summary>
        /// Checks the price entered against the calculated price.  This checks if the figures have been adjusted during the payment processing.
        /// </summary>
        /// <param name="invoiceItemType">InvoiceItem.Type</param>
        /// <param name="price">InvoiceItem.Price</param>
        /// <param name="total">InvoiceItem.Total</param>
        /// <returns></returns>
		public bool VerifyPrice(InvoiceItem.Types invoiceItemType, decimal price, decimal total)
        {
            if (invoiceItemType.Equals(InvoiceItem.Types.EventTickets))
            {
                return Math.Round(total, 2) == Math.Round(this.TicketRun.Price * this.Quantity, 2);
            }
            else if (invoiceItemType.Equals(InvoiceItem.Types.EventTicketsBookingFee))
            {
                return Math.Round(total, 2) == Math.Round(this.TicketRun.BookingFee * this.Quantity, 2);
            }
            else
                throw new Exception("invalid invoice item type: " + Utilities.CamelCaseToString(invoiceItemType.ToString()));
        }
Exemple #5
0
        /// <summary>
        /// Checks if the IBuyable Bob is ready to be processed. This is used as a pre-purchasing check.
        /// Verifies if the Ticket Run is still running
        /// Verifies if the Ticket Run has enough tickets remaining
        /// Verifies if the Ticket price and booking fee havent been changed
        /// Verifies that the usr does not exceed the max tickets per usr
        /// Verifies that the usr's card does not exceed the max tickets per card
        /// </summary>
        /// <param name="invoiceItemType">InvoiceItem.Type</param>
        /// <param name="price">InvoiceItem.Price</param>
        /// <returns></returns>
		public bool IsReadyForProcessing(InvoiceItem.Types invoiceItemType, decimal price, decimal total)
        {
            if (invoiceItemType.Equals(InvoiceItem.Types.EventTickets))
            {
                if (this.Enabled)
                    throw new DsiUserFriendlyException("This ticket has already been purchased.");

                if (this.Cancelled)
                    throw new DsiUserFriendlyException("This ticket has already been cancelled.");

                this.TicketRun = new TicketRun(this.TicketRunK);

                if (!this.TicketRun.Status.Equals(Bobs.TicketRun.TicketRunStatus.Running))
                {
                    throw new DsiUserFriendlyException("This ticket run is not currently selling tickets. Status: " + Utilities.CamelCaseToString(this.TicketRun.Status.ToString()));
                }

                if (!VerifyPrice(invoiceItemType, price, total))
                {
                    throw new DsiUserFriendlyException("Price wrong! Please restart and try again.");
                }

                // Update the BuyableLockDateTime, as the time between the Ticket saved and the user paying for it is not determined. This will re-lock the ticket for a further period.
                this.Reserve();
                

                // As this Ticket has been entered in the database and will be counted when other people are trying to purchase tickets it is calculated in the CurrentNumberOfTicketsSold, so we need to remove Ticket.Quantity.
                int currentNumberOfTicketsSold = this.TicketRun.CurrentNumberOfTicketsSold - this.Quantity;
                int ticketsRemaining = this.TicketRun.MaxTickets - currentNumberOfTicketsSold;
                if (ticketsRemaining < this.Quantity)
                {
                    if (ticketsRemaining <= 0)
                    {
                        if (this.TicketRun.SoldTickets >= this.TicketRun.MaxTickets)
                        {
                            if (this.TicketRun.SoldTickets > this.TicketRun.MaxTickets)
                                this.AdminEmailAlertWrapper("Exception in Ticket.IsReadyForProcessing(): TicketRunK= " + this.TicketRunK.ToString() + ", SoldTickets= " + this.TicketRun.SoldTickets.ToString() + ", MaxTickets= " + this.TicketRun.MaxTickets.ToString());

                            throw new DsiUserFriendlyException("No tickets left for this ticket run.");
                        }

                        throw new DsiUserFriendlyException("No tickets currently available for this ticket run. " + Vars.TICKETS_PLEASE_TRY_AGAIN_IN);
                    }
                    else
                        throw new DsiUserFriendlyException("Only " + ticketsRemaining.ToString() + " ticket" + (ticketsRemaining > 1 ? "s" : "") + " currently available for this ticket run.");
                }

                // As this Ticket has been entered in the database and will be counted if usr is trying to purchase tickets in another window, so it is calculated in the CurrentTicketsSoldForUsr, so we need to remove Ticket.Quantity.
                int usrEventTickets = this.Event.TicketsSoldForUsr(this.BuyerUsrK) + this.Event.TicketsAwaitingPaymentForUsrTotal(this.BuyerUsrK) - this.Quantity;
                if (usrEventTickets >= Vars.TICKETS_MAX_PER_USR)
                {
                    if (usrEventTickets > Vars.TICKETS_MAX_PER_USR)
                    {
                        this.AdminEmailAlertWrapper("Exception in Ticket.IsReadyForProcessing(): Usr trying to exceed max tickets per user. Usr event tickets= " + this.Event.TicketsSoldForUsr(this.BuyerUsrK).ToString() + ", usr tickets awaiting payment= " + this.Event.TicketsAwaitingPaymentForUsrTotal(this.BuyerUsrK).ToString());
                    }
                    throw new DsiUserFriendlyException("You have reached the ticket limit for this event. You cannot buy anymore tickets for this event.");
                }
                else if (usrEventTickets + this.Quantity > Vars.TICKETS_MAX_PER_USR)
                {
                    throw new DsiUserFriendlyException("This will exceed your ticket limit for this event. You can only purchase " + ((int)(Vars.TICKETS_MAX_PER_USR - usrEventTickets)).ToString() + " more ticket" + (Vars.TICKETS_MAX_PER_USR - usrEventTickets > 1 ? "s" : "") + " for this event.");
                }

                // As this Ticket has been entered in the database and will be counted if usr is trying to purchase tickets in another window, so it is calculated in the CurrentTicketsSoldForUsr, so we need to remove Ticket.Quantity.
                int cardEventTickets = this.Event.TicketsSoldForCard(this.CardNumberHash) + this.Event.TicketsAwaitingPaymentForCardTotal(this.CardNumberHash) - this.Quantity;
                if (cardEventTickets >= Vars.TICKETS_MAX_PER_CARD)
                {
                    if (cardEventTickets > Vars.TICKETS_MAX_PER_CARD)
                        this.AdminEmailAlertWrapper("Exception in Ticket.IsReadyForProcessing(): Usr trying to exceed max tickets per card. Card event tickets= " + this.Event.TicketsSoldForCard(this.CardNumberHash).ToString() + ", card tickets awaiting payment= " + this.Event.TicketsAwaitingPaymentForCardTotal(this.CardNumberHash).ToString());

                    if (this.Event.TicketsSoldForCard(this.CardNumberHash) >= Vars.TICKETS_MAX_PER_CARD)
                        throw new DsiUserFriendlyException("You have reached the ticket limit for this event. You cannot buy anymore tickets for this event with this card.");
                    else
                        throw new DsiUserFriendlyException("You cannot buy anymore tickets for this event right now with this card. " + Vars.TICKETS_PLEASE_TRY_AGAIN_IN);
                }
                else if (cardEventTickets + this.Quantity > Vars.TICKETS_MAX_PER_CARD)
                {
                    throw new DsiUserFriendlyException("This will exceed your ticket limit for this event. You can only purchase " + ((int)(Vars.TICKETS_MAX_PER_CARD - cardEventTickets)).ToString() + " more ticket" + (Vars.TICKETS_MAX_PER_CARD - cardEventTickets > 1 ? "s" : "") + " for this event with this card.");
                }

                return true;
            }
            else if (invoiceItemType.Equals(InvoiceItem.Types.EventTicketsBookingFee))
            {
                if (!VerifyPrice(invoiceItemType, price, total))
                {
                    throw new DsiUserFriendlyException("Booking fee wrong! Please restart and try again.");
                }
                return true;
            }
            else
                throw new Exception("invalid invoice item type: " + Utilities.CamelCaseToString(invoiceItemType.ToString()));
        }
		public bool IsProcessed(InvoiceItem.Types invoiceItemType)
		{
			if (invoiceItemType.Equals(InvoiceItem.Types.UsrDonate) || invoiceItemType.Equals(InvoiceItem.Types.CharityDonation))
				return this.Enabled;
			else
				throw new Exception("invalid invoice item type: " + Utilities.CamelCaseToString(invoiceItemType.ToString()));
		}
Exemple #7
0
		/// <summary>
		/// Checks if the IBuyableCredits Bob is ready to be processed. This is used as a pre-purchasing check.
		/// </summary>
		/// <param name="invoiceItemType">InvoiceItem.Type</param>
		/// <param name="price">InvoiceItem.Price</param>
		/// <returns></returns>
		public bool IsReadyForProcessingCredits(InvoiceItem.Types invoiceItemType, int priceCredits)
		{
			if (InvoiceItem.BaseType(invoiceItemType).Equals(InvoiceItem.Types.Banner))
			{
				if (!StatusBooked)
				{
					if (CheckDates())
					{
						if (VerifyPriceCredits(invoiceItemType, priceCredits))
						{
							return true;
						}
						else
						{
							throw new DsiUserFriendlyException("price wrong!");
						}
					}
					else
					{
						throw new DsiUserFriendlyException("dates wrong!");
					}
				}
				else
					return false;
			}
			else if (InvoiceItem.BaseType(invoiceItemType).Equals(InvoiceItem.Types.Design))
			{
				if (VerifyPriceCredits(invoiceItemType, priceCredits))
				{
					return true;
				}
				else
				{
					throw new DsiUserFriendlyException("price wrong!");
				}
			}
			else
				throw new Exception("invalid invoice item type: " + Utilities.CamelCaseToString(invoiceItemType.ToString()));
		}
		/// <summary>
		/// Checks the price entered against the calculated price.  This checks if the figures have been adjusted during the payment processing.
		/// </summary>
		/// <param name="invoiceItemType">InvoiceItem.Type</param>
		/// <param name="price">InvoiceItem.Price</param>
		/// <returns></returns>
		public bool VerifyPrice(InvoiceItem.Types invoiceItemType, decimal price, decimal total)
		{
			if (invoiceItemType.Equals(InvoiceItem.Types.GuestlistCredit))
				return Math.Round(price, 2) == Math.Round(this.Credits * this.Promoter.GuestlistCharge, 2);
			else
				throw new Exception("invalid invoice item type: " + Utilities.CamelCaseToString(invoiceItemType.ToString()));
		}
		/// <summary>
		/// Checks if the IBuyable Bob is ready to be processed. This is used as a pre-purchasing check.
		/// </summary>
		/// <param name="invoiceItemType">InvoiceItem.Type</param>
		/// <param name="price">InvoiceItem.Price</param>
		/// <returns></returns>
		public bool IsReadyForProcessing(InvoiceItem.Types invoiceItemType, decimal price, decimal total)
		{
			if (invoiceItemType.Equals(InvoiceItem.Types.GuestlistCredit))
			{
				if (!this.Done)
				{
					if (VerifyPrice(invoiceItemType, price, total))
						return true;
					else
						throw new DsiUserFriendlyException("price wrong!");
				}
			}
			else
				throw new Exception("invalid invoice item type: " + Utilities.CamelCaseToString(invoiceItemType.ToString()));

			return this.Done;
		}
Exemple #10
0
		/// <summary>
		/// Checks if the IBuyableCredits Bob is ready to be processed. This is used as a pre-purchasing check.
		/// </summary>
		/// <param name="invoiceItemType">InvoiceItem.Type</param>
		/// <param name="price">InvoiceItem.Price</param>
		/// <returns></returns>
		public bool IsReadyForProcessingCredits(InvoiceItem.Types invoiceItemType, int priceCredits)
		{
			if (invoiceItemType.Equals(InvoiceItem.Types.EventDonate))
			{
				if (!this.Donated)
				{
					if (VerifyPriceCredits(invoiceItemType, priceCredits))
						return true;
					else
						throw new DsiUserFriendlyException("price wrong!");
				}
			}
			else
				throw new Exception("Invalid invoice item type: " + Utilities.CamelCaseToString(invoiceItemType.ToString()));

			return this.Donated;
		}
Exemple #11
0
		/// <summary>
		/// Unprocesses the IBuyable Bob. For events, it sets the event donation off, and updates the event.
		/// </summary>
		/// <param name="invoiceItemType">InvoiceItem.Type</param>
		/// <returns></returns>
		public bool Unprocess(InvoiceItem.Types invoiceItemType)
		{
			if (invoiceItemType.Equals(InvoiceItem.Types.EventDonate))
			{
				if (this.Donated)
				{
					this.Donated = false;
					this.UpdateHasHighlight(false);
					this.Update();
				}
			}
			else
				throw new Exception("invalid invoice item type: " + Utilities.CamelCaseToString(invoiceItemType.ToString()));

			return !IsProcessed(invoiceItemType);
		}
Exemple #12
0
		/// <summary>
		/// Checks the price entered against the calculated price.  This checks if the figures have been adjusted during the payment processing.
		/// </summary>
		/// <param name="invoiceItemType">InvoiceItem.Type</param>
		/// <param name="price">InvoiceItem.Price</param>
		/// <returns></returns>
		public bool VerifyPriceCredits(InvoiceItem.Types invoiceItemType, int priceCredits)
		{
			if (invoiceItemType.Equals(InvoiceItem.Types.EventDonate))
			{
				return priceCredits == Vars.EventHighlightPriceCredits(this);
			}
			else
				throw new Exception("Invalid invoice item type: " + Utilities.CamelCaseToString(invoiceItemType.ToString()));
		}
Exemple #13
0
		/// <summary>
		/// Verifies if the IBuyable Bob has already been processed successfully.
		/// </summary>
		/// <param name="invoiceItemType">InvoiceItem.Type</param>
		/// <returns></returns>
		public bool IsProcessed(InvoiceItem.Types invoiceItemType)
		{
			if (InvoiceItem.BaseType(invoiceItemType).Equals(InvoiceItem.Types.Banner))
			{
				return this.StatusBooked;
			}
			else if (InvoiceItem.BaseType(invoiceItemType).Equals(InvoiceItem.Types.Design))
			{
				return this.DesignProcessed;
			}
			else
				throw new Exception("Invalid invoice item type: " + Utilities.CamelCaseToString(invoiceItemType.ToString()));
		}
Exemple #14
0
		/// <summary>
		/// Unprocesses the IBuyable Bob. For banners, it sets the event donation off, and updates the event.
		/// </summary>
		/// <param name="invoiceItemType">InvoiceItem.Type</param>
		/// <returns></returns>
		public bool Unprocess(InvoiceItem.Types invoiceItemType)
		{
			if (InvoiceItem.BaseType(invoiceItemType).Equals(InvoiceItem.Types.Banner))
			{
				this.StatusBooked = false;
				this.Update();

				return !IsProcessed(invoiceItemType);
			}
			else if (InvoiceItem.BaseType(invoiceItemType).Equals(InvoiceItem.Types.Design))
			{

				Mailer m = new Mailer();
				m.Subject = this.DesignType.ToString() + " design service UNPROCESSED, banner: " + this.K + ", promoter: " + this.Promoter.Name;
				m.Body = "<p><b>Invoice UNPROCESSED (stop work! invoice was refunded or error happened after processing!)</b></p>";
				m.Body += "<p>Banner: <b><a href=\"[LOGIN(" + this.Url() + ")]\">" + this.K.ToString() + "</a></b></p>";
				m.Body += "<p>Promoter: <b><a href=\"[LOGIN(" + this.Promoter.Url() + ")]\">" + this.Promoter.Name + "</a> (K=" + this.Promoter.K.ToString() + ")</b></p>";
				m.Body += "<p>Service type: <b>" + this.DesignType.ToString() + "</b></p>";
				m.Body += "<p>Banner position: <b>" + this.Position.ToString() + "</b></p>";
				m.Body += "<p>Banner goes live: <b>" + this.FirstDay.ToString("dddd dd/MM/yy") + "</b></p>";
				m.RedirectUrl = this.Url();

				m.UsrRecipient = new Usr(1);
				m.Send();

				m.UsrRecipient = new Usr(2);
				m.Send();

				//send unprocess email to John?
				this.DesignProcessed = false;
				this.Update();

				return !IsProcessed(invoiceItemType);
			}
			else
				throw new Exception("Invalid invoice item type: " + Utilities.CamelCaseToString(invoiceItemType.ToString()));
		}
		public bool Process(InvoiceItem.Types invoiceItemType, decimal price, decimal total)
		{
			if (VerifyPrice(invoiceItemType, price, total))
			{
				if (invoiceItemType.Equals(InvoiceItem.Types.UsrDonate) || invoiceItemType.Equals(InvoiceItem.Types.CharityDonation))
				{
					this.ProcessDonation();
				}
				else
					throw new Exception("invalid invoice item type: " + Utilities.CamelCaseToString(invoiceItemType.ToString()));
			}
			else
			{
				throw new Exception("price wrong!");
			}

			return IsProcessed(invoiceItemType);
		}
		/// <summary>
		/// Unprocesses the IBuyable Bob. For guestlist credit, it removes the guestlist credit amount from the promoter, sets the guestlist credit to not done, and updates the promoter and the guest list credit.
		/// </summary>
		/// <param name="invoiceItemType">InvoiceItem.Type</param>
		/// <returns></returns>
		public bool Unprocess(InvoiceItem.Types invoiceItemType)
		{
			if (invoiceItemType.Equals(InvoiceItem.Types.GuestlistCredit))
			{
				if (this.Done)
				{
					this.Done = false;
					this.DateTimeDone = DateTime.MinValue;
					this.Promoter.GuestlistCredit -= this.Credits;
					this.Update();
					this.Promoter.Update();
				}
			}
			else
				throw new Exception("invalid invoice item type: " + Utilities.CamelCaseToString(invoiceItemType.ToString()));

			return !IsProcessed(invoiceItemType);
		}
		public bool Unprocess(InvoiceItem.Types invoiceItemType)
		{
			if (invoiceItemType.Equals(InvoiceItem.Types.UsrDonate) || invoiceItemType.Equals(InvoiceItem.Types.CharityDonation))
			{
				this.UnprocessDonation();
			}
			else
				throw new Exception("invalid invoice item type: " + Utilities.CamelCaseToString(invoiceItemType.ToString()));

			return true;
		}
		/// <summary>
		/// Verifies if the IBuyable Bob has already been processed successfully.
		/// </summary>
		/// <param name="invoiceItemType">InvoiceItem.Type</param>
		/// <returns></returns>
		public bool IsProcessed(InvoiceItem.Types invoiceItemType)
		{
			if (invoiceItemType.Equals(InvoiceItem.Types.GuestlistCredit))
				return this.Done;
			else
				throw new Exception("invalid invoice item type: " + Utilities.CamelCaseToString(invoiceItemType.ToString()));
		}
		public bool VerifyPrice(InvoiceItem.Types invoiceItemType, decimal price, decimal total)
		{
			if (invoiceItemType.Equals(InvoiceItem.Types.UsrDonate) || invoiceItemType.Equals(InvoiceItem.Types.CharityDonation))
				return total == this.DonationIcon.Price;
			else
				throw new Exception("invalid invoice item type: " + Utilities.CamelCaseToString(invoiceItemType.ToString()));
		}
Exemple #20
0
        /// <summary>
		/// Checks the price entered against the calculated price.  This checks if the figures have been adjusted during the payment processing.
		/// </summary>
		/// <param name="invoiceItemType">InvoiceItem.Type</param>
		/// <param name="price">InvoiceItem.Price</param>
		/// <returns></returns>
		public bool VerifyPriceCredits(InvoiceItem.Types invoiceItemType, int priceCredits)
		{
			if (InvoiceItem.BaseType(invoiceItemType).Equals(InvoiceItem.Types.Banner))
			{
				return priceCredits >= this.PriceCredits;
			}
			else if (InvoiceItem.BaseType(invoiceItemType).Equals(InvoiceItem.Types.Design))
			{
				return priceCredits >= Vars.BannerDesignPriceCredits(Banner.GetDesignTypeFromInvoiceItemType(invoiceItemType));
			}
			else
				throw new Exception("invalid invoice item type: " + Utilities.CamelCaseToString(invoiceItemType.ToString()));
		}