inventree / inventree-python

Python library for communication with inventree via API
https://docs.inventree.org/en/latest/api/python/python/
MIT License
26 stars 34 forks source link

How to convert currencies #163

Closed gunstr closed 1 year ago

gunstr commented 1 year ago

I have done inventory valuation for tax purposes by exporting all stock items to excel using the admin panel in InvenTree and then filter out what items should be included in excel. One challenge I had was that stock items were exported in purchase price currency why I had to do the conversions in excel.

Now I am looking for alternatives and have tested to create a similar table using the Python model but are ending up with the same problem. What I want to do is to get all prices in the default currency directly or have the possibility to do a conversion using the InvenTree conversion rates before I create the excel file.

I see there is a Currency class in the inventree-python code but I have not been able to figure out how to use it. Is it's even possible to use it for conversion or to get the exchange rate in this way? If so I would appreciate a pointer in the right direction.

SchrodingersGat commented 1 year ago

@gunstr as luck would have it, I've just finished adding a new current API support for InvenTree - https://github.com/inventree/InvenTree/pull/4293

Subsequently I have also updated the Python interface to support this - https://github.com/inventree/inventree-python/pull/164

The new currency features are documented here - https://docs.inventree.org/en/latest/api/python/currency/

You will have to update to the latest version of the python bindings - 0.10.0 - https://pypi.org/project/inventree/

Also, you'll need to update your server. The new features will be available in the upcoming 0.10.0 server release, or available now on latest/master

gunstr commented 1 year ago

Awesome - works like a charm! Many thanks @SchrodingersGat