diff --git a/admin-dev/themes/default/template/controllers/orders/helpers/view/view.tpl b/admin-dev/themes/default/template/controllers/orders/helpers/view/view.tpl
index 8a8e8c6859798..d2fa21e143dac 100755
--- a/admin-dev/themes/default/template/controllers/orders/helpers/view/view.tpl
+++ b/admin-dev/themes/default/template/controllers/orders/helpers/view/view.tpl
@@ -53,6 +53,15 @@
statesShipped.push({$state['id_order_state']});
{/if}
{/foreach}
+ var order_discount_price = {if ($order->getTaxCalculationMethod() == $smarty.const.PS_TAX_EXC)}
+ {$order->total_discounts_tax_excl}
+ {else}
+ {$order->total_discounts_tax_incl}
+ {/if};
+ var okButton = "{l s='Yes'}";
+ var cancelButton = "{l s='No'}";
+ var alertTitle = "{l s='Voucher refund'}";
+ var alertMsg = "{l s='Do you want to refund the voucher?'}";
{assign var="hook_invoice" value={hook h="displayInvoice" id_order=$order->id}}
diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php
index c08c14b409da9..cee6183b7ad2e 100755
--- a/controllers/admin/AdminOrdersController.php
+++ b/controllers/admin/AdminOrdersController.php
@@ -656,6 +656,9 @@ public function postProcess()
$this->reinjectQuantity($order_detail, $order_detail_list[$id_order_detail]['quantity']);
}
+ if (Tools::isSubmit('refund_voucher_off'))
+ $amount -= Tools::getValue('order_discount_price');
+
$shipping_cost_amount = (float)str_replace(',', '.', Tools::getValue('partialRefundShippingCost'));
if ($shipping_cost_amount > 0)
$amount += $shipping_cost_amount;
@@ -867,6 +870,9 @@ public function postProcess()
if (Tools::isSubmit('generateCreditSlip') && !count($this->errors))
{
$product_list = array();
+ if (Tools::isSubmit('refund_voucher_off'))
+ $amount = $order_detail->unit_price_tax_incl * $full_quantity_list[$id_order_detail] - Tools::getValue('order_discount_price');
+
foreach ($full_product_list as $id_order_detail)
{
$order_detail = new OrderDetail((int)$id_order_detail);
@@ -874,7 +880,7 @@ public function postProcess()
'id_order_detail' => $id_order_detail,
'quantity' => $full_quantity_list[$id_order_detail],
'unit_price' => $order_detail->unit_price_tax_excl,
- 'amount' => $order_detail->unit_price_tax_incl * $full_quantity_list[$id_order_detail],
+ 'amount' => $amount ? $amount : $order_detail->unit_price_tax_incl * $full_quantity_list[$id_order_detail],
);
}
@@ -935,6 +941,9 @@ public function postProcess()
if (Tools::isSubmit('shippingBack'))
$total += $order->total_shipping;
+ if (Tools::isSubmit('refund_voucher_off'))
+ $total -= Tools::getValue('order_discount_price');
+
$cartrule->reduction_amount = $total;
$cartrule->reduction_tax = true;
$cartrule->minimum_amount_currency = $order->id_currency;
diff --git a/js/admin_order.js b/js/admin_order.js
index 09daa177a2c27..4f789b0b04d37 100644
--- a/js/admin_order.js
+++ b/js/admin_order.js
@@ -856,7 +856,24 @@ $(document).ready(function() {
$('.partial_refund_fields').hide();
$('.standard_refund_fields').fadeIn();
}
+
+ if (order_discount_price)
+ $('.container-command-top-spacing').submit(function(e) {
+ e.preventDefault();
+ var that = $(this);
+ $.alerts.okButton= okButton;
+ $.alerts.cancelButton= cancelButton;
+ jConfirm(alertMsg, alertTitle, function(confirm){
+ if (confirm === false) {
+ that.append('');
+ that.append('');
+ }
+ that.append('');
+ that.unbind('submit').submit();
+ });
+ });
});
+
$('#desc-order-partial_refund').click(function() {
$('.cancel_product_change_link:visible').trigger('click');
closeAddProduct();
@@ -871,6 +888,22 @@ $(document).ready(function() {
$('.product_action').hide();
$('.partial_refund_fields').fadeIn();
}
+
+ if (order_discount_price)
+ $('.container-command-top-spacing').submit(function(e) {
+ e.preventDefault();
+ var that = $(this);
+ $.alerts.okButton= okButton;
+ $.alerts.cancelButton= cancelButton;
+ jConfirm(alertMsg, alertTitle, function(confirm){
+ if (confirm === false) {
+ that.append('');
+ that.append('');
+ }
+ that.append('');
+ that.unbind('submit').submit();
+ });
+ });
});
});