Report Generation

WorkWithPlus provides the possibility of working with PDF reports with the same Hierarchical Declaration that you use in Web Panels and Transactions.

The Challenge

The customer needs to print a PDF Invoice with the Sales of the Supermarket. This invoice is going to be used for final users so is important to create a layout with great look&feel.

As you already know, WorkWithPlus automatically generates Excel, CSV and PDF reports within the Selection objects, including the filters and other settings selected in the screen.  

However, for this requirement, the customer need a customized report with a special layout and look&feel, so we’re going to create them using WorkWithPlus templates for report generation. 

So, apply WorkWithPlus to the Sale and Product transactions and register some products and sales for the Supermarket. Create a new procedure called InvoiceReport, apply WorkWithPlus to it and select the InvoiceReportLite template.

After having selected this template, the tree and the preview of the report will be displayed:

TemplatesReportTemplates_img00

As you can visualize, you can work with a PDF report in the same way you work with transactions and web panels by using the real time preview and the hierarchical declaration. In this way, you can change and customize the layout if you need to modify it. 

WorkWithPlus creates the desired layout and you only need to add the necessary code in the Source section of the procedure to load the invoice properly:

&CompanyName = 'The Coca-Cola Company'

&Phone = '+598-2604-1325'
&Mail = 'info@coca.com'
&Website = 'http://www.cocacolacompany.com'

&AddressLine1 = 'Av. Italia 6201'
&AddressLine2 = 'Montevideo, Uruguay'
&AddressLine3 = '11300'
print printTitle

For Each Sale   
    &TaxInvoice = SaleTotalAmount*0.23    
    &BilledTo = PersonFullName
    &BilledToAddressLine1 = 'Av. Italia 2387'
    &BilledToAddressLine2 = 'Montevideo, Uruguay'
    &BilledToAddressLine3 = '12500'    
    &InvoiceNumber = "#"+SaleId.ToFormattedString()
    &Date = SaleDate
    &InvoiceTotal = "$"+SaleTotalAmount.ToFormattedString()    
    print printDetailInfo
    print printLines_titles
    For Each Sale.Products
        &ProductName = ProductName
        &UnitCost = ProductPrice.ToFormattedString()
        &Quantity = SaleProductQuantity
        &LineTotal = SaleProductTotal.ToFormattedString()
        print printLines_data
    EndFor
    &Tax=&TaxInvoice.ToFormattedString()
    &SubTotal = SaleTotalAmount.ToFormattedString()
    &LinesTotal = &InvoiceTotal
    print printTotals
 EndFor

Important: You should also add the Output_file rule and set the Call Protocol of the procedure as HTTP.

Finally, you should add a User Action in the Sales Selection to call this new procedure. For this User Action, we will use the possibility to include a Font Icon as follows:

TemplatesReportTemplates_img11

Comment: you can find more icons in the following site: http://fontawesome.io/examples/

Run the application to visualize the Invoice at runtime:

TemplatesReportTemplates_img10

In the tree you can add printblocks and gridprintblocks:

TemplatesReportTemplates_img05

Inside these you can add some elements to form your report:

TemplatesReportTemplates_img06

You can select many elements in the tree and change different properties to highlight the fields to be displayed in the report.

TemplatesReportTemplates_img09

Summary

Well done! You should now be able to:

  • Create a procedure by using WorkWithPlus
  • Customize the defined procedure