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; }
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!"); }
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 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())); }
/// <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())); }
/// <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; }
/// <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); }
/// <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())); }
/// <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())); }
/// <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; }
/// <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); }
/// <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())); }
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); }
/// <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); }
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())); }
/// <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 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())); }
/// <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())); }