示例#1
0
		public bool Process(InvoiceItem.Types invoiceItemType, decimal price, decimal total) 
		{
			if (IsReadyForProcessing(invoiceItemType, price, total))
			{
                this.ActionDateTime = DateTime.Now;
				this.Enabled = true;
                this.BuyableObjectType = Model.Entities.ObjectType.Invoice;
				this.UpdateWithRecalculateBalance();

				return true;
			}
			return false;
		}
示例#2
0
		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;
		}
示例#3
0
		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()));
		}
        protected void InvoiceItemsGridView_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName.ToUpper().Equals("ADD"))
            {
				GridViewRow row = InvoiceItemsGridView.FooterRow;

				CustomValidator revenueStartDateCustomValidator = ((CustomValidator)row.FindControl("NewRevenueStartDateCalCustomValidator"));
				CustomValidator revenueEndDateCustomValidator1 = ((CustomValidator)row.FindControl("NewRevenueEndDateCalCustomValidator1"));
				CustomValidator revenueEndDateCustomValidator2 = ((CustomValidator)row.FindControl("NewRevenueEndDateCalCustomValidator2"));
				
				revenueStartDateCustomValidator.Enabled = InvoiceItem.DoesTypeHaveRevenueDateRange((InvoiceItem.Types)Convert.ToInt32(((DropDownList)row.FindControl("NewTypeDropDownList")).SelectedValue));
				revenueEndDateCustomValidator1.Enabled = revenueStartDateCustomValidator.Enabled;
				revenueEndDateCustomValidator2.Enabled = revenueStartDateCustomValidator.Enabled;

				Page.Validate("InvoiceItemNew");
				if (Page.IsValid)
				{
					try
					{
						// add new row from footer to db
						InvoiceItem newInvoiceItem = new InvoiceItem();
						
						newInvoiceItem.Description = ((TextBox)row.FindControl("NewDescriptionTextBox")).Text.Trim();
						newInvoiceItem.RevenueStartDate = ((Spotted.CustomControls.Cal)row.FindControl("NewRevenueStartDateCal")).Date;
						newInvoiceItem.RevenueEndDate = ((Spotted.CustomControls.Cal)row.FindControl("NewRevenueEndDateCal")).Date;
						newInvoiceItem.VatCode = (InvoiceItem.VATCodes)Convert.ToInt32(((DropDownList)row.FindControl("NewVatCodeDropDownList")).SelectedValue);
						newInvoiceItem.Discount = Utilities.ConvertPercentageStringToDouble(((TextBox)row.FindControl("uiNewDiscountTextBox")).Text);
						newInvoiceItem.AgencyDiscount = Utilities.ConvertPercentageStringToDouble(uiAgencyDiscountTextBox.Text);
						if (((TextBox)row.FindControl("NewTotalTextBox")).Text.Length > 0)
						{	newInvoiceItem.SetTotal(Utilities.ConvertMoneyStringToDecimal(((TextBox)row.FindControl("NewTotalTextBox")).Text)); }
						else
						{ newInvoiceItem.PriceBeforeDiscount = Utilities.ConvertMoneyStringToDecimal(((TextBox)row.FindControl("NewPriceBeforeDiscountTextBox")).Text); }
						//newInvoiceItem.Price = Math.Abs(Utilities.ConvertMoneyStringToDecimal(((TextBox)row.FindControl("NewPriceBeforeDiscountTextBox")).Text));
						//newInvoiceItem.Vat = Convert.ToDouble(((TextBox)row.FindControl("NewVatTextBox")).Text);
						//newInvoiceItem.Total = Convert.ToDouble(((TextBox)row.FindControl("NewTotalTextBox")).Text);
						newInvoiceItem.Type = (InvoiceItem.Types)Convert.ToInt32(((DropDownList)row.FindControl("NewTypeDropDownList")).SelectedValue);

						string alertMessage = "";
						if (revenueStartDateCustomValidator.Enabled == false && Utilities.GetStartOfDay(newInvoiceItem.RevenueStartDate) != DateTime.Today)
						{
							newInvoiceItem.RevenueStartDate = DateTime.Now;
							alertMessage += Utilities.CamelCaseToString(newInvoiceItem.Type.ToString()) + " revenue start date autoset to " + Utilities.DateToString(DateTime.Now) + ". ";
						}
						if (revenueEndDateCustomValidator1.Enabled == false && Utilities.GetStartOfDay(newInvoiceItem.RevenueEndDate) != DateTime.Today)
						{
							newInvoiceItem.RevenueEndDate = DateTime.Now;
							alertMessage += Utilities.CamelCaseToString(newInvoiceItem.Type.ToString()) + " revenue end date autoset to " + Utilities.DateToString(DateTime.Now) + ".";
						}

						if (alertMessage.Length > 0)
						{
							InvoiceItemsMessageLabel.Text = "* " + alertMessage;
							InvoiceItemsMessageLabel.Visible = true;
						}
						InvoiceItemDataHolderList.Add(new InvoiceItemDataHolder(newInvoiceItem));

						ViewState["InvoiceItemDataHolderList"] = InvoiceItemDataHolderList;
						SetupUnprocessedBanners();
					}
					catch (Exception)
					{ }
					finally
					{
						CalculateInvoiceItemVatAndTotals();
					}
				}
            }
        }
示例#5
0
		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!");
		}
示例#6
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()));
        }
示例#7
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()));
        }
示例#8
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;
		}
示例#9
0
		/// <summary>
		/// Processes the IBuyableCredits Bob. For events, it verifies that the event donation IsReadyForProcessing. If yes, then it sets event donation status to Donated, and updates the event.
		/// </summary>
		/// <param name="invoiceItemType">InvoiceItem.Type</param>
		/// <param name="price">InvoiceItem.Price</param>
		/// <returns></returns>
		public bool ProcessCredits(InvoiceItem.Types invoiceItemType, int priceCredits)
		{
			if (IsReadyForProcessingCredits(invoiceItemType, priceCredits))
			{
				this.Donated = true;
				this.UpdateHasHighlight(false);
				this.Update();
			}

			return IsProcessed(invoiceItemType);
		}
示例#10
0
		public void UpdateTicketInvoiceItemTaxCode()
		{
			if(this.VatStatus == VatStatusEnum.Registered)
			{
				InvoiceItem.VATCodes vatCode = InvoiceItem.VATCodes.T1;
				foreach (TicketPromoterEvent ticketPromoterEvent in TicketPromoterEvents)
				{
					bool updated = false;

					foreach (TicketRun ticketRun in ticketPromoterEvent.TicketRuns)
					{
						foreach (Ticket ticket in ticketRun.Tickets)
						{
							try
							{
								InvoiceItem ticketInvoiceItem = new InvoiceItem(ticket.InvoiceItemK);
								if (ticketInvoiceItem.VatCode != vatCode)
								{
									decimal total = ticketInvoiceItem.Total;
									ticketInvoiceItem.VatCode = vatCode;
									ticketInvoiceItem.SetTotal(total);
									ticketInvoiceItem.Update();
									ticketInvoiceItem.Invoice.UpdatePrice();
									ticketInvoiceItem.Invoice.Update();

									if (ticket.Cancelled)
									{
										foreach (Invoice credit in ticketInvoiceItem.Invoice.CreditsApplied)
										{
											foreach (InvoiceItem creditItem in credit.Items)
											{
												if (creditItem.Type == ticketInvoiceItem.Type && Math.Abs(Math.Round(creditItem.Total, 2)) == Math.Round(ticketInvoiceItem.Total, 2))
												{
													creditItem.VatCode = vatCode;
													creditItem.SetTotal(creditItem.Total);
													creditItem.Update();
													creditItem.Invoice.UpdatePrice();
													creditItem.Invoice.Update();
												}
											}
										}
									}

									updated = true;
								}
							}
							catch (Exception ex)
							{
								Utilities.AdminEmailAlert("Exception occurred for TicketK= " + ticket.K.ToString(), "Exception occurred in UpdateTicketInvoiceItemTaxCode()", ex, this);
							}
						}
					}

					if (updated)
					{
						ticketPromoterEvent.CalculateTotalFundsAndVat();
						ticketPromoterEvent.Update();
						if (ticketPromoterEvent.FundsTransfer != null && ticketPromoterEvent.FundsTransfer.Amount != ticketPromoterEvent.TotalFunds)
						{
							// Admin email alert
							Utilities.AdminEmailAlert("Funds do not match release transfer funds.<br>TransferK= " + ticketPromoterEvent.FundsTransfer.K.ToString()
														+ ", PromoterK= " + ticketPromoterEvent.PromoterK.ToString() + ", EventK= " + ticketPromoterEvent.EventK.ToString(), 
													  "Exception occurred in UpdateTicketInvoiceItemTaxCode()", new Exception(), this);
						}
					}
				}
			}
		}
示例#11
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()));
		}
示例#12
0
		public bool VerifyPrice(InvoiceItem.Types invoiceItemType, decimal price, decimal total)
		{
			return invoiceItemType == InvoiceItem.Types.CampaignCredits && price >= 0 && Math.Round(price, 2) == (this.IsPriceFixed ? CampaignCredit.CalculateTotalCostForCredits(this.Credits, this.FixedDiscount, this.Promoter) : CampaignCredit.CalculateTotalCostForCredits(this.Credits, this.Promoter));
		}
示例#13
0
		public bool IsProcessed(InvoiceItem.Types invoiceItemType)
		{
            return invoiceItemType == InvoiceItem.Types.CampaignCredits && K != 0 && this.Enabled && this.Credits > 0;
		}
示例#14
0
		public bool Unprocess(InvoiceItem.Types invoiceItemType)
		{
			if (IsProcessed(invoiceItemType))
			{
				this.Credits = 0;
				this.Enabled = false;
				this.Update();
			}
			return true;
		}
示例#15
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.GuestlistCredit))
				return this.Done;
			else
				throw new Exception("invalid invoice item type: " + Utilities.CamelCaseToString(invoiceItemType.ToString()));
		}
示例#16
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);
		}
示例#17
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()));
        }
示例#18
0
		public static bool DoesTypeHaveRevenueDateRange(InvoiceItem.Types invoiceItemType)
		{
			switch (invoiceItemType)
			{
				case Types.CharityDonation:
				case Types.Design:
				case Types.DesignBannerAnimatedGif:
				case Types.DesignBannerFlash:
				case Types.DesignBannerJpg:
				case Types.DsiEventTickets:
				case Types.EventDonate:
				case Types.EventTickets:
				case Types.EventTicketsBookingFee:
				case Types.EventTicketsDelivery:
				case Types.GuestlistCredit:
				case Types.UsrDonate:
					return false;

				default:
					return true;
			}
		}
示例#19
0
        /// <summary>
        /// Processes the IBuyable Bob. For banners, it verifies that the banner IsReadyForProcessing. If yes, then it sets banner status to Booked, stores the price, and updates the banner.
        /// </summary>
        /// <param name="invoiceItemType">InvoiceItem.Type</param>
        /// <param name="price">InvoiceItem.Price</param>
        /// <returns></returns>
		public bool Process(InvoiceItem.Types invoiceItemType, decimal price, decimal total)
        {
            if (invoiceItemType.Equals(InvoiceItem.Types.EventTickets))
            {
                if (IsReadyForProcessing(invoiceItemType, price, total))
                {
                    try
                    {
                        this.Enabled = true;
                        this.BuyDateTime = DateTime.Now;
						try
						{
							if (this.TicketRun.Promoter.AddRandomCodeToTickets)
								this.SetRandomCode();
						}
						catch { }
                        this.Update();
                    }
                    catch {}

                    this.TicketRun.CalculateSoldTicketsAndUpdate();

					try
					{
						if (this.BuyerUsr.FacebookConnected && this.BuyerUsr.FacebookStoryBuyTicket)
						{
							FacebookPost.CreateBuyTicket(this.BuyerUsr, this.Event);
						}
					}
					catch { }
                }
            }
            else if (invoiceItemType.Equals(InvoiceItem.Types.EventTicketsBookingFee))
            {
                IsReadyForProcessing(invoiceItemType, price, total);
            }

            return IsProcessed(invoiceItemType);
        }
示例#20
0
		public static bool DoesItemApplyToSalesUsrAmount(InvoiceItem.Types invoiceItemType)
		{
			return invoiceItemType.Equals(InvoiceItem.Types.EventDonate) ||
				   invoiceItemType.Equals(InvoiceItem.Types.GuestlistCredit) ||
				   invoiceItemType.Equals(InvoiceItem.Types.BannerTop) ||
				   invoiceItemType.Equals(InvoiceItem.Types.BannerHotbox) ||
				   invoiceItemType.Equals(InvoiceItem.Types.BannerPhoto) ||
				   invoiceItemType.Equals(InvoiceItem.Types.BannerEmail) ||
				   invoiceItemType.Equals(InvoiceItem.Types.OtherWebAdvertising) ||
				   invoiceItemType.Equals(InvoiceItem.Types.NonWebAdvertising) ||
				   invoiceItemType.Equals(InvoiceItem.Types.BannerSkyscraper) ||
				   invoiceItemType.Equals(InvoiceItem.Types.Eflyer) ||
				   invoiceItemType.Equals(InvoiceItem.Types.CampaignCredits);

		}
示例#21
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()));
 }
示例#22
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 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()));
		}
示例#23
0
        protected void CreditItemsGridView_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName.ToUpper().Equals("ADD"))
            {
				Page.Validate("CreditItemNew");
				if (Page.IsValid)
				{
					try
					{
						// add new row from footer to db
						InvoiceItem newCreditItem = new InvoiceItem();

						GridViewRow row = CreditItemsGridView.FooterRow;

						newCreditItem.Description = ((TextBox)row.FindControl("NewDescriptionTextBox")).Text.Trim();
						newCreditItem.RevenueStartDate = ((Spotted.CustomControls.Cal)row.FindControl("NewRevenueStartDateCal")).Date;
						newCreditItem.RevenueEndDate = ((Spotted.CustomControls.Cal)row.FindControl("NewRevenueEndDateCal")).Date;
						if (((TextBox)row.FindControl("NewTotalTextBox")).Text.Length > 0)
							newCreditItem.SetTotal(Math.Abs(Utilities.ConvertMoneyStringToDecimal(((TextBox)row.FindControl("NewTotalTextBox")).Text)));
						else
							newCreditItem.PriceBeforeDiscount = Math.Abs(Utilities.ConvertMoneyStringToDecimal(((TextBox)row.FindControl("NewPriceTextBox")).Text));

						newCreditItem.VatCode = (InvoiceItem.VATCodes)Convert.ToInt32(((DropDownList)row.FindControl("NewVatCodeDropDownList")).SelectedValue);
						newCreditItem.Type = (InvoiceItem.Types)Convert.ToInt32(((DropDownList)row.FindControl("NewTypeDropDownList")).SelectedValue);

						CreditItemDataHolderList.Add(new InvoiceItemDataHolder(newCreditItem));

						ViewState["CreditItemDataHolderList"] = CreditItemDataHolderList;
					}
					catch (Exception)
					{ }
					finally
					{
						CalculateCreditItemVatAndTotals();
					}
				}
            }
        }
示例#24
0
		/// <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;
		}
示例#25
0
		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);
		}
示例#26
0
		/// <summary>
		/// Processes the IBuyable Bob. For guestlist credits, it verifies that the guestlist credit IsReadyForProcessing. If yes, then add credits to the promoter account, sets guestlist credit as done, and updates the promoter and the guestlist credit.
		/// </summary>
		/// <param name="invoiceItemType">InvoiceItem.Type</param>
		/// <param name="price">InvoiceItem.Price</param>
		/// <returns></returns>
		public bool Process(InvoiceItem.Types invoiceItemType, decimal price, decimal total)
		{
			if (IsReadyForProcessing(invoiceItemType, price, total))
			{
				this.Done = true;
				this.DateTimeDone = DateTime.Now;
				this.Promoter.GuestlistCredit += this.Credits;
				this.Update();
				this.Promoter.Update();
			}
			
			return IsProcessed(invoiceItemType);
		}
示例#27
0
		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()));
		}
示例#28
0
		/// <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);
		}
示例#29
0
		private static decimal[] SpreadRevenueOverMonths(InvoiceItem invoiceItem)
		{
			invoiceItem.RevenueEndDate = invoiceItem.RevenueEndDate < invoiceItem.RevenueStartDate ? invoiceItem.RevenueStartDate : invoiceItem.RevenueEndDate;

			// Set both DateTimes to the start of their respective days. This allows for easier calculations.
			invoiceItem.RevenueStartDate = new DateTime(invoiceItem.RevenueStartDate.Year, invoiceItem.RevenueStartDate.Month, invoiceItem.RevenueStartDate.Day);
			invoiceItem.RevenueEndDate = new DateTime(invoiceItem.RevenueEndDate.Year, invoiceItem.RevenueEndDate.Month, invoiceItem.RevenueEndDate.Day);

			int nbrOfMonths = (invoiceItem.RevenueEndDate.Year * 12 + invoiceItem.RevenueEndDate.Month) - (invoiceItem.RevenueStartDate.Year * 12 + invoiceItem.RevenueStartDate.Month) + 1;

			decimal[] priceSpreadOverMonths = new decimal[nbrOfMonths];//remember this array starts from the start date...
			// Have to add 1 day, cause EndDate also counts as 1 day
			TimeSpan spanOfDays = invoiceItem.RevenueEndDate.AddDays(1) - invoiceItem.RevenueStartDate;

			int startDayInMonth = invoiceItem.RevenueStartDate.Day;
			DateTime endOfMonth = new DateTime(invoiceItem.RevenueStartDate.Year, invoiceItem.RevenueStartDate.Month, 1).AddMonths(1).AddMilliseconds(-1);

			int counter = 0;
			bool isFinalMonth = false;
			//DateTime revEndDatePlusOneMonth = invoiceItem.RevenueEndDate.AddMonths(1);
			while (endOfMonth <= invoiceItem.RevenueEndDate.AddDays(1).AddMonths(1).AddDays(-1))
			{
				if (endOfMonth > invoiceItem.RevenueEndDate)
				{
					endOfMonth = invoiceItem.RevenueEndDate;
					isFinalMonth = true;
				}

				// Have to add 1 day, cause StartDate also counts as 1 day
				priceSpreadOverMonths[counter] = Math.Round((endOfMonth.Day - startDayInMonth + 1) * invoiceItem.Price / spanOfDays.Days, 2);

				if (isFinalMonth)
					break;

				// Get next end of month
				endOfMonth = endOfMonth.AddDays(1).AddMonths(1).AddDays(-1);
				startDayInMonth = 1;
				counter++;
			}

			decimal sum = 0;
			foreach (decimal d in priceSpreadOverMonths)
			{
				sum += d;
			}

			// If there are any pennies left over from rounding, then adjust the first month accordingly.
			priceSpreadOverMonths[0] += Math.Round(invoiceItem.Price - sum, 2);

			return priceSpreadOverMonths;
		}
示例#30
0
		public bool IsReadyForProcessing(InvoiceItem.Types invoiceItemType, decimal price, decimal total)
		{
            return !this.Enabled && this.BuyableObjectType == Model.Entities.ObjectType.Invoice && this.BuyableObjectK == 0 && VerifyPrice(invoiceItemType, price, total);
		}