SBD.GL General Ledger: Part 4 Report

Now it is time to add a report
Lets start with a profit and loss, which is always over a period of time.

https://documentation.devexpress.com/eXpressAppFramework/112734/Getting-Started/Comprehensive-Tutorial-MainDemo-Application/Extra-Modules/Create-a-Report-in-Visual-Studio

I followed the steps to create my initial report
Strangely not all the properties of the Transaction class appear in the field list.

I found to make a field visible in the report designer, I had to not use [Browseable(false)]

       // [Browsable(false)]
        [VisibleInDetailView(false)]
        [VisibleInListView(false)]
        [Required]
        public Decimal Amount { get; set; }

After messing around a bit I got

So how to resolve that?
I guess I will try deleting the assignment

   this.collectionDataSource1.ObjectTypeName = "SBD.GL.Module.BusinessObjects.Transaction";

Er and close all the windows

Now I can open the designer again.

I am going to try things a different way

Reading
https://documentation.devexpress.com/eXpressAppFramework/113645/Concepts/Extra-Modules/Reports-V2-Module/Create-Predefined-Static-Reports

I need to alter some code

       public override IEnumerable<ModuleUpdater> GetModuleUpdaters(IObjectSpace objectSpace, Version versionFromDB) {
            ModuleUpdater updater = new DatabaseUpdate.Updater(objectSpace, versionFromDB);

            PredefinedReportsUpdater predefinedReportsUpdater =
                new PredefinedReportsUpdater(Application, objectSpace, versionFromDB);
            predefinedReportsUpdater.AddPredefinedReport<PandLReport>("P and L Report", typeof(PandLReportDto));

            return new ModuleUpdater[] { updater, predefinedReportsUpdater };
        }

Looking at my old question
https://www.devexpress.com/Support/Center/Question/Details/T337192/how-to-add-a-report-based-on-an-object-collection-into-xaf

https://documentation.devexpress.com/XtraReports/18098/Detailed-Guide-to-DevExpress-Reporting/Shape-Report-Data/Filter-Data/Filter-Data-at-the-Data-Source-Level-Runtime-Sample

I set up the parameters I wanted using the report properties , parameters collection

and then I added code to the report to set the data source.

  public partial class PandLReport : DevExpress.XtraReports.UI.XtraReport
    {
        public PandLReport()
        {
            InitializeComponent();
            InitializeParameters();
        }

        private void InitializeParameters()
        {
            if ((DateTime) Parameters[0].Value == DateTime.MinValue)
            {
                var date = DateTime.Today;
                var firstDayOfMonth = new DateTime(date.Year, date.Month, 1);
                Parameters[0].Value = firstDayOfMonth;
            }

            if ((DateTime) Parameters[1].Value == DateTime.MinValue)
            {
                Parameters[1].Value = DateTime.Today;
            }
        }

        protected override void OnParametersRequestSubmit(ParametersRequestEventArgs e)
        {
            BindToData();
            base.OnParametersRequestSubmit(e);
        }

        private void BindToData()
        {
          

            var fromDate = (DateTime) this.Parameters[0].Value;
            var toDate = (DateTime) this.Parameters[1].Value  ;
            var results = PandLReportData.PandL(fromDate, toDate);
            DataSource = results;
        }
    }

Part 5