Bug 100562 - DB() function, period and lifetime parameter
Summary: DB() function, period and lifetime parameter
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: All All
: medium normal
Assignee: Winfried Donkers
URL:
Whiteboard: target:5.3.0
Keywords:
Depends on:
Blocks:
 
Reported: 2016-06-23 11:19 UTC by raal
Modified: 2016-10-25 18:54 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description raal 2016-06-23 11:19:34 UTC
ODF specification:  6.12.13 DB
Summary: Compute the depreciation allowance of an asset.
Syntax: DB( Number cost ; Number salvage ; Integer lifeTime ; Number period [ ; Number month = 12 ] )
Returns: Currency
Constraints: cost > 0, salvage >= 0, lifetime >0; period > 0; 0 < month < 13

=DB(25000;1000;0;1;6)
=DB(25000;1000;36;0;6)
=DB(25000;1000;36;-1;6)

period parameter specified as "period > 0". Lifetime as "lifetime> 0". These formulas should throws error.

Checked in excel and excel return error.
Comment 1 Winfried Donkers 2016-06-23 13:52:29 UTC
Actually, Calc uses some extra constraints as well (apart from the 2 missing constraints):
salvage <= cost
lifeTime <= 1200
period <= (lifeTime+1)

The first makes sense, and IMHO should be added to ODFF (as DDB does have the constraint salvage <= cost).
The others may be there because of the used calculation and/or to ensure fast calculations, I don't know.
Comment 2 Commit Notification 2016-06-23 20:17:22 UTC
Winfried Donkers committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=716f4ef1625cece6fe8326213df24c52d56c9432

tdf#100562 Add constraints for function DB

It will be available in 5.3.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 3 raal 2016-06-25 05:47:13 UTC
Thanks Winfried
Verified  Version: 5.3.0.0.alpha0+
Build ID: 0325b22a2a2b537a71f53b7c5d3e6c13fef68911
CPU Threads: 4; OS Version: Linux 4.4; UI Render: default; 
TinderBox: Linux-rpm_deb-x86_64@70-TDF, Branch:master, Time: 2016-06-24_23:36:22