dodil/erp-method

modules/payments/signoff/payments/payments_payout.bpmn

<?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:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dodil="https://git.dodil.io/dodil/erp-platform/bpmn/1" id="Definitions_payments_v8" name="Payments &amp; collections processes" targetNamespace="https://git.dodil.io/dodil/erp-platform/processes" exporter="erp-platform erp-compose bpmn" exporterVersion="1">
 <bpmn:collaboration id="Collaboration_payments_v8">
  <bpmn:documentation>Payments &amp; collections: one pool per entity lifecycle, generated from module.yaml.</bpmn:documentation>
  <bpmn:participant id="Participant_payments_payout" name="Payout" processRef="Process_payments_payout_v8" />
 </bpmn:collaboration>
 <bpmn:process id="Process_payments_payout_v8" name="Payout" isExecutable="false">
  <bpmn:documentation>Lifecycle of the payout, generated from module.yaml by erp-compose bpmn; change the workflow there, not this file. States: requested, approved, exported, paid, returned, cancelled.</bpmn:documentation>
  <bpmn:laneSet id="LaneSet_payout">
   <bpmn:lane id="Lane_payout_system" name="The system">
    <bpmn:flowNodeRef>Start_payout</bpmn:flowNodeRef>
    <bpmn:flowNodeRef>Task_request_payout</bpmn:flowNodeRef>
    <bpmn:flowNodeRef>Task_confirm_payout_paid</bpmn:flowNodeRef>
    <bpmn:flowNodeRef>Task_record_payout_return</bpmn:flowNodeRef>
    <bpmn:flowNodeRef>Task_cancel_payout</bpmn:flowNodeRef>
    <bpmn:flowNodeRef>Gateway_payout_paid__if</bpmn:flowNodeRef>
    <bpmn:flowNodeRef>End_payout_paid</bpmn:flowNodeRef>
    <bpmn:flowNodeRef>End_payout_returned</bpmn:flowNodeRef>
    <bpmn:flowNodeRef>End_payout_cancelled</bpmn:flowNodeRef>
   </bpmn:lane>
   <bpmn:lane id="Lane_payout_approver" name="Owner / finance manager">
    <bpmn:flowNodeRef>Task_approve_payout</bpmn:flowNodeRef>
    <bpmn:flowNodeRef>Task_approve_payout_batch</bpmn:flowNodeRef>
    <bpmn:flowNodeRef>Gateway_payout_requested__if</bpmn:flowNodeRef>
   </bpmn:lane>
   <bpmn:lane id="Lane_payout_cashier" name="Whoever records money (bookkeeper, office manager)">
    <bpmn:flowNodeRef>Task_export_payout_run</bpmn:flowNodeRef>
    <bpmn:flowNodeRef>Gateway_payout_approved__if</bpmn:flowNodeRef>
   </bpmn:lane>
  </bpmn:laneSet>
  <bpmn:startEvent id="Start_payout" name="Payout needed">
   <bpmn:outgoing>Flow_Start_payout__Task_request_payout</bpmn:outgoing>
  </bpmn:startEvent>
  <bpmn:serviceTask id="Task_request_payout" name="Take a payout another module asks for (v6, PAY-51)" dodil:step="request_payout" implementation="##unspecified">
   <bpmn:documentation>By: The system. From none to requested. When: payout_ref unique (a repeat answers the same); the payee is a person partner (business-partner kind person); a paying bank account of the company in the currency; amount above zero; due_on today or later. Effect: a payout with its source_module and source_document, waiting for an approver.</bpmn:documentation>
   <bpmn:incoming>Flow_Start_payout__Task_request_payout</bpmn:incoming>
   <bpmn:outgoing>Flow_Task_request_payout__Gateway_payout_requested__if</bpmn:outgoing>
  </bpmn:serviceTask>
  <bpmn:userTask id="Task_approve_payout" name="Approve the payout" dodil:step="approve_payout" dodil:approval="true">
   <bpmn:documentation>By: Owner / finance manager. From requested to approved. When: the approver is not the payee nor the requester's approver of the source document (email AND sub). Effect: who and when. An approval.</bpmn:documentation>
   <bpmn:incoming>Flow_Gateway_payout_requested__if__Task_approve_payout</bpmn:incoming>
   <bpmn:outgoing>Flow_Task_approve_payout__Gateway_payout_approved__if</bpmn:outgoing>
  </bpmn:userTask>
  <bpmn:task id="Task_approve_payout_batch" name="Approve a batch of payouts (v7, PAY-52)" dodil:step="approve_payout_batch" dodil:approval="true">
   <bpmn:documentation>By: Owner / finance manager or The system. From requested to approved. When: every payout of the batch_ref whose payee is not the approver (email AND sub); by system only when payout_auto_approve_sources names the source_module. Effect: the approver's own payout, if any, stays requested for another approver. An approval.</bpmn:documentation>
   <bpmn:incoming>Flow_Gateway_payout_requested__if__Task_approve_payout_batch</bpmn:incoming>
   <bpmn:outgoing>Flow_Task_approve_payout_batch__Gateway_payout_approved__if</bpmn:outgoing>
  </bpmn:task>
  <bpmn:userTask id="Task_export_payout_run" name="Export the payout run" dodil:step="export_payout_run">
   <bpmn:documentation>By: Whoever records money (bookkeeper, office manager). From approved to exported. When: the payee's bank account read from hr (GET /persons/{person_id}/bank-account) or, without it, typed and confirmed by a second person; the cashier is not the approver. Effect: a pain.001 or Bacs Standard 18 file of the approved payouts of one paying account and payment date, stored as an object; the bank details only in the file.</bpmn:documentation>
   <bpmn:incoming>Flow_Gateway_payout_approved__if__Task_export_payout_run</bpmn:incoming>
   <bpmn:outgoing>Flow_Task_export_payout_run__Task_confirm_payout_paid</bpmn:outgoing>
  </bpmn:userTask>
  <bpmn:task id="Task_confirm_payout_paid" name="Confirm what the bank paid" dodil:step="confirm_payout_paid">
   <bpmn:documentation>By: The system or Whoever records money (bookkeeper, office manager). From exported to paid. When: a matched statement debit, or a bank_ref and paid_on today or earlier given by the cashier. Effect: journal &lt;clearing_purpose&gt; / bank (employee_payable for expenses, net_pay_payable for payroll), event payout, derived from the payout_ref; after commit the source is told (expenses' POST /reports/{source_document}/paid; v7 payroll's POST /pay-runs/{source_document}/payouts/{payout_ref}/paid), retried until it answers 2xx.</bpmn:documentation>
   <bpmn:incoming>Flow_Task_export_payout_run__Task_confirm_payout_paid</bpmn:incoming>
   <bpmn:outgoing>Flow_Task_confirm_payout_paid__Gateway_payout_paid__if</bpmn:outgoing>
  </bpmn:task>
  <bpmn:task id="Task_record_payout_return" name="Record a payout the bank returned" dodil:step="record_payout_return">
   <bpmn:documentation>By: The system or Whoever records money (bookkeeper, office manager). From paid to returned. When: a statement credit naming the payout, or the cashier with the bank's return reference. Effect: the journal reversed (event payout_return); the source is told it was not paid (v7: payroll's route with status returned).</bpmn:documentation>
   <bpmn:incoming>Flow_Gateway_payout_paid__if__Task_record_payout_return</bpmn:incoming>
   <bpmn:outgoing>Flow_Task_record_payout_return__End_payout_returned</bpmn:outgoing>
  </bpmn:task>
  <bpmn:task id="Task_cancel_payout" name="Cancel the payout" dodil:step="cancel_payout">
   <bpmn:documentation>By: The system or Owner / finance manager. From requested / approved to cancelled. When: not exported; by system only for the module that requested it (POST /payouts/{payout_ref}/cancel). Requires: reason.</bpmn:documentation>
   <bpmn:incoming>Flow_Gateway_payout_requested__if__Task_cancel_payout</bpmn:incoming>
   <bpmn:incoming>Flow_Gateway_payout_approved__if__Task_cancel_payout</bpmn:incoming>
   <bpmn:outgoing>Flow_Task_cancel_payout__End_payout_cancelled</bpmn:outgoing>
  </bpmn:task>
  <bpmn:exclusiveGateway id="Gateway_payout_requested__if" name="Payout requested: what next?">
   <bpmn:incoming>Flow_Task_request_payout__Gateway_payout_requested__if</bpmn:incoming>
   <bpmn:outgoing>Flow_Gateway_payout_requested__if__Task_approve_payout</bpmn:outgoing>
   <bpmn:outgoing>Flow_Gateway_payout_requested__if__Task_approve_payout_batch</bpmn:outgoing>
   <bpmn:outgoing>Flow_Gateway_payout_requested__if__Task_cancel_payout</bpmn:outgoing>
  </bpmn:exclusiveGateway>
  <bpmn:exclusiveGateway id="Gateway_payout_approved__if" name="Payout approved: what next?">
   <bpmn:incoming>Flow_Task_approve_payout__Gateway_payout_approved__if</bpmn:incoming>
   <bpmn:incoming>Flow_Task_approve_payout_batch__Gateway_payout_approved__if</bpmn:incoming>
   <bpmn:outgoing>Flow_Gateway_payout_approved__if__Task_export_payout_run</bpmn:outgoing>
   <bpmn:outgoing>Flow_Gateway_payout_approved__if__Task_cancel_payout</bpmn:outgoing>
  </bpmn:exclusiveGateway>
  <bpmn:exclusiveGateway id="Gateway_payout_paid__if" name="Payout paid: done, or go on?">
   <bpmn:incoming>Flow_Task_confirm_payout_paid__Gateway_payout_paid__if</bpmn:incoming>
   <bpmn:outgoing>Flow_Gateway_payout_paid__if__Task_record_payout_return</bpmn:outgoing>
   <bpmn:outgoing>Flow_Gateway_payout_paid__if__End_payout_paid</bpmn:outgoing>
  </bpmn:exclusiveGateway>
  <bpmn:endEvent id="End_payout_paid" name="Payout paid">
   <bpmn:incoming>Flow_Gateway_payout_paid__if__End_payout_paid</bpmn:incoming>
  </bpmn:endEvent>
  <bpmn:endEvent id="End_payout_returned" name="Payout returned">
   <bpmn:incoming>Flow_Task_record_payout_return__End_payout_returned</bpmn:incoming>
  </bpmn:endEvent>
  <bpmn:endEvent id="End_payout_cancelled" name="Payout cancelled">
   <bpmn:incoming>Flow_Task_cancel_payout__End_payout_cancelled</bpmn:incoming>
  </bpmn:endEvent>
  <bpmn:sequenceFlow id="Flow_Start_payout__Task_request_payout" sourceRef="Start_payout" targetRef="Task_request_payout" />
  <bpmn:sequenceFlow id="Flow_Gateway_payout_requested__if__Task_approve_payout" sourceRef="Gateway_payout_requested__if" targetRef="Task_approve_payout" />
  <bpmn:sequenceFlow id="Flow_Gateway_payout_requested__if__Task_approve_payout_batch" sourceRef="Gateway_payout_requested__if" targetRef="Task_approve_payout_batch" />
  <bpmn:sequenceFlow id="Flow_Gateway_payout_requested__if__Task_cancel_payout" sourceRef="Gateway_payout_requested__if" targetRef="Task_cancel_payout" />
  <bpmn:sequenceFlow id="Flow_Task_request_payout__Gateway_payout_requested__if" sourceRef="Task_request_payout" targetRef="Gateway_payout_requested__if" />
  <bpmn:sequenceFlow id="Flow_Gateway_payout_approved__if__Task_export_payout_run" sourceRef="Gateway_payout_approved__if" targetRef="Task_export_payout_run" />
  <bpmn:sequenceFlow id="Flow_Gateway_payout_approved__if__Task_cancel_payout" sourceRef="Gateway_payout_approved__if" targetRef="Task_cancel_payout" />
  <bpmn:sequenceFlow id="Flow_Task_approve_payout__Gateway_payout_approved__if" sourceRef="Task_approve_payout" targetRef="Gateway_payout_approved__if" />
  <bpmn:sequenceFlow id="Flow_Task_approve_payout_batch__Gateway_payout_approved__if" sourceRef="Task_approve_payout_batch" targetRef="Gateway_payout_approved__if" />
  <bpmn:sequenceFlow id="Flow_Task_export_payout_run__Task_confirm_payout_paid" sourceRef="Task_export_payout_run" targetRef="Task_confirm_payout_paid" />
  <bpmn:sequenceFlow id="Flow_Gateway_payout_paid__if__Task_record_payout_return" sourceRef="Gateway_payout_paid__if" targetRef="Task_record_payout_return" />
  <bpmn:sequenceFlow id="Flow_Gateway_payout_paid__if__End_payout_paid" name="done" sourceRef="Gateway_payout_paid__if" targetRef="End_payout_paid" />
  <bpmn:sequenceFlow id="Flow_Task_confirm_payout_paid__Gateway_payout_paid__if" sourceRef="Task_confirm_payout_paid" targetRef="Gateway_payout_paid__if" />
  <bpmn:sequenceFlow id="Flow_Task_record_payout_return__End_payout_returned" sourceRef="Task_record_payout_return" targetRef="End_payout_returned" />
  <bpmn:sequenceFlow id="Flow_Task_cancel_payout__End_payout_cancelled" sourceRef="Task_cancel_payout" targetRef="End_payout_cancelled" />
 </bpmn:process>
 <bpmndi:BPMNDiagram id="BPMNDiagram_payments_v8">
  <bpmndi:BPMNPlane id="BPMNPlane_payments_v8" bpmnElement="Collaboration_payments_v8">
   <bpmndi:BPMNShape id="Participant_payments_payout_di" bpmnElement="Participant_payments_payout" isHorizontal="true">
    <dc:Bounds x="0" y="0" width="1810" height="660" />
   </bpmndi:BPMNShape>
   <bpmndi:BPMNShape id="Lane_payout_system_di" bpmnElement="Lane_payout_system" isHorizontal="true">
    <dc:Bounds x="30" y="0" width="1780" height="260" />
   </bpmndi:BPMNShape>
   <bpmndi:BPMNShape id="Lane_payout_approver_di" bpmnElement="Lane_payout_approver" isHorizontal="true">
    <dc:Bounds x="30" y="260" width="1780" height="260" />
   </bpmndi:BPMNShape>
   <bpmndi:BPMNShape id="Lane_payout_cashier_di" bpmnElement="Lane_payout_cashier" isHorizontal="true">
    <dc:Bounds x="30" y="520" width="1780" height="140" />
   </bpmndi:BPMNShape>
   <bpmndi:BPMNShape id="Start_payout_di" bpmnElement="Start_payout">
    <dc:Bounds x="157" y="42" width="36" height="36" />
   </bpmndi:BPMNShape>
   <bpmndi:BPMNShape id="Task_request_payout_di" bpmnElement="Task_request_payout">
    <dc:Bounds x="295" y="20" width="100" height="80" />
   </bpmndi:BPMNShape>
   <bpmndi:BPMNShape id="Task_approve_payout_di" bpmnElement="Task_approve_payout">
    <dc:Bounds x="635" y="280" width="100" height="80" />
   </bpmndi:BPMNShape>
   <bpmndi:BPMNShape id="Task_approve_payout_batch_di" bpmnElement="Task_approve_payout_batch">
    <dc:Bounds x="635" y="400" width="100" height="80" />
   </bpmndi:BPMNShape>
   <bpmndi:BPMNShape id="Task_export_payout_run_di" bpmnElement="Task_export_payout_run">
    <dc:Bounds x="975" y="540" width="100" height="80" />
   </bpmndi:BPMNShape>
   <bpmndi:BPMNShape id="Task_confirm_payout_paid_di" bpmnElement="Task_confirm_payout_paid">
    <dc:Bounds x="1145" y="20" width="100" height="80" />
   </bpmndi:BPMNShape>
   <bpmndi:BPMNShape id="Task_record_payout_return_di" bpmnElement="Task_record_payout_return">
    <dc:Bounds x="1485" y="20" width="100" height="80" />
   </bpmndi:BPMNShape>
   <bpmndi:BPMNShape id="Task_cancel_payout_di" bpmnElement="Task_cancel_payout">
    <dc:Bounds x="635" y="20" width="100" height="80" />
   </bpmndi:BPMNShape>
   <bpmndi:BPMNShape id="Gateway_payout_requested__if_di" bpmnElement="Gateway_payout_requested__if">
    <dc:Bounds x="490" y="295" width="50" height="50" />
   </bpmndi:BPMNShape>
   <bpmndi:BPMNShape id="Gateway_payout_approved__if_di" bpmnElement="Gateway_payout_approved__if">
    <dc:Bounds x="830" y="555" width="50" height="50" />
   </bpmndi:BPMNShape>
   <bpmndi:BPMNShape id="Gateway_payout_paid__if_di" bpmnElement="Gateway_payout_paid__if">
    <dc:Bounds x="1340" y="35" width="50" height="50" />
   </bpmndi:BPMNShape>
   <bpmndi:BPMNShape id="End_payout_paid_di" bpmnElement="End_payout_paid">
    <dc:Bounds x="1517" y="162" width="36" height="36" />
   </bpmndi:BPMNShape>
   <bpmndi:BPMNShape id="End_payout_returned_di" bpmnElement="End_payout_returned">
    <dc:Bounds x="1687" y="42" width="36" height="36" />
   </bpmndi:BPMNShape>
   <bpmndi:BPMNShape id="End_payout_cancelled_di" bpmnElement="End_payout_cancelled">
    <dc:Bounds x="837" y="42" width="36" height="36" />
   </bpmndi:BPMNShape>
   <bpmndi:BPMNEdge id="Flow_Start_payout__Task_request_payout_di" bpmnElement="Flow_Start_payout__Task_request_payout">
    <di:waypoint x="193" y="60" />
    <di:waypoint x="295" y="60" />
   </bpmndi:BPMNEdge>
   <bpmndi:BPMNEdge id="Flow_Gateway_payout_requested__if__Task_approve_payout_di" bpmnElement="Flow_Gateway_payout_requested__if__Task_approve_payout">
    <di:waypoint x="540" y="320" />
    <di:waypoint x="635" y="320" />
   </bpmndi:BPMNEdge>
   <bpmndi:BPMNEdge id="Flow_Gateway_payout_requested__if__Task_approve_payout_batch_di" bpmnElement="Flow_Gateway_payout_requested__if__Task_approve_payout_batch">
    <di:waypoint x="540" y="320" />
    <di:waypoint x="610" y="320" />
    <di:waypoint x="610" y="440" />
    <di:waypoint x="635" y="440" />
   </bpmndi:BPMNEdge>
   <bpmndi:BPMNEdge id="Flow_Gateway_payout_requested__if__Task_cancel_payout_di" bpmnElement="Flow_Gateway_payout_requested__if__Task_cancel_payout">
    <di:waypoint x="540" y="320" />
    <di:waypoint x="610" y="320" />
    <di:waypoint x="610" y="60" />
    <di:waypoint x="635" y="60" />
   </bpmndi:BPMNEdge>
   <bpmndi:BPMNEdge id="Flow_Task_request_payout__Gateway_payout_requested__if_di" bpmnElement="Flow_Task_request_payout__Gateway_payout_requested__if">
    <di:waypoint x="395" y="60" />
    <di:waypoint x="465" y="60" />
    <di:waypoint x="465" y="320" />
    <di:waypoint x="490" y="320" />
   </bpmndi:BPMNEdge>
   <bpmndi:BPMNEdge id="Flow_Gateway_payout_approved__if__Task_export_payout_run_di" bpmnElement="Flow_Gateway_payout_approved__if__Task_export_payout_run">
    <di:waypoint x="880" y="580" />
    <di:waypoint x="975" y="580" />
   </bpmndi:BPMNEdge>
   <bpmndi:BPMNEdge id="Flow_Gateway_payout_approved__if__Task_cancel_payout_di" bpmnElement="Flow_Gateway_payout_approved__if__Task_cancel_payout">
    <di:waypoint x="855" y="605" />
    <di:waypoint x="855" y="620" />
    <di:waypoint x="685" y="620" />
    <di:waypoint x="685" y="100" />
   </bpmndi:BPMNEdge>
   <bpmndi:BPMNEdge id="Flow_Task_approve_payout__Gateway_payout_approved__if_di" bpmnElement="Flow_Task_approve_payout__Gateway_payout_approved__if">
    <di:waypoint x="735" y="320" />
    <di:waypoint x="805" y="320" />
    <di:waypoint x="805" y="580" />
    <di:waypoint x="830" y="580" />
   </bpmndi:BPMNEdge>
   <bpmndi:BPMNEdge id="Flow_Task_approve_payout_batch__Gateway_payout_approved__if_di" bpmnElement="Flow_Task_approve_payout_batch__Gateway_payout_approved__if">
    <di:waypoint x="735" y="440" />
    <di:waypoint x="805" y="440" />
    <di:waypoint x="805" y="580" />
    <di:waypoint x="830" y="580" />
   </bpmndi:BPMNEdge>
   <bpmndi:BPMNEdge id="Flow_Task_export_payout_run__Task_confirm_payout_paid_di" bpmnElement="Flow_Task_export_payout_run__Task_confirm_payout_paid">
    <di:waypoint x="1075" y="580" />
    <di:waypoint x="1120" y="580" />
    <di:waypoint x="1120" y="60" />
    <di:waypoint x="1145" y="60" />
   </bpmndi:BPMNEdge>
   <bpmndi:BPMNEdge id="Flow_Gateway_payout_paid__if__Task_record_payout_return_di" bpmnElement="Flow_Gateway_payout_paid__if__Task_record_payout_return">
    <di:waypoint x="1390" y="60" />
    <di:waypoint x="1485" y="60" />
   </bpmndi:BPMNEdge>
   <bpmndi:BPMNEdge id="Flow_Gateway_payout_paid__if__End_payout_paid_di" bpmnElement="Flow_Gateway_payout_paid__if__End_payout_paid">
    <di:waypoint x="1390" y="60" />
    <di:waypoint x="1492" y="60" />
    <di:waypoint x="1492" y="180" />
    <di:waypoint x="1517" y="180" />
   </bpmndi:BPMNEdge>
   <bpmndi:BPMNEdge id="Flow_Task_confirm_payout_paid__Gateway_payout_paid__if_di" bpmnElement="Flow_Task_confirm_payout_paid__Gateway_payout_paid__if">
    <di:waypoint x="1245" y="60" />
    <di:waypoint x="1340" y="60" />
   </bpmndi:BPMNEdge>
   <bpmndi:BPMNEdge id="Flow_Task_record_payout_return__End_payout_returned_di" bpmnElement="Flow_Task_record_payout_return__End_payout_returned">
    <di:waypoint x="1585" y="60" />
    <di:waypoint x="1687" y="60" />
   </bpmndi:BPMNEdge>
   <bpmndi:BPMNEdge id="Flow_Task_cancel_payout__End_payout_cancelled_di" bpmnElement="Flow_Task_cancel_payout__End_payout_cancelled">
    <di:waypoint x="735" y="60" />
    <di:waypoint x="837" y="60" />
   </bpmndi:BPMNEdge>
  </bpmndi:BPMNPlane>
 </bpmndi:BPMNDiagram>
</bpmn:definitions>