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 · 22 comments
Assignees
Labels
bug Something isn't working more information requested Needs more info from OP

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.

@fanvyr
Copy link

fanvyr commented Oct 25, 2024

@Civolilah
Thanks for your help and guidance.
I've checked and there are indeed only 4 Products in the Report list. So the env-var should solve it.
But now im confused, which env file to edit.

Can you give me a hint in which folder to look?
I got everything in the /app folder. There is code , data and pkg

Here's the code folder: But all those .env files seems to be the wrong ones.

app-code-folder

Here's the data folder:

app-data-folder

The public folder is empty.

@turbo124
Copy link
Member

I've tested this locally, i think the URI is missing some additional data, my request looks something like this:

http://dv5r.test:8009/api/v1/expense_categories?status=active&per_page=1&filter=&with=Wpmbk5ezJn

note the with= this is exact ID of the category, and it is also the reason why the per_page=1 because there is only one expected result.

@turbo124 turbo124 added more information requested Needs more info from OP and removed backlog labels Oct 27, 2024
@fanvyr
Copy link

fanvyr commented Oct 27, 2024

@turbo124
I don't fully get how you're connecting this here. If the with parameter is present, wouldn't it then be right to get only one result? As I here WANT all (or lets say the normal 20), then the with parameter should not be present right?

@turbo124
Copy link
Member

turbo124 commented Oct 27, 2024

@fanvyr sorry, i see this now. Appears to only be impacting Docker installations @Civolilah
image

The network tab shows some very odd network calls to the /expense_categories route. First a call for ?per_page=100, followed by per_page=1

Non-Docker
image

@Civolilah it also looks like our default .env.example file has

VITE_IS_TEST=true

@beganovich is there any reason we bake this default into the .env.example?

@fanvyr
Copy link

fanvyr commented Oct 27, 2024

Well, we already figured out that the VITE_IS_TEST is somehow set to true based on the reports page. But I cannot figure out how to properly set it to false. Be reminded, I'm hosting it via cloudron. Well, they do deploy via docker, but they have their own "Compose" System via a Manifest.json file for each application which I cannot access or edit.

I've also created a ticket in the cloudron forum. Sadly very limited responses there.

@turbo124
Copy link
Member

@fanvyr the issue is not on your side, i believe the pipeline we use to produce the build has it set to true by default.

@beganovich
Copy link
Member

@turbo124 not that I know about. We'll switch to VITE_IS_TEST=false by default & update the CI.

@beganovich beganovich added bug Something isn't working and removed more information requested Needs more info from OP labels Oct 28, 2024
@beganovich beganovich added the more information requested Needs more info from OP label Oct 28, 2024
@fanvyr
Copy link

fanvyr commented Oct 28, 2024

@turbo124 not that I know about. We'll switch to VITE_IS_TEST=false by default & update the CI.

Perfect. Can you let me know when its done?

Thank you so much

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working more information requested Needs more info from OP
Projects
None yet
Development

No branches or pull requests

5 participants