Skip to content

Rounding problems when using fractional quantities #242

@jbullock35

Description

@jbullock35

LighterPack displays the total quantity of units in each section. Usually, users have only integer values for units of things that they carry, and in that case, this feature works fine.

But at https://lighterpack.com/r/zu7cb9, it's not working fine. The consumables section of my list looks like this:

Image

Possible solution

The quantity being displayed with so many digits is category.subtotalQty in client/components/category.vue. In turn, I think that the bug can be fixed by changing this line in the calculateSubtotal() function: https://github.com/galenmaly/lighterpack/blob/master/client/dataTypes.js#L107. But I am out of my depth, so I'm reluctant to file a PR.

Related: why use fractional quantities for gear?

You may wonder: does it ever make sense for users to input fractional quantities. Yes, it does. For example, a user may carry a different amount of water for each trip. But instead of creating a new "water" gear item for each trip, the cleaner approach is to create a single "water" item—1L of water, weighing 1kg—and then to adjust the quantity as needed for individual trips. For example, you may take 1.0 "quantity" of water for this month's trip, 2.25 "quantity" of water for next month's trip, and 3.33 "quantity" of water for the trip after that—all without creating separate "water" items for each trup.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions