This is a migrated thread and some comments may be shown as answers.

Vat Summary grouped by percentage (in group footer)

1 Answer 149 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Denis
Top achievements
Rank 1
Denis asked on 28 Nov 2018, 10:47 AM
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); 

1 Answer, 1 is accepted

Sort by
0
Todor
Telerik team
answered on 03 Dec 2018, 08:34 AM
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
Tags
General Discussions
Asked by
Denis
Top achievements
Rank 1
Answers by
Todor
Telerik team
Share this question
or