Hi, This MWE is a spreadsheet representing a factuur. The rows are billable items. From the sum of the rows the VAT of 21% is calculated (sourceline 32). This unrounded value results in an incorrect sum at the end.
So, how can I round this value to two decimal places?
With kind regards,
Michael
%% Start MWE
\usemodule[spreadsheet]
% Text for the first line of a specification
\def\title{%
\startrow[bottomframe=on]
\startcell[align=flushleft ,width=0.48\textwidth] "{\bf \sc
beschrijving}" \stopcell
\startcell[align=flushright,width=0.16\textwidth] "{\bf \sc aantal}"
\stopcell
\startcell[align=flushright,width=0.16\textwidth] "{\bf \sc prijs}"
\stopcell
\startcell[align=flushright,width=0.20\textwidth] "{\bf \sc bedrag}"
\stopcell
%% \startcell[align=flushright,width=0.25\textwidth] "{\bf \sc btw}"
\stopcell
\stoprow
}
% Simply billable
\def\billable#1#2#3{%
\startrow
\startcell[align=flushleft ] "#1" \stopcell
\startcell[align=flushright] @ "0.2f" #2 \stopcell
\startcell[align=flushright] @ "0.2f €" #3 \stopcell
\startcell[align=flushright] @ "0.2f €" #2 * #3 \stopcell
\stoprow
}
% Calculate the BTW. Now we calculate a percentage of the sum instead of
the sum of the percentages.
\def\btw{%
\startrow[topframe=on]
\startcell[align=flushleft] "BTW\ {21}\procent" \stopcell
\startcell \strut \stopcell
\startcell \strut \stopcell
\startcell[align=flushright] @ "0.2f €" sum(D) * 0.21 \stopcell %
Here's the value that needs rounding
\stoprow
}
% Calculate the Grand Total
\def\total{%
\startrow[topframe=on]
\startcell[align=flushleft] "{\bf Factuurbedrag}" \stopcell
\startcell \strut \stopcell
\startcell \strut \stopcell
\startcell[align=flushright, style=bf] @ "0.2f €" sum(D) \stopcell
\stoprow
}
\starttext
% Here is the specification
\startspreadsheettable[dutch][frame=off]
\title
% add your line items
\billable{Project: Foo}{2.5}{15}
\billable{Project: Bar}{2.5}{15}
\billable{Project: Hat}{3.5}{15}
\btw
\total
\stopspreadsheettable
\stoptext
% finis
rounding.tex
Description: TeX document
rounding.pdf
Description: Adobe PDF document
___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : [email protected] / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror) archive : https://github.com/contextgarden/context wiki : https://wiki.contextgarden.net ___________________________________________________________________________________
