<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:bioc="http://bpmn.io/schema/bpmn/biocolor/1.0" xmlns:color="http://www.omg.org/spec/BPMN/non-normative/color/1.0" id="Definitions_invoice_approval" targetNamespace="http://bpmn.io/schema/bpmn">
  <bpmn:collaboration id="Collaboration_invoice_approval">
    <bpmn:participant id="Participant_invoice_approval" name="Invoice Approval" processRef="Process_invoice_approval" />
  </bpmn:collaboration>
  <bpmn:process id="Process_invoice_approval" name="Invoice Approval" isExecutable="true">
    <bpmn:laneSet id="LaneSet_invoice_approval">
      <bpmn:lane id="Lane_1" name="Accounts Payable"><bpmn:flowNodeRef>Start</bpmn:flowNodeRef><bpmn:flowNodeRef>Check</bpmn:flowNodeRef><bpmn:flowNodeRef>Amount</bpmn:flowNodeRef><bpmn:flowNodeRef>Pay</bpmn:flowNodeRef><bpmn:flowNodeRef>Reconcile</bpmn:flowNodeRef><bpmn:flowNodeRef>End</bpmn:flowNodeRef></bpmn:lane>
      <bpmn:lane id="Lane_2" name="Budget Owner"><bpmn:flowNodeRef>Approve</bpmn:flowNodeRef><bpmn:flowNodeRef>Approved</bpmn:flowNodeRef><bpmn:flowNodeRef>Reject</bpmn:flowNodeRef><bpmn:flowNodeRef>EndRejected</bpmn:flowNodeRef></bpmn:lane>
      <bpmn:lane id="Lane_3" name="CFO"><bpmn:flowNodeRef>ApproveCfo</bpmn:flowNodeRef></bpmn:lane>
    </bpmn:laneSet>
    <bpmn:startEvent id="Start" name="Invoice received"><bpmn:outgoing>Flow_1</bpmn:outgoing></bpmn:startEvent>
    <bpmn:userTask id="Check" name="Check invoice against the order"><bpmn:incoming>Flow_1</bpmn:incoming><bpmn:outgoing>Flow_2</bpmn:outgoing></bpmn:userTask>
    <bpmn:exclusiveGateway id="Amount" name="High amount?" default="Flow_3"><bpmn:incoming>Flow_2</bpmn:incoming><bpmn:outgoing>Flow_3</bpmn:outgoing><bpmn:outgoing>Flow_4</bpmn:outgoing></bpmn:exclusiveGateway>
    <bpmn:userTask id="Approve" name="Approve the invoice"><bpmn:incoming>Flow_3</bpmn:incoming><bpmn:outgoing>Flow_5</bpmn:outgoing></bpmn:userTask>
    <bpmn:userTask id="ApproveCfo" name="Approve the high invoice"><bpmn:incoming>Flow_4</bpmn:incoming><bpmn:outgoing>Flow_6</bpmn:outgoing></bpmn:userTask>
    <bpmn:exclusiveGateway id="Approved" name="Approved?" default="Flow_7"><bpmn:incoming>Flow_5</bpmn:incoming><bpmn:incoming>Flow_6</bpmn:incoming><bpmn:outgoing>Flow_7</bpmn:outgoing><bpmn:outgoing>Flow_8</bpmn:outgoing></bpmn:exclusiveGateway>
    <bpmn:userTask id="Pay" name="Pay the invoice"><bpmn:incoming>Flow_7</bpmn:incoming><bpmn:outgoing>Flow_9</bpmn:outgoing></bpmn:userTask>
    <bpmn:userTask id="Reconcile" name="Reconcile the payment"><bpmn:incoming>Flow_9</bpmn:incoming><bpmn:outgoing>Flow_10</bpmn:outgoing></bpmn:userTask>
    <bpmn:endEvent id="End" name="Invoice paid"><bpmn:incoming>Flow_10</bpmn:incoming></bpmn:endEvent>
    <bpmn:userTask id="Reject" name="Return the invoice to the supplier"><bpmn:incoming>Flow_8</bpmn:incoming><bpmn:outgoing>Flow_11</bpmn:outgoing></bpmn:userTask>
    <bpmn:endEvent id="EndRejected" name="Invoice rejected"><bpmn:incoming>Flow_11</bpmn:incoming></bpmn:endEvent>
    <bpmn:sequenceFlow id="Flow_1" sourceRef="Start" targetRef="Check" />
    <bpmn:sequenceFlow id="Flow_2" sourceRef="Check" targetRef="Amount" />
    <bpmn:sequenceFlow id="Flow_3" name="No" sourceRef="Amount" targetRef="Approve" />
    <bpmn:sequenceFlow id="Flow_4" name="Yes" sourceRef="Amount" targetRef="ApproveCfo"><bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${pi.fields.labels.includes('high-value')}</bpmn:conditionExpression></bpmn:sequenceFlow>
    <bpmn:sequenceFlow id="Flow_5" sourceRef="Approve" targetRef="Approved" />
    <bpmn:sequenceFlow id="Flow_6" sourceRef="ApproveCfo" targetRef="Approved" />
    <bpmn:sequenceFlow id="Flow_7" name="Yes" sourceRef="Approved" targetRef="Pay" />
    <bpmn:sequenceFlow id="Flow_8" name="No" sourceRef="Approved" targetRef="Reject"><bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${cur.fields.status.name == 'Rejected'}</bpmn:conditionExpression></bpmn:sequenceFlow>
    <bpmn:sequenceFlow id="Flow_9" sourceRef="Pay" targetRef="Reconcile" />
    <bpmn:sequenceFlow id="Flow_10" sourceRef="Reconcile" targetRef="End" />
    <bpmn:sequenceFlow id="Flow_11" sourceRef="Reject" targetRef="EndRejected" />
  </bpmn:process>
  <bpmndi:BPMNDiagram id="Diagram_invoice_approval">
    <bpmndi:BPMNPlane id="Plane_invoice_approval" bpmnElement="Collaboration_invoice_approval">
      <bpmndi:BPMNShape id="Participant_invoice_approval_di" bpmnElement="Participant_invoice_approval" isHorizontal="true"><dc:Bounds x="160" y="80" width="1740" height="420" /></bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Lane_1_di" bpmnElement="Lane_1" isHorizontal="true"><dc:Bounds x="190" y="80" width="1710" height="140" /></bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Lane_2_di" bpmnElement="Lane_2" isHorizontal="true"><dc:Bounds x="190" y="220" width="1710" height="140" /></bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Lane_3_di" bpmnElement="Lane_3" isHorizontal="true"><dc:Bounds x="190" y="360" width="1710" height="140" /></bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Start_di" bpmnElement="Start"><dc:Bounds x="282" y="132" width="36" height="36" /><bpmndi:BPMNLabel><dc:Bounds x="250" y="174" width="100" height="27" /></bpmndi:BPMNLabel></bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Check_di" bpmnElement="Check" bioc:stroke="#1e88e5" bioc:fill="#bbdefb" color:background-color="#bbdefb" color:border-color="#1e88e5"><dc:Bounds x="425" y="110" width="150" height="80" /></bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Amount_di" bpmnElement="Amount" isMarkerVisible="true"><dc:Bounds x="675" y="125" width="50" height="50" /><bpmndi:BPMNLabel><dc:Bounds x="597" y="93" width="90" height="27" /></bpmndi:BPMNLabel></bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Approve_di" bpmnElement="Approve" bioc:stroke="#43a047" bioc:fill="#c8e6c9" color:background-color="#c8e6c9" color:border-color="#43a047"><dc:Bounds x="825" y="250" width="150" height="80" /></bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="ApproveCfo_di" bpmnElement="ApproveCfo" bioc:stroke="#fb8c00" bioc:fill="#ffe0b2" color:background-color="#ffe0b2" color:border-color="#fb8c00"><dc:Bounds x="825" y="390" width="150" height="80" /></bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Approved_di" bpmnElement="Approved" isMarkerVisible="true"><dc:Bounds x="1075" y="265" width="50" height="50" /><bpmndi:BPMNLabel><dc:Bounds x="997" y="233" width="90" height="27" /></bpmndi:BPMNLabel></bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Pay_di" bpmnElement="Pay" bioc:stroke="#1e88e5" bioc:fill="#bbdefb" color:background-color="#bbdefb" color:border-color="#1e88e5"><dc:Bounds x="1225" y="110" width="150" height="80" /></bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Reconcile_di" bpmnElement="Reconcile" bioc:stroke="#1e88e5" bioc:fill="#bbdefb" color:background-color="#bbdefb" color:border-color="#1e88e5"><dc:Bounds x="1425" y="110" width="150" height="80" /></bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="End_di" bpmnElement="End"><dc:Bounds x="1682" y="132" width="36" height="36" /><bpmndi:BPMNLabel><dc:Bounds x="1650" y="174" width="100" height="27" /></bpmndi:BPMNLabel></bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Reject_di" bpmnElement="Reject" bioc:stroke="#43a047" bioc:fill="#c8e6c9" color:background-color="#c8e6c9" color:border-color="#43a047"><dc:Bounds x="1225" y="250" width="150" height="80" /></bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="EndRejected_di" bpmnElement="EndRejected"><dc:Bounds x="1482" y="272" width="36" height="36" /><bpmndi:BPMNLabel><dc:Bounds x="1450" y="314" width="100" height="27" /></bpmndi:BPMNLabel></bpmndi:BPMNShape>
      <bpmndi:BPMNEdge id="Flow_1_di" bpmnElement="Flow_1"><di:waypoint x="318" y="150" /><di:waypoint x="425" y="150" /></bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_2_di" bpmnElement="Flow_2"><di:waypoint x="575" y="150" /><di:waypoint x="675" y="150" /></bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_3_di" bpmnElement="Flow_3"><di:waypoint x="700" y="175" /><di:waypoint x="700" y="290" /><di:waypoint x="825" y="290" /><bpmndi:BPMNLabel><dc:Bounds x="712" y="270" width="30" height="14" /></bpmndi:BPMNLabel></bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_4_di" bpmnElement="Flow_4"><di:waypoint x="700" y="175" /><di:waypoint x="700" y="430" /><di:waypoint x="825" y="430" /><bpmndi:BPMNLabel><dc:Bounds x="712" y="410" width="30" height="14" /></bpmndi:BPMNLabel></bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_5_di" bpmnElement="Flow_5"><di:waypoint x="975" y="290" /><di:waypoint x="1075" y="290" /></bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_6_di" bpmnElement="Flow_6"><di:waypoint x="975" y="430" /><di:waypoint x="1100" y="430" /><di:waypoint x="1100" y="315" /></bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_7_di" bpmnElement="Flow_7"><di:waypoint x="1100" y="265" /><di:waypoint x="1100" y="150" /><di:waypoint x="1225" y="150" /><bpmndi:BPMNLabel><dc:Bounds x="1112" y="130" width="30" height="14" /></bpmndi:BPMNLabel></bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_8_di" bpmnElement="Flow_8"><di:waypoint x="1125" y="290" /><di:waypoint x="1225" y="290" /><bpmndi:BPMNLabel><dc:Bounds x="1133" y="270" width="30" height="14" /></bpmndi:BPMNLabel></bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_9_di" bpmnElement="Flow_9"><di:waypoint x="1375" y="150" /><di:waypoint x="1425" y="150" /></bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_10_di" bpmnElement="Flow_10"><di:waypoint x="1575" y="150" /><di:waypoint x="1682" y="150" /></bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_11_di" bpmnElement="Flow_11"><di:waypoint x="1375" y="290" /><di:waypoint x="1482" y="290" /></bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</bpmn:definitions>
