<?xml version="1.0" encoding="UTF-8"?>
<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="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" id="sample-diagram" targetNamespace="http://bpmn.io/schema/bpmn" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd">
  <bpmn2:collaboration id="Collaboration_1vzc4e2">
    <bpmn2:participant id="Participant_1g6enp2" name="Account Payable" processRef="Process_1" />
    <bpmn2:participant id="Participant_1e7gk8x" name="Manager" processRef="Process_0t314on" />
    <bpmn2:messageFlow id="MessageFlow_18tfm5f" sourceRef="Task_cancelByAdmin" targetRef="event_cancel" />
  </bpmn2:collaboration>
  <bpmn2:process id="Process_1" isExecutable="false">
    <bpmn2:startEvent id="StartEvent_AP">
      <bpmn2:outgoing>SequenceFlow_129vlnl</bpmn2:outgoing>
    </bpmn2:startEvent>
    <bpmn2:userTask id="task_issue_invoice" name="Issue Invoice">
      <bpmn2:incoming>SequenceFlow_129vlnl</bpmn2:incoming>
      <bpmn2:outgoing>SequenceFlow_1nmqrtq</bpmn2:outgoing>
    </bpmn2:userTask>
    <bpmn2:eventBasedGateway id="ExclusiveGateway_04dgpye">
      <bpmn2:incoming>SequenceFlow_1nmqrtq</bpmn2:incoming>
      <bpmn2:incoming>SequenceFlow_0cokf0m</bpmn2:incoming>
      <bpmn2:outgoing>SequenceFlow_147bbuq</bpmn2:outgoing>
      <bpmn2:outgoing>SequenceFlow_1ucmquu</bpmn2:outgoing>
      <bpmn2:outgoing>SequenceFlow_0dq5qq6</bpmn2:outgoing>
    </bpmn2:eventBasedGateway>
    <bpmn2:intermediateCatchEvent id="event_cancel" name="Cancel by Admin">
      <bpmn2:incoming>SequenceFlow_0dq5qq6</bpmn2:incoming>
      <bpmn2:outgoing>SequenceFlow_0karre6</bpmn2:outgoing>
      <bpmn2:messageEventDefinition />
    </bpmn2:intermediateCatchEvent>
    <bpmn2:receiveTask id="task_got_payment" name="Got Payment">
      <bpmn2:incoming>SequenceFlow_147bbuq</bpmn2:incoming>
      <bpmn2:outgoing>SequenceFlow_1ml8g8q</bpmn2:outgoing>
    </bpmn2:receiveTask>
    <bpmn2:endEvent id="EndEvent_0sxnxfz">
      <bpmn2:incoming>SequenceFlow_1ml8g8q</bpmn2:incoming>
    </bpmn2:endEvent>
    <bpmn2:intermediateCatchEvent id="event_timer" name="30 days later">
      <bpmn2:incoming>SequenceFlow_1ucmquu</bpmn2:incoming>
      <bpmn2:outgoing>SequenceFlow_1h10gv4</bpmn2:outgoing>
      <bpmn2:timerEventDefinition id="TimerEventDefinition_07xu06a">
        <bpmn2:timeDuration>PT2S</bpmn2:timeDuration>
      </bpmn2:timerEventDefinition>
    </bpmn2:intermediateCatchEvent>
    <bpmn2:endEvent id="EndEvent_0ypa03q">
      <bpmn2:incoming>SequenceFlow_0karre6</bpmn2:incoming>
      <bpmn2:terminateEventDefinition />
    </bpmn2:endEvent>
    <bpmn2:scriptTask id="task_reminder" name="Issue Reminder">
      <bpmn2:incoming>SequenceFlow_1h10gv4</bpmn2:incoming>
      <bpmn2:outgoing>SequenceFlow_0cokf0m</bpmn2:outgoing>
      <bpmn2:script>
            let data = item.data;
            console.log("sending a reminder scirpt");
            console.log(data);
            
            if (typeof data.reminderCounter === 'undefined') {
              data['reminderCounter']=0;
            }            
            
            data['reminderCounter']=data['reminderCounter']+1;
            this.token.log('testing from the inside: ');
      </bpmn2:script>
    </bpmn2:scriptTask>
    <bpmn2:sequenceFlow id="SequenceFlow_129vlnl" sourceRef="StartEvent_AP" targetRef="task_issue_invoice" />
    <bpmn2:sequenceFlow id="SequenceFlow_1nmqrtq" sourceRef="task_issue_invoice" targetRef="ExclusiveGateway_04dgpye" />
    <bpmn2:sequenceFlow id="SequenceFlow_0cokf0m" sourceRef="task_reminder" targetRef="ExclusiveGateway_04dgpye" />
    <bpmn2:sequenceFlow id="SequenceFlow_147bbuq" sourceRef="ExclusiveGateway_04dgpye" targetRef="task_got_payment" />
    <bpmn2:sequenceFlow id="SequenceFlow_1ucmquu" sourceRef="ExclusiveGateway_04dgpye" targetRef="event_timer">
      <bpmn2:conditionExpression>(item.data.reminderCounter &lt; 1)</bpmn2:conditionExpression>
    </bpmn2:sequenceFlow>
    <bpmn2:sequenceFlow id="SequenceFlow_0dq5qq6" sourceRef="ExclusiveGateway_04dgpye" targetRef="event_cancel" />
    <bpmn2:sequenceFlow id="SequenceFlow_0karre6" sourceRef="event_cancel" targetRef="EndEvent_0ypa03q" />
    <bpmn2:sequenceFlow id="SequenceFlow_1ml8g8q" sourceRef="task_got_payment" targetRef="EndEvent_0sxnxfz" />
    <bpmn2:sequenceFlow id="SequenceFlow_1h10gv4" sourceRef="event_timer" targetRef="task_reminder" />
  </bpmn2:process>
  <bpmn2:process id="Process_0t314on">
    <bpmn2:startEvent id="StartEvent_Manager">
      <bpmn2:outgoing>SequenceFlow_1vs4h9e</bpmn2:outgoing>
    </bpmn2:startEvent>
    <bpmn2:userTask id="Task_cancelByAdmin" name="Cancel Invoice">
      <bpmn2:incoming>SequenceFlow_1vs4h9e</bpmn2:incoming>
      <bpmn2:outgoing>SequenceFlow_0yw5wjo</bpmn2:outgoing>
    </bpmn2:userTask>
    <bpmn2:endEvent id="endEvent_managerProcess">
      <bpmn2:incoming>SequenceFlow_0yw5wjo</bpmn2:incoming>
    </bpmn2:endEvent>
    <bpmn2:sequenceFlow id="SequenceFlow_1vs4h9e" sourceRef="StartEvent_Manager" targetRef="Task_cancelByAdmin" />
    <bpmn2:sequenceFlow id="SequenceFlow_0yw5wjo" sourceRef="Task_cancelByAdmin" targetRef="endEvent_managerProcess" />
  </bpmn2:process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_1">
    <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Collaboration_1vzc4e2">
      <bpmndi:BPMNShape id="Participant_1g6enp2_di" bpmnElement="Participant_1g6enp2">
        <dc:Bounds x="137" y="10" width="613" height="321" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge id="SequenceFlow_1h10gv4_di" bpmnElement="SequenceFlow_1h10gv4">
        <di:waypoint x="455" y="88" />
        <di:waypoint x="530" y="88" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="448" y="67" width="90" height="12" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="SequenceFlow_1ml8g8q_di" bpmnElement="SequenceFlow_1ml8g8q">
        <di:waypoint x="552" y="166" />
        <di:waypoint x="605" y="166" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="534" y="145" width="90" height="12" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="SequenceFlow_0karre6_di" bpmnElement="SequenceFlow_0karre6">
        <di:waypoint x="483" y="266" />
        <di:waypoint x="596" y="266" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="495" y="245" width="90" height="12" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="SequenceFlow_0dq5qq6_di" bpmnElement="SequenceFlow_0dq5qq6">
        <di:waypoint x="391" y="191" />
        <di:waypoint x="391" y="266" />
        <di:waypoint x="447" y="266" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="361" y="223" width="90" height="12" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="SequenceFlow_1ucmquu_di" bpmnElement="SequenceFlow_1ucmquu">
        <di:waypoint x="402" y="152" />
        <di:waypoint x="437" y="152" />
        <di:waypoint x="437" y="106" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="375" y="131" width="90" height="12" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="SequenceFlow_147bbuq_di" bpmnElement="SequenceFlow_147bbuq">
        <di:waypoint x="416" y="166" />
        <di:waypoint x="452" y="166" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="389" y="145" width="90" height="12" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="SequenceFlow_0cokf0m_di" bpmnElement="SequenceFlow_0cokf0m">
        <di:waypoint x="530" y="35" />
        <di:waypoint x="391" y="35" />
        <di:waypoint x="391" y="141" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="416" y="14" width="90" height="12" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="SequenceFlow_1nmqrtq_di" bpmnElement="SequenceFlow_1nmqrtq">
        <di:waypoint x="341" y="166" />
        <di:waypoint x="366" y="166" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="309" y="145" width="90" height="12" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="SequenceFlow_129vlnl_di" bpmnElement="SequenceFlow_129vlnl">
        <di:waypoint x="211" y="166" />
        <di:waypoint x="241" y="166" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="181" y="145" width="90" height="12" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNShape id="StartEvent_AP_di" bpmnElement="StartEvent_AP">
        <dc:Bounds x="175" y="148" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="148" y="188" width="90" height="12" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="UserTask_121jsnk_di" bpmnElement="task_issue_invoice">
        <dc:Bounds x="241" y="126" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="EventBasedGateway_0p9yu3x_di" bpmnElement="ExclusiveGateway_04dgpye">
        <dc:Bounds x="366" y="141" width="50" height="50" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="346" y="195" width="90" height="12" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="IntermediateCatchEvent_07ie3nh_di" bpmnElement="event_cancel">
        <dc:Bounds x="447" y="248" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="423" y="288" width="84" height="13" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="task_got_payment_di" bpmnElement="task_got_payment">
        <dc:Bounds x="452" y="126" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="EndEvent_0sxnxfz_di" bpmnElement="EndEvent_0sxnxfz">
        <dc:Bounds x="605" y="148" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="578" y="188" width="90" height="12" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="event_timer_di" bpmnElement="event_timer">
        <dc:Bounds x="419" y="70" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="449" y="57" width="64" height="13" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="EndEvent_1aed36i_di" bpmnElement="EndEvent_0ypa03q">
        <dc:Bounds x="596" y="248" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="568" y="288" width="90" height="12" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="ScriptTask_0bnr6jz_di" bpmnElement="task_reminder">
        <dc:Bounds x="530" y="23" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Participant_1e7gk8x_di" bpmnElement="Participant_1e7gk8x">
        <dc:Bounds x="137" y="339" width="611" height="107" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge id="SequenceFlow_0yw5wjo_di" bpmnElement="SequenceFlow_0yw5wjo">
        <di:waypoint x="350" y="393" />
        <di:waypoint x="413" y="393" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="337" y="372" width="90" height="12" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="SequenceFlow_1vs4h9e_di" bpmnElement="SequenceFlow_1vs4h9e">
        <di:waypoint x="219" y="393" />
        <di:waypoint x="250" y="393" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="190" y="372" width="90" height="12" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNShape id="StartEvent_Manager_di" bpmnElement="StartEvent_Manager">
        <dc:Bounds x="183" y="375" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="156" y="415" width="90" height="12" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="UserTask_0qa04ti_di" bpmnElement="Task_cancelByAdmin">
        <dc:Bounds x="250" y="353" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="EndEvent_1q7mkqe_di" bpmnElement="endEvent_managerProcess">
        <dc:Bounds x="413" y="375" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="385" y="415" width="90" height="12" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge id="MessageFlow_18tfm5f_di" bpmnElement="MessageFlow_18tfm5f">
        <di:waypoint x="299" y="353" />
        <di:waypoint x="299" y="266" />
        <di:waypoint x="447" y="266" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="269" y="303.5" width="90" height="12" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</bpmn2:definitions>
