On 27/06/2020 15:46, Tuno Tunante wrote: > Dear all, > > Long time using beancount and more and more happy. Thank you! > > Sometimes you could need to make more complex searches or accounting. I > would like to propose you a script to help to > export the ledge to a PostgreSQL database. > > The file import_csv.sh do: > > * Delete (if exist) the old table with all the transactions > * Generate the CSV from the current bean file > * Create the table in the database > * Import the data to the table > * Erase all the spaces in front and behind all the string entries. > > All the information and some examples for translate the bean-query to > psql commands are here: > > https://github.com/tinotuno/Beancount-PostgreSQL
Hello, I quickly skimmed through the script and it looks like you are using real numbers to represent amounts in the PostgreSQL table. This is not the correct way to represent financial quantities: because many finite decimal numbers do not have a finite representation in binary, they need to be stored with rounding errors. The rounding errors on most functions computed on these values depend on the order in which the values are used. Thus it is very likely to end up with discrepancies on computed values. The right data type to use is "decimal" (or "numeric" in SQL) which allow exact representation and computation (up to a fixed number of digits). This is supported by PostgreSQL: https://www.postgresql.org/docs/current/datatype-numeric.html#DATATYPE-NUMERIC-DECIMAL Cheers, Dan -- You received this message because you are subscribed to the Google Groups "Beancount" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/beancount/8df36167-1851-8b16-7a7e-dd3aa35d2bf3%40grinta.net.
