Skip to content

Commit

Permalink
MOL-657: Fix Mollie Refund Warnings magmodules#2 (mollie#291)
Browse files Browse the repository at this point in the history
  • Loading branch information
KienerNL authored Feb 11, 2022
1 parent 1829430 commit ccc7a7a
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,17 +146,17 @@ Component.override('sw-order-line-items-grid', {
},

refundAmountPending() {
let total = 0.0;
let total = 0;
this.refunds.forEach((refund) => {
if(refund.isPending || refund.isQueued) {
total += (refund.amount.value || 0);
total += (refund.amount.value * 100 || 0);
}
});
return total;
return Math.max(0, total / 100);
},

orderRefundAmount() {
return this.order.amountTotal - this.refundedAmount - this.refundAmountPending;
return Math.max(0, ((this.order.amountTotal * 100) - (this.refundedAmount * 100) - (this.refundAmountPending * 100)) / 100);
},

refundAmountHigherThanOrderThreshold() {
Expand Down Expand Up @@ -247,12 +247,12 @@ Component.override('sw-order-line-items-grid', {
.then((response) => {
if (response.success) {
this.createNotificationSuccess({
message: this.$tc('mollie-payments.modals.refund.success'),
message: this.$tc('mollie-payments.modals.refund.cancelSuccess'),
});
this.showRefundModal = false;
} else {
this.createNotificationError({
message: this.$tc('mollie-payments.modals.refund.error'),
message: this.$tc('mollie-payments.modals.refund.cancelError'),
});
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@
refundAmount : currency(refundAmount, order.currency.shortName),
}) }}
<template #actions>
<sw-button @click="setRefundAmount(orderRefundAmount)">
<sw-button @click="setRefundAmount(orderRefundAmount)" v-if="orderMaximum > 0">
{{ $tc('mollie-payments.modals.refund.warning.refundAmountButton', 0, {
amount: currency(orderRefundAmount, order.currency.shortName)
}) }}
Expand All @@ -172,13 +172,13 @@
refundAmount : currency(refundAmount, order.currency.shortName),
}) }}
<template #actions>
<sw-button @click="setRefundAmount(orderRefundAmount)">
<sw-button @click="setRefundAmount(orderRefundAmount)" v-if="orderMaximum > 0">
{{ $tc('mollie-payments.modals.refund.warning.refundAmountButton', 0, {
amount: currency(orderRefundAmount, order.currency.shortName)
}) }}
</sw-button>
<sw-button v-if="remainingAmount > orderRefundAmount"
@click="setRefundAmount(remainingAmount)">
@click="setRefundAmount(remainingAmount)" v-if="remainingAmount > 0">
{{ $tc('mollie-payments.modals.refund.warning.refundAmountButton', 0, {
amount: currency(remainingAmount, order.currency.shortName)
}) }}
Expand Down
6 changes: 4 additions & 2 deletions src/Resources/app/administration/src/snippet/de-DE.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,12 @@
"title": "Rückerstattung über Mollie",
"success": "Es wurde eine Rückerstattung bei Mollie erstellt. Es kann bis zu 2 Stunden dauern, bis die Rückerstattung abgeschlossen ist. Bis dahin können Sie die Rückerstattung stornieren.",
"error": "Beim Erstellen einer Rückerstattung ist etwas schief gelaufen.",
"cancelSuccess": "Die Erstattung wurde storniert.",
"cancelError": "Beim Versuch, diese Erstattung zu stornieren, ist etwas schief gelaufen.",
"warning": {
"low-amount": "Bitte geben Sie einen zu erstattenden Betrag ein.",
"orderThreshold": "Achtung, Sie versuchen, mehr als den Gesamtbetrag dieser Bestellung zu erstatten ({orderMaximum}.)",
"mollieThreshold": "Der Betrag, den Sie zu erstatten versuchen, übersteigt den von Mollie erlaubten Höchstbetrag ({mollieMaximum}.)",
"orderThreshold": "Achtung, Sie versuchen, mehr als den verbleibenden Gesamtbetrag dieser Bestellung zu erstatten ({orderMaximum})",
"mollieThreshold": "Der Betrag, den Sie zu erstatten versuchen, übersteigt den von Mollie erlaubten Höchstbetrag ({mollieMaximum})",
"refundAmountButton": "{amount} zurückerstatten"
},
"confirmButton": "Rückerstatten",
Expand Down
6 changes: 4 additions & 2 deletions src/Resources/app/administration/src/snippet/en-GB.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,12 @@
"title": "Refund through Mollie",
"success": "A refund has been created in Mollie. It may take 2 hours for the refund to complete. Until this time, you can cancel the refund.",
"error": "Something went wrong creating a refund.",
"cancelSuccess": "The refund has been canceled.",
"cancelError": "Something went wrong trying to cancel this refund.",
"warning": {
"low-amount": "Please enter an amount to be refunded.",
"orderThreshold": "Attention, you are trying to refund more than the total amount of this order ({orderMaximum}.)",
"mollieThreshold": "The amount you're trying to refund exceeds the maximum amount allowed by Mollie ({mollieMaximum}.)",
"orderThreshold": "Attention, you are trying to refund more than the total amount remaining on this order ({orderMaximum})",
"mollieThreshold": "The amount you're trying to refund exceeds the maximum amount allowed by Mollie ({mollieMaximum})",
"refundAmountButton": "Refund {amount}"
},
"confirmButton": "Refund",
Expand Down
6 changes: 4 additions & 2 deletions src/Resources/app/administration/src/snippet/nl-NL.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,12 @@
"title": "Terugbetaling via Mollie",
"success": "Er is een terugbetaling aangemaakt bij Mollie. Het kan 2 uur duren voordat de terugbetaling is voltooid. Tot deze tijd kunt u de terugbetaling annuleren.",
"error": "Er is iets mis gegaan bij het aanmaken van een terugbetaling.",
"cancelSuccess": "De terugbetaling is geannuleerd.",
"cancelError": "Er is iets misgegaan bij het proberen te annuleren van deze terugbetaling.",
"warning": {
"low-amount": "Voer een terug te betalen bedrag in.",
"orderThreshold": "Attentie, u probeert meer terug te betalen dan het totaalbedrag van deze bestelling ({orderMaximum}.)",
"mollieThreshold": "Het bedrag dat u probeert terug te betalen overschrijdt het maximumbedrag dat is toegestaan door Mollie ({mollieMaximum}.)",
"orderThreshold": "Attentie, u probeert meer terug te betalen dan het overgebleven totaalbedrag van deze bestelling ({orderMaximum})",
"mollieThreshold": "Het bedrag dat u probeert terug te betalen overschrijdt het maximumbedrag dat is toegestaan door Mollie ({mollieMaximum})",
"refundAmountButton": "{amount} terugbetalen"
},
"confirmButton": "Terugbetalen",
Expand Down

0 comments on commit ccc7a7a

Please sign in to comment.