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 string CreateAddress(CompanyInformationEntity companyInformationEntity)
 {
     return string.Format("{0}{1}{2}{3}{4}{5}",
                          StringOrEmpty(companyInformationEntity.Name),
                          StringOrEmpty(companyInformationEntity.AddressLine1),
                          StringOrEmpty(companyInformationEntity.AddressLine2),
                          StringOrEmpty(companyInformationEntity.Locality),
                          StringOrEmpty(companyInformationEntity.PostalTown),
                          StringOrEmpty(companyInformationEntity.PostCode));
 }
 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;
 }