-
-
Notifications
You must be signed in to change notification settings - Fork 130
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
Add price override in react delivery form #4860
base: master
Are you sure you want to change the base?
Conversation
```javascript fetch('/api/task?groups=task,address,barcode') .then((response) => response.json()) .then((data) => console.log(data)); ```
…/coopcycle/coopcycle-web into feat/deliveryform-override-price
# Conflicts: # src/Entity/Store.php
@@ -49,11 +49,16 @@ final class TaxRate | |||
|
|||
public function __construct(BaseTaxRate $taxRate, string $name, array $alternatives = []) | |||
{ | |||
var_dump($taxRate->getCode()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be removed
* @var DeliveryPriceInput | ||
* @Groups({"delivery_create"}) | ||
*/ | ||
private $deliveryPriceInput; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIK there is no need to create a new DeliveryPriceInput
for this, you can use the existing ArbitraryPrice
.
This way in Appbundle\Action\Delivery\Create
, you don't need to convert the DeliveryPriceInput
into an ArbitraryPrice
. Just put the @var ArbitraryPrice
and/or add type hinting, and API Platform will understand.
$arbitraryPrice = new ArbitraryPrice( | ||
$data->getDeliveryPriceInput()->getVariantName(), | ||
$data->getDeliveryPriceInput()->getPriceIncVATcents() | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See other comment, you could avoid doing this conversion by using ArbitraryPrice
for serialization.
@@ -26,7 +28,20 @@ public function __invoke(Delivery $data) | |||
throw new ValidationException($errors); | |||
} | |||
|
|||
$this->pricingManager->createOrder($data); | |||
$useArbitraryPrice = $this->authorizationCheckerInterface->isGranted('ROLE_ADMIN') && !is_null($data->getDeliveryPriceInput()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you use ArbitraryPrice
in Delivery
class, !is_null($data->getDeliveryPriceInput())
could be replaced by a more expressive & positive method name, hasArbitraryPrice()
.
"deliveryPriceInput": { | ||
"priceIncVATcents": 1200, | ||
"variantName": "my custom variant" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not belong here. To test that the order has been created, yes you should target the orders API.
Eventually, you can return an IRI corresponding to the created order:
"order": "/api/orders/1"
"deliveryPrice": { | ||
"variantName": "my custom variant", | ||
"value": 1200, | ||
"@*@": "@*@" | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need this, you just need to check the value of total
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i wanted to check the variant name, how can i do that without this call? (+ I need the variant name when editing the delivery)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add the field in OrderItemNormalizer
#4851
#4848
#4853
#4854
#4856