Vat Summary grouped by percentage (in group footer)

2 posts, 0 answers
  1. Mario
    Mario avatar
    7 posts
    Member since:
    May 2017

    Posted 28 Nov 2018 Link to this post

    Hi,
    My Telerik Reporting is R2 2018.
    In the group footer section of my report, I need to have a grouping by VAT rates, with the corresponding totals for both the taxable amount and the corresponding tax (see attached image)

    In myFile.xaml I have:  ItemsSource="{Binding MyDataSource.SummaryVat}

    Text="{Binding MyDataSource.TotTaxable, StringFormat=N2}}"
    Text="{Binding MyDataSource.TotImposta, StringFormat=N2}}"


    and also: ItemsSource="{Binding MyDataSource.SummaryVatFree}
    Text="{Binding MyDataSource.TotTaxableFree, StringFormat=N2}}"
    Text="{Binding MyDataSource.TotVatFree, StringFormat=N2}}"


    In my class MyDataSource I have:
    SummaryVat = new List<MyComplexObject>(from x in listaInfoSales
                                                                        where !x.IsSaleFree
                                                                        group x by x.VatPercentage into g
                                                                        select new MyComplexObject
                                                                        {
                                                                            VatPercentage = g.Key,
                                                                            Tot = g.Sum(x => x.TotValore) / (1 + g.Key / 100)
                                                                        });

                        TotTaxable = SummaryVat.Sum(x => x.Tot);
                        TotImposta = SummaryVat.Sum(x => x.TotVat);

                        SummaryVatFree = new List<MyComplexObject>(from x in listaInfoSales
                                                                               where x.IsSaleFree
                                                                               group x by x.VatPercentage into g
                                                                               select new MyComplexObject
                                                                               {
                                                                                   VatPercentage = g.Key,
                                                                                   Tot = g.Sum(x => x.TotDiscountSales) / (1 + g.Key / 100)
                                                                               });


                        TotTaxableFree = SummaryVatFree.Sum(x => x.Tot);
                        TotVatFree = SummaryVatFree.Sum(x => x.TotVat); 
  2. Todor
    Admin
    Todor avatar
    294 posts

    Posted 03 Dec 2018 Link to this post

    Hello Mario,

    From the code snippets I assume that the Grouping and calculation of the Totals are done with custom code. Telerik Reporting provides this functionality out-of-the-box.

    You may set the raw (i.e. without explicit grouping or totals) listaInfoSales as ObjectDataSource for the report (or other data item). Then you may Add Grouping by the corresponding Field (IsSaleFree for the Taxable and TaxFree items; VatPercentage to group by VAT rates). The Totals can be set with Expressions in the Group Footer section - we provide Aggregate Functions like Sum(), etc. The aggregate function would be executed over the scope of the Group, i.e. for a group of single VAT rate Sum will total over the items with the corresponding VAT rate only.

    You may check our Product Catalog demo report that demonstrates how to use Grouping to structure your report. Our CSharp/VB demo reports can be found in (Telerik Reporting installation folder)\Examples\CSharp(or VB) (e.g. C:\Program Files (x86)\Progress\Telerik Reporting R3 2018\Examples\CSharp). The project is CSharp(or VB).ReportLibrary. The report is ProductCatalog.cs(or .vb) in sub folder ProductCatalog.
    The corresponding Standalone designer report is in  (Telerik Reporting installation folder)\Report Designer\Examples - Product Catalog.trdp.

    Regards,
    Todor
    Progress Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top