[FIX] fleet: use services dates in report start date computation
When adding some services to a vehicle that does not have any
immatriculation date, the costs report does not consider these services.
To reproduce the error:
(DB without any demo data)
1. Create a vehicle V
- Remove the Immatriculation Date
2. Add a service for V
- The category of the service type does not matter
- Cost > 0
- Date: today
3. Fleet > Reporting > Costs
Error: Costs Analysis is empty, the service is not considered
In the SQL view, the date used as start point is the oldest
immatriculation date. Therefore, if the vehicle doesn't have this date,
the report lines won't be generated.
OPW-2477004
X-original-commit: 8d362af654c1905535d78fbf8d73677633b65d63
This commit is contained in:
@@ -50,8 +50,8 @@ WITH service_costs AS (
|
||||
fleet_category fl ON fl.id = ve.fleet_id
|
||||
CROSS JOIN generate_series((
|
||||
SELECT
|
||||
min(acquisition_date)
|
||||
FROM fleet_vehicle), CURRENT_DATE, '1 month') d
|
||||
min(date)
|
||||
FROM fleet_vehicle_log_services), CURRENT_DATE, '1 month') d
|
||||
LEFT JOIN fleet_vehicle_log_services se ON se.vehicle_id = ve.id
|
||||
AND date_trunc('month', se.date) = date_trunc('month', d)
|
||||
WHERE
|
||||
|
||||
Reference in New Issue
Block a user