some minor fixes
This commit is contained in:
parent
96477feb74
commit
fecb9e8813
3 changed files with 25 additions and 10 deletions
|
|
@ -172,6 +172,7 @@ The implementation uses `PluginException` for error handling with two error type
|
||||||
- [Upload Invoice](https://ksef-test.mf.gov.pl/docs/v2/index.html#tag/Wysylka-interaktywna/paths/~1api~1v2~1sessions~1online~1%7BreferenceNumber%7D~1invoices/post)
|
- [Upload Invoice](https://ksef-test.mf.gov.pl/docs/v2/index.html#tag/Wysylka-interaktywna/paths/~1api~1v2~1sessions~1online~1%7BreferenceNumber%7D~1invoices/post)
|
||||||
- [Facture Details](https://github.com/CIRFMF/ksef-docs/blob/main/sesja-interaktywna.md#2-wys%C5%82anie-faktury)
|
- [Facture Details](https://github.com/CIRFMF/ksef-docs/blob/main/sesja-interaktywna.md#2-wys%C5%82anie-faktury)
|
||||||
- [XML Invoice Example](https://github.com/CIRFMF/ksef-docs/blob/main/faktury/weryfikacja-faktury.md)
|
- [XML Invoice Example](https://github.com/CIRFMF/ksef-docs/blob/main/faktury/weryfikacja-faktury.md)
|
||||||
|
- [QR Code](https://github.com/CIRFMF/ksef-docs/blob/main/kody-qr.md)
|
||||||
|
|
||||||
- [Github Discussions](https://github.com/CIRFMF/ksef-docs/issues/351#issuecomment-3538013805)
|
- [Github Discussions](https://github.com/CIRFMF/ksef-docs/issues/351#issuecomment-3538013805)
|
||||||
- [Github Discussions](https://github.com/CIRFMF/ksef-docs/issues/399)
|
- [Github Discussions](https://github.com/CIRFMF/ksef-docs/issues/399)
|
||||||
|
|
|
||||||
|
|
@ -72,6 +72,8 @@ public class KSeFAdapter implements SignalAdapter {
|
||||||
final String TYPE_TEXTBLOCK = "textblock";
|
final String TYPE_TEXTBLOCK = "textblock";
|
||||||
public static final String DOCUMENT_ERROR = "DOCUMENT_ERROR";
|
public static final String DOCUMENT_ERROR = "DOCUMENT_ERROR";
|
||||||
public static final String CONFIG_ERROR = "CONFIG_ERROR";
|
public static final String CONFIG_ERROR = "CONFIG_ERROR";
|
||||||
|
public static final String API_ERROR = "API_ERROR";
|
||||||
|
public static final String BUSINESSPARTNER_ERROR = "BUSINESSPARTNER_ERROR";
|
||||||
public static final String LINE_ITEMS_PROPERTY = "invoice.items";
|
public static final String LINE_ITEMS_PROPERTY = "invoice.items";
|
||||||
private static Logger logger = Logger.getLogger(EInvoiceAdapter.class.getName());
|
private static Logger logger = Logger.getLogger(EInvoiceAdapter.class.getName());
|
||||||
|
|
||||||
|
|
@ -151,7 +153,7 @@ public class KSeFAdapter implements SignalAdapter {
|
||||||
model.setDueDateTime(workitem.getItemValueLocalDate("invoice.duedate"));
|
model.setDueDateTime(workitem.getItemValueLocalDate("invoice.duedate"));
|
||||||
|
|
||||||
// Update Addresses
|
// Update Addresses
|
||||||
TradeParty billingAddress = buildAddress(workitem.getItemValueString("partner.id"), "buyer", model);
|
TradeParty billingAddress = buildAddress(workitem, "buyer", model);
|
||||||
model.setTradeParty(billingAddress);
|
model.setTradeParty(billingAddress);
|
||||||
|
|
||||||
// Update Invoice Type (RodzajFaktury) -> VAT | KOR
|
// Update Invoice Type (RodzajFaktury) -> VAT | KOR
|
||||||
|
|
@ -221,7 +223,9 @@ public class KSeFAdapter implements SignalAdapter {
|
||||||
* @param type Der Typ der TradeParty
|
* @param type Der Typ der TradeParty
|
||||||
* @return TradeParty
|
* @return TradeParty
|
||||||
*/
|
*/
|
||||||
public TradeParty buildAddress(String partnerID, String type, EInvoiceModel model) throws PluginException {
|
public TradeParty buildAddress(ItemCollection workitem, String type, EInvoiceModel model) throws PluginException {
|
||||||
|
|
||||||
|
String partnerID = workitem.getItemValueString("partner.id");
|
||||||
if (partnerID == null || partnerID.isEmpty()) {
|
if (partnerID == null || partnerID.isEmpty()) {
|
||||||
throw new PluginException(this.getClass().getName(), DOCUMENT_ERROR, "Missing partnerID");
|
throw new PluginException(this.getClass().getName(), DOCUMENT_ERROR, "Missing partnerID");
|
||||||
}
|
}
|
||||||
|
|
@ -273,7 +277,14 @@ public class KSeFAdapter implements SignalAdapter {
|
||||||
tradeParty.setStreetAddress(businessPartner.getItemValueString("partner.address"));
|
tradeParty.setStreetAddress(businessPartner.getItemValueString("partner.address"));
|
||||||
|
|
||||||
if ("buyer".equals(type)) {
|
if ("buyer".equals(type)) {
|
||||||
tradeParty.setVatNumber(businessPartner.getItemValueString("partner.vat"));
|
// if we do NOT have a partner.vat we can not upload the invoice!
|
||||||
|
String partnerVAT = businessPartner.getItemValueString("partner.vat");
|
||||||
|
if (partnerVAT.isBlank()) {
|
||||||
|
throw new PluginException(this.getClass().getName(), BUSINESSPARTNER_ERROR,
|
||||||
|
"Business Partner ID '" + partnerID + "' does not contain a VAT ID !");
|
||||||
|
}
|
||||||
|
workitem.setItemValue("partner.vat", partnerVAT);
|
||||||
|
tradeParty.setVatNumber(partnerVAT);
|
||||||
// Update or create NrKlienta element directly under Podmiot2
|
// Update or create NrKlienta element directly under Podmiot2
|
||||||
Element podmiot2 = model.findOrCreateChildNode(model.getRoot(), EInvoiceNS.KSEF, "Podmiot2");
|
Element podmiot2 = model.findOrCreateChildNode(model.getRoot(), EInvoiceNS.KSEF, "Podmiot2");
|
||||||
model.updateElementValue(podmiot2, EInvoiceNS.KSEF, "NrKlienta",
|
model.updateElementValue(podmiot2, EInvoiceNS.KSEF, "NrKlienta",
|
||||||
|
|
|
||||||
|
|
@ -239,6 +239,8 @@ public class KSeFAPIService {
|
||||||
// if status code 200 and if we have a ksef.upo.referencenumber we download the
|
// if status code 200 and if we have a ksef.upo.referencenumber we download the
|
||||||
// document
|
// document
|
||||||
if (code == 200 && !referenceNumber.isEmpty()) {
|
if (code == 200 && !referenceNumber.isEmpty()) {
|
||||||
|
checkSessionStatusInvoices(workitem);
|
||||||
|
|
||||||
FileData upoFileData = downloadUOPXML(workitem);
|
FileData upoFileData = downloadUOPXML(workitem);
|
||||||
workitem.addFileData(upoFileData);
|
workitem.addFileData(upoFileData);
|
||||||
|
|
||||||
|
|
@ -278,7 +280,6 @@ public class KSeFAPIService {
|
||||||
int httpResponse = -1;
|
int httpResponse = -1;
|
||||||
int statusCode = -1;
|
int statusCode = -1;
|
||||||
String statusDescription;
|
String statusDescription;
|
||||||
String statusDetails;
|
|
||||||
logger.info("│ ├── GET: " + uri);
|
logger.info("│ ├── GET: " + uri);
|
||||||
HttpResponse<String> response = null;
|
HttpResponse<String> response = null;
|
||||||
try {
|
try {
|
||||||
|
|
@ -306,27 +307,29 @@ public class KSeFAPIService {
|
||||||
JsonArray invoicesArray = jsonObject.getJsonArray("invoices");
|
JsonArray invoicesArray = jsonObject.getJsonArray("invoices");
|
||||||
if (invoicesArray != null && !invoicesArray.isEmpty()) {
|
if (invoicesArray != null && !invoicesArray.isEmpty()) {
|
||||||
JsonObject firstInvoice = invoicesArray.getJsonObject(0);
|
JsonObject firstInvoice = invoicesArray.getJsonObject(0);
|
||||||
|
if (firstInvoice.containsKey("ksefNumber")) {
|
||||||
|
String ksefNumber = firstInvoice.getString("ksefNumber");
|
||||||
|
logger.info("│ ├── ksefNumber: " + ksefNumber);
|
||||||
|
workitem.setItemValue("ksef.number", ksefNumber);
|
||||||
|
}
|
||||||
// Status Code aus dem status-Objekt extrahieren
|
// Status Code aus dem status-Objekt extrahieren
|
||||||
if (firstInvoice.containsKey("status")) {
|
if (firstInvoice.containsKey("status")) {
|
||||||
JsonObject statusObject = firstInvoice.getJsonObject("status");
|
JsonObject statusObject = firstInvoice.getJsonObject("status");
|
||||||
if (statusObject.containsKey("code")) {
|
if (statusObject.containsKey("code")) {
|
||||||
statusCode = statusObject.getInt("code");
|
statusCode = statusObject.getInt("code");
|
||||||
statusDescription = statusObject.getString("description");
|
statusDescription = statusObject.getString("description");
|
||||||
|
|
||||||
// Convert details array to a single string
|
// Convert details array to a single string
|
||||||
statusDetails = "";
|
|
||||||
if (statusObject.containsKey("details")) {
|
if (statusObject.containsKey("details")) {
|
||||||
JsonArray detailsArray = statusObject.getJsonArray("details");
|
JsonArray detailsArray = statusObject.getJsonArray("details");
|
||||||
statusDetails = detailsArray.stream()
|
String details = detailsArray.stream()
|
||||||
.map(v -> ((JsonString) v).getString())
|
.map(v -> ((JsonString) v).getString())
|
||||||
.collect(Collectors.joining("; "));
|
.collect(Collectors.joining("; "));
|
||||||
|
statusDescription = statusDescription + ": " + details;
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info("│ ├── Status Code: " + statusCode);
|
logger.info("│ ├── Status Code: " + statusCode);
|
||||||
logger.info("│ ├── Status details: " + statusDetails);
|
|
||||||
workitem.setItemValue("ksef.status.code", statusCode);
|
workitem.setItemValue("ksef.status.code", statusCode);
|
||||||
workitem.setItemValue("ksef.status.description", statusDescription + ": "
|
workitem.setItemValue("ksef.status.description", statusDescription);
|
||||||
+ statusDetails);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue