1/*  Part of SWI-Prolog odf-sheet pack
    2
    3    Author:        Jan Wielemaker
    4    E-mail:        J.Wielemaker@vu.nl
    5    WWW:           http://www.swi-prolog.org/pack/list?p=odf-sheet
    6
    7    Copyright (c) 2012-2014, VU University of Amsterdam
    8    All rights reserved.
    9
   10    Redistribution and use in source and binary forms, with or without
   11    modification, are permitted provided that the following conditions are
   12    met:
   13
   14    1. Redistributions of source code must retain the above copyright
   15    notice, this list of conditions and the following disclaimer.
   16
   17    2. Redistributions in binary form must reproduce the above copyright
   18    notice, this list of conditions and the following disclaimer in the
   19    documentation and/or other materials provided with the distribution.
   20
   21    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
   22    IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
   23    TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
   24    PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
   25    HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   26    SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
   27    TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
   28    PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
   29    LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
   30    NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
   31    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   32*/
   33
   34:- module(of_functions,
   35	  [ pmt/6			% +Rate, +Nper, +Pv, +Fv, +PayType, -Value
   36	  ]).

Advanced Open Formula functions

This module provides the more advanced functions defined by the Open Formula specification.

See also
- http://cgit.freedesktop.org/libreoffice/core/tree/sc/source/core/tool/interpr2.cxx */
To be done
- Implement most of them
 pmt(+Zins, +Zzr, +Bw, +Zw, +F, -Value)
See also
- http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-part2.html#PMT
- http://wiki.openoffice.org/wiki/Documentation/How_Tos/Calc:_PMT_function
   52pmt(Zins, Zzr, Bw, Zw, _, Value) :-
   53	Zins =:= 0.0, !,
   54	Rmz is (Bw+Zw)/Zzr,
   55	Value is -Rmz.
   56pmt(Zins, Zzr, Bw, Zw, F, Value) :-
   57	Term is (1.0+Zins)**Zzr,
   58	(   F > 0.0
   59	->  Rmz is (Zw*Zins/(Term-1.0)
   60		      + Bw*Zins/(1.0-1.0/Term)) / (1.0+Zins)
   61	;   Rmz is Zw*Zins/(Term-1.0)
   62	             + Bw*Zins/(1.0-1.0/Term)
   63	),
   64	Value is -Rmz