这是indexloc提供的服务,不要输入任何密码
Skip to content

Invoice line prices are rounded by MySQL #585

@NoRePercussions

Description

@NoRePercussions

invoice_lines.price is stored as a float.

Traditionally, integers with a magnitude of up to 24 bits are exactly representable (<= 16,777,216). So theoretically, a value like 11,111.11 is representable to within half a cent (and should render correctly). Instead, when we create an invoice with a single line we observe the following:

  • $11,111.11 -> $11,111.10
  • $111,111.1 -> $111,111.0
  • $1,111,111 -> $1,111,110

This is because rather than directly output the stored float value, MySQL rounds it to 6 decimal sigfigs. https://bugs.mysql.com/bug.php?id=87794

Since it is still stored exact, casting to another type will change any past invoices. Past lines need to be rounded to 6 sigfigs at rest to maintain records.

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions