Example #1
0
        public IDataExportService ExportTaxReport(TaxReport report)
        {
            this.loggingService.WriteLine("Beginning export of tax report...");

            var dialog = new SaveFileDialog
            {
                Filter = this.GenerateFilter(),
                InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),
                FileName = report.Year + "-scrooge-tax-report",
                DefaultExt = ".xlsx",
                CheckPathExists = true
            };

            this.loggingService.WriteLine("Activating SaveFileDialog...");
            var result = dialog.ShowDialog();

            if (result.GetValueOrDefault(false))
            {
                this.loggingService.WriteLine("User confirmed");
                var ext = Path.GetExtension(dialog.FileName)?.Substring(1);
                var serializer = ext == null
                    ? null
                    : (this.serializers.ContainsKey(ext) ? this.serializers[ext] : null);

                if (serializer == null)
                {
                    this.loggingService.WriteLine("No file type specified - uh oh...");
                    MessageBox.Show("You have to specify a file type!", "Error"); // No styling, shouldn't happen anyway
                    return this;
                }

                this.loggingService.WriteLine("Using serializer: " + ext);
                serializer.SerializeTaxReport(report, dialog.FileName);
                this.loggingService.WriteLine("Exporting done.");
            }
            else
            {
                this.loggingService.WriteLine("Exporting aborted.");
            }

            return this;
        }
        public DataCell[][] TaxReportToCellData(TaxReport report)
        {
            var data = new List<DataCell[]>
            {
                new[]
                {
                    new DataCell("Tax report - " + report.Year, DataCellType.HeadingBig),
                    DataCell.Empty
                },
                new[] {DataCell.Empty, DataCell.Empty},
                new[]
                {new DataCell("Sales", DataCellType.Text), new DataCell(report.Sales.ToString(), DataCellType.Number)},
                new[]
                {
                    new DataCell("Net sales", DataCellType.Text),
                    new DataCell(report.NetSales.ToString(), DataCellType.Number)
                },
                new[]
                {
                    new DataCell("Sales tax", DataCellType.Text, DataCellOutline.Top),
                    new DataCell(report.SalesTax.ToString(), DataCellType.Number, DataCellOutline.Top)
                },
                new[]
                {
                    new DataCell("- Input tax", DataCellType.Text),
                    new DataCell(report.InputTax.ToString(), DataCellType.Number)
                },
                new[]
                {
                    new DataCell("Tax payable", DataCellType.Text, DataCellOutline.Top),
                    new DataCell(report.TaxPayable.ToString(), DataCellType.Number, DataCellOutline.Top)
                },
                new[]
                {
                    new DataCell("- Advanced tax payments", DataCellType.Text),
                    new DataCell(report.AdvanceTaxPayements.ToString(), DataCellType.Number)
                },
                new[]
                {
                    new DataCell(report.OutstandingMoney >= 0 ? "Liability" : "Claim", DataCellType.Text,
                        DataCellOutline.Top),
                    new DataCell(
                        report.OutstandingMoney >= 0
                            ? report.OutstandingMoney.ToString()
                            : (-report.OutstandingMoney).ToString(),
                        report.OutstandingMoney >= 0 ? DataCellType.ResultBad : DataCellType.ResultGood,
                        DataCellOutline.Top)
                }
            };

            return data.ToArray();
        }
Example #3
0
 public void SerializeTaxReport(TaxReport report, string filename)
 {
     var cellData = Singleton<DataSerializationHelper>.Instance.TaxReportToCellData(report);
     PDFDataSerializer.WriteToPDF(cellData, filename);
 }