Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calculate the distance for a task into a tasklist even when no vehicle is set #4805

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
32 changes: 32 additions & 0 deletions app/DoctrineMigrations/Version20250114155816.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

declare(strict_types=1);

namespace Application\Migrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20250114155816 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}

public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE task RENAME COLUMN co2_emissions TO emitted_co2');
$this->addSql('ALTER TABLE task RENAME COLUMN distance_from_previous TO traveled_distance_meter');
}

public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs

}
}
3 changes: 3 additions & 0 deletions app/config/message_bus/task.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ services:
arguments:
- '@event_recorder'
- '@translator'
- '@AppBundle\Entity\TaskListRepository'
- '@routing_service'
- '@logger'
tags:
- name: command_handler
handles: AppBundle\Domain\Task\Command\MarkAsDone
Expand Down
18 changes: 18 additions & 0 deletions features/deliveries.feature
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ Feature: Deliveries
| sylius_channels.yml |
| sylius_products.yml |
| sylius_taxation.yml |
| payment_methods.yml |
| stores.yml |
And the store with name "Acme" has an OAuth client named "Acme"
And the OAuth client with name "Acme" has an access token
Expand Down Expand Up @@ -191,6 +192,7 @@ Feature: Deliveries
| sylius_channels.yml |
| sylius_products.yml |
| sylius_taxation.yml |
| payment_methods.yml |
| stores.yml |
And the store with name "Acme" has an OAuth client named "Acme"
And the OAuth client with name "Acme" has an access token
Expand Down Expand Up @@ -302,6 +304,7 @@ Feature: Deliveries
| sylius_channels.yml |
| sylius_products.yml |
| sylius_taxation.yml |
| payment_methods.yml |
| stores.yml |
And the store with name "Acme" has an OAuth client named "Acme"
And the OAuth client with name "Acme" has an access token
Expand Down Expand Up @@ -432,6 +435,7 @@ Feature: Deliveries
| sylius_channels.yml |
| sylius_products.yml |
| sylius_taxation.yml |
| payment_methods.yml |
| stores.yml |
And the store with name "Acme" has an OAuth client named "Acme"
And the OAuth client with name "Acme" has an access token
Expand Down Expand Up @@ -526,6 +530,7 @@ Feature: Deliveries
| sylius_channels.yml |
| sylius_products.yml |
| sylius_taxation.yml |
| payment_methods.yml |
| stores.yml |
And the store with name "Acme" has an OAuth client named "Acme"
And the OAuth client with name "Acme" has an access token
Expand Down Expand Up @@ -1217,6 +1222,7 @@ Feature: Deliveries
| sylius_channels.yml |
| sylius_products.yml |
| sylius_taxation.yml |
| payment_methods.yml |
| stores.yml |
And the store with name "Acme" has an OAuth client named "Acme"
And the OAuth client with name "Acme" has an access token
Expand Down Expand Up @@ -1307,6 +1313,7 @@ Feature: Deliveries
| sylius_channels.yml |
| sylius_products.yml |
| sylius_taxation.yml |
| payment_methods.yml |
| stores.yml |
And the store with name "Acme" has an OAuth client named "Acme"
And the OAuth client with name "Acme" has an access token
Expand Down Expand Up @@ -1401,6 +1408,7 @@ Feature: Deliveries
| sylius_channels.yml |
| sylius_products.yml |
| sylius_taxation.yml |
| payment_methods.yml |
| stores.yml |
And the store with name "Acme" has an OAuth client named "Acme"
And the OAuth client with name "Acme" has an access token
Expand Down Expand Up @@ -1497,6 +1505,7 @@ Feature: Deliveries
| sylius_channels.yml |
| sylius_products.yml |
| sylius_taxation.yml |
| payment_methods.yml |
| stores.yml |
And the store with name "Acme" has an OAuth client named "Acme"
And the OAuth client with name "Acme" has an access token
Expand Down Expand Up @@ -1591,6 +1600,7 @@ Feature: Deliveries
| sylius_channels.yml |
| sylius_products.yml |
| sylius_taxation.yml |
| payment_methods.yml |
| stores.yml |
Given the current time is "2020-04-02 11:00:00"
And the store with name "Acme" has an OAuth client named "Acme"
Expand Down Expand Up @@ -1686,6 +1696,7 @@ Feature: Deliveries
| sylius_channels.yml |
| sylius_products.yml |
| sylius_taxation.yml |
| payment_methods.yml |
| stores.yml |
And the store with name "Acme" has an OAuth client named "Acme"
And the OAuth client with name "Acme" has an access token
Expand Down Expand Up @@ -1804,6 +1815,7 @@ Feature: Deliveries
"""
Then the response status code should be 400
And the response should be in JSON
Then print last JSON response
And the JSON should match:
"""
{
Expand All @@ -1812,6 +1824,11 @@ Feature: Deliveries
"hydra:title":"An error occurred",
"hydra:description":@string@,
"violations":[
{
"propertyPath":"items",
"message":@string@,
"code":null
},
{
"propertyPath":"items",
"message":@string@,
Expand Down Expand Up @@ -1991,6 +2008,7 @@ Feature: Deliveries
| sylius_channels.yml |
| sylius_products.yml |
| sylius_taxation.yml |
| payment_methods.yml |
| stores.yml |
Given the current time is "2022-05-05 12:00:00"
And the store with name "Acme" has an OAuth client named "Acme"
Expand Down
4 changes: 4 additions & 0 deletions features/deliveries_multi.feature
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Feature: Multi-step deliveries
| sylius_channels.yml |
| sylius_products.yml |
| sylius_taxation.yml |
| payment_methods.yml |
| stores.yml |
Given the setting "latlng" has value "48.856613,2.352222"
And the store with name "Acme" has an OAuth client named "Acme"
Expand Down Expand Up @@ -105,6 +106,7 @@ Feature: Multi-step deliveries
| sylius_channels.yml |
| sylius_products.yml |
| sylius_taxation.yml |
| payment_methods.yml |
| stores.yml |
Given the setting "latlng" has value "48.856613,2.352222"
And the store with name "Acme" has an OAuth client named "Acme"
Expand Down Expand Up @@ -233,6 +235,7 @@ Feature: Multi-step deliveries
| sylius_channels.yml |
| sylius_products.yml |
| sylius_taxation.yml |
| payment_methods.yml |
| stores.yml |
Given the setting "latlng" has value "48.856613,2.352222"
And the store with name "Acme" has an OAuth client named "Acme"
Expand Down Expand Up @@ -357,6 +360,7 @@ Feature: Multi-step deliveries
| sylius_channels.yml |
| sylius_products.yml |
| sylius_taxation.yml |
| payment_methods.yml |
| stores.yml |
Given the setting "latlng" has value "48.856613,2.352222"
And the store with name "Acme" has an OAuth client named "Acme"
Expand Down
4 changes: 3 additions & 1 deletion features/dispatch.feature
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,9 @@ Feature: Dispatch
"orgName": @string@,
"images": @array@,
"hasIncidents": @boolean@,
"barcode": "@array@"
"barcode": "@array@",
"emittedCo2": "@integer@",
"traveledDistanceMeter": "@integer@"
}
"""

Expand Down
1 change: 0 additions & 1 deletion features/fixtures/ORM/task_list.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ AppBundle\Entity\Task:
doneAfter: <identity(new \DateTime('2018-03-03 13:00:00'))>
doneBefore: <identity(new \DateTime('2018-03-03 13:30:00'))>
comments: "addToProblem"
previous: "@task_4"
task_6:
address: "@address_3"
doneAfter: <identity(new \DateTime('2018-03-02 12:00:00'))>
Expand Down
36 changes: 27 additions & 9 deletions features/tasks.feature
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ Feature: Tasks
"next":null,
"packages": [],
"barcode": "@array@",
"createdAt":"@[email protected]()"
"createdAt":"@[email protected]()",
"emittedCo2": "@integer@",
"traveledDistanceMeter": "@integer@"
},
{
"@id":"@[email protected]('/api/tasks')",
Expand Down Expand Up @@ -85,7 +87,9 @@ Feature: Tasks
"next":null,
"packages":[],
"barcode": "@array@",
"createdAt":"@[email protected]()"
"createdAt":"@[email protected]()",
"emittedCo2": "@integer@",
"traveledDistanceMeter": "@integer@"
},
{
"@id":"@[email protected]('/api/tasks')",
Expand Down Expand Up @@ -117,7 +121,9 @@ Feature: Tasks
"orgName":"",
"images":[],
"next":null,
"createdAt":"@[email protected]()"
"createdAt":"@[email protected]()",
"emittedCo2": "@integer@",
"traveledDistanceMeter": "@integer@"
},
{
"@id":"@[email protected]('/api/tasks')",
Expand Down Expand Up @@ -149,7 +155,9 @@ Feature: Tasks
"orgName":"",
"images":[],
"next":null,
"createdAt":"@[email protected]()"
"createdAt":"@[email protected]()",
"emittedCo2": "@integer@",
"traveledDistanceMeter": "@integer@"
}
],
"hydra:view": {
Expand Down Expand Up @@ -647,7 +655,9 @@ Feature: Tasks
"incidents": [],
"packages": [],
"barcode": "@array@",
"createdAt":"@[email protected]()"
"createdAt":"@[email protected]()",
"emittedCo2": "@integer@",
"traveledDistanceMeter": "@integer@"
}
"""

Expand Down Expand Up @@ -1120,7 +1130,9 @@ Feature: Tasks
"incidents": [],
"packages": [],
"barcode": "@array@",
"createdAt":"@[email protected]()"
"createdAt":"@[email protected]()",
"emittedCo2": "@integer@",
"traveledDistanceMeter": "@integer@"
}
"""

Expand Down Expand Up @@ -1203,7 +1215,9 @@ Feature: Tasks
"incidents": [],
"packages": [],
"barcode": "@array@",
"createdAt":"@[email protected]()"
"createdAt":"@[email protected]()",
"emittedCo2": "@integer@",
"traveledDistanceMeter": "@integer@"
}
"""

Expand Down Expand Up @@ -1336,7 +1350,9 @@ Feature: Tasks
"incidents": [],
"packages": [],
"barcode": "@array@",
"createdAt":"@[email protected]()"
"createdAt":"@[email protected]()",
"emittedCo2": "@integer@",
"traveledDistanceMeter": "@integer@"
},
{
"@id":"@[email protected]('/api/tasks')",
Expand Down Expand Up @@ -1368,7 +1384,9 @@ Feature: Tasks
"incidents": [],
"packages": [],
"barcode": "@array@",
"createdAt":"@[email protected]()"
"createdAt":"@[email protected]()",
"emittedCo2": "@integer@",
"traveledDistanceMeter": "@integer@"
}
],
"hydra:totalItems":2,
Expand Down
1 change: 1 addition & 0 deletions features/urbantz.feature
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ Feature: Urbantz
| sylius_channels.yml |
| sylius_products.yml |
| sylius_taxation.yml |
| payment_methods.yml |
| stores.yml |
And the store with name "Acme" has an API key
And the store with name "Acme" is associated with Urbantz hub "61289572c2b7aab94f380d76"
Expand Down
6 changes: 4 additions & 2 deletions src/Action/TaskList/SetItems.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace AppBundle\Action\TaskList;

use ApiPlatform\Core\Api\IriConverterInterface;
use AppBundle\Doctrine\EventSubscriber\TaskSubscriber\TaskListProvider;
use AppBundle\Entity\TaskList;
use AppBundle\Entity\TaskList\Item;
use AppBundle\Entity\Tour;
Expand All @@ -20,7 +21,8 @@ public function __construct(
private EntityManagerInterface $entityManager,
private UserManager $userManager,
private TaskListManager $taskListManager,
private TaskListNormalizer $taskListNormalizer
private TaskListNormalizer $taskListNormalizer,
private TaskListProvider $taskListProvider
)
{}

Expand All @@ -29,7 +31,7 @@ public function __invoke(Request $request)
$date = new \DateTime($request->get('date'));
$user = $this->userManager->findUserByUsername($request->get('username'));

$taskList = $this->taskListManager->getTaskListForUser($date, $user);
$taskList = $this->taskListProvider->getTaskListForUserAndDate($date, $user);

// Tasks are sent as JSON payload
$data = json_decode($request->getContent(), true);
Expand Down
Loading
Loading