AI reports
This commit is contained in:
@@ -284,7 +284,7 @@ GROUP BY
|
||||
ORDER BY i.register_date DESC;
|
||||
",
|
||||
'filename' => 'invoices_2024.csv',
|
||||
],
|
||||
], // invoices 2024
|
||||
[
|
||||
'sql' => "
|
||||
SELECT
|
||||
@@ -323,7 +323,99 @@ 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 'Surowiec'
|
||||
WHEN 4 THEN 'Usługa'
|
||||
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 'Surowiec'
|
||||
WHEN 4 THEN 'Usługa'
|
||||
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_2025.csv',
|
||||
], // correct invoices 2025
|
||||
[
|
||||
'sql' => "
|
||||
SELECT
|
||||
@@ -361,7 +453,7 @@ GROUP BY
|
||||
ORDER BY i.register_date DESC;
|
||||
",
|
||||
'filename' => 'rw_2025.csv',
|
||||
],
|
||||
], // rw 2025
|
||||
[
|
||||
'sql' => "
|
||||
SELECT
|
||||
@@ -399,7 +491,7 @@ GROUP BY
|
||||
ORDER BY i.register_date DESC;
|
||||
",
|
||||
'filename' => 'rw_2024.csv',
|
||||
],
|
||||
], // rw 2024
|
||||
[
|
||||
'sql' => "
|
||||
SELECT
|
||||
@@ -411,7 +503,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
|
||||
];
|
||||
|
||||
$report = [];
|
||||
|
||||
Reference in New Issue
Block a user