<?xml version="1.0" encoding="UTF-8"?>
<!-- Contract routing by value (template contract-approval), evaluated by the business
     rule task "Route by value" of contract_approval.bpmn.
     Input
       value   the contract's total value, in its currency
     Outputs
       financeReview      true from 10,000: finance reviews it after legal
       executiveSignOff   true from 100,000: an executive signs it off as well
       approvalLevel      "legal", "finance" or "executive": the last review it needs
     FIRST: the three ranges meet without a gap or an overlap, [10000..100000[ being
     10,000 included and 100,000 excluded. The last rule answers a contract whose value
     is missing or not a number: it gets every review, so no review is ever skipped
     for want of a value. Change the two thresholds here; the process reads only the
     outputs. -->
<definitions
  xmlns="https://www.omg.org/spec/DMN/20191111/MODEL/"
  xmlns:dmndi="https://www.omg.org/spec/DMN/20191111/DMNDI/"
  xmlns:dc="http://www.omg.org/spec/DMN/20180521/DC/"
  id="def_contract_routing"
  name="Contract routing"
  namespace="http://priostack.com/templates">
  <decision id="contract_routing" name="Contract routing by value">
    <decisionTable id="dt_contract_routing" hitPolicy="FIRST">
      <input id="in_value" label="Contract value">
        <inputExpression id="ie_value" typeRef="number">
          <text>value</text>
        </inputExpression>
      </input>
      <output id="out_finance" label="Finance review" name="financeReview" typeRef="boolean"/>
      <output id="out_executive" label="Executive sign-off" name="executiveSignOff" typeRef="boolean"/>
      <output id="out_level" label="Approval level" name="approvalLevel" typeRef="string"/>
      <rule id="r_legal">
        <inputEntry id="ie_legal_value"><text>&lt; 10000</text></inputEntry>
        <outputEntry id="oe_legal_finance"><text>false</text></outputEntry>
        <outputEntry id="oe_legal_executive"><text>false</text></outputEntry>
        <outputEntry id="oe_legal_level"><text>"legal"</text></outputEntry>
        <annotationEntry><text>Under 10,000: legal review only</text></annotationEntry>
      </rule>
      <rule id="r_finance">
        <inputEntry id="ie_finance_value"><text>[10000..100000[</text></inputEntry>
        <outputEntry id="oe_finance_finance"><text>true</text></outputEntry>
        <outputEntry id="oe_finance_executive"><text>false</text></outputEntry>
        <outputEntry id="oe_finance_level"><text>"finance"</text></outputEntry>
        <annotationEntry><text>10,000 to under 100,000: legal, then finance</text></annotationEntry>
      </rule>
      <rule id="r_executive">
        <inputEntry id="ie_executive_value"><text>&gt;= 100000</text></inputEntry>
        <outputEntry id="oe_executive_finance"><text>true</text></outputEntry>
        <outputEntry id="oe_executive_executive"><text>true</text></outputEntry>
        <outputEntry id="oe_executive_level"><text>"executive"</text></outputEntry>
        <annotationEntry><text>100,000 or more: legal, finance, then an executive</text></annotationEntry>
      </rule>
      <rule id="r_unknown">
        <inputEntry id="ie_unknown_value"><text>-</text></inputEntry>
        <outputEntry id="oe_unknown_finance"><text>true</text></outputEntry>
        <outputEntry id="oe_unknown_executive"><text>true</text></outputEntry>
        <outputEntry id="oe_unknown_level"><text>"executive"</text></outputEntry>
        <annotationEntry><text>No value, or not a number: every review</text></annotationEntry>
      </rule>
    </decisionTable>
  </decision>
  <dmndi:DMNDI>
    <dmndi:DMNDiagram>
      <dmndi:DMNShape dmnElementRef="contract_routing">
        <dc:Bounds x="157" y="81" width="180" height="80"/>
      </dmndi:DMNShape>
    </dmndi:DMNDiagram>
  </dmndi:DMNDI>
</definitions>
