Пример #1
0
		private static void AddRefundToEmail(Mailer mailer, Transfer transfer)
		{
			if ((transfer.Status.Equals(Transfer.StatusEnum.Pending) || transfer.Status.Equals(Transfer.StatusEnum.Success)) && transfer.Type.Equals(Transfer.TransferTypes.Refund))
			{
				mailer.Attachments.Add(new System.Net.Mail.Attachment(Utilities.GenerateReportMemoryStream(false, transfer), "DontStayIn " + transfer.TypeToString + " #" + transfer.K.ToString() + ".doc", "application/word"));

				if (transfer.Promoter != null)
                    mailer.Body += @"<p><a href=""[LOGIN(" + transfer.UrlReport() + "\")]>" + transfer.TypeToString + " for " + Utilities.MoneyToHTML(Math.Abs(transfer.Amount)) + "</a> has been ";
				else
                    mailer.Body += "<p>" + transfer.TypeToString + " for " + Utilities.MoneyToHTML(Math.Abs(transfer.Amount)) + " has been ";

				if (transfer.Status.Equals(Transfer.StatusEnum.Pending))
					mailer.Body += "setup";
				else if (transfer.Status.Equals(Transfer.StatusEnum.Success))
					mailer.Body += "successfully processed";

				if (transfer.Promoter != null)
				{
					mailer.Body += " on your " + transfer.Promoter.LinkEmail() + " promoter account.</p>";
				}
				else
				{
					mailer.Body += ".</p>";
				}

				if (transfer.TransferRefundedK != 0)
				{
					Transfer transferRefunded = new Transfer(transfer.TransferRefundedK);
					mailer.Attachments.Add(new System.Net.Mail.Attachment(Utilities.GenerateReportMemoryStream(false, transferRefunded), "DontStayIn " + transferRefunded.TypeToString + " #" + transferRefunded.K.ToString() + ".doc", "application/word"));
					if (transfer.Promoter != null)
						mailer.Body += @"<ul type=""circle""><li><a href=""[LOGIN(" + transferRefunded.UrlReport() + "\")]>Refunding transfer #" + transferRefunded.K.ToString() + "</a></li></ul>";
					else
						mailer.Body += @"<ul type=""circle""><li>Refunding " + transferRefunded.TypeToString.ToLower() + " #" + transferRefunded.K.ToString() + "</li></ul>";
				}
				AddAppliedInvoices(mailer, transfer);
			}
		}
Пример #2
0
		private static void AddSuccessfulPaymentToEmail(Mailer mailer, Transfer transfer)
		{
			if (transfer.Status.Equals(Transfer.StatusEnum.Success) && transfer.Type.Equals(Transfer.TransferTypes.Payment))
			{
				mailer.Attachments.Add(new System.Net.Mail.Attachment(Utilities.GenerateReportMemoryStream(false, transfer), "DontStayIn " + transfer.TypeToString + " #" + transfer.K.ToString() + ".doc", "application/word"));
				if (transfer.Promoter != null)
				{
                    mailer.Body += @"<p><a href=""[LOGIN(" + transfer.UrlReport() + "\")]>Successful " + transfer.TypeToString.ToLower() + " for " + Utilities.MoneyToHTML(Math.Abs(transfer.Amount))
								+ "</a> has been processed on your " + transfer.Promoter.LinkEmail() + " promoter account.</p>";
				}
				else if (transfer.Usr != null)
				{
                    mailer.Body += "<p>Successful " + transfer.TypeToString.ToLower() + " for " + Utilities.MoneyToHTML(Math.Abs(transfer.Amount)) + " has been processed on your " + transfer.Usr.LinkEmail() + " user account.</p>";
				}
				AddAppliedInvoices(mailer, transfer);
			}
		}
Пример #3
0
			public PromoterAccountItem(Transfer transfer)
			{
				this.K = transfer.K;
                this.Outstanding = transfer.AmountRemaining().ToString("c");
				if (transfer.Type.Equals(Transfer.TransferTypes.Payment))
				{
					this.OriginalType = Type.Payment;
                    if (transfer.Method == Transfer.Methods.TicketSales)
                        this.OriginalType = Type.TicketSales;
				}
				else
				{
					this.OriginalType = Type.Refund;
                    if (transfer.TransferRefunded != null && transfer.TransferRefunded.Method == Transfer.Methods.TicketSales)
                        this.OriginalType = Type.TicketSalesRelease;
                    // We dont show outstanding money for refunds that having been successfully processed
                    if(transfer.Status == Transfer.StatusEnum.Success)
                        this.Outstanding = (0).ToString("c");
				}				
                
                this.Date = transfer.DateTimeComplete > DateTime.MinValue ? transfer.DateTimeComplete : transfer.DateTimeCreated;
				this.Total = Math.Abs(transfer.Amount).ToString("c");
				this.Status = transfer.Status.ToString();
				this.ViewLink = Utilities.LinkNewWindow(transfer.UrlReport(), "View");
                if(this.OriginalType == Type.TicketSales && transfer.TicketPromoterEvent != null)
                    this.ViewLink = Utilities.LinkNewWindow(transfer.TicketPromoterEvent.UrlReport(), "View");
				this.EditLink = "<small>" + Utilities.LinkNewWindow(transfer.UrlAdmin(), "[Edit]") + "</small>";
			}
Пример #4
0
		private static void AddPendingPaymentToEmail(Mailer mailer, Transfer transfer)
		{
			if (transfer.Status.Equals(Transfer.StatusEnum.Pending) && transfer.Type.Equals(Transfer.TransferTypes.Payment))
			{
				mailer.Attachments.Add(new System.Net.Mail.Attachment(Utilities.GenerateReportMemoryStream(false, transfer), "DontStayIn " + transfer.TypeToString + " #" + transfer.K.ToString() + ".doc", "application/word"));
				if (transfer.Promoter != null)
				{
					mailer.Body += @"<p><a href=""[LOGIN(" + transfer.UrlReport() + "\")]>" + transfer.Status.ToString() + " " + transfer.TypeToString.ToLower() + "</a> for "
                                + Utilities.MoneyToHTML(Math.Abs(transfer.Amount)) + " has been setup on your " + transfer.Promoter.LinkEmail() + " promoter account.</p>";

					if (transfer.Method.Equals(Transfer.Methods.Cheque))
						mailer.Body += "<p>Please make your cheque payable to:<br>Development Hell Limited<br>Greenhill House, Thorpe Road, Peterborough, PE3 6RU</p><p>Add reference #" + transfer.K.ToString() + " to the back of the cheque</p>";
					else if (transfer.Method.Equals(Transfer.Methods.BankTransfer))
						mailer.Body += "<p>Please make BACS transfer details:<br>Bank name: Barclays Bank PLC<br>Branch Name: Commercial Bank Basingstoke<br>Sort Code: 20-37-63<br>Account #: 00478377<br>(IBAN for international transfers: GB04 BARC 2037 6300 4783 77)</p><p>Add BACS reference #" + transfer.K.ToString() + "</p>";
					else
						mailer.Body += "<p>Please make payment to:<br>Development Hell Limited<br>Greenhill House, Thorpe Road, Peterborough, PE3 6RU</p>";
				}
				AddAppliedInvoices(mailer, transfer);
			}
		}
Пример #5
0
		public StringBuilder GenerateReportStringBuilder(bool linksEnabled)
		{
			DateTime taxDate = DateTime.Now;
			if (this.TaxDateTime != null && this.TaxDateTime > DateTime.MinValue)
				taxDate = this.TaxDateTime;


			StringBuilder sb = new StringBuilder();
			decimal amountPaid = 0;

			sb.Append(@"<form id='form1' runat='server'><div style='font-family:Verdana;'><table width='100%' border='0' cellspacing='0' cellpadding='0' height='100%'><tr><td valign='top'>
						<table width='100%'>");

			sb.Append(Utilities.GenerateHTMLHeaderRowString(this.Type.Equals(Invoice.Types.Credit) ? this.TypeToString.ToUpper() + "&nbsp;NOTE" : this.TypeToString.ToUpper()));

			sb.Append(@"<tr>
								<td colspan=1 align='left' valign='top' width='450' style='padding-left:48px;'>");
            if (this.Promoter != null)
            {
                if (this.Promoter.AccountsName.Length > 0)
                {
                    sb.Append(this.Promoter.AccountsName);
                    sb.Append("<br>");
                }
                else if (this.Usr != null && this.Usr.FullName.Length > 0 && this.Usr.IsPromoter && this.Usr.IsPromoterK(this.K))
                {
                    sb.Append(this.Usr.FullName);
                    sb.Append("<br>");
                }
                else if (this.Promoter.PrimaryUsr != null && this.Promoter.PrimaryUsr.FullName.Length > 0)
                {
                    sb.Append(this.Promoter.PrimaryUsr.FullName);
                    sb.Append("<br>");
                }

                if (this.Promoter.Name.Length > 0)
                {
                    sb.Append(this.Promoter.Name);
                    sb.Append("<br>");
                }
                sb.Append(this.Promoter.AddressHtml);
            }
            else if (this.Usr != null)
            {
                if (this.Usr.FullName.Length > 0)
                {
                    sb.Append(this.Usr.FullName);
                    sb.Append("<br>");
                }
                sb.Append(this.Usr.AddressHtml());
            }

			// Addition of Created and renaming of "Date" to "Tax Date", as per Dave's request 7/2/07
			sb.Append(@"</td><td width='350'></td><td valign='top' width='100'>" + this.TypeToString + "&nbsp;No.");
			if (this.PurchaseOrderNumber.Length > 0)
				sb.Append("<br><br>Purchase&nbsp;Order&nbsp;No.");
			sb.Append("<br><br>Acc&nbsp;No.<br><br>Created<br><br>Tax&nbsp;Date");
			if (this.Type.Equals(Invoice.Types.Invoice))
				sb.Append("<br><br>Due Date");
			sb.Append(@"</td><td align='right' valign='top' width='125'>");

			if (this.Type.Equals(Invoice.Types.Invoice))
				sb.Append("INV");
			else
				sb.Append("CRD");

			sb.Append(this.K.ToString());
			if (this.PurchaseOrderNumber.Length > 0)
				sb.Append("<br><br><nobr>" + this.PurchaseOrderNumber.Replace("-", "&#8209;"));
			sb.Append("</nobr><br><br>");
			if (this.Promoter != null)
				sb.Append(this.PromoterK.ToString());
			else if (this.Usr != null)
				sb.Append(this.UsrK.ToString());
			else
				sb.Append("&nbsp;");

			// Addition of Created, as per Dave's request 7/2/07
			sb.Append("<br><br>");
			sb.Append(this.CreatedDateTime.ToString("dd/MM/yy"));

			sb.Append("<br><br>");

			// Replacing CreatedDateTime with TaxDateTime, as per Gee's request for OASIS v1.5
			//sb.Append(this.CreatedDateTime.ToString("dd/MM/yy"));
			sb.Append(this.TaxDateTime.ToString("dd/MM/yy"));

			if (this.Type.Equals(Invoice.Types.Invoice))
			{
				sb.Append("<br><br>");
				sb.Append(this.DueDateTime.ToString("dd/MM/yy"));
			}
			sb.Append("</td></tr>");

			//if(this.PaidDateTime != null && this.PaidDateTime > DateTime.MinValue)
			//{
			//    sb.Append(@"<br><br><b>Date Completed</b><br>" + this.PaidDateTime.ToShortDateString());
			//}

			sb.Append(@"</table><br><br>
						<table width='100%' cellspacing='0' cellpadding='3' class='BorderBlack Top Right Bottom'>
							<tr>
								<td style='vertical-align:bottom;' class='BorderBlack Bottom Left' width='350'><b>Item</b></td>
								<td style='vertical-align:bottom;' class='BorderBlack Bottom Left' width='55' align='left'><b>Tax&nbsp;Code</b></td>
								<td style='vertical-align:bottom;' class='BorderBlack Bottom Left' width='90' align='left'><b>Price</b></td>
								<td style='vertical-align:bottom;' class='BorderBlack Bottom Left' width='85' align='left'><b>VAT</b></td>
								<td style='vertical-align:bottom;' class='BorderBlack Bottom Left' width='90' align='left'><b>Total</b></td>
							</tr>");

			Query InvoiceItemQuery = new Query(new Q(InvoiceItem.Columns.InvoiceK, this.K));
			InvoiceItemSet invoiceItemSet = new InvoiceItemSet(InvoiceItemQuery);

			List<InvoiceItem.VATCodes> invoiceItemVatCodes = new List<InvoiceItem.VATCodes>();

			foreach (InvoiceItem invoiceItem in invoiceItemSet)
			{
				if (!invoiceItemVatCodes.Contains(invoiceItem.VatCode))
					invoiceItemVatCodes.Add(invoiceItem.VatCode);

				sb.Append(@"<tr>
								<td class='BorderBlack Left'>" + invoiceItem.Description +
								(invoiceItem.Discount > 0 ? " <small>@ " + invoiceItem.Discount.ToString("P2") + " discount</small>" : "") +
								@"</td>");

				if (!this.VatCode.Equals(Invoice.VATCodes.T1))
				{
					sb.Append(@"<td class='BorderBlack Left' width='55' align='left'>" + this.VatCode.ToString() + @"</td>");
				}
				else
				{
					sb.Append(@"<td class='BorderBlack Left' width='55' align='left'>" + invoiceItem.VatCode.ToString() + @"</td>");
				}

				sb.Append(@"<td class='BorderBlack Left' width='90' align='right'>" + Utilities.MoneyToHTML(invoiceItem.Price) + @"</td>
							<td class='BorderBlack Left' width='85' align='right'>" + Utilities.MoneyToHTML(invoiceItem.Vat) + @"</td>
							<td class='BorderBlack Left' width='90' align='right'>" + Utilities.MoneyToHTML(invoiceItem.Total) + @"</td>
						</tr>");
			}

			sb.Append(@"<tr>
							<td class='BorderBlack Top Left' colspan='2' align='right'><b>TOTAL:</b></td>
							<td class='BorderBlack Top Left' width='90' align='right'><b>" + Utilities.MoneyToHTML(this.Price) + @"</b></td>
							<td class='BorderBlack Top Left' width='85' align='right'><b>" + Utilities.MoneyToHTML(this.Vat) + @"</b></td>
							<td class='BorderBlack Top Left' width='90' align='right'><b>" + Utilities.MoneyToHTML(this.Total) + @"</b></td>
						</tr></table>");

			InvoiceItem.VATCodes[] invoiceItemVatCodeArray = invoiceItemVatCodes.ToArray();
			Array.Sort(invoiceItemVatCodeArray);

			sb.Append("<small><i><b>VAT Rate:</b> ");
			if (this.VatCode.Equals(Invoice.VATCodes.T1) && invoiceItemVatCodeArray.Length > 0)
			{
				foreach (InvoiceItem.VATCodes vatCode in invoiceItemVatCodeArray)
				{
					sb.Append(vatCode.ToString());
					sb.Append("=");
					sb.Append(InvoiceItem.VATRate(vatCode, taxDate).ToString("0.0%"));
					sb.Append("&nbsp;&nbsp;");
				}
			}
			else
			{
				sb.Append(this.VatCode.ToString());
				sb.Append("=");
				sb.Append(Invoice.VATRate(this.VatCode, taxDate).ToString("0.0%"));
			}
			sb.Append("</i></small><br>");

			sb.Append("<br>");

			Query InvoiceTransferQuery = new Query(new And(new Q(InvoiceTransfer.Columns.InvoiceK, this.K),
														   new Or(new Q(Transfer.Columns.Status, Transfer.StatusEnum.Pending),
																  new Q(Transfer.Columns.Status, Transfer.StatusEnum.Success),
																  new Q(Transfer.Columns.Status, Transfer.StatusEnum.Cancelled))));
			InvoiceTransferQuery.TableElement = new Join(InvoiceTransfer.Columns.TransferK, Transfer.Columns.K);
			InvoiceTransferSet invoiceTransferSet = new InvoiceTransferSet(InvoiceTransferQuery);

			bool nonSuccessfulTransfer = false;

			if (invoiceTransferSet.Count > 0)
			{
				sb.Append(@"<br><table width='100%' cellspacing='0' cellpadding='3' class='BorderBlack Top Right Bottom'>
							<tr>
								<td style='vertical-align:bottom;' class='BorderBlack Bottom Left' width='205'><b>Transfer</b></td>
								<td style='vertical-align:bottom;' class='BorderBlack Bottom Left' width='65' align='left'><b>Date</b></td>
								<td style='vertical-align:bottom;' class='BorderBlack Bottom Left' width='75' align='left'><b>Method</b></td>
								<td style='vertical-align:bottom;' class='BorderBlack Bottom Left' width='150' align='left'><b>Method Ref#</b></td>
								<td style='vertical-align:bottom;' class='BorderBlack Bottom Left' width='90' align='left'><b>Status</b></td>
								<td style='vertical-align:bottom;' class='BorderBlack Bottom Left' width='85' align='left'><b>Amount</b></td>
							</tr>");

				foreach (InvoiceTransfer invoiceTransfer in invoiceTransferSet)
				{
					Transfer transfer = new Transfer(invoiceTransfer.TransferK);

					sb.Append(@"<tr>
								<td class='BorderBlack Left'>");
					if (linksEnabled)
						sb.Append(Utilities.Link(transfer.UrlReport(), transfer.Type.ToString() + " #" + transfer.K.ToString()));
					else
						sb.Append(transfer.Type.ToString() + " #" + transfer.K.ToString());

					sb.Append(@"</td>
								<td class='BorderBlack Left' width='65' align='left'>" + transfer.DateTimeCreated.ToString("dd/MM/yy") + @"</td>
								<td class='BorderBlack Left' width='75' align='left'><nobr>" + Utilities.CamelCaseToString(transfer.Method.ToString()) + @"</nobr></td>
								<td class='BorderBlack Left' width='150' align='left'>");

					sb.Append(transfer.ReferenceNumberToHtml());

					sb.Append(@"</td>
								<td class='BorderBlack Left' width='90' align='left'>" + transfer.Status.ToString() + @"</td>
								<td class='BorderBlack Left' width='85' align='right'>" + Utilities.MoneyToHTML(invoiceTransfer.Amount) + @"</td>
							</tr>");

					if (!transfer.Status.Equals(Transfer.StatusEnum.Success))
						nonSuccessfulTransfer = true;
					else
						amountPaid += invoiceTransfer.Amount;
				}

				sb.Append(@"</table>");

				// For now, this note only pertains to Invoices
				if (this.Type.Equals(Invoice.Types.Invoice) && nonSuccessfulTransfer == true)
					sb.Append(@"<small><i>(<b>Note:</b> Only successful transfers will be applied to the payment total. Pending and cancelled transfers will not be applied)</i></small><br>");

				sb.Append("<br>");
			}

			Query InvoiceCreditQuery = new Query();

			if (this.Type.Equals(Invoice.Types.Invoice))
			{
				InvoiceCreditQuery = new Query(new Q(InvoiceCredit.Columns.InvoiceK, this.K));
			}
			else
			{
				InvoiceCreditQuery = new Query(new Q(InvoiceCredit.Columns.CreditInvoiceK, this.K));
			}

			InvoiceCreditSet invoiceCreditSet = new InvoiceCreditSet(InvoiceCreditQuery);

			if (invoiceCreditSet.Count > 0)
			{
				string invoiceHeader = "Invoice";
				Invoice invoice = new Invoice();

				if (this.Type.Equals(Invoice.Types.Invoice))
					invoiceHeader = "Credit";

				sb.Append(@"<br><table width='100%' cellspacing='0' cellpadding='3' class='BorderBlack Top Bottom Right'>
						<tr>
							<td style='vertical-align:bottom;' class='BorderBlack Bottom Left' width='335'><b>" + invoiceHeader + @"</b></td>
							<td style='vertical-align:bottom;' class='BorderBlack Bottom Left' width='70' align='left'><b>Date</b></td>
							<td style='vertical-align:bottom;' class='BorderBlack Bottom Left' width='90' align='left'><b>Price</b></td>
							<td style='vertical-align:bottom;' class='BorderBlack Bottom Left' width='85' align='left'><b>VAT</b></td>
							<td style='vertical-align:bottom;' class='BorderBlack Bottom Left' width='90' align='left'><b>Total</b></td>
						</tr>");

				foreach (InvoiceCredit invoiceCredit in invoiceCreditSet)
				{
					if (this.Type.Equals(Invoice.Types.Invoice))
					{
						// Credit amounts are negative
						amountPaid -= invoiceCredit.Amount;

						invoice = new Invoice(invoiceCredit.CreditInvoiceK);
					}
					else
						invoice = new Invoice(invoiceCredit.InvoiceK);

					sb.Append(@"<tr>
							<td class='BorderBlack Left'>");
					if (linksEnabled)
						sb.Append(Utilities.Link(invoice.UrlReport(), invoiceHeader + " #" + invoice.K.ToString()));
					else
						sb.Append(invoiceHeader + " #" + invoice.K.ToString());

					// Replacing CreatedDateTime with TaxDateTime, as per Gee's request for OASIS v1.5
					sb.Append(@"</td>
							<td class='BorderBlack Left' width='70' align='left'>" + invoice.TaxDateTime.ToString("dd/MM/yy") + @"</td>
							<td class='BorderBlack Left' width='90' align='right'>" + Utilities.MoneyToHTML(invoice.Price) + @"</td>
							<td class='BorderBlack Left' width='85' align='right'>" + Utilities.MoneyToHTML(invoice.Vat) + @"</td>
							<td class='BorderBlack Left' width='90' align='right'>" + Utilities.MoneyToHTML(invoice.Total) + @"</td>
						</tr>");
				}
				sb.Append(@"</table><br><br>");
			}

			if (this.Type.Equals(Invoice.Types.Invoice))
			{
				// Invoice Summary
				sb.Append(@"<br><table width='250'>
							<tr>
								<td colspan=2><b>Summary</b></td>
							</tr>
							<tr>
								<td width='135'>Invoice&nbsp;Total:</td>
								<td width='115' align='right'>" + Utilities.MoneyToHTML(this.Total) + @"</td>
							</tr>
							<tr>
								<td width='135'>Payment&nbsp;Total:</td>
								<td width='115' align='right'>" + Utilities.MoneyToHTML(amountPaid) + @"</td>
							</tr>
							<tr>
								<td width='135'><b>Outstanding:</b></td>                                
								<td width='115' align='right'><b>" + Utilities.MoneyToHTML(this.Total - amountPaid) + @"</b></td>
							</tr></table><br><br>");
			}

			sb.Append(@"</td></tr>");

			sb.Append(@"
<tr>
	<td valign='bottom' align='center'>
		<div style='width:50%;padding:20px;border:2px solid #000000;text-align:left;'>
			Bank details for payments:<br>
			Development Hell Limited<br>
			Barlcays Bank PLC, Commercial Bank Basingstoke<br>
			Sort Code: 20-37-63<br>
			Account number: 00478377<br>
			For international payments:<br>
			IBAN - GB04BARC20376300478377<br>
			Swift - BARCGB22
		</div>
	</td>
</tr>");

			// DSI Registration Footer
			sb.Append(Utilities.GenerateHTMLFooterRowString());

			sb.Append(@"</table></div></form>");

			return sb;
		}