diff --git a/doc/zoho/README.md b/doc/zoho/README.md index 2660495..fa01f61 100644 --- a/doc/zoho/README.md +++ b/doc/zoho/README.md @@ -2,22 +2,7 @@ AGL Dubai nutzt Zoho als Platform zusammen mit einer lokalen Steuerkanzlei -## Test/Prod Account Imixs - -https://api-console.zoho.eu/ -https://api-console.zoho.eu/client/1000.NLTM2KUEHI696MSLGEIANATVGGX7IN - -``` -zoho.accesstoken 1000.18f5fbeaf572425b8062d015d541aad5.a704efa994774ef33d7af75106468a13 -zoho.apidomain https://www.zohoapis.eu -zoho.clientid 1000.GR5FTPZYB06HEWSFSSX4DJU3OBD4EJ -zoho.clientsecret 3f3e74c5212bbc924a7ebf77f887c6296db1106c47 -zoho.code 1000.c184c7592a218fee58f7b7855b56eb77.7b533ff9f570fd6ab3296784caeec072 -zoho.organization 20105697367 -zoho.refreshtoken 1000.98fe4d0c4f676237b400bf8a3dc219f3.03d6bacf5b988d339eb788c4ecff440e -zoho.scope ZohoBooks.contacts.ALL ZohoBooks.invoices.CREATE ZohoBooks.invoices.READ ZohoBooks.invoices.UPDATE - -``` +Testaccount - siehe [SECRETS.md](SECRETS.md) # API Dokumentation diff --git a/doc/zoho/SECRETS.md b/doc/zoho/SECRETS.md index 63761e4..952e01f 100644 --- a/doc/zoho/SECRETS.md +++ b/doc/zoho/SECRETS.md @@ -8,9 +8,15 @@ https://api-console.zoho.eu/ https://api-console.zoho.eu/client/1000.NLTM2KUEHI696MSLGEIANATVGGX7IN ``` -OrganizationID=20105697367 -client ID= 1000.NLTM2KUEHI696MSLGEIANATVGGX7IN -client secret= ee9ba49f16e77c64abb89cea13542d2326d8d03ce8 +zoho.accesstoken 1000.18f5fbeaf572425b8062d015d541aad5.a704efa994774ef33d7af75106468a13 +zoho.apidomain https://www.zohoapis.eu +zoho.clientid 1000.GR5FTPZYB06HEWSFSSX4DJU3OBD4EJ +zoho.clientsecret 3f3e74c5212bbc924a7ebf77f887c6296db1106c47 +zoho.code 1000.c184c7592a218fee58f7b7855b56eb77.7b533ff9f570fd6ab3296784caeec072 +zoho.organization 20105697367 +zoho.refreshtoken 1000.98fe4d0c4f676237b400bf8a3dc219f3.03d6bacf5b988d339eb788c4ecff440e +zoho.scope ZohoBooks.contacts.ALL ZohoBooks.invoices.CREATE ZohoBooks.invoices.READ ZohoBooks.invoices.UPDATE + ``` # API Dokumentation @@ -24,3 +30,10 @@ https://books.zoho.eu/app/20105697367 https://accounts.zoho.eu/home# Base API URI= https://accounts.zoho.eu/ + +# AGL Organisation + +https://api-console.zoho.com + +info@imixs.com +password imixs4zoho diff --git a/office-alexander-logistics-app/src/main/java/com/alexanderlogistics/zoho/ZohoAPIService.java b/office-alexander-logistics-app/src/main/java/com/alexanderlogistics/zoho/ZohoAPIService.java index 06ac9a1..040279e 100644 --- a/office-alexander-logistics-app/src/main/java/com/alexanderlogistics/zoho/ZohoAPIService.java +++ b/office-alexander-logistics-app/src/main/java/com/alexanderlogistics/zoho/ZohoAPIService.java @@ -180,12 +180,17 @@ public class ZohoAPIService { zohoInvoice = createResponse.getInvoice(); // now add attachments (optional) - if (files != null) { - for (FileData file : files) { - attacheFileData(zohoInvoice.getInvoiceId(), file, "invoices", accessToken); + try { + if (files != null) { + for (FileData file : files) { + attacheFileData(zohoInvoice.getInvoiceId(), file, "invoices", accessToken); + } } + // now mark the invoice as send + markInvoiceAsSend(zohoInvoice.getInvoiceId(), "invoices", accessToken); + } catch (PluginException e) { + logger.warning("Failed to export Invoice: " + e.getMessage()); } - logger.info("│ ├── Invoice Export successful."); return zohoInvoice; } else { @@ -344,4 +349,56 @@ public class ZohoAPIService { } } + /** + * This method marks an invoice as send + * + * + * curl --request POST \ --url + * 'https://www.zohoapis.com/books/v3/invoices/982000000567114/status/sent?organization_id=10234695' + * \ --header 'Authorization: Zoho-oauthtoken + * 1000.41d9xxxxxxxxxxxxxxxxxxxxxxxxc2d1.8fccxxxxxxxxxxxxxxxxxxxxxxxx125f' + * + * + * @param invoiceId The Zoho invoice ID + * @param uriPattern The API endpoint pattern (e.g., "invoices") + * @param accessToken The OAuth access token + * @throws PluginException If the API call fails + */ + public void markInvoiceAsSend(String invoiceId, String uriPattern, String accessToken) throws PluginException { + String uri = zohoOAuthManager.getBaseURI() + uriPattern + "/" + // + invoiceId + // + "/status/sent" + // + "?organization_id=" + zohoOAuthManager.getOrganization(); + + logger.fine("│ ├── mark invoice as sent '" + invoiceId + "'..."); + logger.fine("│ ├── ...uri: " + uri + "..."); + + try { + // JSON serialisieren + String requestBody = ""; + logger.fine("│ ├── " + requestBody); + + HttpRequest request = HttpRequest.newBuilder().uri(URI.create(uri)) + .header("Authorization", "Zoho-oauthtoken " + accessToken) + .header("Content-Type", "application/json").POST(HttpRequest.BodyPublishers.ofString(requestBody)) + .build(); + + HttpResponse response = httpClient.send(request, HttpResponse.BodyHandlers.ofString()); + logger.fine("├── Zoho Response:"); + logger.fine("│ ├── Status Code: " + response.statusCode()); + logger.fine("│ ├── Response Body: " + response.body()); + if (response.statusCode() >= 300) { + throw new PluginException(this.getClass().getName(), "Zoho API error", + "Failed to create invoice. Status code: " + response.statusCode() + ", Response: " + + response.body()); + } + + logger.info("│ ├── OK - status update 'send' successfully"); + + } catch (IOException | InterruptedException e) { + throw new PluginException(this.getClass().getName(), "Zoho API error", + "Failed to add attachment: " + e.getMessage(), e); + } + } + } diff --git a/office-alexander-logistics-app/src/main/java/com/alexanderlogistics/zoho/dto/ZohoExpense.java b/office-alexander-logistics-app/src/main/java/com/alexanderlogistics/zoho/dto/ZohoExpense.java new file mode 100644 index 0000000..3dcb56b --- /dev/null +++ b/office-alexander-logistics-app/src/main/java/com/alexanderlogistics/zoho/dto/ZohoExpense.java @@ -0,0 +1,89 @@ +package com.alexanderlogistics.zoho.dto; + +import java.time.LocalDate; +import java.util.List; + +import jakarta.json.bind.annotation.JsonbDateFormat; +import jakarta.json.bind.annotation.JsonbProperty; + +public class ZohoExpense { + + @JsonbProperty("expense_id") + private String expenseId; + + @JsonbProperty("customer_id") + private String customerId; + + @JsonbDateFormat("yyyy-MM-dd") + private LocalDate date; + + @JsonbProperty("due_date") + @JsonbDateFormat("yyyy-MM-dd") + private LocalDate dueDate; + + @JsonbProperty("reference_number") + private String invoiceNumber; + + @JsonbProperty("line_items") + private List lineItems; + + private double total; + + // Getter und Setter + + public String getInvoiceId() { + return invoiceId; + } + + public void setInvoiceId(String invoiceId) { + this.invoiceId = invoiceId; + } + + public String getCustomerId() { + return customerId; + } + + public void setCustomerId(String customerId) { + this.customerId = customerId; + } + + public LocalDate getDate() { + return date; + } + + public void setDate(LocalDate date) { + this.date = date; + } + + public LocalDate getDueDate() { + return dueDate; + } + + public void setDueDate(LocalDate duedate) { + this.dueDate = duedate; + } + + public String getInvoiceNumber() { + return invoiceNumber; + } + + public void setInvoiceNumber(String invoiceNumber) { + this.invoiceNumber = invoiceNumber; + } + + public List getLineItems() { + return lineItems; + } + + public void setLineItems(List lineItems) { + this.lineItems = lineItems; + } + + public double getTotal() { + return total; + } + + public void setTotal(double total) { + this.total = total; + } +} diff --git a/workflow/dwc/rechnungsausgang-dwc-1.0.3-draft.bpmn b/workflow/dwc/rechnungsausgang-dwc-1.0.3-draft.bpmn index 3b8e3d6..d4478f4 100644 --- a/workflow/dwc/rechnungsausgang-dwc-1.0.3-draft.bpmn +++ b/workflow/dwc/rechnungsausgang-dwc-1.0.3-draft.bpmn @@ -143,6 +143,7 @@ th { font-weight: bold;} TextAnnotation_2 IntermediateCatchEvent_1 event_D2TmxA + event_orShLw @@ -474,6 +475,7 @@ Bei Fragen wenden Sie sich bitte an info@imixs.com SequenceFlow_34 sequenceFlow_zhcE7Q sequenceFlow_6zqWyg + sequenceFlow_0D6BEw SequenceFlow_61 @@ -1507,6 +1509,79 @@ Wiedervorlage wird um 7 bzw. 5 Tage erhöht + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ]]> + + + + + + + + + + + + false + + + + sequenceFlow_0D6BEw + + + + @@ -1942,8 +2017,8 @@ Wiedervorlage wird um 7 bzw. 5 Tage erhöht - - + + @@ -1979,6 +2054,18 @@ Wiedervorlage wird um 7 bzw. 5 Tage erhöht + + + + + + + + + + + + diff --git a/workflow/dwc/rechnungseingang-dwc-1.0.4-draft.bpmn b/workflow/dwc/rechnungseingang-dwc-1.0.4-draft.bpmn index 15f9b0a..4c1b2a1 100644 --- a/workflow/dwc/rechnungseingang-dwc-1.0.4-draft.bpmn +++ b/workflow/dwc/rechnungseingang-dwc-1.0.4-draft.bpmn @@ -165,6 +165,7 @@ TextAnnotation_2 IntermediateCatchEvent_62 gateway_Al0gGg + event_vjVWqA @@ -1461,6 +1462,7 @@ if (workitem.getItemValueString('payment.type')!="direct_debit" && workitem.get SequenceFlow_41 SequenceFlow_14 sequenceFlow_y2ISGw + sequenceFlow_BQWujA @@ -4900,11 +4902,28 @@ Export erfolgt über eine asynchrone Verarbeitung im Modell 'cargosoft-export']] + + + + + + + + + + + + sequenceFlow_BQWujA + + + + + @@ -5552,8 +5571,8 @@ Export erfolgt über eine asynchrone Verarbeitung im Modell 'cargosoft-export']] - - + + @@ -6065,6 +6084,17 @@ Export erfolgt über eine asynchrone Verarbeitung im Modell 'cargosoft-export']] + + + + + + + + + + +