AI reports
This commit is contained in:
@@ -360,7 +360,7 @@ GROUP BY
|
||||
ORDER BY i.register_date DESC;
|
||||
",
|
||||
'filename' => 'invoices_2024.csv',
|
||||
],
|
||||
], // invoices 2024
|
||||
[
|
||||
'sql' => "
|
||||
SELECT
|
||||
@@ -400,7 +400,101 @@ GROUP BY
|
||||
ORDER BY i.register_date DESC;
|
||||
",
|
||||
'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' => "
|
||||
SELECT
|
||||
@@ -440,7 +534,7 @@ GROUP BY
|
||||
ORDER BY i.register_date DESC;
|
||||
",
|
||||
'filename' => 'ecommerce_invoices_2024.csv',
|
||||
],
|
||||
], // ecommerce invoices 2024
|
||||
[
|
||||
'sql' => "
|
||||
SELECT
|
||||
@@ -480,7 +574,7 @@ GROUP BY
|
||||
ORDER BY i.register_date DESC;
|
||||
",
|
||||
'filename' => 'ecommerce_invoices_2025.csv',
|
||||
],
|
||||
], // ecommerce invoices 2025
|
||||
[
|
||||
'sql' => "
|
||||
SELECT
|
||||
@@ -492,7 +586,7 @@ ORDER BY i.register_date DESC;
|
||||
JOIN ecmstocks AS s ON ss.stock_id = s.id
|
||||
ORDER BY quantity + 0 DESC;",
|
||||
'filename' => 'stocks.csv',
|
||||
],
|
||||
], // stocks
|
||||
[
|
||||
'sql' => "
|
||||
SELECT
|
||||
@@ -530,7 +624,7 @@ GROUP BY
|
||||
ORDER BY i.register_date DESC;
|
||||
",
|
||||
'filename' => 'rw_2025.csv',
|
||||
],
|
||||
], // rw 2025
|
||||
[
|
||||
'sql' => "
|
||||
SELECT
|
||||
@@ -568,7 +662,7 @@ GROUP BY
|
||||
ORDER BY i.register_date DESC;
|
||||
",
|
||||
'filename' => 'rw_2024.csv',
|
||||
],
|
||||
], // rw 2024
|
||||
];
|
||||
|
||||
$report = [];
|
||||
|
||||
Reference in New Issue
Block a user