Skip to content

Commit

Permalink
Update new service confirutations
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomanhez committed Jun 10, 2021
1 parent 7c50eb6 commit e566409
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 31 deletions.
10 changes: 0 additions & 10 deletions src/Resources/config/admin_routing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,6 @@ sylius_refund_admin_credit_memo_download:
defaults:
_controller: Sylius\RefundPlugin\Action\Admin\DownloadCreditMemoAction

sylius_refund_order_refund_payment_list:
path: /orders/{orderNumber}/refund-payments
methods: [GET]
defaults:
_controller: sylius_refund.controller.refund_payment:indexAction
_sylius:
template: "@SyliusRefundPlugin/Order/Admin/RefundPayment/list.html.twig"
repository:
method: findByOrderNumber
arguments: $orderNumber

sylius_refund_complete_refund_payment:
path: /orders/{orderNumber}/refund-payments/{id}/complete
Expand Down
1 change: 1 addition & 0 deletions src/Resources/config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
<argument type="service" id="Sylius\RefundPlugin\Provider\UnitRefundedTotalProviderInterface" />
<argument type="service" id="Sylius\RefundPlugin\Checker\UnitRefundingAvailabilityCheckerInterface" />
<argument type="service" id="sylius.repository.order" />
<argument type="service" id="sylius_refund.repository.refund_payment" />
<tag name="twig.extension"/>
</service>

Expand Down
5 changes: 0 additions & 5 deletions src/Resources/config/services/listeners.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,5 @@
<argument>@SyliusRefundPlugin/Order/Admin/creditMemos.html.twig</argument>
<tag name="kernel.event_listener" event="sonata.block.event.sylius.admin.order.show.after_summary" method="onBlockEvent" />
</service>

<service id="sylius_refund_plugin.block_event_listener.order_show.refund_payments" class="Sylius\Bundle\UiBundle\Block\BlockEventListener">
<argument>@SyliusRefundPlugin/Order/Admin/refundPayments.html.twig</argument>
<tag name="kernel.event_listener" event="sonata.block.event.sylius.admin.order.show.after_summary" method="onBlockEvent" />
</service>
</services>
</container>
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{% import '@SyliusAdmin/Common/Macro/money.html.twig' as money %}
{% set refund_payments = get_all_refund_payments_by_order_number(order.number) %}
{% set refund_payments = get_all_refund_payments_by_order(order) %}
{% if refund_payments|length > 0 %}
{% include '@SyliusAdmin/Order/Label/PaymentState/' ~ order.paymentState ~ '.html.twig' with { 'value': 'sylius.ui.' ~ order.paymentState, 'attached': true } %}
<h3 class="ui dividing header">{{ 'sylius_refund.ui.refund_payments'|trans }}</h3>
<div class="ui relaxed divided list">
{% for refund_payment in refund_payments %}
<div class="item">
<div class="right floated content">
<div class="item" {{ sylius_test_html_attribute('refund') }}>
<div class="right floated content" {{ sylius_test_html_attribute('refund-status') }}>
{% include '@SyliusRefundPlugin/Common/Label/refundPaymentState.html.twig' with {'data': refund_payment.state} %}
</div>
<i class="large payment icon"></i>
Expand All @@ -19,7 +19,7 @@
</div>
</div>
{% if sm_can(refund_payment, 'complete', 'sylius_refund_refund_payment') %}
<form action="{{ path('sylius_refund_complete_refund_payment', {'orderNumber': refund_payment.orderNumber, 'id': refund_payment.id}) }}" method="POST">
<form action="{{ path('sylius_refund_complete_refund_payment', {'orderNumber': refund_payment.orderNumber, 'id': refund_payment.id}) }}" method="POST" {{ sylius_test_html_attribute('refund-button') }}>
<button class="ui icon labeled yellow loadable button"><i class="check icon"></i> {{ 'sylius.ui.complete'|trans }}</button>
</form>
{% endif %}
Expand Down
8 changes: 4 additions & 4 deletions src/Twig/OrderRefundsExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ public function getFunctions(): array
[$this, 'getUnitRefundLeft']
),
new TwigFunction(
'get_all_refund_payments_by_order_number',
[$this, 'getAllRefundPaymentsByOrderNumber']
'get_all_refund_payments_by_order',
[$this, 'getAllRefundPaymentsByOrder']
)
];
}
Expand Down Expand Up @@ -102,8 +102,8 @@ public function getRefundedTotal(string $orderNumber): int
return ($this->orderRefundedTotalProvider)($order);
}

public function getAllRefundPaymentsByOrderNumber(string $orderNumber): array
public function getAllRefundPaymentsByOrder(OrderInterface $order): array
{
return $this->refundPaymentRepository->findBy(['orderNumber' => $orderNumber]);
return $this->refundPaymentRepository->findBy(['order' => $order]);
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{% import '@SyliusAdmin/Common/Macro/money.html.twig' as money %}
{% set refund_payments = get_all_refund_payments_by_order_number(order.number) %}
{% set refund_payments = get_all_refund_payments_by_order(order) %}
{% if refund_payments|length > 0 %}
{% include '@SyliusAdmin/Order/Label/PaymentState/' ~ order.paymentState ~ '.html.twig' with { 'value': 'sylius.ui.' ~ order.paymentState, 'attached': true } %}
<h3 class="ui dividing header">{{ 'sylius_refund.ui.refund_payments'|trans }}</h3>
<div class="ui relaxed divided list">
{% for refund_payment in refund_payments %}
<div class="item">
<div class="right floated content">
<div class="item" {{ sylius_test_html_attribute('refund') }}>
<div class="right floated content" {{ sylius_test_html_attribute('refund-status') }}>
{% include '@SyliusRefundPlugin/Common/Label/refundPaymentState.html.twig' with {'data': refund_payment.state} %}
</div>
<i class="large payment icon"></i>
Expand All @@ -19,7 +19,7 @@
</div>
</div>
{% if sm_can(refund_payment, 'complete', 'sylius_refund_refund_payment') %}
<form action="{{ path('sylius_refund_complete_refund_payment', {'orderNumber': refund_payment.orderNumber, 'id': refund_payment.id}) }}" method="POST">
<form action="{{ path('sylius_refund_complete_refund_payment', {'orderNumber': refund_payment.orderNumber, 'id': refund_payment.id}) }}" method="POST" {{ sylius_test_html_attribute('refund-button') }}>
<button class="ui icon labeled yellow loadable button"><i class="check icon"></i> {{ 'sylius.ui.complete'|trans }}</button>
</form>
{% endif %}
Expand Down
8 changes: 4 additions & 4 deletions tests/Behat/Page/Admin/Order/ShowPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ public function hasRefundsButton(): bool

public function hasRefundPaymentsWithStatus(int $count, string $status): bool
{
$refundPayments = $this->getDocument()->findAll('css', '#refund-payments tbody tr');
$refundPayments = $this->getDocument()->findAll('css', '[data-test-refund-status]');

$refundPaymentsWithStatus = 0;
/** @var NodeElement $refundPayment */
foreach ($refundPayments as $refundPayment) {
if (strpos($refundPayment->getText(), $status)) {
if ($refundPayment->getText() == $status) {
$refundPaymentsWithStatus++;
}
}
Expand All @@ -49,7 +49,7 @@ public function hasRefundPaymentsWithStatus(int $count, string $status): bool

public function completeRefundPayment(int $number): void
{
$refundPayments = $this->getDocument()->findAll('css', '#refund-payments tbody tr');
$refundPayments = $this->getDocument()->findAll('css', '[data-test-refund-button]');

/** @var NodeElement $refundPayment */
$refundPayment = $refundPayments[$number];
Expand All @@ -59,7 +59,7 @@ public function completeRefundPayment(int $number): void

public function canCompleteRefundPayment(int $number): bool
{
$refundPayments = $this->getDocument()->findAll('css', '#refund-payments tbody tr');
$refundPayments = $this->getDocument()->findAll('css', '[data-test-refund]');

/** @var NodeElement $refundPayment */
$refundPayment = $refundPayments[$number];
Expand Down

0 comments on commit e566409

Please sign in to comment.