Repository: django-money/django-money

Issue:
Money should not override `__rsub__` method
As [reported](https://github.com/py-moneyed/py-moneyed/issues/144) in pymoneyed the following test case fails:

```python
from moneyed import Money as PyMoney
from djmoney.money import Money


def test_sub_negative():
    total = PyMoney(0, "EUR")
    bills = (Money(8, "EUR"), Money(25, "EUR"))
    for bill in bills:
        total -= bill
    assert total == Money(-33, "EUR")

# AssertionError: assert <Money: -17 EUR> == <Money: -33 EUR>
```

This is caused by `djmoney.money.Money` overriding `__rsub__`.

Discussion:
codecov-io: # [Codecov](https://codecov.io/gh/django-money/django-money/pull/594?src=pr&el=h1) Report
> Merging [#594](https://codecov.io/gh/django-money/django-money/pull/594?src=pr&el=desc) (1e72a05) into [master](https://codecov.io/gh/django-money/django-money/commit/bb222ed619f72a0112aef8c0fd9a4823b1e6e388?el=desc) (bb222ed) will **decrease** coverage by `0.23%`.
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/django-money/django-money/pull/594/graphs/tree.svg?width=650&height=150&src=pr&token=S9wbtL0BRG)](https://codecov.io/gh/django-money/django-money/pull/594?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master     #594      +/-   ##
==========================================
- Coverage   98.15%   97.91%   -0.24%     
==========================================
  Files          29       29              
  Lines         922      913       -9     
  Branches      158      158              
==========================================
- Hits          905      894      -11     
- Misses         12       14       +2     
  Partials        5        5              
```


| [Impacted Files](https://codecov.io/gh/django-money/django-money/pull/594?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [djmoney/money.py](https://codecov.io/gh/django-money/django-money/pull/594/diff?src=pr&el=tree#diff-ZGptb25leS9tb25leS5weQ==) | `100.00% <ø> (ø)` | |
| [djmoney/apps.py](https://codecov.io/gh/django-money/django-money/pull/594/diff?src=pr&el=tree#diff-ZGptb25leS9hcHBzLnB5) | `81.81% <0.00%> (-18.19%)` | :arrow_down: |
| [djmoney/models/managers.py](https://codecov.io/gh/django-money/django-money/pull/594/diff?src=pr&el=tree#diff-ZGptb25leS9tb2RlbHMvbWFuYWdlcnMucHk=) | `99.30% <0.00%> (-0.01%)` | :arrow_down: |
| [djmoney/models/fields.py](https://codecov.io/gh/django-money/django-money/pull/594/diff?src=pr&el=tree#diff-ZGptb25leS9tb2RlbHMvZmllbGRzLnB5) | `100.00% <0.00%> (ø)` | |
| [djmoney/templatetags/djmoney.py](https://codecov.io/gh/django-money/django-money/pull/594/diff?src=pr&el=tree#diff-ZGptb25leS90ZW1wbGF0ZXRhZ3MvZGptb25leS5weQ==) | `100.00% <0.00%> (ø)` | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/django-money/django-money/pull/594?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/django-money/django-money/pull/594?src=pr&el=footer). Last update [bb222ed...1e72a05](https://codecov.io/gh/django-money/django-money/pull/594?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/djmoney/money.py b/djmoney/money.py
index 70bea0b..b744c66 100644
--- a/djmoney/money.py
+++ b/djmoney/money.py
@@ -106,7 +106,6 @@ class Money(DefaultMoney):
     # we overwrite the 'targets' so the wrong synonyms are called
     # Example: we overwrite __add__; __radd__ calls __add__ on DefaultMoney...
     __radd__ = __add__
-    __rsub__ = __sub__
     __rmul__ = __mul__
 
 
diff --git a/docs/changes.rst b/docs/changes.rst
index 2643b4d..8c0b272 100644
--- a/docs/changes.rst
+++ b/docs/changes.rst
@@ -15,6 +15,7 @@ Changelog
 **Fixed**
 
 - Pin ``pymoneyed<1.0`` as it changed the ``repr`` output of the ``Money`` class.
+- Subtracting ``Money`` from ``moneyed.Money``. Regression, introduced in ``1.2``. `#593`_
 
 `1.2.2`_ - 2020-12-29
 ---------------------
@@ -694,6 +695,7 @@ wrapping with ``money_manager``.
 .. _0.3: https://github.com/django-money/django-money/compare/0.2...0.3
 .. _0.2: https://github.com/django-money/django-money/compare/0.2...a6d90348085332a393abb40b86b5dd9505489b04
 
+.. _#593: https://github.com/django-money/django-money/issues/593
 .. _#586: https://github.com/django-money/django-money/issues/586
 .. _#585: https://github.com/django-money/django-money/pull/585
 .. _#583: https://github.com/django-money/django-money/issues/583


Test patch:
diff --git a/tests/test_money.py b/tests/test_money.py
index 65199c4..bb7ea79 100644
--- a/tests/test_money.py
+++ b/tests/test_money.py
@@ -2,7 +2,7 @@ from django.utils.translation import override
 
 import pytest
 
-from djmoney.money import Money, get_current_locale
+from djmoney.money import DefaultMoney, Money, get_current_locale
 
 
 def test_repr():
@@ -114,3 +114,12 @@ def test_decimal_places_display_overwrite():
     assert str(number) == "$1.23457"
     number.decimal_places_display = None
     assert str(number) == "$1.23"
+
+
+def test_sub_negative():
+    # See GH-593
+    total = DefaultMoney(0, "EUR")
+    bills = (Money(8, "EUR"), Money(25, "EUR"))
+    for bill in bills:
+        total -= bill
+    assert total == Money(-33, "EUR")