Repository: rotki/rotki

Issue:
Crypto.com cashback and earn rewards appear as "buy" after file import
As described in the subject, after importing transactions from the mobile app csv, all CRO cashback appear as "buy". Likewise, for the weekly rewards from Crypto Earn (when you lock some crypto for specific periods and get in-kind rewards).

Rotki version: 1.23.2



Discussion:

Resolving patch:
diff --git a/rotkehlchen/data/importer.py b/rotkehlchen/data/importer.py
--- a/rotkehlchen/data/importer.py
+++ b/rotkehlchen/data/importer.py
@@ -240,10 +240,6 @@ def _consume_cryptocom_entry(self, csv_row: Dict[str, Any], **kwargs: Any) -> No
         if row_type in (
             'crypto_purchase',
             'crypto_exchange',
-            'referral_gift',
-            'referral_bonus',
-            'crypto_earn_interest_paid',
-            'referral_card_cashback',
             'card_cashback_reverted',
             'reimbursement',
             'viban_purchase',
@@ -338,6 +334,11 @@ def _consume_cryptocom_entry(self, csv_row: Dict[str, Any], **kwargs: Any) -> No
             'pay_checkout_reward',
             'transfer_cashback',
             'supercharger_reward_to_app_credited',
+            'referral_card_cashback',
+            'referral_gift',
+            'referral_bonus',
+            'crypto_earn_interest_paid',
+
         ):
             asset = asset_from_cryptocom(csv_row['Currency'])
             amount = deserialize_asset_amount(csv_row['Amount'])


Test patch:
diff --git a/rotkehlchen/tests/utils/dataimport.py b/rotkehlchen/tests/utils/dataimport.py
--- a/rotkehlchen/tests/utils/dataimport.py
+++ b/rotkehlchen/tests/utils/dataimport.py
@@ -160,18 +160,6 @@ def assert_cryptocom_import_results(rotki: Rotkehlchen):
         fee_currency=A_USD,
         link='',
         notes=get_cryptocom_note('Buy MCO'),
-    ), Trade(
-        timestamp=Timestamp(1596014223),
-        location=Location.CRYPTOCOM,
-        base_asset=A_MCO,
-        quote_asset=A_USD,
-        trade_type=TradeType.BUY,
-        amount=AssetAmount(FVal('12.32402069')),
-        rate=Price(FVal('4.057117499045678736198226879')),
-        fee=Fee(ZERO),
-        fee_currency=A_USD,
-        link='',
-        notes=get_cryptocom_note('Sign-up Bonus Unlocked'),
     ), Trade(
         timestamp=Timestamp(1596209827),
         location=Location.CRYPTOCOM,
@@ -184,18 +172,6 @@ def assert_cryptocom_import_results(rotki: Rotkehlchen):
         fee_currency=A_USD,
         link='',
         notes=get_cryptocom_note('MCO -> ETH'),
-    ), Trade(
-        timestamp=Timestamp(1596429934),
-        location=Location.CRYPTOCOM,
-        base_asset=A_ETH,
-        quote_asset=A_EUR,
-        trade_type=TradeType.BUY,
-        amount=AssetAmount(FVal('0.00061475')),
-        rate=Price(FVal('309.0687271248474989833265555')),
-        fee=Fee(ZERO),
-        fee_currency=A_USD,
-        link='',
-        notes=get_cryptocom_note('Crypto Earn'),
     ), Trade(
         timestamp=Timestamp(1596465565),
         location=Location.CRYPTOCOM,
@@ -232,30 +208,6 @@ def assert_cryptocom_import_results(rotki: Rotkehlchen):
         fee_currency=A_USD,
         link='',
         notes=get_cryptocom_note('Card Rebate: Deliveries'),
-    ), Trade(
-        timestamp=Timestamp(1602515376),
-        location=Location.CRYPTOCOM,
-        base_asset=A_CRO,
-        quote_asset=A_EUR,
-        trade_type=TradeType.BUY,
-        amount=AssetAmount(FVal('52.151')),
-        rate=Price(FVal('0.06692105616383194953116910510')),
-        fee=Fee(ZERO),
-        fee_currency=A_USD,
-        link='',
-        notes=get_cryptocom_note('Card Cashback'),
-    ), Trade(
-        timestamp=Timestamp(1602526176),
-        location=Location.CRYPTOCOM,
-        base_asset=A_CRO,
-        quote_asset=A_EUR,
-        trade_type=TradeType.BUY,
-        amount=AssetAmount(FVal('482.2566417')),
-        rate=Price(FVal('0.08756748243245604635910191136')),
-        fee=Fee(ZERO),
-        fee_currency=A_USD,
-        link='',
-        notes=get_cryptocom_note('Referral Bonus Reward'),
     ), Trade(
         timestamp=Timestamp(1606833565),
         location=Location.CRYPTOCOM,
@@ -357,7 +309,51 @@ def assert_cryptocom_import_results(rotki: Rotkehlchen):
     assert expected_movements == asset_movements
 
     expected_ledger_actions = [LedgerAction(
-        identifier=7,
+        identifier=4,
+        timestamp=Timestamp(1596014223),
+        action_type=LedgerActionType.INCOME,
+        location=Location.CRYPTOCOM,
+        amount=AssetAmount(FVal('12.32402069')),
+        asset=A_MCO,
+        rate=None,
+        rate_asset=None,
+        link=None,
+        notes=get_cryptocom_note('Sign-up Bonus Unlocked'),
+    ), LedgerAction(
+        identifier=3,
+        timestamp=Timestamp(1596429934),
+        action_type=LedgerActionType.INCOME,
+        location=Location.CRYPTOCOM,
+        amount=AssetAmount(FVal('0.00061475')),
+        asset=A_ETH,
+        rate=None,
+        rate_asset=None,
+        link=None,
+        notes=get_cryptocom_note('Crypto Earn'),
+    ), LedgerAction(
+        identifier=2,
+        timestamp=Timestamp(1602515376),
+        action_type=LedgerActionType.INCOME,
+        location=Location.CRYPTOCOM,
+        amount=AssetAmount(FVal('52.151')),
+        asset=A_CRO,
+        rate=None,
+        rate_asset=None,
+        link=None,
+        notes=get_cryptocom_note('Card Cashback'),
+    ), LedgerAction(
+        identifier=1,
+        timestamp=Timestamp(1602526176),
+        action_type=LedgerActionType.INCOME,
+        location=Location.CRYPTOCOM,
+        amount=AssetAmount(FVal('482.2566417')),
+        asset=A_CRO,
+        rate=None,
+        rate_asset=None,
+        link=None,
+        notes=get_cryptocom_note('Referral Bonus Reward'),
+    ), LedgerAction(
+        identifier=11,
         timestamp=Timestamp(1615097829),
         action_type=LedgerActionType.EXPENSE,
         location=Location.CRYPTOCOM,
@@ -368,7 +364,7 @@ def assert_cryptocom_import_results(rotki: Rotkehlchen):
         link=None,
         notes=get_cryptocom_note('Card Rebate Reversal: Netflix'),
     ), LedgerAction(
-        identifier=5,
+        identifier=9,
         timestamp=Timestamp(1616237351),
         action_type=LedgerActionType.INCOME,
         location=Location.CRYPTOCOM,
@@ -379,7 +375,7 @@ def assert_cryptocom_import_results(rotki: Rotkehlchen):
         link=None,
         notes=get_cryptocom_note('Pay Rewards'),
     ), LedgerAction(
-        identifier=6,
+        identifier=10,
         timestamp=Timestamp(1616237351),
         action_type=LedgerActionType.EXPENSE,
         location=Location.CRYPTOCOM,
@@ -390,7 +386,7 @@ def assert_cryptocom_import_results(rotki: Rotkehlchen):
         link=None,
         notes=get_cryptocom_note('To +49XXXXXXXXXX'),
     ), LedgerAction(
-        identifier=4,
+        identifier=8,
         timestamp=Timestamp(1616266740),
         action_type=LedgerActionType.INCOME,
         location=Location.CRYPTOCOM,
@@ -401,7 +397,7 @@ def assert_cryptocom_import_results(rotki: Rotkehlchen):
         link=None,
         notes=get_cryptocom_note('From +49XXXXXXXXXX'),
     ), LedgerAction(
-        identifier=3,
+        identifier=7,
         timestamp=Timestamp(1616669547),
         action_type=LedgerActionType.EXPENSE,
         location=Location.CRYPTOCOM,
@@ -412,7 +408,7 @@ def assert_cryptocom_import_results(rotki: Rotkehlchen):
         link=None,
         notes=get_cryptocom_note('Merchant XXX'),
     ), LedgerAction(
-        identifier=2,
+        identifier=6,
         timestamp=Timestamp(1616669548),
         action_type=LedgerActionType.INCOME,
         location=Location.CRYPTOCOM,
@@ -423,7 +419,7 @@ def assert_cryptocom_import_results(rotki: Rotkehlchen):
         link=None,
         notes=get_cryptocom_note('Pay Rewards'),
     ), LedgerAction(
-        identifier=1,
+        identifier=5,
         timestamp=Timestamp(1616670041),
         action_type=LedgerActionType.INCOME,
         location=Location.CRYPTOCOM,