AI reports

This commit is contained in:
Michał Zieliński
2025-08-27 08:54:00 +02:00
parent f3c8adb3c8
commit eab6fc87b1

View File

@@ -360,7 +360,7 @@ GROUP BY
ORDER BY i.register_date DESC; ORDER BY i.register_date DESC;
", ",
'filename' => 'invoices_2024.csv', 'filename' => 'invoices_2024.csv',
], ], // invoices 2024
[ [
'sql' => " 'sql' => "
SELECT SELECT
@@ -400,7 +400,101 @@ GROUP BY
ORDER BY i.register_date DESC; ORDER BY i.register_date DESC;
", ",
'filename' => 'invoices_2025.csv', 'filename' => 'invoices_2025.csv',
], ], // invoices 2025
[
'sql' => "
SELECT
i.document_no,
i.register_date,
oi.document_no AS FV,
oi.register_date AS FV_date,
i.parent_name,
p.code,
p.name,
CASE p.group_ks
WHEN 1 THEN 'Towar handlowy'
WHEN 2 THEN 'Wyrób gotowy'
WHEN 3 THEN 'Usługi'
WHEN '530547ef-2dea-7622-843b-59d745b14c64' THEN 'Materiały'
WHEN '8451dded-710f-51c2-7ed1-60a377eaa7b7' THEN 'Surowce'
ELSE 'Nieznane'
END AS group_ks,
GROUP_CONCAT(c.name ORDER BY cb.position SEPARATOR ' | ') AS category,
ii.quantity_corrected AS quantity_correced,
ii.total_netto_corrected AS total_netto_corrected
FROM ecminvoiceouts AS i
INNER JOIN ecminvoiceoutitems AS ii ON i.id = ii.ecminvoiceout_id
INNER JOIN ecmproducts AS p ON ii.ecmproduct_id = p.id
INNER JOIN ecminvoiceouts AS oi ON oi.id = i.ecminvoiceout_id
LEFT JOIN ecmproductcategories_bean AS cb ON cb.bean_id COLLATE utf8_general_ci = p.id COLLATE utf8_general_ci
AND cb.bean_name = 'EcmProducts'
AND cb.deleted = 0
LEFT JOIN ecmproductcategories AS c ON c.id = cb.ecmproductcategory_id
WHERE i.type = 'correct' AND YEAR(i.register_date) = 2024
GROUP BY
i.document_no,
i.register_date,
oi.document_no,
oi.register_date,
i.parent_name,
p.code,
p.name,
p.group_ks,
ii.quantity,
ii.price_netto,
ii.quantity_corrected,
ii.total_netto_corrected
ORDER BY i.register_date DESC;
",
'filename' => 'correct_invoices_2024.csv',
], // correct invoices 2024
[
'sql' => "
SELECT
i.document_no,
i.register_date,
oi.document_no AS FV,
oi.register_date AS FV_date,
i.parent_name,
p.code,
p.name,
CASE p.group_ks
WHEN 1 THEN 'Towar handlowy'
WHEN 2 THEN 'Wyrób gotowy'
WHEN 3 THEN 'Usługi'
WHEN '530547ef-2dea-7622-843b-59d745b14c64' THEN 'Materiały'
WHEN '8451dded-710f-51c2-7ed1-60a377eaa7b7' THEN 'Surowce'
ELSE 'Nieznane'
END AS group_ks,
GROUP_CONCAT(c.name ORDER BY cb.position SEPARATOR ' | ') AS category,
ii.quantity_corrected AS quantity_correced,
ii.total_netto_corrected AS total_netto_corrected
FROM ecminvoiceouts AS i
INNER JOIN ecminvoiceoutitems AS ii ON i.id = ii.ecminvoiceout_id
INNER JOIN ecmproducts AS p ON ii.ecmproduct_id = p.id
INNER JOIN ecminvoiceouts AS oi ON oi.id = i.ecminvoiceout_id
LEFT JOIN ecmproductcategories_bean AS cb ON cb.bean_id COLLATE utf8_general_ci = p.id COLLATE utf8_general_ci
AND cb.bean_name = 'EcmProducts'
AND cb.deleted = 0
LEFT JOIN ecmproductcategories AS c ON c.id = cb.ecmproductcategory_id
WHERE i.type = 'correct' AND YEAR(i.register_date) = 2025
GROUP BY
i.document_no,
i.register_date,
oi.document_no,
oi.register_date,
i.parent_name,
p.code,
p.name,
p.group_ks,
ii.quantity,
ii.price_netto,
ii.quantity_corrected,
ii.total_netto_corrected
ORDER BY i.register_date DESC;
",
'filename' => 'correct_invoices_2025.csv',
], // correct invoices 2025
[ [
'sql' => " 'sql' => "
SELECT SELECT
@@ -440,7 +534,7 @@ GROUP BY
ORDER BY i.register_date DESC; ORDER BY i.register_date DESC;
", ",
'filename' => 'ecommerce_invoices_2024.csv', 'filename' => 'ecommerce_invoices_2024.csv',
], ], // ecommerce invoices 2024
[ [
'sql' => " 'sql' => "
SELECT SELECT
@@ -480,7 +574,7 @@ GROUP BY
ORDER BY i.register_date DESC; ORDER BY i.register_date DESC;
", ",
'filename' => 'ecommerce_invoices_2025.csv', 'filename' => 'ecommerce_invoices_2025.csv',
], ], // ecommerce invoices 2025
[ [
'sql' => " 'sql' => "
SELECT SELECT
@@ -492,7 +586,7 @@ ORDER BY i.register_date DESC;
JOIN ecmstocks AS s ON ss.stock_id = s.id JOIN ecmstocks AS s ON ss.stock_id = s.id
ORDER BY quantity + 0 DESC;", ORDER BY quantity + 0 DESC;",
'filename' => 'stocks.csv', 'filename' => 'stocks.csv',
], ], // stocks
[ [
'sql' => " 'sql' => "
SELECT SELECT
@@ -530,7 +624,7 @@ GROUP BY
ORDER BY i.register_date DESC; ORDER BY i.register_date DESC;
", ",
'filename' => 'rw_2025.csv', 'filename' => 'rw_2025.csv',
], ], // rw 2025
[ [
'sql' => " 'sql' => "
SELECT SELECT
@@ -568,7 +662,7 @@ GROUP BY
ORDER BY i.register_date DESC; ORDER BY i.register_date DESC;
", ",
'filename' => 'rw_2024.csv', 'filename' => 'rw_2024.csv',
], ], // rw 2024
]; ];
$report = []; $report = [];