<?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"
                  id="Definitions_3"
                  targetNamespace="http://forven.com.br/bpmn">

  <bpmn:collaboration id="Collaboration_3">
    <bpmn:participant id="Participant_3" name="Autorização de O.S. / NFS-e" processRef="Process_3" />
  </bpmn:collaboration>

  <bpmn:process id="Process_3" isExecutable="false">

    <bpmn:laneSet id="LaneSet_3">
      <bpmn:lane id="Lane_Sistema" name="Sistema">
        <bpmn:flowNodeRef>StartEvent_1</bpmn:flowNodeRef>
        <bpmn:flowNodeRef>Task_MontaOS</bpmn:flowNodeRef>
        <bpmn:flowNodeRef>Task_ClicaAutorizar</bpmn:flowNodeRef>
        <bpmn:flowNodeRef>Gateway_EmiteNFSe</bpmn:flowNodeRef>
        <bpmn:flowNodeRef>Task_AplicaEfeitosDireto</bpmn:flowNodeRef>
      </bpmn:lane>
      <bpmn:lane id="Lane_ComNFSe" name="Com NFS-e">
        <bpmn:flowNodeRef>Task_TransmitePrefeitura</bpmn:flowNodeRef>
        <bpmn:flowNodeRef>Gateway_Autorizada</bpmn:flowNodeRef>
        <bpmn:flowNodeRef>Task_NegadaErro</bpmn:flowNodeRef>
        <bpmn:flowNodeRef>EndEvent_Negada</bpmn:flowNodeRef>
      </bpmn:lane>
      <bpmn:lane id="Lane_EfeitosAutomaticos" name="Efeitos automáticos">
        <bpmn:flowNodeRef>Task_EstoqueBaixa</bpmn:flowNodeRef>
        <bpmn:flowNodeRef>Task_FinanceiroContas</bpmn:flowNodeRef>
        <bpmn:flowNodeRef>Gateway_Sucesso</bpmn:flowNodeRef>
        <bpmn:flowNodeRef>EndEvent_Sucesso</bpmn:flowNodeRef>
        <bpmn:flowNodeRef>Task_Rollback</bpmn:flowNodeRef>
        <bpmn:flowNodeRef>EndEvent_Rollback</bpmn:flowNodeRef>
      </bpmn:lane>
    </bpmn:laneSet>

    <bpmn:startEvent id="StartEvent_1" name="Início">
      <bpmn:outgoing>Flow_1</bpmn:outgoing>
    </bpmn:startEvent>

    <bpmn:task id="Task_MontaOS" name="Monta a O.S.&#10;(serviços + peças vinculadas)">
      <bpmn:incoming>Flow_1</bpmn:incoming>
      <bpmn:outgoing>Flow_2</bpmn:outgoing>
    </bpmn:task>

    <bpmn:task id="Task_ClicaAutorizar" name="Clica em Autorizar">
      <bpmn:incoming>Flow_2</bpmn:incoming>
      <bpmn:outgoing>Flow_3</bpmn:outgoing>
    </bpmn:task>

    <bpmn:exclusiveGateway id="Gateway_EmiteNFSe" name="A empresa emite NFS-e?">
      <bpmn:incoming>Flow_3</bpmn:incoming>
      <bpmn:outgoing>Flow_4</bpmn:outgoing>
      <bpmn:outgoing>Flow_5</bpmn:outgoing>
    </bpmn:exclusiveGateway>

    <bpmn:task id="Task_AplicaEfeitosDireto" name="Aplica os efeitos direto,&#10;sem transmissão fiscal">
      <bpmn:incoming>Flow_4</bpmn:incoming>
      <bpmn:outgoing>Flow_10</bpmn:outgoing>
    </bpmn:task>

    <bpmn:task id="Task_TransmitePrefeitura" name="Transmite à Prefeitura&#10;(Receita Nacional)">
      <bpmn:incoming>Flow_5</bpmn:incoming>
      <bpmn:outgoing>Flow_6</bpmn:outgoing>
    </bpmn:task>

    <bpmn:exclusiveGateway id="Gateway_Autorizada" name="Autorizada?">
      <bpmn:incoming>Flow_6</bpmn:incoming>
      <bpmn:outgoing>Flow_7</bpmn:outgoing>
      <bpmn:outgoing>Flow_9</bpmn:outgoing>
    </bpmn:exclusiveGateway>

    <bpmn:task id="Task_NegadaErro" name="Negada ou erro&#10;nada é alterado">
      <bpmn:incoming>Flow_7</bpmn:incoming>
      <bpmn:outgoing>Flow_8</bpmn:outgoing>
    </bpmn:task>

    <bpmn:endEvent id="EndEvent_Negada" name="Fim - nada alterado">
      <bpmn:incoming>Flow_8</bpmn:incoming>
    </bpmn:endEvent>

    <bpmn:task id="Task_EstoqueBaixa" name="Estoque&#10;baixa das peças usadas">
      <bpmn:incoming>Flow_9</bpmn:incoming>
      <bpmn:incoming>Flow_10</bpmn:incoming>
      <bpmn:outgoing>Flow_11</bpmn:outgoing>
    </bpmn:task>

    <bpmn:task id="Task_FinanceiroContas" name="Financeiro&#10;gera Contas a Receber + boleto">
      <bpmn:incoming>Flow_11</bpmn:incoming>
      <bpmn:outgoing>Flow_12</bpmn:outgoing>
    </bpmn:task>

    <bpmn:exclusiveGateway id="Gateway_Sucesso" name="Estoque e Financeiro OK?">
      <bpmn:incoming>Flow_12</bpmn:incoming>
      <bpmn:outgoing>Flow_13</bpmn:outgoing>
      <bpmn:outgoing>Flow_14</bpmn:outgoing>
    </bpmn:exclusiveGateway>

    <bpmn:endEvent id="EndEvent_Sucesso" name="Fim - concluído">
      <bpmn:incoming>Flow_13</bpmn:incoming>
    </bpmn:endEvent>

    <bpmn:task id="Task_Rollback" name="Estoque e Financeiro falharam&#10;Tudo é desfeito, inclusive a&#10;autorização já concedida">
      <bpmn:incoming>Flow_14</bpmn:incoming>
      <bpmn:outgoing>Flow_15</bpmn:outgoing>
    </bpmn:task>

    <bpmn:endEvent id="EndEvent_Rollback" name="Fim - desfeito">
      <bpmn:incoming>Flow_15</bpmn:incoming>
    </bpmn:endEvent>

    <bpmn:sequenceFlow id="Flow_1" sourceRef="StartEvent_1" targetRef="Task_MontaOS" />
    <bpmn:sequenceFlow id="Flow_2" sourceRef="Task_MontaOS" targetRef="Task_ClicaAutorizar" />
    <bpmn:sequenceFlow id="Flow_3" sourceRef="Task_ClicaAutorizar" targetRef="Gateway_EmiteNFSe" />
    <bpmn:sequenceFlow id="Flow_4" name="não" sourceRef="Gateway_EmiteNFSe" targetRef="Task_AplicaEfeitosDireto" />
    <bpmn:sequenceFlow id="Flow_5" name="sim" sourceRef="Gateway_EmiteNFSe" targetRef="Task_TransmitePrefeitura" />
    <bpmn:sequenceFlow id="Flow_6" sourceRef="Task_TransmitePrefeitura" targetRef="Gateway_Autorizada" />
    <bpmn:sequenceFlow id="Flow_7" name="não" sourceRef="Gateway_Autorizada" targetRef="Task_NegadaErro" />
    <bpmn:sequenceFlow id="Flow_8" sourceRef="Task_NegadaErro" targetRef="EndEvent_Negada" />
    <bpmn:sequenceFlow id="Flow_9" name="sim" sourceRef="Gateway_Autorizada" targetRef="Task_EstoqueBaixa" />
    <bpmn:sequenceFlow id="Flow_10" sourceRef="Task_AplicaEfeitosDireto" targetRef="Task_EstoqueBaixa" />
    <bpmn:sequenceFlow id="Flow_11" sourceRef="Task_EstoqueBaixa" targetRef="Task_FinanceiroContas" />
    <bpmn:sequenceFlow id="Flow_12" sourceRef="Task_FinanceiroContas" targetRef="Gateway_Sucesso" />
    <bpmn:sequenceFlow id="Flow_13" sourceRef="Gateway_Sucesso" targetRef="EndEvent_Sucesso" />
    <bpmn:sequenceFlow id="Flow_14" name="falha" sourceRef="Gateway_Sucesso" targetRef="Task_Rollback" />
    <bpmn:sequenceFlow id="Flow_15" sourceRef="Task_Rollback" targetRef="EndEvent_Rollback" />

  </bpmn:process>

  <bpmndi:BPMNDiagram id="BPMNDiagram_3">
    <bpmndi:BPMNPlane id="BPMNPlane_3" bpmnElement="Collaboration_3">

      <bpmndi:BPMNShape id="Participant_3_di" bpmnElement="Participant_3" isHorizontal="true">
        <dc:Bounds x="0" y="0" width="920" height="1276" />
      </bpmndi:BPMNShape>

      <bpmndi:BPMNShape id="Lane_Sistema_di" bpmnElement="Lane_Sistema" isHorizontal="true">
        <dc:Bounds x="40" y="0" width="880" height="500" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Lane_ComNFSe_di" bpmnElement="Lane_ComNFSe" isHorizontal="true">
        <dc:Bounds x="40" y="500" width="880" height="340" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Lane_EfeitosAutomaticos_di" bpmnElement="Lane_EfeitosAutomaticos" isHorizontal="true">
        <dc:Bounds x="40" y="840" width="880" height="416" />
      </bpmndi:BPMNShape>

      <bpmndi:BPMNShape id="StartEvent_1_di" bpmnElement="StartEvent_1">
        <dc:Bounds x="442" y="20" width="36" height="36" />
      </bpmndi:BPMNShape>

      <bpmndi:BPMNShape id="Task_MontaOS_di" bpmnElement="Task_MontaOS">
        <dc:Bounds x="350" y="90" width="220" height="70" />
      </bpmndi:BPMNShape>

      <bpmndi:BPMNShape id="Task_ClicaAutorizar_di" bpmnElement="Task_ClicaAutorizar">
        <dc:Bounds x="350" y="190" width="220" height="70" />
      </bpmndi:BPMNShape>

      <bpmndi:BPMNShape id="Gateway_EmiteNFSe_di" bpmnElement="Gateway_EmiteNFSe" isMarkerVisible="true">
        <dc:Bounds x="435" y="310" width="50" height="50" />
      </bpmndi:BPMNShape>

      <bpmndi:BPMNShape id="Task_AplicaEfeitosDireto_di" bpmnElement="Task_AplicaEfeitosDireto">
        <dc:Bounds x="80" y="405" width="220" height="70" />
      </bpmndi:BPMNShape>

      <bpmndi:BPMNShape id="Task_TransmitePrefeitura_di" bpmnElement="Task_TransmitePrefeitura">
        <dc:Bounds x="350" y="535" width="220" height="70" />
      </bpmndi:BPMNShape>

      <bpmndi:BPMNShape id="Gateway_Autorizada_di" bpmnElement="Gateway_Autorizada" isMarkerVisible="true">
        <dc:Bounds x="435" y="660" width="50" height="50" />
      </bpmndi:BPMNShape>

      <bpmndi:BPMNShape id="Task_NegadaErro_di" bpmnElement="Task_NegadaErro">
        <dc:Bounds x="620" y="650" width="220" height="70" />
      </bpmndi:BPMNShape>

      <bpmndi:BPMNShape id="EndEvent_Negada_di" bpmnElement="EndEvent_Negada">
        <dc:Bounds x="712" y="750" width="36" height="36" />
      </bpmndi:BPMNShape>

      <bpmndi:BPMNShape id="Task_EstoqueBaixa_di" bpmnElement="Task_EstoqueBaixa">
        <dc:Bounds x="350" y="875" width="220" height="70" />
      </bpmndi:BPMNShape>

      <bpmndi:BPMNShape id="Task_FinanceiroContas_di" bpmnElement="Task_FinanceiroContas">
        <dc:Bounds x="350" y="975" width="220" height="70" />
      </bpmndi:BPMNShape>

      <bpmndi:BPMNShape id="Gateway_Sucesso_di" bpmnElement="Gateway_Sucesso" isMarkerVisible="true">
        <dc:Bounds x="435" y="1075" width="50" height="50" />
      </bpmndi:BPMNShape>

      <bpmndi:BPMNShape id="EndEvent_Sucesso_di" bpmnElement="EndEvent_Sucesso">
        <dc:Bounds x="442" y="1142" width="36" height="36" />
      </bpmndi:BPMNShape>

      <bpmndi:BPMNShape id="Task_Rollback_di" bpmnElement="Task_Rollback">
        <dc:Bounds x="620" y="1075" width="220" height="90" />
      </bpmndi:BPMNShape>

      <bpmndi:BPMNShape id="EndEvent_Rollback_di" bpmnElement="EndEvent_Rollback">
        <dc:Bounds x="712" y="1195" width="36" height="36" />
      </bpmndi:BPMNShape>

      <bpmndi:BPMNEdge id="Flow_1_di" bpmnElement="Flow_1">
        <di:waypoint x="460" y="56" />
        <di:waypoint x="460" y="90" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_2_di" bpmnElement="Flow_2">
        <di:waypoint x="460" y="160" />
        <di:waypoint x="460" y="190" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_3_di" bpmnElement="Flow_3">
        <di:waypoint x="460" y="260" />
        <di:waypoint x="460" y="310" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_4_di" bpmnElement="Flow_4">
        <di:waypoint x="435" y="335" />
        <di:waypoint x="190" y="335" />
        <di:waypoint x="190" y="405" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="290" y="320" width="25" height="14" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_5_di" bpmnElement="Flow_5">
        <di:waypoint x="460" y="360" />
        <di:waypoint x="460" y="535" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="466" y="440" width="20" height="14" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_6_di" bpmnElement="Flow_6">
        <di:waypoint x="460" y="605" />
        <di:waypoint x="460" y="660" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_7_di" bpmnElement="Flow_7">
        <di:waypoint x="485" y="685" />
        <di:waypoint x="620" y="685" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="540" y="670" width="25" height="14" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_8_di" bpmnElement="Flow_8">
        <di:waypoint x="730" y="720" />
        <di:waypoint x="730" y="750" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_9_di" bpmnElement="Flow_9">
        <di:waypoint x="460" y="710" />
        <di:waypoint x="460" y="875" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="466" y="780" width="20" height="14" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_10_di" bpmnElement="Flow_10">
        <di:waypoint x="190" y="475" />
        <di:waypoint x="190" y="910" />
        <di:waypoint x="350" y="910" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_11_di" bpmnElement="Flow_11">
        <di:waypoint x="460" y="945" />
        <di:waypoint x="460" y="975" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_12_di" bpmnElement="Flow_12">
        <di:waypoint x="460" y="1045" />
        <di:waypoint x="460" y="1075" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_13_di" bpmnElement="Flow_13">
        <di:waypoint x="460" y="1125" />
        <di:waypoint x="460" y="1142" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_14_di" bpmnElement="Flow_14">
        <di:waypoint x="485" y="1100" />
        <di:waypoint x="620" y="1100" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="540" y="1085" width="30" height="14" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_15_di" bpmnElement="Flow_15">
        <di:waypoint x="730" y="1165" />
        <di:waypoint x="730" y="1195" />
      </bpmndi:BPMNEdge>

    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>

</bpmn:definitions>
