Skip to content

4157 - Mejorado el informe de desgloses y añadido información de documentos enlazados#69

Open
daniel89fg wants to merge 6 commits intomainfrom
4157-desgloses-document
Open

4157 - Mejorado el informe de desgloses y añadido información de documentos enlazados#69
daniel89fg wants to merge 6 commits intomainfrom
4157-desgloses-document

Conversation

@daniel89fg
Copy link
Contributor

Copilot AI review requested due to automatic review settings February 4, 2026 10:53
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR significantly enhances the breakdown report by adding richer filters (including product/variant and company-dependent options), switching the output to a tabbed, on-screen view with optional XLS/PDF export, and wiring in links to related documents and entities.

Changes:

  • Extends the breakdown report UI to include a product/variant autocomplete, dynamic warehouse and payment-method filters per company, and a post-submit result area with tabs for units, net amounts, and a document list.
  • Refactors ReportBreakdown to centralize filter initialization, build a structured $data array for the view (units/net/documents for both sales and purchases), and add export support via ExportManager (filters summary + three data pages) in XLS/PDF formats.
  • Introduces helper methods for building URLs to customers, variants, and documents, new AJAX endpoints for warehouses/payment methods/variants, and updates aggregation logic to use month-name keys instead of numeric indices.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 9 comments.

File Description
View/ReportBreakdown.html.twig Reworks the filter form layout, adds product/variant and report type/format selectors, and renders the new tabbed units/net/document breakdown, with JS hooks for AJAX filters and autocompletes.
Controller/ReportBreakdown.php Refactors filter initialization and reporting logic to populate $data for the view, adds export via ExportManager, new autocomplete/AJAX handlers, and new grouping/URL helper methods for customers, products, and documents.
Comments suppressed due to low confidence (3)

Controller/ReportBreakdown.php:1152

  • Here $agrupados is iterated to print CSV lines, but the line that previously populated it with getDatosAgrupadosRef() has been commented out above, so $agrupados is never defined. To avoid runtime notices and empty output, reintroduce the aggregation step (aligned with the new month-key structure) or remove this method if it is no longer reachable.
        // agrupamos los datos por proveedor, referencia, año y mes
        //$agrupados = $this->getDatosAgrupadosRef($data, 'codproveedor');

        // imprimimos las líneas
        foreach ($agrupados as $codproveedor => $referencias) {
            foreach ($referencias as $referencia => $years) {
                foreach ($years as $year => $meses) {
                    echo '"' . $codproveedor . '";' . $this->getNombreProveedor($codproveedor) . ';"' . $referencia . '";' . $year;
                    foreach ($meses as $mes) {
                        echo ';' . number_format($mes, FS_NF0, ',', '');
                    }
                    echo "\n";
                }
                echo ";;;;;;;;;;;;;;;\n";
            }
            echo ";;;;;;;;;;;;;;;\n";

Controller/ReportBreakdown.php:1216

  • Similarly to the other CSV helpers, this method iterates $agrupados but the call that was populating it with getDatosAgrupadosRef() is now commented out, so $agrupados is never defined. To prevent runtime errors and unusable CSVs, either reintroduce the aggregation step with the updated month keys or remove this method if CSV output is no longer part of the public behavior.
        // agrupamos los datos por cliente, referencia, añi y mes
        //$agrupados = $this->getDatosAgrupadosRef($data, 'codcliente');

        // imprimimos las líneas
        foreach ($agrupados as $codcliente => $referencias) {
            foreach ($referencias as $referencia => $years) {
                foreach ($years as $year => $meses) {
                    echo '"' . $codcliente . '";' . $this->getNombreCliente($codcliente) . ';"' . $referencia . '";' . $year;
                    foreach ($meses as $mes) {
                        echo ';' . number_format($mes, FS_NF0, ',', '');

Controller/ReportBreakdown.php:1072

  • getTotalesAgrupados() still assumes month indexes 1..13 when initializing $totales, but getDatosAgrupados() / getDatosAgrupadosRef() now generate month keys like 'january', 'february', … and 'total'. Once $agrupados is correctly populated again, this mismatch will cause notices and totals stored under unexpected keys; it would be safer to initialize and iterate totals using the same month key set as the aggregation functions (and to treat the annual total separately if needed).
    protected function getTotalesAgrupados(array $agrupados): array
    {
        $totales = [];
        foreach ($agrupados as $years) {
            foreach ($years as $year => $meses) {
                if (!isset($totales[$year])) {
                    $totales[$year] = [
                        1 => 0, // enero
                        2 => 0,
                        3 => 0,
                        4 => 0,
                        5 => 0,
                        6 => 0,
                        7 => 0,
                        8 => 0,
                        9 => 0,
                        10 => 0,
                        11 => 0,
                        12 => 0, // diciembre
                        13 => 0 // total anual
                    ];

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

daniel89fg and others added 5 commits February 4, 2026 13:44
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments