Add Action report for Balance Sheet and Profit and Loss

You’re right. It is not a requirement to full fit the exact format else the information it has to contain. Maybe I would have to express it better.

In the UK I think it depends on the type / size of the company, for example: https://www.legislation.gov.uk/uksi/2008/409/schedule/1/made

1 Like

Fixed by who?

I do not see what you are referring to. Such reports have maximum 4 context fields.

I do not see why using the id instead of the record name when it is a Many2One.

This is exactly my proposal with CSV export.

By the definition of the report.

I mean that we have other information on the context that may be irrelevant for the report but we should include on the CSV header if we use a generic way.

Yes, the data is the same but there won’t be any header nor any footer on the CSV export. And I think it is important to have a proper header and footer for oficial document like balance sheet. For example, we may show on the header:

  • The title for the report (Balance Sheet or Income Statement)
  • The company name
  • The title of the columns with the date

And on the footer:

  • The page number (the report may fill up several pages so we must now if it is complete or not.)

Also the CSV export does not allow to customize the style which is important for some companies to produce more fancy reports: For example using diferent styles depending on the depth of the chart.

From what I understand what changes is the detail of the information. We have the same in Spain and we use two diferent charts to create a more detailed type structure. For big companies there are also more accounts required.

Yes, I think that is correct, but the main point was that there are some required formats that you must choose from.

Who made that definition? Where is it?

I do not understand what is your point.

The proposal is specially about adding header (maybe footer) to the CSV.

Where is the official format of such document?

The accountants that created the concept of such report.

Here is an example

Then we will miss the styles and formate.

I do not see how we can generate something like this with CSV:


BTW: I have a sample report template that I can share if somebody is interested. I can only upload images to the discuss topic.

A report template does not work for tree structured data. That’s why those trees do not have.
I see no way to have a proper template on tree structured data except. Indeed what is expected a kind of print screen which is what CSV proposal tend to approach.
Or we need to have a list like representation of those reports.

In Spain by the government.

You can see Balance Sheet at 26th and 101th pages.

You can see Revenue and Loss at 29th page.

Why not? You just need to pass the records in the proper order and then it just works. This is another reason to always export the full tree despite the selected reports. Here is some sample code that I used for the report:

                                                                               
        ids = []                                                               
                                                                               
        def add_childs(record):                                                
            ids.append(record.id)                                              
            for child in record.childs:                                        
                if child.statement != 'balance':                               
                    continue                                                   
                add_childs(child)                                              
                                                                               
        for record in Type.search([                                            
                    ('company', '=', context['company']),                      
                    ('statement', '=', 'balance'),                             
                    ('parent.parent', '=', None),                              
                    ]):                                                        
            add_childs(record)                                                 
        report_context['records'] = Type.browse(ids)  

Then you can do loop the records variable and they will be printed in the parent/children order.

User can select what ever records they want and get weird result (or mistakes).

Then you can not manage the depth of the report.

If that was simple to solve, it was already done.
Printing tree data structure is complicated and not yet supported.

Completly agree. But here I think we are adding to much complexity when there is not so much. Let me explain:

Printing a tree structure (specially with partial nodes) is complex because you need to export the children of the selected records in the right order.

But when printing the Balance Sheet or the Profit and Loss it does not make sense to print a partial representation of the report because when you export those reports it’s because you want to share the full picture of your company with somebody else. That’s why I said:

The main issue here is that we use a tree structure for storing the data but on the report we should print them as a list of records. It will be great to add some way to diferentiate the depth of the tree (tabbing or diferent styles).

So for me the only way to do this is to create a report template that loads the records in the right order.

I think you want to have a generic way to export a tree using CSV files but I do not think this is the scope of this discussion.

I want a generic way to make a printable document based on tree structure expanded in the client.
I do not see the point to make special implementation (in standard) case by case when this is a generic needs. So as usual I prefer that Tryton is missing something than having a partial solution.

Do you have any other case in mind to export a tree structure expanded with the client?

For me having a generic solution to export Balance Sheet and Profit and loss using CSV will also be a partial solution because it will miss the following features:

  • It won’t be possible to customize the report on each instance. This is important because as companies my want to include it’s logo or use some diferent layout for the report. I’ve seen for example some companies that want to print an horitzontal Balance Sheet with the Assets on the left and the Liabilities on the right side.
  • It won’t be possible to convert the report to diferent formats. Some people prefer to have PDF files because they are not modificable.
  • When printing a CSV report it won’t have any header and footer printed per page.
  • The CSV will have a plain list of tree and it won’t be possible to diferentiate which records are child of another record.

Mainly an reporting as tree like the projects, the sale reporting based on a tree like category.
We have few in standard in part because we do not have such feature.

I’m not tide to CSV but it looks like a good place to start.

Internal reporting are not the main concern about customization because they are internal.

Any good spreadsheet program can export as PDF. And we could have an API to do that on server-side.

Already explained that the context will be the header.

That’s why I talk about using record name.

This is not for only internal reporting but for external reporting. The reports should be sent to:

  • Banks when asking for a loan
  • Inverstors of the company

Why we need to reinvent the wheel if we already have format conversion for reports?

Using the rec_name will be a nightmare for accountants as it will print the full name of the tree for each item in the report. For the spanish chart of accounts this means printing:

Plan General Contable Español 2008\BALANCE NORMAL (PGCE 2008)\TOTAL ACTIVO (A + B)\A) ACTIVO NO CORRIENTE\IV. Inversiones en empresas del grupo y asociadas a largo plazo\1. Instrumentos de patrimonio

While the end user will expect only to see the last item: 1. Instrumentos de patrimonio

And authorities as Registro Mercantil.

He leído con detenimiento lo expuesto y es realmente necesario el poder imprimir los balances, en Venezuela es imprescindible para cualquier gestión bancaria ó con los entes de gobierno, si tienes una auditoria de impuestos solicitan los libros al igual que un balance impreso y el estado de Ganancias y Pérdidas.

Con los sistemas que he manejado la diferencia de estos reportes son prácticamente imperceptible varia solo la posición de la información ó la profundidad en el detalle.

Tryton ha logrado cubrir en gran medida todas las necesidades y requerimientos en la legislación y manejo de la empresa aquí en Venezuela, inclusive a superado con creces las expectativas. Pero no he de negar que realmente echo de menos los reportes de balance general y ganancias y perdidas impresos ó en PDF que se obtienen con el sistema anterior.

Aun en estos tiempos de documentación digital la legislación nos exige mantener copia impresa de estos reportes al menos por 10 años.

Estaremos al pendiente del progreso de esta discusión, mientras agradeceria me indiquen como obtengo el CVS para ajustarlo en mis formatos anteriores.

Aquí unas capturas de los que se obtenia en el sistema anterior:
Balance General

Ganancias y Pérdidas

I think I got a solution to fix both problems the CSV export and the report on tree structure.

First we add a forth key to the data sent to the report. It contains the indentation level for every ids (empty for list). This information can be used on the template to indent the records correctly. This prevents to compute it on the server side which may not be reliable depending on the actual root in the client and if the type of graph the tree is (if parent is a Many2One or Many2Many).

Second on ir.action we allow to specify if the action runs on the selected records or the listed record. This is similar to Issue 9090: Add export CSV route - Tryton issue tracker. For tree this means that it is the ids of all the rows which has a parent expanded.This way report that has meaning only as an all, can set this flag and always be complete (of course there are always the case of newly created node between the client read and the report generation but I think it can be understood).

Third the CSV export that are using “Listed Record” and based on a tree, we do not use the domain (which limit only to roots) but use the rows which has a parent expanded. And when formatting the lines, we add spaces to the first column following the level.

Here are:

1 Like