From 919ad796de0e1d859b09f3fb39d0bc51cf962b0d Mon Sep 17 00:00:00 2001 From: Ralph Soika Date: Fri, 9 May 2025 10:52:28 +0200 Subject: [PATCH] zoho integration --- doc/zoho/SECRETS.md | 23 ++------------- .../zoho/ZohoAPIService.java | 3 +- .../zoho/ZohoExportAdapter.java | 8 +++-- .../zoho/ZohoOAuthManager.java | 6 ++-- .../zoho/dto/ZohoBillItem.java | 19 ++++++++---- .../src/main/webapp/pages/admin/zoho.xhtml | 6 +++- .../dwc/rechnungseingang-dwc-1.0.4-draft.bpmn | 29 +++++++++++++++---- 7 files changed, 57 insertions(+), 37 deletions(-) diff --git a/doc/zoho/SECRETS.md b/doc/zoho/SECRETS.md index c88a5de..db962a9 100644 --- a/doc/zoho/SECRETS.md +++ b/doc/zoho/SECRETS.md @@ -19,27 +19,6 @@ zoho.scope ZohoBooks.contacts.ALL ZohoBooks.invoices.CREATE ZohoBooks.i ``` -## Forum - -form@imixs.com -imixs4zoho - -https://api-console.zoho.eu/ - -ZohoBooks.contacts.ALL,ZohoBooks.invoices.ALL,ZohoBooks.bills.ALL - -``` -zoho.accesstoken 1.....3 -zoho.apidomain https://www.zohoapis.eu -zoho.clientid 1000.5SMVXH92JIA5BTIGJF27OY41TAFFAS -zoho.clientsecret 64aabb5e819757e471c9d0dff6a072b1bcf2c7687d -zoho.code 10- -zoho.organization 886888983 -zoho.refreshtoken 10...ff440e -zoho.scope ZohoBooks.contacts.ALL ZohoBooks.invoices.CREATE ZohoBooks.invoices.READ ZohoBooks.invoices.UPDATE - -``` - ## Atari atari.600xl@gmail.com @@ -59,6 +38,8 @@ zoho.scope ZohoBooks.contacts.ALL,ZohoBooks.invoices.ALL,ZohoBooks.bill info@imixs.com imixs4zoho +http://books.zoho.com/ + https://api-console.zoho.com/ ZohoBooks.contacts.ALL,ZohoBooks.invoices.ALL,ZohoBooks.bills.ALL 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 f7364c6..9da0de6 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 @@ -482,7 +482,8 @@ public class ZohoAPIService { ZohoBillItem lineItem = new ZohoBillItem(); lineItem.setName(itemCol.getItemValueString("name")); lineItem.setAccountId(accountID); - lineItem.setAmount(itemCol.getItemValueDouble("amount")); + lineItem.setQuantity(1); + lineItem.setRate(itemCol.getItemValueDouble("amount")); return lineItem; }).collect(Collectors.toList()); diff --git a/office-alexander-logistics-app/src/main/java/com/alexanderlogistics/zoho/ZohoExportAdapter.java b/office-alexander-logistics-app/src/main/java/com/alexanderlogistics/zoho/ZohoExportAdapter.java index 270efe8..416ccdc 100644 --- a/office-alexander-logistics-app/src/main/java/com/alexanderlogistics/zoho/ZohoExportAdapter.java +++ b/office-alexander-logistics-app/src/main/java/com/alexanderlogistics/zoho/ZohoExportAdapter.java @@ -96,7 +96,9 @@ public class ZohoExportAdapter implements SignalAdapter { files = snapshot.getFileData(); if (files != null) { for (FileData file : files) { - zohoAPIService.attacheFileData(zohoInvoice.getInvoiceId(), file, "invoices", accessToken); + if (file.getName().toLowerCase().endsWith(".pdf")) { + zohoAPIService.attacheFileData(zohoInvoice.getInvoiceId(), file, "invoices", accessToken); + } } } } @@ -126,7 +128,9 @@ public class ZohoExportAdapter implements SignalAdapter { files = snapshot.getFileData(); if (files != null) { for (FileData file : files) { - zohoAPIService.attacheFileData(zohoBill.getBillId(), file, "bills", accessToken); + if (file.getName().toLowerCase().endsWith(".pdf")) { + zohoAPIService.attacheFileData(zohoBill.getBillId(), file, "bills", accessToken); + } } } } diff --git a/office-alexander-logistics-app/src/main/java/com/alexanderlogistics/zoho/ZohoOAuthManager.java b/office-alexander-logistics-app/src/main/java/com/alexanderlogistics/zoho/ZohoOAuthManager.java index 28300ff..a9dca9b 100644 --- a/office-alexander-logistics-app/src/main/java/com/alexanderlogistics/zoho/ZohoOAuthManager.java +++ b/office-alexander-logistics-app/src/main/java/com/alexanderlogistics/zoho/ZohoOAuthManager.java @@ -161,7 +161,8 @@ public class ZohoOAuthManager { saveTokenData(zohoConfig, tokenResponse); } else { - throw new RuntimeException("Failed to get tokens: " + response.statusCode() + " - " + response.body()); + throw new RuntimeException("Failed to update access and refresh tokens: " + response.statusCode() + + " - " + response.body()); } } catch (IOException | InterruptedException e) { @@ -213,7 +214,8 @@ public class ZohoOAuthManager { return zohoConfig.getItemValueString("zoho.accessToken"); } else { - throw new RuntimeException("Failed to get tokens: " + response.statusCode() + " - " + response.body()); + throw new RuntimeException( + "Failed to refresh accesss tokens: " + response.statusCode() + " - " + response.body()); } } catch (IOException | InterruptedException e) { diff --git a/office-alexander-logistics-app/src/main/java/com/alexanderlogistics/zoho/dto/ZohoBillItem.java b/office-alexander-logistics-app/src/main/java/com/alexanderlogistics/zoho/dto/ZohoBillItem.java index 0cca422..802a4ba 100644 --- a/office-alexander-logistics-app/src/main/java/com/alexanderlogistics/zoho/dto/ZohoBillItem.java +++ b/office-alexander-logistics-app/src/main/java/com/alexanderlogistics/zoho/dto/ZohoBillItem.java @@ -5,7 +5,8 @@ import jakarta.json.bind.annotation.JsonbProperty; public class ZohoBillItem { private String description; private String name; - private double amount; + private double rate; + private double quantity; @JsonbProperty("account_id") private String accountId; @@ -36,12 +37,20 @@ public class ZohoBillItem { this.accountId = accountId; } - public double getAmount() { - return amount; + public double getRate() { + return rate; } - public void setAmount(double amount) { - this.amount = amount; + public void setRate(double rate) { + this.rate = rate; + } + + public double getQuantity() { + return quantity; + } + + public void setQuantity(double quantity) { + this.quantity = quantity; } } diff --git a/office-alexander-logistics-app/src/main/webapp/pages/admin/zoho.xhtml b/office-alexander-logistics-app/src/main/webapp/pages/admin/zoho.xhtml index c074abc..cde0c46 100644 --- a/office-alexander-logistics-app/src/main/webapp/pages/admin/zoho.xhtml +++ b/office-alexander-logistics-app/src/main/webapp/pages/admin/zoho.xhtml @@ -48,6 +48,8 @@
+ Default: + https://accounts.zoho.com/oauth/v2/token
@@ -60,6 +62,8 @@
API Base URL *
+ Default: + https://www.zohoapis.<YOUR-DOMAIN>com/books/v3/
@@ -78,7 +82,7 @@
-
Accountant ID *
+
Costs Account ID *
diff --git a/workflow/dwc/rechnungseingang-dwc-1.0.4-draft.bpmn b/workflow/dwc/rechnungseingang-dwc-1.0.4-draft.bpmn index 4c1b2a1..14741f1 100644 --- a/workflow/dwc/rechnungseingang-dwc-1.0.4-draft.bpmn +++ b/workflow/dwc/rechnungseingang-dwc-1.0.4-draft.bpmn @@ -4918,6 +4918,12 @@ Export erfolgt über eine asynchrone Verarbeitung im Modell 'cargosoft-export']] + + + + + + @@ -5215,9 +5221,9 @@ Export erfolgt über eine asynchrone Verarbeitung im Modell 'cargosoft-export']] - + - + @@ -5738,9 +5744,10 @@ Export erfolgt über eine asynchrone Verarbeitung im Modell 'cargosoft-export']] - - - + + + + @@ -6095,6 +6102,18 @@ Export erfolgt über eine asynchrone Verarbeitung im Modell 'cargosoft-export']] + + + + + + + + + + + +