bugfix: it was not possible to create documents with customers not havin a tax ID. But the customer tax id should not be required! …altered some code…
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
@@ -1,16 +1,14 @@
|
||||
/* © SRSoftware 2025 */
|
||||
package de.srsoftware.umbrella.core.model;
|
||||
|
||||
import static de.srsoftware.tools.Optionals.emptyIfNull;
|
||||
import static de.srsoftware.umbrella.core.Constants.*;
|
||||
import static de.srsoftware.umbrella.core.Field.*;
|
||||
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.missingFieldException;
|
||||
|
||||
import de.srsoftware.tools.Mappable;
|
||||
import de.srsoftware.umbrella.core.exceptions.UmbrellaException;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
import org.json.JSONObject;
|
||||
|
||||
public final class Customer implements Mappable {
|
||||
@@ -73,7 +71,7 @@ public final class Customer implements Mappable {
|
||||
if (!json.has(ID) || !(json.get(ID) instanceof String id)) throw missingFieldException(ID);
|
||||
if (!json.has(NAME) || !(json.get(NAME) instanceof String name)) throw missingFieldException(NAME);
|
||||
if (!json.has(EMAIL) || !(json.get(EMAIL) instanceof String email)) throw missingFieldException(EMAIL);
|
||||
if (!json.has(TAX_ID) || !(json.get(TAX_ID) instanceof String taxId)) throw missingFieldException(TAX_ID);
|
||||
var taxId = json.has(TAX_ID) && json.get(TAX_ID) instanceof String tid ? tid : null;
|
||||
var lang = json.has(LANGUAGE) && json.get(LANGUAGE) instanceof String l ? l : FALLBACK_LANG;
|
||||
return new Customer(id,name,email,taxId,lang);
|
||||
}
|
||||
@@ -104,11 +102,11 @@ public final class Customer implements Mappable {
|
||||
|
||||
@Override
|
||||
public Map<String, Object> toMap() {
|
||||
return Map.of(
|
||||
"id", id,
|
||||
"name", name,
|
||||
"email", email,
|
||||
"tax_id", taxNumber
|
||||
);
|
||||
var map = new HashMap<String,Object>();
|
||||
map.put("id", id);
|
||||
map.put("name", name);
|
||||
map.put("email", email);
|
||||
map.put("tax_id", emptyIfNull(taxNumber));
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user