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

Expense category options not displaying in drop down menu when entering expense (repeat bug) #2151

Open
TekWarren opened this issue Jul 29, 2024 · 14 comments
Assignees
Labels

Comments

@TekWarren
Copy link

Setup

  • Version: latest
  • Environment: docker

Interface

  • React: []

Describe the bug

This is a repeat bug although I can not find the previous post I submitted here or on the forum:
Expense Category drop down is not displaying the full list of options. I am able to start typing the name of the other options and then I can select the corresponding item.

Steps To Reproduce

Create new expense having multiple expense categories, click drop down option, only one item is displayed.

Expected Behavior

All expense categories displayed in drop down menu.

Additional context

I can't find my previous report of this but seemed like a quick fix. I can reproduce this in two different local instances, also cleared browser cache/cookies same result.

Screenshots

Can add if requested.

@turbo124
Copy link
Member

We only bring down the first 20 expense categories, the rest are searchable (if nothing local, then we perform the search over the api)

@turbo124 turbo124 added the question Further information is requested label Jul 30, 2024
@TekWarren
Copy link
Author

I only have 5-6 categories. This has come up before.

...not a question...

@turbo124
Copy link
Member

Cannot recreate.

@TekWarren
Copy link
Author

I have a prod and test instance, it occurs in both. I'll make sure I'm on latest again and screenshot later if it still present.

@TekWarren
Copy link
Author

Just pulled latest, tested in two different browsers. You had me look for something specific in the browser console last time this happened but I don't recall what it was. Seems I had to just wait it out last time and at some point after some releases it was normal again...I can type out my known categories so I guess I will do that for now.
image
image

@TekWarren
Copy link
Author

TekWarren commented Jul 30, 2024

One more question...you said only 20 categories are shown in this menu by default. Is it possible this setting is stuck at 1 in both my instances? Is this something I can look for in the DB or is this hard coded?

@turbo124
Copy link
Member

check your browser console and inspect what the query parameter looks like for

/api/v1/expense_categories.

if this is for an existing expense with a category already assigned, inspect what the payload looks like there.

@TekWarren
Copy link
Author

This was noticed upon entering new expenses but does occur on existing (only one category shown and no "list").

I'll be honest I found references in the console to /api/v1/expense_categories but I have no idea what I'm looking for nor would I understand if something is off. -Sorry I have next to no programing knowledge. I think I am in the area but don't know what would be helpful to report back.

I think this is where I was kind of left just typing the categories in previously across some versions and then all the sudden after some update the expense category list was working again.

Thank you

@fanvyr
Copy link

fanvyr commented Oct 23, 2024

i host 5 servers with invoice ninja instances and found the same bug in ALL of them. Must have come with some update.
The issue is actually, that the request for the expense_categories asks the server for 1 result per page.
Not 20....
CleanShot 2024-10-23 at 14 47 18
So the result is obviously only 1 category (mostly the last created one..)

Is there an option to change that in the settings or is it hardcoded?

Thanks

@turbo124 turbo124 transferred this issue from invoiceninja/invoiceninja Oct 23, 2024
@turbo124 turbo124 added backlog and removed question Further information is requested labels Oct 23, 2024
@turbo124
Copy link
Member

turbo124 commented Oct 23, 2024

Can you provide the screenshot from the headers tab as well please. we'd need to see the full URI

@Civolilah
Copy link
Collaborator

@fanvyr Hey, I just checked the behavior of the Expense Selector that you're having issue with. We have some tests made for this selector, and for testing certain edge cases, we used the VITE_IS_TEST environment variable. I'm not sure why it's set to "true" by default in your docker setup. This variable can cause the dropdown to show just one item instead of all of them. If the VITE_IS_TEST variable is set to "true" in your .env file, that would explain what you're experiencing.

Please let me know if I can help you with anything else.

@fanvyr
Copy link

fanvyr commented Oct 24, 2024

Hey,

thanks for the Feedback.

@turbo124
Sorry, cannot give you the full Headers Tab, but the full URI i can give you (except my selfhosted-url ;-)

/api/v1/expense_categories?status=active&per_page=1&sort=name%7Casc&filter= 

@Civolilah
How you're figuring the VITE_IS_TEST is set to true ?
I'm using Cloudron for deploying. I just checked the .env file, and the VITE_IS_TEST is not listed there at all. I will though add it and set it to false, to try it. Will update this post.

Thanks Guys

EDIT:
i did add the VITE_IS_TEST = false and restarted the app. Nothing changed sadly.

@TekWarren
Copy link
Author

Just wanted to pop in here and say thank you to those who have added to this issue. It's nice to see some traction on an issue that was dismissed and I have been just dealing with since reporting the second time.

I am following the conversation and will try to provide additional information if possible/needed.

@Civolilah
Copy link
Collaborator

Hey,

thanks for the Feedback.

@turbo124 Sorry, cannot give you the full Headers Tab, but the full URI i can give you (except my selfhosted-url ;-)

/api/v1/expense_categories?status=active&per_page=1&sort=name%7Casc&filter= 

@Civolilah How you're figuring the VITE_IS_TEST is set to true ? I'm using Cloudron for deploying. I just checked the .env file, and the VITE_IS_TEST is not listed there at all. I will though add it and set it to false, to try it. Will update this post.

Thanks Guys

EDIT: i did add the VITE_IS_TEST = false and restarted the app. Nothing changed sadly.

@fanvyr Thanks for helping us debug the issue you're experiencing. I've deeply checked the logic and found that we never set per_page to 1 except in this one case, and nothing can set it programmatically through the code. However, you clearly have an issue since the URL shows it. I'm still quite sure that the .env file in the REACT project is causing this for you. To be 100% certain, you can check one more detail where we use the same variable for tests. On the Reports page, please select "Invoice Item" report and then check the "Products" dropdown. If you have MORE than 4 products, there should be only 4 products in the dropdown if your .env file has the VITE_IS_TEST variable accidentally set to "true".

Helpful screenshot:

Screenshot 2024-10-24 at 17 39 49

If there are only 4 products in the dropdown but you have more than 4 "Active" products in your Products table, we're certain that you just need to delete or set this .env variable to "false".

Just please make sure you're configuring the .env file in the React (frontend) project, not in the PHP (backend). To ensure you're changing the right file, verify that there's a VITE_API_URL variable present - if this variable exists in that same file, you're configuring the correct file.

Please let me know if you experience any additional issues.

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

4 participants