diff --git a/composer.json b/composer.json index e5d094b..093f640 100644 --- a/composer.json +++ b/composer.json @@ -4,6 +4,16 @@ "keywords": ["sylius", "sylius-plugin", "click-and-collect", "pickup", "shipping", "covid-19"], "description": "Click and Collect plugin for Sylius, to sell and deliver securely during the COVID-19 pandemic.", "license": "AGPL-3.0-or-later", + "repositories": [ + { + "type": "vcs", + "url": "https://github.com/dunglas/AdminOrderCreationPlugin" + }, + { + "type": "vcs", + "url": "https://github.com/dew326/FOSJsRoutingBundle" + } + ], "require": { "php": "^7.4", "simshaun/recurr": "^4.0", @@ -11,6 +21,7 @@ "symfony/lock": "^4.4 || ^5.0" }, "require-dev": { + "friendsofsymfony/jsrouting-bundle": "dev-fix-duplicated-port-in-absolute-path as 2.5.3", "phpstan/extension-installer": "^1.0", "phpstan/phpstan": "^0.12.0", "phpstan/phpstan-doctrine": "^0.12.0", @@ -18,6 +29,7 @@ "phpstan/phpstan-webmozart-assert": "^0.12.0", "phpunit/phpunit": "^8.0", "sensiolabs/security-checker": "^6.0", + "sylius/admin-order-creation-plugin": "dev-patch-1", "sylius-labs/coding-standard": "^3.1", "symfony/browser-kit": "^4.4", "symfony/debug-bundle": "^4.4", diff --git a/tests/Application/config/bundles.php b/tests/Application/config/bundles.php index 2d262d7..50e6999 100644 --- a/tests/Application/config/bundles.php +++ b/tests/Application/config/bundles.php @@ -61,6 +61,8 @@ Sylius\Bundle\ShopBundle\SyliusShopBundle::class => ['all' => true], FOS\OAuthServerBundle\FOSOAuthServerBundle::class => ['all' => true], Sylius\Bundle\AdminApiBundle\SyliusAdminApiBundle::class => ['all' => true], + FOS\JsRoutingBundle\FOSJsRoutingBundle::class => ['all' => true], + Sylius\AdminOrderCreationPlugin\SyliusAdminOrderCreationPlugin::class => ['all' => true], CoopTilleuls\SyliusClickNCollectPlugin\CoopTilleulsSyliusClickNCollectPlugin::class => ['all' => true], Symfony\Bundle\DebugBundle\DebugBundle::class => ['dev' => true, 'test' => true, 'test_cached' => true], Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true, 'test_cached' => true], diff --git a/tests/Application/config/packages/_sylius.yaml b/tests/Application/config/packages/_sylius.yaml index 81456ae..3b86bee 100644 --- a/tests/Application/config/packages/_sylius.yaml +++ b/tests/Application/config/packages/_sylius.yaml @@ -6,6 +6,9 @@ imports: - { resource: "@SyliusShopBundle/Resources/config/app/config.yml" } + + - { resource: "@SyliusAdminOrderCreationPlugin/Resources/config/app/config.yml" } + parameters: sylius_core.public_dir: '%kernel.project_dir%/public' diff --git a/tests/Application/config/routes/sylius_admin.yaml b/tests/Application/config/routes/sylius_admin.yaml index 1ba48d6..9e758ae 100644 --- a/tests/Application/config/routes/sylius_admin.yaml +++ b/tests/Application/config/routes/sylius_admin.yaml @@ -1,3 +1,6 @@ sylius_admin: resource: "@SyliusAdminBundle/Resources/config/routing.yml" prefix: /admin + +sylius_admin_order_creation: + resource: "@SyliusAdminOrderCreationPlugin/Resources/config/app/routing.yml" diff --git a/tests/Application/templates/bundles/SyliusAdminBundle/Order/Show/Summary/_item.html.twig b/tests/Application/templates/bundles/SyliusAdminBundle/Order/Show/Summary/_item.html.twig new file mode 100644 index 0000000..fe177a5 --- /dev/null +++ b/tests/Application/templates/bundles/SyliusAdminBundle/Order/Show/Summary/_item.html.twig @@ -0,0 +1,52 @@ +{% import "@SyliusAdmin/Common/Macro/money.html.twig" as money %} + +{% set orderPromotionAdjustment = constant('Sylius\\Component\\Core\\Model\\AdjustmentInterface::ORDER_PROMOTION_ADJUSTMENT') %} +{% set unitPromotionAdjustment = constant('Sylius\\Component\\Core\\Model\\AdjustmentInterface::ORDER_UNIT_PROMOTION_ADJUSTMENT') %} +{% set shippingAdjustment = constant('Sylius\\Component\\Core\\Model\\AdjustmentInterface::SHIPPING_ADJUSTMENT') %} +{% set taxAdjustment = constant('Sylius\\Component\\Core\\Model\\AdjustmentInterface::TAX_ADJUSTMENT') %} +{% set orderItemDiscountAdjustment = constant('Sylius\\AdminOrderCreationPlugin\\Form\\Type\\AdjustmentType::ORDER_ITEM_DISCOUNT_ADJUSTMENT') %} + +{% set variant = item.variant %} +{% set product = variant.product %} + +{% set unitDiscount = item.units.first.adjustmentsTotal(unitPromotionAdjustment) + item.getAdjustmentsTotalRecursively(orderItemDiscountAdjustment) / item.quantity %} +{% set discountedUnitPrice = item.fullDiscountedUnitPrice + item.getAdjustmentsTotalRecursively(orderItemDiscountAdjustment) / item.quantity %} +{% set subtotal = item.quantity * (item.unitPrice + item.units.first.adjustmentsTotal(unitPromotionAdjustment) + item.units.first.adjustmentsTotal(orderPromotionAdjustment)) + item.getAdjustmentsTotalRecursively(orderItemDiscountAdjustment) %} + +{% set taxIncluded = sylius_admin_order_unit_tax_included(item) %} +{% set taxExcluded = sylius_admin_order_unit_tax_excluded(item) %} + + + + {% include '@SyliusAdmin/Product/_info.html.twig' %} + + + {{ money.format(item.unitPrice, order.currencyCode) }} + + + {{ money.format(unitDiscount, order.currencyCode) }} + + + {{ money.format(item.units.first.adjustmentsTotal(orderPromotionAdjustment), order.currencyCode) }} + + + {{ money.format(discountedUnitPrice, order.currencyCode) }} + + + {{ item.quantity }} + + + {{ money.format(subtotal, order.currencyCode) }} + + +
{{ money.format(taxExcluded, order.currencyCode) }}
+
+
{{ money.format(taxIncluded, order.currencyCode) }} +
+ ({{ 'sylius.ui.included_in_price'|trans }}) +
+ + + {{ money.format(item.total, order.currencyCode) }} + + diff --git a/tests/Application/templates/bundles/SyliusAdminBundle/Order/Show/Summary/_totals.html.twig b/tests/Application/templates/bundles/SyliusAdminBundle/Order/Show/Summary/_totals.html.twig new file mode 100644 index 0000000..ab2a43d --- /dev/null +++ b/tests/Application/templates/bundles/SyliusAdminBundle/Order/Show/Summary/_totals.html.twig @@ -0,0 +1,73 @@ +{% import "@SyliusAdmin/Common/Macro/money.html.twig" as money %} + +{% set orderPromotionAdjustment = constant('Sylius\\Component\\Core\\Model\\AdjustmentInterface::ORDER_PROMOTION_ADJUSTMENT') %} +{% set orderShippingPromotionAdjustment = constant('Sylius\\Component\\Core\\Model\\AdjustmentInterface::ORDER_SHIPPING_PROMOTION_ADJUSTMENT') %} +{% set itemPromotionAdjustment = constant('Sylius\\Component\\Core\\Model\\AdjustmentInterface::ORDER_ITEM_PROMOTION_ADJUSTMENT') %} +{% set shippingAdjustment = constant('Sylius\\Component\\Core\\Model\\AdjustmentInterface::SHIPPING_ADJUSTMENT') %} +{% set taxAdjustment = constant('Sylius\\Component\\Core\\Model\\AdjustmentInterface::TAX_ADJUSTMENT') %} +{% set orderDiscountAdjustment = constant('Sylius\\AdminOrderCreationPlugin\\Form\\Type\\AdjustmentType::ORDER_DISCOUNT_ADJUSTMENT') %} + +{% set orderShippingPromotions = sylius_aggregate_adjustments(order.getAdjustmentsRecursively(orderShippingPromotionAdjustment)) %} + + + + + {{ 'sylius.ui.tax_total'|trans }}: + {{ money.format(order.taxTotal, order.currencyCode) }} + + + {{ 'sylius.ui.items_total'|trans }}: + {{ money.format(order.itemsTotal, order.currencyCode) }} + + + + + {% if not order.adjustments(shippingAdjustment).isEmpty() %} +
+
{{ 'sylius.ui.shipping'|trans }}:
+ {% for adjustment in order.adjustments(shippingAdjustment) %} +
+
{{ money.format(adjustment.amount, order.currencyCode) }}
+
+
+ {{ adjustment.label }}: +
+
+
+ {% endfor %} +
+ {% else %} +

{{ 'sylius.ui.no_shipping_charges'|trans }}

+ {% endif %} + + {% if not orderShippingPromotions is empty %} + +
+
{{ 'sylius.ui.shipping_discount'|trans }}:
+ {% for label, amount in orderShippingPromotions %} +
+
+ {{ money.format(amount, order.currencyCode) }} +
+
+ {% endfor %} +
+ + {% endif %} + + {{ 'sylius.ui.shipping_total'|trans }}: + {{ money.format(order.shippingTotal, order.currencyCode) }} + + + + + {{ 'sylius_admin_order_creation.ui.order_discount'|trans }}: + {{ money.format(order.getAdjustmentsTotalRecursively(orderDiscountAdjustment), order.currencyCode) }} + + + + + {{ 'sylius.ui.order_total'|trans }}: + {{ money.format(order.total, order.currencyCode) }} + + diff --git a/tests/Application/templates/bundles/SyliusAdminBundle/Order/Show/_payment.html.twig b/tests/Application/templates/bundles/SyliusAdminBundle/Order/Show/_payment.html.twig new file mode 100644 index 0000000..72e0eaa --- /dev/null +++ b/tests/Application/templates/bundles/SyliusAdminBundle/Order/Show/_payment.html.twig @@ -0,0 +1,44 @@ +{% import "@SyliusAdmin/Common/Macro/money.html.twig" as money %} +{% import '@SyliusUi/Macro/labels.html.twig' as label %} + +
+
+ {% include '@SyliusAdmin/Common/Label/paymentState.html.twig' with {'data': payment.state} %} +
+ +
+
+ {{ payment.method }} +
+
+ {{ money.format(payment.amount, payment.order.currencyCode) }} +
+
+ {% if sm_can(payment, 'complete', 'sylius_payment') %} +
+
+ + + +
+
+ {% if payment.details['payment-link'] is defined %} +
+ + + +
+ {% endif %} + {% endif %} + {% if sm_can(payment, 'refund', 'sylius_payment') %} +
+
+ + + +
+
+ {% endif %} +
diff --git a/tests/Application/templates/bundles/SyliusAdminOrderCreationPlugin/Order/create.html.twig b/tests/Application/templates/bundles/SyliusAdminOrderCreationPlugin/Order/create.html.twig new file mode 100644 index 0000000..fda6d05 --- /dev/null +++ b/tests/Application/templates/bundles/SyliusAdminOrderCreationPlugin/Order/create.html.twig @@ -0,0 +1,25 @@ +{% extends '@!SyliusAdminOrderCreationPlugin/Order/create.html.twig' %} + +{% block content %} + {{ parent() }} + + {# json_encode(65) is for JSON_UNESCAPED_SLASHES|JSON_HEX_TAG to avoid JS XSS #} + +{% endblock %} + +{% block javascripts %} + {{ parent() }} + + {% include '@CoopTilleulsSyliusClickNCollectPlugin/fullcalendar/_scripts.html.twig' %} + {% include '@SyliusUi/_javascripts.html.twig' with {'path': 'bundles/cooptilleulssyliusclickncollectplugin/click_n_collect.js'} %} +{% endblock %} + +{% block stylesheets %} + {{ parent() }} + + {% include '@CoopTilleulsSyliusClickNCollectPlugin/fullcalendar/_styles.html.twig' %} +{% endblock %}