Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Can't add activity via API because of currency mismatch #3094

Open
brhahlen opened this issue Mar 4, 2024 · 5 comments
Open

[BUG] Can't add activity via API because of currency mismatch #3094

brhahlen opened this issue Mar 4, 2024 · 5 comments

Comments

@brhahlen
Copy link

brhahlen commented Mar 4, 2024

Important Notice

The issue tracker is ONLY used for reporting bugs. New features should be discussed in our Slack community or in Discussions.

Incomplete or non-reproducible issues may be closed, but we are here to help! If you encounter difficulties reproducing the bug or need assistance, please reach out to our community channels mentioned above.

Thank you for your understanding and cooperation!

Bug Description

When trying to add a new activity via the API, the following error pops up:

{
    "error": "Bad Request",
    "message": [
        "activities.0.currency (\"EUR\") does not match with currency of bitcoin (\"USD\")"
    ]
}

This used to work in a previous version of Ghostfolio.

To Reproduce

  1. Send the following request:
{
  "activities": [
    {
      "accountId": "ACCOUNTID",
      "currency": "EUR",
      "dataSource": "COINGECKO",
      "date": "2024-03-03T16:26:00.000Z",
      "fee": 0.04,
      "quantity": 0.00030409,
      "symbol": "bitcoin",
      "type": "BUY",
      "unitPrice": 57405
    }
  ]
}

Expected behavior

In a previous version of Ghostfolio, this API call would work without problem, as it would just convert the EUR to USD.

Adding the activity manually via the GUI works, even when setting the currency to EUR.

Screenshots

Logs

ghostfolio  | [Nest] 142  - 03/04/2024, 9:53:02 AM   ERROR [class ImportController{constructor(e,t,a){this.configurationService=e,this.importService=t,this.request=a}async import(t,a=!1){if(!Qa(this.request.user.permissions,Oa))throw new e.HttpException((0,gt.getReasonPhrase)(gt.StatusCodes.FORBIDDEN),gt.StatusCodes.FORBIDDEN);let r=this.configurationService.get("MAX_ACTIVITIES_TO_IMPORT");this.configurationService.get("ENABLE_FEATURE_SUBSCRIPTION")&&"Premium"===this.request.user.subscription.type&&(r=Number.MAX_SAFE_INTEGER);try{return{activities:await this.importService.import({isDryRun:a,maxActivitiesToImport:r,accountsDto:t.accounts??[],activitiesDto:t.activities,user:this.request.user})}}catch(o){throw e.Logger.error(o,Xc),new e.HttpException({error:(0,gt.getReasonPhrase)(gt.StatusCodes.BAD_REQUEST),message:[o.message]},gt.StatusCodes.BAD_REQUEST)}}async gatherDividends(e,t){const a=this.request.user.Settings.settings.baseCurrency;return{activities:await this.importService.getDividends({dataSource:e,symbol:t,userCurrency:a})}}}] Error: activities.0.currency ("EUR") does not match with currency of bitcoin ("USD")

Environment

  • Ghostfolio Version 2.60.0
  • Self-hosted
  • Experimental Features Enabled
  • Firefox
  • Windows
  • API call via Postman

Additional context

@obarlev
Copy link

obarlev commented Mar 8, 2024

Same issue for me

@christoph93
Copy link
Contributor

I get the same error when using the import activities functions.
image
So I tried setting the dataSource to MANUAL in my import file, but then I get this error:
image
I can import it manually by adding an activity and setting the currency to EUR, but it's converted to USD anyway.

@brhahlen
Copy link
Author

brhahlen commented Apr 4, 2024

Issue is still present in the latest version.

@jvyoralek
Copy link

I'm experiencing the same issue. It's quite common for transactions to be conducted in a currency different from the asset's currency because they are typically converted into the account's currency.

However, when I attempt to insert a record via the API, it fails, even though inserting the same transaction through the UI succeeds without any problems and includes automatic conversion to the asset's currency.

Example

API

{
    "accountId": "c50ea5fe-ce5b-47e0-ba82-c46b4fa04a91",
    "currency": "EUR",
    "dataSource": "YAHOO",
    "date": "2022-07-27T19:56:32+00:00",
    "fee": 0,
    "quantity": 1.0,
    "symbol": "META",
    "type": "BUY",
    "unitPrice": 166.25
}

will end with:

{
    "error": "Bad Request",
    "message": [
        "activities.0.currency (\"EUR\") does not match with currency of META (\"USD\")"
    ]
}

UI

image

image

Ghostfolio Version 2.70.0

@steffen-lorenz
Copy link

steffen-lorenz commented Apr 22, 2024

I'm currently having the same issue (self-hosted), and if i add the transaction manually, every view like e.g. Holdings says "Oops! Something went wrong. Please try again later."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants