emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Daniele Nicolodi <daniele@grinta.net>
To: Christian Moe <mail@christianmoe.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: org-tables with monetary amounts
Date: Thu, 15 Oct 2020 22:02:58 +0200	[thread overview]
Message-ID: <a45ad641-61ab-2aae-25d4-8b7dacb0d43c@grinta.net> (raw)
In-Reply-To: <87sgaj26qq.fsf@christianmoe.com>

On 12/10/2020 10:22, Christian Moe wrote:
> 
> Hi, Daniele,
> 
> Good that it's working for you. I'll try to explain the unclear parts.
> 
> Daniele Nicolodi writes:
> 
>> On 24/09/2020 11:17, Christian Moe wrote:
>>
>>> Now, with the Calc command to simplify units, you can add dollars to
>>> euros and get the result in whichever currency comes first in the
>>> algebraic expression
>>>
>>>   | 3 USD | 4 EUR | 6.58 EUR |
>>>   #+tblfm: $3=usimplify($2+$1)
>>>
>>>   | 3 USD | 4 EUR | 7.6511628 USD |
>>>   #+tblfm: $3=usimplify($1+$2)
>>
>> Having to explicitly use usimplify() is a bit too verbose. It would be
>> ideal if this could be somehow be implicit.
> 
> Yes, or at least with a less obtrusive syntax, like a mode flag,
> something like
> 
>   $3=$2+$1;u

I had a look and unfortunately the implementation of mode flags is not
easily extensible, thus this cannot easily implemented in independent code.

Also, it would probably make sense to have this being a Calc mode
activated with an org-table formula mode flag, rather than something
implemented in org-table. I don't know how easy it would be to extend Calc.


>>> I don't use this functionality, so I don't have answers to all the
>>> questions you'll now have -- including how to get the desired precision
>>> without lopping off the currency unit in the last example!
>>
>> Having the desired fixed precision is quite important for this to be
>> useful. In y recent tests I had to drop the units (currencies) to
>> achieve this. It would be nice to find a way to avoid it.

Turns our this is actually easy. There are two ways to specify
visualization format for table cells: a format specifier like

$3=$1+$2;%.2f

which results in the units being stripped, and a Calc formatting mode
flag, like

$3=$1+$2;f2

which does not strip the units.

Cheers,
Dan


  parent reply	other threads:[~2020-10-15 20:05 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-22 14:57 org-tables with monetary amounts Daniele Nicolodi
2020-09-22 23:25 ` Nicholas Savage
2020-09-23  9:37 ` Russell Adams
2020-09-23 16:55 ` Eric S Fraga
2020-09-25 11:20   ` Daniele Nicolodi
2020-09-25 11:57     ` Alan Schmitt
2020-09-23 21:26 ` Nick Dokos
2020-09-24  9:17 ` Christian Moe
2020-09-24 11:47   ` Eric S Fraga
2020-10-09 16:14   ` Daniele Nicolodi
2020-10-12  8:22     ` Christian Moe
2020-10-12  9:43       ` Eric S Fraga
2020-10-13  7:10         ` Derek Feichtinger
2020-10-14  7:38           ` Christian Moe
2020-10-15 20:02       ` Daniele Nicolodi [this message]
2020-09-25  9:25 ` Neil Jerram
2020-09-25 11:35   ` Daniele Nicolodi
2020-09-26 18:38     ` Neil Jerram

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a45ad641-61ab-2aae-25d4-8b7dacb0d43c@grinta.net \
    --to=daniele@grinta.net \
    --cc=emacs-orgmode@gnu.org \
    --cc=mail@christianmoe.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).