mirror of
https://github.com/grocy/grocy.git
synced 2025-08-19 20:11:16 +00:00
Exclude self-produced product prices from spending reports (#2596)
* Exclude self-produced product prices from spending reports * Fix SQL query * Code style --------- Co-authored-by: Bernd Bestel <bernd@berrnd.de>
This commit is contained in:
@@ -9,16 +9,18 @@ class StockReportsController extends BaseController
|
||||
{
|
||||
public function Spendings(Request $request, Response $response, array $args)
|
||||
{
|
||||
$where = "pph.transaction_type != 'self-production'";
|
||||
|
||||
if (isset($request->getQueryParams()['start_date']) && isset($request->getQueryParams()['end_date']) && IsIsoDate($request->getQueryParams()['start_date']) && IsIsoDate($request->getQueryParams()['end_date']))
|
||||
{
|
||||
$startDate = $request->getQueryParams()['start_date'];
|
||||
$endDate = $request->getQueryParams()['end_date'];
|
||||
$where = "pph.purchased_date BETWEEN '$startDate' AND '$endDate'";
|
||||
$where .= " AND pph.purchased_date BETWEEN '$startDate' AND '$endDate'";
|
||||
}
|
||||
else
|
||||
{
|
||||
// Default to this month
|
||||
$where = "pph.purchased_date >= DATE(DATE('now', 'localtime'), 'start of month')";
|
||||
$where .= " AND pph.purchased_date >= DATE(DATE('now', 'localtime'), 'start of month')";
|
||||
}
|
||||
|
||||
$groupBy = 'product';
|
||||
|
Reference in New Issue
Block a user