Invoice import modification
authorVásáry Dániel <vasary@elgekko.net>
Wed, 15 Nov 2023 10:59:35 +0000 (11:59 +0100)
committerVásáry Dániel <vasary@elgekko.net>
Wed, 15 Nov 2023 10:59:35 +0000 (11:59 +0100)
14 files changed:
lis-app/src/test/java/hu/user/lis/RepositoryIT.java
lis-db/migrations/environments/prod.properties
lis-db/migrations/environments/test.properties [new file with mode: 0644]
lis-db/migrations/scripts/012_add_created_by_import_to_partner.sql [new file with mode: 0644]
lis-db/migrations/scripts/013_create_incvoice_import.sql [new file with mode: 0644]
lis-db/pom.xml
lis-db/src/main/java/hu/user/lis/db/InvoiceImport.java [new file with mode: 0644]
lis-db/src/main/java/hu/user/lis/db/Partner.java
lis-db/src/main/java/hu/user/lis/db/converter/StringListConverter.java [new file with mode: 0644]
lis-db/src/main/java/hu/user/lis/db/repository/InvoiceImportRepository.java [new file with mode: 0644]
lis-workflow/src/main/java/hu/user/lis/workflow/invoice/DownloadInvoiceData.java
lis-workflow/src/main/java/hu/user/lis/workflow/invoice/ListNewInvoices.java
lis-workflow/src/main/resources/assign-incoming-invoices.bpmn [new file with mode: 0644]
lis-workflow/src/main/resources/import-incoming-invoices.bpmn

index b00e823d4b8353a3c5474a69d5f4272d9677dc35..64753718d8cc38cae0642eea913d574619630925 100644 (file)
@@ -6,9 +6,7 @@
 package hu.user.lis;
 
 import hu.user.lis.db.*;
-import hu.user.lis.db.repository.ProjectRepository;
-import hu.user.lis.db.repository.ServiceRecordRepository;
-import hu.user.lis.db.repository.TreasuryRepository;
+import hu.user.lis.db.repository.*;
 import hu.user.lis.service.data.ProjectService;
 import hu.user.lis.service.data.TreasuryService;
 import lombok.extern.log4j.Log4j2;
@@ -22,9 +20,11 @@ import org.springframework.test.context.TestPropertySource;
 import org.springframework.test.context.junit4.SpringRunner;
 
 import javax.persistence.EntityNotFoundException;
+import java.util.Arrays;
 import java.util.List;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
 
 
 @Log4j2
@@ -47,6 +47,12 @@ public class RepositoryIT {
     @Autowired
     private TreasuryRepository treasuryRepository;
 
+    @Autowired
+    private InvoiceImportRepository invoiceImportRepository;
+
+    @Autowired
+    private InvoiceRepository invoiceRepository;
+
     @Test
     public void testRepositoryCapabilities() {
         List<ServiceRecord> allItems = serviceRecordRepository.findAll();
@@ -102,4 +108,24 @@ public class RepositoryIT {
 
         projectRepository.deleteAll();
     }
+
+    @Test
+    public void createImportInvoice() {
+        List<Invoice> invoices = invoiceRepository.findAll();
+
+        Invoice invoice = invoices.get(0);
+
+        InvoiceImport invoiceImport = InvoiceImport.builder()
+                .invoice(invoice)
+                .suggestedProjects(Arrays.asList("X1", "X2"))
+                .build();
+
+        invoiceImportRepository.saveAndFlush(invoiceImport);
+
+        assertNotNull(invoiceImport.getImported());
+        assertEquals("X1", invoiceImport.getSuggestedProjects().get(0));
+        assertEquals("X2", invoiceImport.getSuggestedProjects().get(1));
+        invoiceImportRepository.delete(invoiceImport);
+
+    }
 }
index c5d02a9ac7147e3418bfeab8f1e86d3ba9f1c55b..77fc048c43a2b8c5eca757f7e31bbe0d7110d503 100644 (file)
@@ -4,9 +4,9 @@ time_zone=GMT+0:00
 script_char_set=UTF-8
 ## JDBC connection properties.
 driver=com.ibm.db2.jcc.DB2Driver
-url=jdbc:db2://dvdev.in.useribm.hu:50000/lis
+url=jdbc:db2://db2.in.useribm.hu:50000/slycrm
 username=db2admin
-password=password
+password=Passw@rd01
 #
 # A NOTE ON STORED PROCEDURES AND DELIMITERS
 #
diff --git a/lis-db/migrations/environments/test.properties b/lis-db/migrations/environments/test.properties
new file mode 100644 (file)
index 0000000..c5d02a9
--- /dev/null
@@ -0,0 +1,57 @@
+## Base time zone to ensure times are consistent across machines
+time_zone=GMT+0:00
+## The character set that scripts are encoded with
+script_char_set=UTF-8
+## JDBC connection properties.
+driver=com.ibm.db2.jcc.DB2Driver
+url=jdbc:db2://dvdev.in.useribm.hu:50000/lis
+username=db2admin
+password=password
+#
+# A NOTE ON STORED PROCEDURES AND DELIMITERS
+#
+# Stored procedures and functions commonly have nested delimiters
+# that conflict with the schema migration parsing.  If you tend
+# to use procs, functions, triggers or anything that could create
+# this situation, then you may want to experiment with
+# send_full_script=true (preferred), or if you can't use
+# send_full_script, then you may have to resort to a full
+# line delimiter such as "GO" or "/" or "!RUN!".
+#
+# Also play with the autocommit settings, as some drivers
+# or databases don't support creating procs, functions or
+# even tables in a transaction, and others require it.
+#
+# This ignores the line delimiters and
+# simply sends the entire script at once.
+# Use with JDBC drivers that can accept large
+# blocks of delimited text at once.
+send_full_script=false
+# This controls how statements are delimited.
+# By default statements are delimited by an
+# end of line semicolon.  Some databases may
+# (e.g. MS SQL Server) may require a full line
+# delimiter such as GO.
+# These are ignored if send_full_script is true.
+delimiter=;
+full_line_delimiter=false
+# If set to true, each statement is isolated
+# in its own transaction.  Otherwise the entire
+# script is executed in one transaction.
+# Few databases should need this set to true,
+# but some do.
+auto_commit=false
+# If set to false, warnings from the database will interrupt migrations.
+ignore_warnings=true
+# Custom driver path to allow you to centralize your driver files
+# Default requires the drivers to be in the drivers directory of your
+# initialized migration directory (created with "migrate init")
+# driver_path=
+# Name of the table that tracks changes to the database
+changelog=CHANGELOG
+# Migrations support variable substitutions in the form of ${variable}
+# in the migration scripts.  All of the above properties will be ignored though,
+# with the exception of changelog.
+# Example: The following would be referenced in a migration file as ${ip_address}
+# ip_address=192.168.0.1
+
diff --git a/lis-db/migrations/scripts/012_add_created_by_import_to_partner.sql b/lis-db/migrations/scripts/012_add_created_by_import_to_partner.sql
new file mode 100644 (file)
index 0000000..8603565
--- /dev/null
@@ -0,0 +1,9 @@
+-- // add created_by_import to partner
+-- Migration SQL that makes the change goes here.
+
+ALTER TABLE partner ADD COLUMN created_by_import SMALLINT NOT NULL DEFAULT 0;
+
+-- //@UNDO
+-- SQL to undo the change goes here.
+
+ALTER TABLE partner DROP COLUMN created_by_import;
diff --git a/lis-db/migrations/scripts/013_create_incvoice_import.sql b/lis-db/migrations/scripts/013_create_incvoice_import.sql
new file mode 100644 (file)
index 0000000..80f3438
--- /dev/null
@@ -0,0 +1,16 @@
+-- // create invoice import
+-- Migration SQL that makes the change goes here.
+
+CREATE TABLE invoice_import (
+    id BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY,
+    invoice_id BIGINT,
+    imported TIMESTAMP NOT NULL,
+    suggested_projects VARCHAR(200),
+    CONSTRAINT pk_invoice_import PRIMARY KEY (id)
+);
+ALTER TABLE invoice_import ADD CONSTRAINT FK_INVOICE_IMPORT_ON_INVOICE FOREIGN KEY (invoice_id) REFERENCES invoice (id);
+
+-- //@UNDO
+-- SQL to undo the change goes here.
+
+DROP TABLE invoice_import;
index ea1d6f8dcae3da31de9b2573503932cea6f4905e..c94753f17a002b28b44a50fe0a473f4e9b63789a 100644 (file)
             <groupId>com.fasterxml.jackson.core</groupId>
             <artifactId>jackson-annotations</artifactId>
         </dependency>
-        <dependency>
-            <groupId>org.hibernate</groupId>
-            <artifactId>hibernate-core</artifactId>
-            <version>5.6.15.Final</version>
-        </dependency>
+        <!--        <dependency>-->
+        <!--            <groupId>org.hibernate</groupId>-->
+        <!--            <artifactId>hibernate-core</artifactId>-->
+        <!--            <version>5.6.15.Final</version>-->
+        <!--        </dependency>-->
     </dependencies>
 </project>
\ No newline at end of file
diff --git a/lis-db/src/main/java/hu/user/lis/db/InvoiceImport.java b/lis-db/src/main/java/hu/user/lis/db/InvoiceImport.java
new file mode 100644 (file)
index 0000000..07ef118
--- /dev/null
@@ -0,0 +1,37 @@
+package hu.user.lis.db;
+
+import com.fasterxml.jackson.annotation.JsonIncludeProperties;
+import hu.user.lis.db.converter.StringListConverter;
+import lombok.*;
+import org.hibernate.annotations.CreationTimestamp;
+
+import javax.persistence.*;
+import java.io.Serializable;
+import java.util.Date;
+import java.util.List;
+
+@Getter
+@Setter
+@Entity
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class InvoiceImport implements Serializable {
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    private Long id;
+
+    @ManyToOne
+    @JoinColumn(name = "invoice_id")
+    @JsonIncludeProperties({"id"})
+    private Invoice invoice;
+
+    @GeneratedValue(strategy = GenerationType.AUTO)
+    @Column(updatable = false)
+    @CreationTimestamp
+    private Date imported;
+
+    @Convert(converter = StringListConverter.class)
+    private List<String> suggestedProjects;
+
+}
index 7bce08c89a71c08cf2406c9966a4f10da60b5523..88e330efed2a75d8ef1eb13fa8e26f20ac0fe80a 100644 (file)
@@ -15,9 +15,15 @@ public class Partner implements Serializable {
     @Id
     @GeneratedValue(strategy = GenerationType.IDENTITY)
     Long id;
+
     String name;
+
     @Column(unique = true)
     String vatNr;
+
     String address;
+
     boolean active;
+    
+    boolean createdByImport;
 }
diff --git a/lis-db/src/main/java/hu/user/lis/db/converter/StringListConverter.java b/lis-db/src/main/java/hu/user/lis/db/converter/StringListConverter.java
new file mode 100644 (file)
index 0000000..8c12157
--- /dev/null
@@ -0,0 +1,23 @@
+package hu.user.lis.db.converter;
+
+import javax.persistence.AttributeConverter;
+import javax.persistence.Converter;
+import java.util.Arrays;
+import java.util.List;
+
+import static java.util.Collections.emptyList;
+
+@Converter
+public class StringListConverter implements AttributeConverter<List<String>, String> {
+    private static final String SPLIT_CHAR = ",";
+
+    @Override
+    public String convertToDatabaseColumn(List<String> stringList) {
+        return stringList != null ? String.join(SPLIT_CHAR, stringList) : "";
+    }
+
+    @Override
+    public List<String> convertToEntityAttribute(String string) {
+        return string != null ? Arrays.asList(string.split(SPLIT_CHAR)) : emptyList();
+    }
+}
\ No newline at end of file
diff --git a/lis-db/src/main/java/hu/user/lis/db/repository/InvoiceImportRepository.java b/lis-db/src/main/java/hu/user/lis/db/repository/InvoiceImportRepository.java
new file mode 100644 (file)
index 0000000..7b4c222
--- /dev/null
@@ -0,0 +1,8 @@
+package hu.user.lis.db.repository;
+
+import hu.user.lis.db.InvoiceImport;
+import org.springframework.data.jpa.repository.JpaRepository;
+
+public interface InvoiceImportRepository extends JpaRepository<InvoiceImport, Long> {
+
+}
index e453367c2348a14ec6e70b5344092af01b0f0019..4fc1ae5c385e20ef30165ebdc29a0bd88b704f4c 100644 (file)
@@ -1,7 +1,10 @@
 package hu.user.lis.workflow.invoice;
 
 import hu.user.lis.db.IncomingInvoice;
+import hu.user.lis.db.InvoiceImport;
 import hu.user.lis.db.Partner;
+import hu.user.lis.db.repository.InvoiceImportRepository;
+import hu.user.lis.db.repository.InvoiceRepository;
 import hu.user.lis.db.repository.PartnerRepository;
 import hu.user.lis.workflow.invoice.service.IncomingInvoiceFetcherService;
 import lombok.extern.log4j.Log4j2;
@@ -17,6 +20,10 @@ import java.util.Optional;
 @Log4j2
 @Component
 public class DownloadInvoiceData implements JavaDelegate {
+    @Autowired
+    private InvoiceImportRepository invoiceImportRepository;
+    @Autowired
+    private InvoiceRepository invoiceRepository;
 
     @Autowired
     private PartnerRepository partnerRepository;
@@ -42,9 +49,18 @@ public class DownloadInvoiceData implements JavaDelegate {
         List<String> projectSuggestions = new ArrayList<>();
         IncomingInvoice invoice = incomingInvoiceFetcherService.getInvoiceDataOnline(invoiceXml, projectSuggestions);
         Optional<Partner> partnerEntity = partnerRepository.findByVatNr(invoice.getPartner().getVatNr());
-        partnerEntity.ifPresent(invoice::setPartner);
-        delegateExecution.setVariableLocal("invoiceEntity", invoice);
-        delegateExecution.setVariableLocal("projectSuggestions", projectSuggestions);
-        log.info("Invoice {} processed", invoiceXml);
+        if (partnerEntity.isPresent()) {
+            invoice.setPartner(partnerEntity.get());
+        } else {
+            invoice.getPartner().setCreatedByImport(true);
+            partnerRepository.save(invoice.getPartner());
+        }
+        invoiceRepository.save(invoice);
+        InvoiceImport invoiceImport = InvoiceImport.builder()
+                .invoice(invoice)
+                .suggestedProjects(projectSuggestions)
+                .build();
+        invoiceImportRepository.save(invoiceImport);
+        log.info("Invoice {} {} processed", invoice.getHumanId(), invoice.getPartner().getName());
     }
 }
index 84b8ce6af23a9533ce446e652010ed9584d95307..286bd715db896f31ece0c67ebec698d1f612e297 100644 (file)
@@ -30,6 +30,8 @@ public class ListNewInvoices implements JavaDelegate {
     @Override
     public void execute(DelegateExecution delegateExecution) throws Exception {
         log.info("Executing");
+
+        //TODO TaxOfficeRequestBuilder params()
         List<String> invoices = incomingInvoiceFetcherService.getNewInvoicesOnline();
         delegateExecution.setVariableLocal("invoices", invoices);
     }
diff --git a/lis-workflow/src/main/resources/assign-incoming-invoices.bpmn b/lis-workflow/src/main/resources/assign-incoming-invoices.bpmn
new file mode 100644 (file)
index 0000000..e25b7f5
--- /dev/null
@@ -0,0 +1,76 @@
+<?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:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_07nj4df" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.14.0" modeler:executionPlatform="Camunda Platform" modeler:executionPlatformVersion="7.15.0">
+  <bpmn:process id="assignIncomingInvoices" name="Assign Incoming Invoices" isExecutable="true" camunda:versionTag="0.1">
+    <bpmn:startEvent id="Event_1v3e1za">
+      <bpmn:outgoing>Flow_1ubjpz9</bpmn:outgoing>
+    </bpmn:startEvent>
+    <bpmn:endEvent id="Event_1cc91rc">
+      <bpmn:incoming>Flow_0uvj71q</bpmn:incoming>
+    </bpmn:endEvent>
+    <bpmn:userTask id="assignProjectAndAttachFile" name="Assign invoice">
+      <bpmn:extensionElements />
+      <bpmn:incoming>Flow_0efz1ox</bpmn:incoming>
+      <bpmn:incoming>Flow_1ubjpz9</bpmn:incoming>
+      <bpmn:outgoing>Flow_0c887e2</bpmn:outgoing>
+    </bpmn:userTask>
+    <bpmn:userTask id="approveAssignment" name="Approve invoice assignment">
+      <bpmn:incoming>Flow_0c887e2</bpmn:incoming>
+      <bpmn:outgoing>Flow_00r2v71</bpmn:outgoing>
+    </bpmn:userTask>
+    <bpmn:exclusiveGateway id="Gateway_1folrc8" default="Flow_0uvj71q">
+      <bpmn:incoming>Flow_00r2v71</bpmn:incoming>
+      <bpmn:outgoing>Flow_0uvj71q</bpmn:outgoing>
+      <bpmn:outgoing>Flow_0efz1ox</bpmn:outgoing>
+    </bpmn:exclusiveGateway>
+    <bpmn:sequenceFlow id="Flow_1ubjpz9" sourceRef="Event_1v3e1za" targetRef="assignProjectAndAttachFile" />
+    <bpmn:sequenceFlow id="Flow_0uvj71q" sourceRef="Gateway_1folrc8" targetRef="Event_1cc91rc" />
+    <bpmn:sequenceFlow id="Flow_0efz1ox" sourceRef="Gateway_1folrc8" targetRef="assignProjectAndAttachFile">
+      <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${not approved}</bpmn:conditionExpression>
+    </bpmn:sequenceFlow>
+    <bpmn:sequenceFlow id="Flow_0c887e2" sourceRef="assignProjectAndAttachFile" targetRef="approveAssignment" />
+    <bpmn:sequenceFlow id="Flow_00r2v71" sourceRef="approveAssignment" targetRef="Gateway_1folrc8" />
+  </bpmn:process>
+  <bpmndi:BPMNDiagram id="BPMNDiagram_1">
+    <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="assignIncomingInvoices">
+      <bpmndi:BPMNShape id="Event_1v3e1za_di" bpmnElement="Event_1v3e1za">
+        <dc:Bounds x="152" y="82" width="36" height="36" />
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNShape id="Event_1cc91rc_di" bpmnElement="Event_1cc91rc">
+        <dc:Bounds x="652" y="82" width="36" height="36" />
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNShape id="Activity_08g5whq_di" bpmnElement="assignProjectAndAttachFile">
+        <dc:Bounds x="240" y="60" width="100" height="80" />
+        <bpmndi:BPMNLabel />
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNShape id="Activity_003yviv_di" bpmnElement="approveAssignment">
+        <dc:Bounds x="400" y="60" width="100" height="80" />
+        <bpmndi:BPMNLabel />
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNShape id="Gateway_1folrc8_di" bpmnElement="Gateway_1folrc8" isMarkerVisible="true">
+        <dc:Bounds x="555" y="75" width="50" height="50" />
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNEdge id="Flow_1ubjpz9_di" bpmnElement="Flow_1ubjpz9">
+        <di:waypoint x="188" y="100" />
+        <di:waypoint x="240" y="100" />
+      </bpmndi:BPMNEdge>
+      <bpmndi:BPMNEdge id="Flow_0uvj71q_di" bpmnElement="Flow_0uvj71q">
+        <di:waypoint x="605" y="100" />
+        <di:waypoint x="652" y="100" />
+      </bpmndi:BPMNEdge>
+      <bpmndi:BPMNEdge id="Flow_0efz1ox_di" bpmnElement="Flow_0efz1ox">
+        <di:waypoint x="580" y="125" />
+        <di:waypoint x="580" y="163" />
+        <di:waypoint x="290" y="163" />
+        <di:waypoint x="290" y="140" />
+      </bpmndi:BPMNEdge>
+      <bpmndi:BPMNEdge id="Flow_0c887e2_di" bpmnElement="Flow_0c887e2">
+        <di:waypoint x="340" y="100" />
+        <di:waypoint x="400" y="100" />
+      </bpmndi:BPMNEdge>
+      <bpmndi:BPMNEdge id="Flow_00r2v71_di" bpmnElement="Flow_00r2v71">
+        <di:waypoint x="500" y="100" />
+        <di:waypoint x="555" y="100" />
+      </bpmndi:BPMNEdge>
+    </bpmndi:BPMNPlane>
+  </bpmndi:BPMNDiagram>
+</bpmn:definitions>
index c33b4822a3ccecbead819fd12530d64015ba309c..ad2f47e852522000bcef3dbf5912976a0026e274 100644 (file)
@@ -10,7 +10,7 @@
       <bpmn:incoming>Flow_1gzempz</bpmn:incoming>
       <bpmn:outgoing>Flow_0y5cjps</bpmn:outgoing>
     </bpmn:serviceTask>
-    <bpmn:subProcess id="assignAndApproveInvoices" name="Assign and approve">
+    <bpmn:subProcess id="downloadInvoices" name="Download">
       <bpmn:incoming>Flow_0y5cjps</bpmn:incoming>
       <bpmn:outgoing>Flow_0vgb0nw</bpmn:outgoing>
       <bpmn:multiInstanceLoopCharacteristics camunda:collection="invoices" camunda:elementVariable="invoice" />
         <bpmn:outgoing>Flow_1ubjpz9</bpmn:outgoing>
       </bpmn:startEvent>
       <bpmn:endEvent id="Event_1cc91rc">
-        <bpmn:incoming>Flow_0uvj71q</bpmn:incoming>
+        <bpmn:incoming>Flow_0e62ocl</bpmn:incoming>
       </bpmn:endEvent>
-      <bpmn:sequenceFlow id="Flow_00r2v71" sourceRef="approveAssignment" targetRef="Gateway_1folrc8" />
-      <bpmn:userTask id="assignProjectAndAttachFile" name="Assign invoice">
-        <bpmn:extensionElements />
-        <bpmn:incoming>Flow_14m4iht</bpmn:incoming>
-        <bpmn:incoming>Flow_0efz1ox</bpmn:incoming>
-        <bpmn:outgoing>Flow_0c887e2</bpmn:outgoing>
-      </bpmn:userTask>
-      <bpmn:sequenceFlow id="Flow_0c887e2" sourceRef="assignProjectAndAttachFile" targetRef="approveAssignment" />
-      <bpmn:userTask id="approveAssignment" name="Approve invoice assignment">
-        <bpmn:incoming>Flow_0c887e2</bpmn:incoming>
-        <bpmn:outgoing>Flow_00r2v71</bpmn:outgoing>
-      </bpmn:userTask>
       <bpmn:serviceTask id="Activity_02fjt6a" name="Download invoice datas" camunda:asyncBefore="true" camunda:delegateExpression="${downloadInvoiceData}">
         <bpmn:extensionElements />
         <bpmn:incoming>Flow_1ubjpz9</bpmn:incoming>
-        <bpmn:outgoing>Flow_14m4iht</bpmn:outgoing>
+        <bpmn:outgoing>Flow_0e62ocl</bpmn:outgoing>
       </bpmn:serviceTask>
       <bpmn:sequenceFlow id="Flow_1ubjpz9" sourceRef="Event_1v3e1za" targetRef="Activity_02fjt6a" />
-      <bpmn:sequenceFlow id="Flow_14m4iht" sourceRef="Activity_02fjt6a" targetRef="assignProjectAndAttachFile" />
-      <bpmn:exclusiveGateway id="Gateway_1folrc8" default="Flow_0uvj71q">
-        <bpmn:incoming>Flow_00r2v71</bpmn:incoming>
-        <bpmn:outgoing>Flow_0uvj71q</bpmn:outgoing>
-        <bpmn:outgoing>Flow_0efz1ox</bpmn:outgoing>
-      </bpmn:exclusiveGateway>
-      <bpmn:sequenceFlow id="Flow_0uvj71q" sourceRef="Gateway_1folrc8" targetRef="Event_1cc91rc" />
-      <bpmn:sequenceFlow id="Flow_0efz1ox" sourceRef="Gateway_1folrc8" targetRef="assignProjectAndAttachFile">
-        <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${not approved}</bpmn:conditionExpression>
-      </bpmn:sequenceFlow>
+      <bpmn:sequenceFlow id="Flow_0e62ocl" sourceRef="Activity_02fjt6a" targetRef="Event_1cc91rc" />
     </bpmn:subProcess>
     <bpmn:endEvent id="Event_07aly41">
       <bpmn:incoming>Flow_0vgb0nw</bpmn:incoming>
     </bpmn:endEvent>
-    <bpmn:sequenceFlow id="Flow_0vgb0nw" sourceRef="assignAndApproveInvoices" targetRef="Event_07aly41" />
-    <bpmn:sequenceFlow id="Flow_0y5cjps" sourceRef="Activity_0q29ngn" targetRef="assignAndApproveInvoices" />
+    <bpmn:sequenceFlow id="Flow_0vgb0nw" sourceRef="downloadInvoices" targetRef="Event_07aly41" />
+    <bpmn:sequenceFlow id="Flow_0y5cjps" sourceRef="Activity_0q29ngn" targetRef="downloadInvoices" />
   </bpmn:process>
   <bpmndi:BPMNDiagram id="BPMNDiagram_1">
     <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="importIncomingInvoices">
         <dc:Bounds x="270" y="137" width="100" height="80" />
       </bpmndi:BPMNShape>
       <bpmndi:BPMNShape id="Event_07aly41_di" bpmnElement="Event_07aly41">
-        <dc:Bounds x="1272" y="159" width="36" height="36" />
+        <dc:Bounds x="872" y="159" width="36" height="36" />
       </bpmndi:BPMNShape>
-      <bpmndi:BPMNShape id="Activity_0u274ph_di" bpmnElement="assignAndApproveInvoices" isExpanded="true">
-        <dc:Bounds x="420" y="77" width="800" height="203" />
+      <bpmndi:BPMNShape id="Activity_0u274ph_di" bpmnElement="downloadInvoices" isExpanded="true">
+        <dc:Bounds x="420" y="77" width="390" height="203" />
         <bpmndi:BPMNLabel />
       </bpmndi:BPMNShape>
       <bpmndi:BPMNShape id="Event_1v3e1za_di" bpmnElement="Event_1v3e1za">
-        <dc:Bounds x="460.33333333333337" y="159" width="36" height="36" />
-      </bpmndi:BPMNShape>
-      <bpmndi:BPMNShape id="Activity_08g5whq_di" bpmnElement="assignProjectAndAttachFile">
-        <dc:Bounds x="710" y="137" width="100" height="80" />
-        <bpmndi:BPMNLabel />
+        <dc:Bounds x="470" y="159" width="36" height="36" />
       </bpmndi:BPMNShape>
-      <bpmndi:BPMNShape id="Activity_003yviv_di" bpmnElement="approveAssignment">
-        <dc:Bounds x="870" y="137" width="100" height="80" />
-        <bpmndi:BPMNLabel />
+      <bpmndi:BPMNShape id="Event_1cc91rc_di" bpmnElement="Event_1cc91rc">
+        <dc:Bounds x="722" y="159" width="36" height="36" />
       </bpmndi:BPMNShape>
       <bpmndi:BPMNShape id="Activity_035tjqs_di" bpmnElement="Activity_02fjt6a">
-        <dc:Bounds x="550" y="137" width="100" height="80" />
-      </bpmndi:BPMNShape>
-      <bpmndi:BPMNShape id="Gateway_1folrc8_di" bpmnElement="Gateway_1folrc8" isMarkerVisible="true">
-        <dc:Bounds x="1025" y="152" width="50" height="50" />
-      </bpmndi:BPMNShape>
-      <bpmndi:BPMNShape id="Event_1cc91rc_di" bpmnElement="Event_1cc91rc">
-        <dc:Bounds x="1122" y="159" width="36" height="36" />
+        <dc:Bounds x="560" y="137" width="100" height="80" />
       </bpmndi:BPMNShape>
-      <bpmndi:BPMNEdge id="Flow_00r2v71_di" bpmnElement="Flow_00r2v71">
-        <di:waypoint x="970" y="177" />
-        <di:waypoint x="1025" y="177" />
-      </bpmndi:BPMNEdge>
-      <bpmndi:BPMNEdge id="Flow_0c887e2_di" bpmnElement="Flow_0c887e2">
-        <di:waypoint x="810" y="177" />
-        <di:waypoint x="870" y="177" />
-      </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="Flow_1ubjpz9_di" bpmnElement="Flow_1ubjpz9">
-        <di:waypoint x="496" y="177" />
-        <di:waypoint x="550" y="177" />
+        <di:waypoint x="506" y="177" />
+        <di:waypoint x="560" y="177" />
       </bpmndi:BPMNEdge>
-      <bpmndi:BPMNEdge id="Flow_14m4iht_di" bpmnElement="Flow_14m4iht">
-        <di:waypoint x="650" y="177" />
-        <di:waypoint x="710" y="177" />
-      </bpmndi:BPMNEdge>
-      <bpmndi:BPMNEdge id="Flow_0uvj71q_di" bpmnElement="Flow_0uvj71q">
-        <di:waypoint x="1075" y="177" />
-        <di:waypoint x="1122" y="177" />
-      </bpmndi:BPMNEdge>
-      <bpmndi:BPMNEdge id="Flow_0efz1ox_di" bpmnElement="Flow_0efz1ox">
-        <di:waypoint x="1050" y="202" />
-        <di:waypoint x="1050" y="240" />
-        <di:waypoint x="760" y="240" />
-        <di:waypoint x="760" y="217" />
+      <bpmndi:BPMNEdge id="Flow_0e62ocl_di" bpmnElement="Flow_0e62ocl">
+        <di:waypoint x="660" y="177" />
+        <di:waypoint x="722" y="177" />
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="Flow_1gzempz_di" bpmnElement="Flow_1gzempz">
         <di:waypoint x="215" y="177" />
         <di:waypoint x="270" y="177" />
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="Flow_0vgb0nw_di" bpmnElement="Flow_0vgb0nw">
-        <di:waypoint x="1220" y="177" />
-        <di:waypoint x="1272" y="177" />
+        <di:waypoint x="810" y="177" />
+        <di:waypoint x="872" y="177" />
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="Flow_0y5cjps_di" bpmnElement="Flow_0y5cjps">
         <di:waypoint x="370" y="177" />