Mike Gerwitz

Activist for User Freedom

aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Gerwitz <mike.gerwitz@rtspecialty.com>2019-01-02 16:57:19 -0500
committerMike Gerwitz <mike.gerwitz@rtspecialty.com>2019-01-02 16:58:56 -0500
commita7f186beffe5dee3e35cf94eb95abccb6256ddfb (patch)
tree4e3fbbe5f2738e91bbf9126908614158d1080304
parentdec3f2ef35753dec6f189fdfd62aac0c87dd0d1d (diff)
downloadtame-a7f186beffe5dee3e35cf94eb95abccb6256ddfb.tar.gz
tame-a7f186beffe5dee3e35cf94eb95abccb6256ddfb.tar.bz2
tame-a7f186beffe5dee3e35cf94eb95abccb6256ddfb.zip
[BC BREAK] rater/core/insurance (_premium_): Add zero and negative assertions
This is a BC break since this generates assertions by default. To maintain BC, set `@allow-zero@' and `@allow-negative@' to `true' in existing template applications. * core/insurance.xml (assert_ignore_premium_zero, assert_ignore_premium_negative): New params. (_premium_): Generate assertions. [@allow-zero@, @allow-negative@]: New params.
-rw-r--r--core/insurance.xml64
1 files changed, 61 insertions, 3 deletions
diff --git a/core/insurance.xml b/core/insurance.xml
index d2cad09..0df9108 100644
--- a/core/insurance.xml
+++ b/core/insurance.xml
@@ -37,15 +37,19 @@
Some notable TODOs:
\begin{enumerate}
- \item Support scalar results;
- \item Fail on zero premium unless explicitly stated;
- \item Fail on negative premium (use a credit template); and
+ \item Support scalar results; and
\item Rounding direction (currently only nearest).
\end{enumerate}
\todo{Template to abstract these {\tt rate-each} generation
templates.}
+ <param name="assert_ignore_premium_zero" type="boolean"
+ desc="Ignore assertion failures for $0 premiums" />
+
+ <param name="assert_ignore_premium_negative" type="boolean"
+ desc="Ignore assertion failures for negative premiums" />
+
<template name="_premium_"
desc="A premium dollar amount">
@@ -113,6 +117,14 @@
</if>
</unless>
+ <param name="@allow-zero@" desc="Allow value of zero (default false)">
+ <text>false</text>
+ </param>
+
+ <param name="@allow-negative@" desc="Allow negative value (default false)">
+ <text>false</text>
+ </param>
+
<rate-each class="@class@" no="@no@" yields="@yields@"
generates="@generates@" index="@index@"
@@ -155,6 +167,52 @@
</unless>
</unless>
</rate-each>
+
+
+ <!-- assertion for non-zero -->
+ <unless name="@allow-zero@" eq="true">
+ <unless name="@generates@" eq="">
+ <t:assert failure="{@desc@} ({@generates@}) must not yield a value
+ of 0 for any index">
+ <any>
+ <match on="assert_ignore_premium_zero" />
+ <t:match-ne on="@generates@" value="ZERO" />
+ </any>
+ </t:assert>
+ </unless>
+
+ <unless name="@yields@" eq="">
+ <t:assert failure="{@desc@} ({@yields@}) must not yield a value of 0">
+ <any>
+ <match on="assert_ignore_premium_zero" />
+ <t:match-ne on="@yields@" value="ZERO" />
+ </any>
+ </t:assert>
+ </unless>
+ </unless>
+
+ <!-- assertion for non-negative -->
+ <unless name="@allow-negative@" eq="true">
+ <unless name="@generates@" eq="">
+ <t:assert failure="{@desc@} ({@generates@}) must not yield a negative
+ value for any index">
+ <any>
+ <match on="assert_ignore_premium_negative" />
+ <t:match-gte on="@generates@" value="ZERO" />
+ </any>
+ </t:assert>
+ </unless>
+
+ <unless name="@yields@" eq="">
+ <t:assert failure="{@desc@} ({@yields@}) must not yield a negative
+ value">
+ <any>
+ <match on="assert_ignore_premium_negative" />
+ <t:match-gte on="@yields@" value="ZERO" />
+ </any>
+ </t:assert>
+ </unless>
+ </unless>
</template>