Skip to content

[FR] Price parsing in data importer should allow more formats #10583

Open

Description

@hvraven

Please verify that this feature request has NOT been suggested before.

  • I checked and didn't find a similar feature request

Problem statement

Currently the data importer expects price information to be a valid float value. When using the importer to upload data for a purchase order this easily fails, as vendors format their data differently.

The concrete example I ran into is a shop, which adds the currency to the price, i.e. the entries are 1.23 €. Additionally there is the extra annoyance of the German tendency to use , for separation, so we also have a mixture of 1.23 and 1,23 (plus 1,23 €).

Suggested solution

As the importer knows based on the column, that the data should contain prices, it should drop any added currency symbols on front or back (any non-numbers).
Ideally it would also detect "german" notation (maybe others use it as well), and translate it to proper floats before parsing.

Describe alternatives you've considered

None

Examples of other systems

No response

Do you want to develop this?

  • I want to develop this. (I need some pointers where to start. I know a lot of Python, but barely any TypeScript and don't know there such parsing should be located)

Activity

  1. added
    enhancement
    triage:not-checked
    on Oct 14, 2025
  2. added
    import / export
    and removed
    triage:not-checked
    on Oct 14, 2025
  3. matmair commented on Oct 14, 2025

    @matmair
    Member

    Would certainly be a good addition. All code for imports is in src/backend/InvenTree/importer - I do not think there will be a need for a lot or even any typescript

  4. SchrodingersGat commented on Oct 14, 2025

    @SchrodingersGat
    Member

    We also handle money values using custom classes already - so potentially these could be adjusted to provide automatic conversion when de-serializing from an imported file:

    class InvenTreeMoneySerializer(MoneyField):

    class InvenTreeModelMoneyField(ModelMoneyField):

  5. added this to the 1.1.0 milestone on Oct 14, 2025
  6. SchrodingersGat commented on Oct 20, 2025

    @SchrodingersGat
    Member

    @hvraven any thoughts on this? Happy to help where I can

  7. hvraven commented on Oct 23, 2025

    @hvraven
    ContributorAuthor

    I started setting up a dev environment and dug a bit in the code spots mentioned. I would hook the logic into the extract_data function. It already handles parsing of booleans and dates as special types.

    if field_type == 'boolean':
    value = InvenTree.helpers.str2bool(value)
    elif field_type == 'date':
    value = value or None

    Currently the currency entries have the field_type set to decimal. Could that be changed to a special currency type? It would be a decimal, but with the special meaning of encoding currency. Or would that break a lot of other stuff. I couldn't immediately find the definition where the field_type is defined.

  8. SchrodingersGat commented on Oct 23, 2025

    @SchrodingersGat
    Member

    Could that be changed to a special currency type?

    We could probably support this. Have a look at how the custom serializer classes I linked above work

  9. modified the milestones: 1.1.0, 1.2.0 on Nov 1, 2025
  10. SchrodingersGat commented on Dec 9, 2025

    @SchrodingersGat
    Member

    @hvraven looking into this further, we could update the InvenTreeMoneySerializer class to provide more "lenient" parsing of pricing information.

    However - we would need to write a parser that can handle different locale formats, etc. Currently the only alternative solution is to properly sanitize the dataset before importing.

    Would you like to look into this? Otherwise I don't think it will receive any priority from the core dev team

  11. modified the milestones: 1.2.0, 1.3.0 on Feb 10, 2026
  12. SchrodingersGat commented on Mar 11, 2026

    @SchrodingersGat
    Member

    As this has not received any attention - and the core dev team is stretched - I will bump this to the 2.0.0 milestone.

  13. modified the milestones: 1.3.0, 2.0.0 on Mar 11, 2026
  14. matmair commented on Apr 2, 2026

    @matmair
    Member

    pymoney, which we already have and in the code base can handle parsing of currency data from a string

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementimport / export

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions