<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions 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:zeebe="http://camunda.org/schema/zeebe/1.0" xmlns:modeler="http://camunda.org/schema/modeler/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="@bpmnkit/core" exporterVersion="0.0.23" modeler:executionPlatform="Camunda Cloud" modeler:executionPlatformVersion="8.9.0">
  <bpmn:process id="contract-approval" name="Contract Approval" isExecutable="true">
    <bpmn:extensionElements>
      <zeebe:versionTag value="1.0.0"/>
    </bpmn:extensionElements>
    <bpmn:startEvent id="contract-requested" name="Contract requested">
      <bpmn:outgoing>Flow_contract-requested_draft-contract</bpmn:outgoing>
    </bpmn:startEvent>
    <bpmn:serviceTask id="draft-contract" name="Draft contract">
      <bpmn:extensionElements>
        <zeebe:taskDefinition type="contract-draft"/>
        <zeebe:ioMapping>
          <zeebe:output source="=documentId" target="documentId"/>
        </zeebe:ioMapping>
      </bpmn:extensionElements>
      <bpmn:incoming>Flow_contract-requested_draft-contract</bpmn:incoming>
      <bpmn:outgoing>Flow_draft-contract_reviews</bpmn:outgoing>
    </bpmn:serviceTask>
    <bpmn:parallelGateway id="reviews">
      <bpmn:incoming>Flow_draft-contract_reviews</bpmn:incoming>
      <bpmn:outgoing>Flow_reviews_legal-review</bpmn:outgoing>
      <bpmn:outgoing>Flow_reviews_finance-review</bpmn:outgoing>
    </bpmn:parallelGateway>
    <bpmn:userTask id="legal-review" name="Legal review">
      <bpmn:extensionElements>
        <zeebe:userTask/>
        <zeebe:assignmentDefinition candidateGroups="legal"/>
      </bpmn:extensionElements>
      <bpmn:incoming>Flow_reviews_legal-review</bpmn:incoming>
      <bpmn:outgoing>Flow_legal-review_reviews-done</bpmn:outgoing>
    </bpmn:userTask>
    <bpmn:userTask id="finance-review" name="Finance review">
      <bpmn:extensionElements>
        <zeebe:userTask/>
        <zeebe:assignmentDefinition candidateGroups="finance"/>
      </bpmn:extensionElements>
      <bpmn:incoming>Flow_reviews_finance-review</bpmn:incoming>
      <bpmn:outgoing>Flow_finance-review_reviews-done</bpmn:outgoing>
    </bpmn:userTask>
    <bpmn:parallelGateway id="reviews-done">
      <bpmn:incoming>Flow_legal-review_reviews-done</bpmn:incoming>
      <bpmn:incoming>Flow_finance-review_reviews-done</bpmn:incoming>
      <bpmn:outgoing>Flow_reviews-done_both-approved</bpmn:outgoing>
    </bpmn:parallelGateway>
    <bpmn:exclusiveGateway id="both-approved" name="Both approved?" default="Flow_both-approved_return-to-requester">
      <bpmn:incoming>Flow_reviews-done_both-approved</bpmn:incoming>
      <bpmn:outgoing>Flow_both-approved_send-for-signature</bpmn:outgoing>
      <bpmn:outgoing>Flow_both-approved_return-to-requester</bpmn:outgoing>
    </bpmn:exclusiveGateway>
    <bpmn:serviceTask id="send-for-signature" name="Send for e-signature">
      <bpmn:extensionElements>
        <zeebe:taskDefinition type="esign-envelope-send"/>
        <zeebe:ioMapping>
          <zeebe:output source="=envelopeId" target="envelopeId"/>
        </zeebe:ioMapping>
      </bpmn:extensionElements>
      <bpmn:incoming>Flow_both-approved_send-for-signature</bpmn:incoming>
      <bpmn:outgoing>Flow_send-for-signature_contract-sent</bpmn:outgoing>
    </bpmn:serviceTask>
    <bpmn:endEvent id="contract-sent" name="Sent for signature">
      <bpmn:incoming>Flow_send-for-signature_contract-sent</bpmn:incoming>
    </bpmn:endEvent>
    <bpmn:serviceTask id="return-to-requester" name="Return to requester">
      <bpmn:extensionElements>
        <zeebe:taskDefinition type="requester-notify"/>
        <zeebe:taskHeaders>
          <zeebe:header key="template" value="contract-changes-requested"/>
        </zeebe:taskHeaders>
      </bpmn:extensionElements>
      <bpmn:incoming>Flow_both-approved_return-to-requester</bpmn:incoming>
      <bpmn:outgoing>Flow_return-to-requester_contract-returned</bpmn:outgoing>
    </bpmn:serviceTask>
    <bpmn:endEvent id="contract-returned" name="Changes requested">
      <bpmn:incoming>Flow_return-to-requester_contract-returned</bpmn:incoming>
    </bpmn:endEvent>
    <bpmn:sequenceFlow id="Flow_contract-requested_draft-contract" sourceRef="contract-requested" targetRef="draft-contract"/>
    <bpmn:sequenceFlow id="Flow_draft-contract_reviews" sourceRef="draft-contract" targetRef="reviews"/>
    <bpmn:sequenceFlow id="Flow_reviews_legal-review" sourceRef="reviews" targetRef="legal-review" name="legal"/>
    <bpmn:sequenceFlow id="Flow_reviews_finance-review" sourceRef="reviews" targetRef="finance-review" name="finance"/>
    <bpmn:sequenceFlow id="Flow_legal-review_reviews-done" sourceRef="legal-review" targetRef="reviews-done"/>
    <bpmn:sequenceFlow id="Flow_finance-review_reviews-done" sourceRef="finance-review" targetRef="reviews-done"/>
    <bpmn:sequenceFlow id="Flow_reviews-done_both-approved" sourceRef="reviews-done" targetRef="both-approved"/>
    <bpmn:sequenceFlow id="Flow_both-approved_send-for-signature" sourceRef="both-approved" targetRef="send-for-signature" name="yes">
      <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">=legalApproved and financeApproved</bpmn:conditionExpression>
    </bpmn:sequenceFlow>
    <bpmn:sequenceFlow id="Flow_send-for-signature_contract-sent" sourceRef="send-for-signature" targetRef="contract-sent"/>
    <bpmn:sequenceFlow id="Flow_both-approved_return-to-requester" sourceRef="both-approved" targetRef="return-to-requester" name="no"/>
    <bpmn:sequenceFlow id="Flow_return-to-requester_contract-returned" sourceRef="return-to-requester" targetRef="contract-returned"/>
  </bpmn:process>
  <bpmndi:BPMNDiagram id="contract-approval_di">
    <bpmndi:BPMNPlane id="contract-approval_di_plane" bpmnElement="contract-approval">
      <bpmndi:BPMNShape id="contract-requested_di" bpmnElement="contract-requested">
        <dc:Bounds x="65" y="42" width="36" height="36"/>
        <bpmndi:BPMNLabel>
          <dc:Bounds x="20" y="82" width="126" height="14"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="draft-contract_di" bpmnElement="draft-contract">
        <dc:Bounds x="201" y="20" width="100" height="80"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="reviews_di" bpmnElement="reviews">
        <dc:Bounds x="401" y="35" width="50" height="50"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="legal-review_di" bpmnElement="legal-review">
        <dc:Bounds x="551" y="20" width="100" height="80"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="finance-review_di" bpmnElement="finance-review">
        <dc:Bounds x="551" y="180" width="100" height="80"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="reviews-done_di" bpmnElement="reviews-done">
        <dc:Bounds x="751" y="35" width="50" height="50"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="both-approved_di" bpmnElement="both-approved">
        <dc:Bounds x="901" y="35" width="50" height="50"/>
        <bpmndi:BPMNLabel>
          <dc:Bounds x="877" y="89" width="98" height="14"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="send-for-signature_di" bpmnElement="send-for-signature">
        <dc:Bounds x="1051" y="180" width="100" height="80"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="contract-sent_di" bpmnElement="contract-sent">
        <dc:Bounds x="1251" y="202" width="36" height="36"/>
        <bpmndi:BPMNLabel>
          <dc:Bounds x="1206" y="242" width="126" height="14"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="return-to-requester_di" bpmnElement="return-to-requester">
        <dc:Bounds x="1051" y="20" width="100" height="80"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="contract-returned_di" bpmnElement="contract-returned">
        <dc:Bounds x="1251" y="42" width="36" height="36"/>
        <bpmndi:BPMNLabel>
          <dc:Bounds x="1210" y="82" width="119" height="14"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge id="Flow_contract-requested_draft-contract_di" bpmnElement="Flow_contract-requested_draft-contract">
        <di:waypoint x="101" y="60"/>
        <di:waypoint x="201" y="60"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_draft-contract_reviews_di" bpmnElement="Flow_draft-contract_reviews">
        <di:waypoint x="301" y="60"/>
        <di:waypoint x="401" y="60"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_reviews_legal-review_di" bpmnElement="Flow_reviews_legal-review">
        <di:waypoint x="451" y="60"/>
        <di:waypoint x="551" y="60"/>
        <bpmndi:BPMNLabel>
          <dc:Bounds x="481" y="36" width="40" height="14"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_reviews_finance-review_di" bpmnElement="Flow_reviews_finance-review">
        <di:waypoint x="426" y="85"/>
        <di:waypoint x="426" y="220"/>
        <di:waypoint x="551" y="220"/>
        <bpmndi:BPMNLabel>
          <dc:Bounds x="402" y="146" width="49" height="14"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_legal-review_reviews-done_di" bpmnElement="Flow_legal-review_reviews-done">
        <di:waypoint x="651" y="60"/>
        <di:waypoint x="751" y="60"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_finance-review_reviews-done_di" bpmnElement="Flow_finance-review_reviews-done">
        <di:waypoint x="601" y="180"/>
        <di:waypoint x="601" y="140"/>
        <di:waypoint x="776" y="140"/>
        <di:waypoint x="776" y="85"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_reviews-done_both-approved_di" bpmnElement="Flow_reviews-done_both-approved">
        <di:waypoint x="801" y="60"/>
        <di:waypoint x="901" y="60"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_both-approved_send-for-signature_di" bpmnElement="Flow_both-approved_send-for-signature">
        <di:waypoint x="926" y="85"/>
        <di:waypoint x="926" y="220"/>
        <di:waypoint x="1051" y="220"/>
        <bpmndi:BPMNLabel>
          <dc:Bounds x="902" y="146" width="40" height="14"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_send-for-signature_contract-sent_di" bpmnElement="Flow_send-for-signature_contract-sent">
        <di:waypoint x="1151" y="220"/>
        <di:waypoint x="1251" y="220"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_both-approved_return-to-requester_di" bpmnElement="Flow_both-approved_return-to-requester">
        <di:waypoint x="951" y="60"/>
        <di:waypoint x="1051" y="60"/>
        <bpmndi:BPMNLabel>
          <dc:Bounds x="981" y="36" width="40" height="14"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_return-to-requester_contract-returned_di" bpmnElement="Flow_return-to-requester_contract-returned">
        <di:waypoint x="1151" y="60"/>
        <di:waypoint x="1251" y="60"/>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</bpmn:definitions>

