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

Take category classification logic from a json instead of code and expose it in the configuration screen #31

Open
brafdlog opened this issue May 5, 2020 · 1 comment
Labels

Comments

@brafdlog
Copy link
Owner

brafdlog commented May 5, 2020

Currently the logic for classifying a transaction relies on the categoryCalculationScript.js.
Most of the logic there is matching patterns of descriptions to patterns or exact matches.
In order to make this easily configurable by the user, we want to move this logic to a json configuration that will contain the list of patterns and exact matches.
After this is taken from the json, expose a ui for managing this in the config screen.

Notes:

  1. We need to allow people to have their own setup - both control category names and control the mapping, because this is something that is not consistent across people and across budgeting tools. In the future we may consider having this configuration per output vendor.
  2. We want this to work both in development from the repository and for the released electron app.
  3. When running for the first time (either in dev or released electron app) should work with a default configuration without requiring an initial setup.
  4. In future consider supporting regex patterns, but not required for initial phase.
  5. Write unit tests for this logic.

Proposed solution:

The getCategoryNameByTransactionDescription will fetch this json and use it to get the transaction category according to the following logic:

Look for an exact match for the transaction description string in the exactMatches arrays.

If not found fall back to looking for substring matches in the patternMatches arrays.

JSON structure:

{
  "exactMatches": {
    "electricity": ["חברת חשמל", "חיוב חשמל חודשי"],
    "groceries": ["המכולת של יהונתן", "המכולת של ברוך"]
  },
  "patternMatches": {
    "car maintenance": ["מוסך", "טסט"],
    "groceries": ["מכולת"]
  }
}

This json should be saved in a place where it can be used both in development and in release. There are a few options to implement this, see open questions.

Have a defaultCategoryMapping.json file committed to git. If the user has no mapping logic defined yet, take the default and save it as the user's json for future customization.

Open questions:

  1. Should this be part of the config or separate json?
  2. Where should this be stored? Could be a json file or local storage etc. See: https://medium.com/cameron-nokes/how-to-store-user-data-in-electron-3ba6bf66bc1e
  3. Need to verify it works nicely with Hebrew category names and patterns.
@brafdlog
Copy link
Owner Author

@baruchiro I updated the description, please take a look and see what you think.

@brafdlog brafdlog added this to the M5 Post MVP publish milestone Dec 17, 2020
@baruchiro baruchiro pinned this issue Jan 12, 2023
@baruchiro baruchiro unpinned this issue Aug 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants