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

Total Value does not account for Quantity #458

Open
5 tasks done
camden-bock opened this issue May 17, 2023 · 5 comments
Open
5 tasks done

Total Value does not account for Quantity #458

camden-bock opened this issue May 17, 2023 · 5 comments
Labels
bug Something isn't working

Comments

@camden-bock
Copy link

camden-bock commented May 17, 2023

First Check

  • This is not a feature request
  • I added a very descriptive title to this issue.
  • I used the GitHub search to find a similar issue and didn't find it.
  • I searched the documentation, with the integrated search.
  • I already read the docs and didn't find an answer.

Homebox Version

0.9.1

What is the issue you are experiencing?

Total Value sums the values (unit purchase price), without accounting for the quantity. It should instead sum the product of the purchase price and the quantity.

I am not very familiar with go, but this is called from frontend/pages/home/statistics.ts which calls frontend/lib/api/classes/stats.ts. I'm guessing that this then goes to line 229 in backend/internal/data/repo/repo_group.go

In 236 of repo_group.go, there is the relevant part of the query:

(SELECT SUM(purchase_price) FROM items WHERE group_items = ? AND items.archived = false) AS total_item_price,

I'm not sure if this is as simple as the following???

(SELECT SUM(purchase_price*quantity) FROM items WHERE group_items = ? AND items.archived = false) AS total_item_price,

How can the maintainer reproduce the issue?

Compare 'total value' to the sum of the BOM 'total price' column.

Deployment

Docker (Linux)

Deployment Details

No response

@camden-bock camden-bock added the bug Something isn't working label May 17, 2023
cRaZy92 added a commit to cRaZy92/homebox that referenced this issue Jul 27, 2023
@Allram
Copy link

Allram commented Aug 7, 2023

Also experiencing this.
I see that @cRaZy92 has fixed this in his own fork with commit: cRaZy92@c6bc12a

Is it possible to get this into this repo as well? :)

@cRaZy92
Copy link
Contributor

cRaZy92 commented Aug 7, 2023

Yea, it was very easy fix, I can create a pull request if that helps.

@hay-kot
Copy link
Owner

hay-kot commented Aug 10, 2023

Yea, it was very easy fix, I can create a pull request if that helps.

Yes, please do!

@cRaZy92
Copy link
Contributor

cRaZy92 commented Aug 12, 2023

Never mind, since I already have a fork with many changes I can't do another one. Sorry, I thought that I could just make PR but I can't.

@Allram
Copy link

Allram commented Aug 12, 2023

I can make one a bit later today based on your solution @cRaZy92.

Allram pushed a commit to Allram/homebox that referenced this issue Aug 12, 2023
hay-kot added a commit that referenced this issue Oct 6, 2023
* Fixed incorrect sum of the total items price

#458

* fix eslint errors

---------

Co-authored-by: Adamko <33964772+cRaZy92@users.noreply.github.com>
hay-kot added a commit that referenced this issue Jan 28, 2024
* Fixed incorrect sum of the total items price

#458

* fix eslint errors

---------

Co-authored-by: Adamko <33964772+cRaZy92@users.noreply.github.com>
Former-commit-id: f13bf29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants