public static string Create(InvoiceEntity invoiceEntity, WeeklyInvoiceDetails weeklyInvoiceDetails, CompanyInformationEntity companyInformationEntity, DateTime now, string invoiceFolder)
        {
            var generator = new Generator();
            var filename = generator.CreateWeeklyInvoice(invoiceEntity, weeklyInvoiceDetails, weeklyInvoiceDetails.Client, companyInformationEntity, now,invoiceFolder);

            return filename;
        }
        /// <summary>
        /// Returns the file name of the newly creasted invoice
        /// </summary>
        /// <param name="invoiceEntity"></param>
        /// <param name="wid"></param>
        /// <param name="client"></param>
        /// <param name="companyInformationEntity"></param>
        /// <param name="now"></param>
        /// <returns></returns>
        public string CreateWeeklyInvoice(InvoiceEntity invoiceEntity, WeeklyInvoiceDetails wid, ClientEntity client, CompanyInformationEntity companyInformationEntity, DateTime now,string invoiceFolder)
        {
            DirectoryCreator.EnsureExistance(invoiceFolder);

            var pdfDoc = new Document(PageSize.A4, 50, 50, 25, 25);

            var pdfFileName = FileNameProvider.GetAvailableFileName(invoiceFolder + "\\Invoice-", InvoiceNameGenerator.GetName(wid.Number, now), ".pdf");

            var output = new FileStream(pdfFileName, FileMode.OpenOrCreate);

            PdfWriter.GetInstance(pdfDoc, output);

            pdfDoc.Open();

            HeaderFactory.Create(pdfDoc, wid.Number, invoiceEntity, companyInformationEntity, now);

            ClientInfoFactory.Create(pdfDoc, CompositeAddressCreator.CreateAddress(client.CompanyInformationEntity), wid.CommentsOrSpecialInstructions);

            CostSummaryFactory.CreateWeekly(pdfDoc, wid, invoiceEntity,now);

            FooterFactory.Create(pdfDoc, invoiceEntity);

            pdfDoc.Close();

            return pdfFileName;
        }
 public static void Create(IElementListener document, int invoiceNumber, InvoiceEntity invoiceEntity, CompanyInformationEntity companyInformationEntity, DateTime now)
 {
     var table = new PdfPTable(2) { WidthPercentage = 100 };
     table.AddCell(GetCompanyNameAndSlogan(invoiceEntity, companyInformationEntity));
     table.AddCell(GetInvoiceTitle());
     table.AddCell(GetCompanyAddress(invoiceEntity, companyInformationEntity));
     table.AddCell(GetInvoiceDetails(invoiceNumber,now));
     document.Add(table);
 }
 public static PdfPCell GetCompanyAddress(InvoiceEntity invoiceEntity, CompanyInformationEntity companyInformationEntity)
 {
     var s = new StringBuilder();
     s.AppendLine(string.Format("{0}, {1}", companyInformationEntity.AddressLine1, companyInformationEntity.PostalTown));
     s.AppendLine(string.Format("{0}, {1}", companyInformationEntity.PostCode, companyInformationEntity.Country));
     s.AppendLine(companyInformationEntity.WebsiteUrl);
     s.AppendLine(string.Format("{0} | {1}", companyInformationEntity.CellPhone, companyInformationEntity.OfficePhone));
     return new PdfPCell(ElementFactory.GetParagraph(s.ToString(), ElementFactory.Fonts.Compact))
     {
         VerticalAlignment = Element.ALIGN_BOTTOM,
         BorderColor = BaseColor.WHITE
     };
 }
 public static PdfPCell GetCompanyNameAndSlogan(InvoiceEntity invoiceEntity, CompanyInformationEntity companyInformationEntity)
 {
     var p = new Paragraph { Alignment = Element.ALIGN_TOP };
     p.Add(ElementFactory.GetParagraph(companyInformationEntity.Name, ElementFactory.Fonts.Large));
     p.Add(ElementFactory.GetParagraph(companyInformationEntity.Slogan, ElementFactory.Fonts.Standard));
     var c = new PdfPCell(p)
         {
             VerticalAlignment = Element.ALIGN_TOP,
             FixedHeight = 50f,
             PaddingTop = 0,
             BorderColor = BaseColor.WHITE
         };
     return c;
 }
        public static void CreateWeekly(Document document, WeeklyInvoiceDetails wid, InvoiceEntity invoiceEntity, DateTime now)
        {
            var table = new PdfPTable(4) { WidthPercentage = 100 };
            var colWidthPercentages = new[] { 1f, 3f, 1f, 1f };
            table.SetWidths(colWidthPercentages);

            var subTotal = wid.ChargeableHours * wid.HourlyRate;

            AddHeader(table);
            AddWeekWorkCost(table, wid, invoiceEntity,now);
            AddSummary(table, subTotal, subTotal * 0.2);

            document.Add(table);
        }
        public static void CreateCustom(Document document, SimpleInvoiceDetails simpleInvoiceDetails, InvoiceEntity invoiceEntity)
        {
            var table = new PdfPTable(4) { WidthPercentage = 100 };
            var colWidthPercentages = new[] { 1f, 3f, 1f, 1f };
            table.SetWidths(colWidthPercentages);

            var subTotal = simpleInvoiceDetails.Quantity * simpleInvoiceDetails.UnitPrice;

            AddHeader(table);
            AddCustomCost(table, simpleInvoiceDetails, subTotal);
            AddSummary(table, subTotal, subTotal * 0.2);

            document.Add(table);
        }
        private static void AddPaymentDetails(Document document, InvoiceEntity invoiceEntity)
        {
            var table = new PdfPTable(3) { WidthPercentage = 45 };
            var colWidthPercentages = new[] { 4f, 1f, 5f };
            table.SetWidths(colWidthPercentages);

            table.AddCell(ElementFactory.CreateCell("Name of Account", Element.ALIGN_LEFT, -1, BaseColor.WHITE, 1, ElementFactory.Fonts.Footer));
            table.AddCell(ElementFactory.CreateCell(":", Element.ALIGN_CENTER, -1, BaseColor.WHITE, 1, ElementFactory.Fonts.Footer));
            table.AddCell(ElementFactory.CreateCell(invoiceEntity.AccountDetails.Name, Element.ALIGN_LEFT, -1, BaseColor.WHITE, 1, ElementFactory.Fonts.Footer));
            table.AddCell(ElementFactory.CreateCell("Account Number:", Element.ALIGN_LEFT, -1, BaseColor.WHITE, 1, ElementFactory.Fonts.Footer));
            table.AddCell(ElementFactory.CreateCell(":", Element.ALIGN_CENTER, -1, BaseColor.WHITE, 1, ElementFactory.Fonts.Footer));
            table.AddCell(ElementFactory.CreateCell(invoiceEntity.AccountDetails.Number, Element.ALIGN_LEFT, -1, BaseColor.WHITE, 1, ElementFactory.Fonts.Footer));
            table.AddCell(ElementFactory.CreateCell("Sort Code", Element.ALIGN_LEFT, -1, BaseColor.WHITE, 1, ElementFactory.Fonts.Footer));
            table.AddCell(ElementFactory.CreateCell(":", Element.ALIGN_CENTER, -1, BaseColor.WHITE, 1, ElementFactory.Fonts.Footer));
            table.AddCell(ElementFactory.CreateCell(invoiceEntity.AccountDetails.SortCode, Element.ALIGN_LEFT, -1, BaseColor.WHITE, 1, ElementFactory.Fonts.Footer));
            document.Add(table);
        }
 public static void Create(Document document, InvoiceEntity invoiceEntity)
 {
     document.Add(ElementFactory.GetParagraph("\n\n\n\n\n" + invoiceEntity.FooterText + "\n\n\n", ElementFactory.Fonts.Footer, Element.ALIGN_JUSTIFIED));
     AddPaymentDetails(document, invoiceEntity);
 }
        private static void AddWeekWorkCost(PdfPTable table, WeeklyInvoiceDetails wid, InvoiceEntity invoiceEntity, DateTime now)
        {
            table.AddCell(ElementFactory.CreateCell(wid.ChargeableHours.ToString(CultureInfo.InvariantCulture)));

            table.AddCell(ElementFactory.CreateCell(
                string.Format("{0} ({1} - {2})",
                invoiceEntity.ChargeableJob.Description,
                now.ToStartOfBusinessWeek().ToString("dd MMM yyyy"),
                now.ToEndOfBusinessWeek().ToString("dd MMM yyyy")), Element.ALIGN_LEFT, 200));

            table.AddCell(ElementFactory.CreateCell(string.Format("{0}", wid.HourlyRate)));

            table.AddCell(ElementFactory.CreateCell((wid.HourlyRate * wid.ChargeableHours).ToString(CurrencyString), Element.ALIGN_RIGHT));
        }