emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* How to get sum from remote table + how to put in bold?
@ 2015-12-06 14:16 Fabrice Niessen
  2015-12-07 18:39 ` Eric S Fraga
  0 siblings, 1 reply; 4+ messages in thread
From: Fabrice Niessen @ 2015-12-06 14:16 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

Hello,

I'm trying to build a template for invoices written in Org... exporting
to PDF (and HTML). Will be officially public as soon as it's DONE.

Though, I have 2 problems currently:

- I'd like to sum up, in table `total', the sub-total column of table
  `items'. But the `remote' call does not seem to accept the `vsum'
  expression. Is this a foreseen limitation?  Is there a workaround to this?

- I'd like to get the computed amount (last line of `total' table) in bold (and,
  if possible, even in a bigger font). How is that doable?

ECM:

--8<---------------cut here---------------start------------->8---
#+TITLE:     Invoice #001
#+OPTIONS:   H:2 num:nil toc:nil

#+LaTeX_CLASS: article
#+LaTeX_CLASS_OPTIONS: [a4paper,table]
#+LaTeX_HEADER: \usepackage{tabu}
#+LaTeX_HEADER: \taburulecolor{gray}

* Items

#+name: items
#+ATTR_LaTeX: :environment tabu :align lXlrlrrl
|              | <35>                                |       |      |     |          |           |   |
| Title of job | Description                         | Type  | Rate |     | Quantity | Sub-total |   |
|--------------+-------------------------------------+-------+------+-----+----------+-----------+---|
| Consultancy  | Quote template                      | Timed |  400 | \EUR/d |      6.5 |   2600.00 | \EUR |
|--------------+-------------------------------------+-------+------+-----+----------+-----------+---|
| Research     | Billing invoice template            | Timed |  400 | \EUR/d |     10.0 |   4000.00 | \EUR |
#+TBLFM: $7=$6*400;%.2f

* Amount Due

#+name: total
#+latex: \hfill\colorbox{yellow}{\begin{minipage}{7.5cm}
#+ATTR_LaTeX: :environment tabu :align Xrl
| /Sub-total/  | 0.00 | \EUR |
|------------+------+---|
| /Tax @ 21%/  | 0.00 | \EUR |
|------------+------+---|
| *Amount Due* | 0.00 | *\EUR* |
#+TBLFM: @1$2=remote(items,vsum(@3$7..@4$7);%.2f::@2$2=@1*0.21;%.2f::@3$2=vsum(@1..@-1);%.2f

#+latex: \end{minipage}}
--8<---------------cut here---------------end--------------->8---

Any hint for me?

Best regards,
Fabrice

-- 
Fabrice Niessen
Leuven, Belgium
http://www.pirilampo.org/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: How to get sum from remote table + how to put in bold?
  2015-12-06 14:16 How to get sum from remote table + how to put in bold? Fabrice Niessen
@ 2015-12-07 18:39 ` Eric S Fraga
  2015-12-07 20:19   ` Fabrice Niessen
  0 siblings, 1 reply; 4+ messages in thread
From: Eric S Fraga @ 2015-12-07 18:39 UTC (permalink / raw)
  To: Fabrice Niessen; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 936 bytes --]

On Sunday,  6 Dec 2015 at 15:16, Fabrice Niessen wrote:
> Hello,
>
> I'm trying to build a template for invoices written in Org... exporting
> to PDF (and HTML). Will be officially public as soon as it's DONE.
>
> Though, I have 2 problems currently:
>
> - I'd like to sum up, in table `total', the sub-total column of table
>   `items'. But the `remote' call does not seem to accept the `vsum'
>   expression. Is this a foreseen limitation?  Is there a workaround to this?
>
> - I'd like to get the computed amount (last line of `total' table) in bold (and,
>   if possible, even in a bigger font). How is that doable?

I've fixed your ECM:

1. moved attr_latex and other latex stuff to before the names of the
tables and
2. inverted the order of vsum and remote so that you do a vsum over what
the remote function returns.

Seems to work.  See attached.
-- 
: Eric S Fraga (0xFFFCF67D), Emacs 25.0.50.2, Org release_8.3.2-379-g38fd09

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: t.org --]
[-- Type: text/x-org, Size: 1360 bytes --]

#+TITLE:     Invoice #001
#+OPTIONS:   H:2 num:nil toc:nil

#+LaTeX_CLASS: article
#+LaTeX_CLASS_OPTIONS: [a4paper,table]
#+LaTeX_HEADER: \usepackage{tabu}
#+LaTeX_HEADER: \taburulecolor{gray}

* Items

#+ATTR_LaTeX: :environment tabu :align lXlrlrrl
#+name: items
|              | <35>                                |       |      |        |          |           |      |
| Title of job | Description                         | Type  | Rate |        | Quantity | Sub-total |      |
|--------------+-------------------------------------+-------+------+--------+----------+-----------+------|
| Consultancy  | Quote template                      | Timed |  400 | \EUR/d |      6.5 |   2600.00 | \EUR |
|--------------+-------------------------------------+-------+------+--------+----------+-----------+------|
| Research     | Billing invoice template            | Timed |  400 | \EUR/d |     10.0 |   4000.00 | \EUR |
#+TBLFM: $7=$6*400;%.2f

* Amount Due

#+latex: \hfill\colorbox{yellow}{\begin{minipage}{7.5cm}
#+ATTR_LaTeX: :environment tabu :align Xrl
#+name: total
| /Sub-total/  | 6600.00 | \EUR |
|------------+---------+------|
| /Tax @ 21%/  | 1386.00 | \EUR |
|------------+---------+------|
| *Amount Due* | 7986.00 | *\EUR* |
#+TBLFM: @1$2=vsum(remote(items,@3$7..@4$7));%.2f::@2$2=@1*0.21;%.2f::@3$2=vsum(@1..@-1);%.2f

#+latex: \end{minipage}}

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: How to get sum from remote table + how to put in bold?
  2015-12-07 18:39 ` Eric S Fraga
@ 2015-12-07 20:19   ` Fabrice Niessen
  2015-12-07 21:37     ` Rasmus
  0 siblings, 1 reply; 4+ messages in thread
From: Fabrice Niessen @ 2015-12-07 20:19 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

Hello,

Eric S Fraga <e.fraga-hclig2XLE9Zaa/9Udqfwiw@public.gmane.org> writes:
> On Sunday,  6 Dec 2015 at 15:16, Fabrice Niessen wrote:
>>
>> I'm trying to build a template for invoices written in
>> Org... exporting to PDF (and HTML). Will be officially public as soon
>> as it's DONE.
>>
>> Though, I have 2 problems currently:
>>
>> - I'd like to sum up, in table `total', the sub-total column of table
>>   `items'. But the `remote' call does not seem to accept the `vsum'
>>   expression. Is this a foreseen limitation?  Is there a workaround to
>>   this?
>>
>> - I'd like to get the computed amount (last line of `total' table) in
>>   bold (and, if possible, even in a bigger font). How is that doable?
>
> I've fixed your ECM:
>
> 1. moved attr_latex and other latex stuff to before the names of the
>    tables and
> 2. inverted the order of vsum and remote so that you do a vsum over what
>    the remote function returns.
>
> Seems to work.

I confirm that you *did* fix my first problem. Simple, neat, and smart.
Thanks a lot!

Any idea how to solve my problem #2: get the computed amount in bold
and/or in another color and/or in bigger font?

Best regards,
Fabrice

-- 
Fabrice Niessen
Leuven, Belgium
http://www.pirilampo.org/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: How to get sum from remote table + how to put in bold?
  2015-12-07 20:19   ` Fabrice Niessen
@ 2015-12-07 21:37     ` Rasmus
  0 siblings, 0 replies; 4+ messages in thread
From: Rasmus @ 2015-12-07 21:37 UTC (permalink / raw)
  To: emacs-orgmode

Hi,

I didn't read OP.

Fabrice Niessen <news@pirilampo.org> writes:

> Any idea how to solve my problem #2: get the computed amount in bold
> and/or in another color and/or in bigger font?

Cf. the manual you can use printf syntax,

     http://orgmode.org/manual/Formula-syntax-for-Calc.html#Formula-syntax-for-Calc

Thus,

| /Sub-total/  |   6600.00 | \EUR   |
|--------------+-----------+-----|
| /Tax @ 21%/  |   1386.00 | \EUR   |
|--------------+-----------+-----|
| *Amount Due* | *7986.00* | *\EUR* |
#+TBLFM: @1$2=vsum(remote(items,@3$7..@4$7));%.2f::@2$2=@1*0.21;%.2f::@3$2=vsum(@1..@-1);*%.2f*

Hope this was what you were after.
Rasmus

-- 
Together we will make the possible totalllly impossible!

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-12-07 21:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-06 14:16 How to get sum from remote table + how to put in bold? Fabrice Niessen
2015-12-07 18:39 ` Eric S Fraga
2015-12-07 20:19   ` Fabrice Niessen
2015-12-07 21:37     ` Rasmus

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).