diff --git a/src/Plugin.php b/src/Plugin.php index de9971e2..6f951daa 100644 --- a/src/Plugin.php +++ b/src/Plugin.php @@ -1147,6 +1147,9 @@ public static function create_refund( Refund $refund ) { $payment->refunds[] = $refund; $refunded_amount = $payment->get_refunded_amount(); + if ( $refunded_amount->is_zero() && $refunded_amount->get_currency() !== $refund->get_amount()->get_currency() ) { + $refunded_amount->set_currency( $refund->get_amount()->get_currency() ); + } $refunded_amount = $refunded_amount->add( $refund->get_amount() ); diff --git a/views/meta-box-payment-lines.php b/views/meta-box-payment-lines.php index 86d22afd..123e9f47 100644 --- a/views/meta-box-payment-lines.php +++ b/views/meta-box-payment-lines.php @@ -203,12 +203,20 @@ function ( PaymentLine $line ) { $line_total = $refund_line->get_total_amount(); + if ( $refunded_amount->is_zero() && $refunded_amount->get_currency() !== $line_total->get_currency() ) { + $refunded_amount->set_currency( $line_total->get_currency() ); + } + $refunded_amount = $refunded_amount->add( $line_total ); if ( $line_total instanceof TaxedMoney ) { $tax_amount = $line_total->get_tax_amount(); if ( null !== $tax_amount ) { + if ( $refunded_tax->is_zero() && $refunded_tax->get_currency() !== $tax_amount->get_currency() ) { + $refunded_tax->set_currency( $tax_amount->get_currency() ); + } + $refunded_tax = $refunded_tax->add( $tax_amount ); } }