Commit 47abd96d by Clinton Blackburn Committed by Clinton Blackburn

Disabled refund notifications for free orders

ECOM-6975
parent 7ea2a493
...@@ -137,7 +137,7 @@ class Refund(StatusMixin, TimeStampedModel): ...@@ -137,7 +137,7 @@ class Refund(StatusMixin, TimeStampedModel):
) )
if total_credit_excl_tax == 0: if total_credit_excl_tax == 0:
refund.approve() refund.approve(notify_purchaser=False)
return refund return refund
...@@ -232,7 +232,7 @@ class Refund(StatusMixin, TimeStampedModel): ...@@ -232,7 +232,7 @@ class Refund(StatusMixin, TimeStampedModel):
logger.error('Unable to revoke fulfillment of all lines of Refund [%d].', self.id) logger.error('Unable to revoke fulfillment of all lines of Refund [%d].', self.id)
self.set_status(REFUND.REVOCATION_ERROR) self.set_status(REFUND.REVOCATION_ERROR)
def approve(self, revoke_fulfillment=True): def approve(self, revoke_fulfillment=True, notify_purchaser=True):
if not self.can_approve: if not self.can_approve:
logger.debug('Refund [%d] cannot be approved.', self.id) logger.debug('Refund [%d] cannot be approved.', self.id)
return False return False
...@@ -240,7 +240,8 @@ class Refund(StatusMixin, TimeStampedModel): ...@@ -240,7 +240,8 @@ class Refund(StatusMixin, TimeStampedModel):
try: try:
self._issue_credit() self._issue_credit()
self.set_status(REFUND.PAYMENT_REFUNDED) self.set_status(REFUND.PAYMENT_REFUNDED)
self._notify_purchaser() if notify_purchaser:
self._notify_purchaser()
except PaymentError: except PaymentError:
logger.exception('Failed to issue credit for refund [%d].', self.id) logger.exception('Failed to issue credit for refund [%d].', self.id)
self.set_status(REFUND.PAYMENT_REFUND_ERROR) self.set_status(REFUND.PAYMENT_REFUND_ERROR)
......
...@@ -171,7 +171,8 @@ class RefundTests(RefundTestMixin, StatusTestsMixin, TestCase): ...@@ -171,7 +171,8 @@ class RefundTests(RefundTestMixin, StatusTestsMixin, TestCase):
# Verify that the order totals $0. # Verify that the order totals $0.
self.assertEqual(order.total_excl_tax, 0) self.assertEqual(order.total_excl_tax, 0)
refund = Refund.create_with_lines(order, list(order.lines.all())) with mock.patch.object(Refund, '_notify_purchaser') as mock_notify:
refund = Refund.create_with_lines(order, list(order.lines.all()))
# Verify that refund lines are not revoked. # Verify that refund lines are not revoked.
self.assertFalse(mock_revoke_line.called) self.assertFalse(mock_revoke_line.called)
...@@ -180,6 +181,9 @@ class RefundTests(RefundTestMixin, StatusTestsMixin, TestCase): ...@@ -180,6 +181,9 @@ class RefundTests(RefundTestMixin, StatusTestsMixin, TestCase):
self.assertEqual(refund.status, REFUND.COMPLETE) self.assertEqual(refund.status, REFUND.COMPLETE)
self.assertEqual(set([line.status for line in refund.lines.all()]), {REFUND_LINE.COMPLETE}) self.assertEqual(set([line.status for line in refund.lines.all()]), {REFUND_LINE.COMPLETE})
# Verify no notification is sent to the purchaser
self.assertFalse(mock_notify.called)
@ddt.unpack @ddt.unpack
@ddt.data( @ddt.data(
(REFUND.OPEN, True), (REFUND.OPEN, True),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment