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 */
|
/* © SRSoftware 2025 */
|
||||||
package de.srsoftware.umbrella.core.model;
|
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.Constants.*;
|
||||||
import static de.srsoftware.umbrella.core.Field.*;
|
import static de.srsoftware.umbrella.core.Field.*;
|
||||||
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.missingFieldException;
|
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.missingFieldException;
|
||||||
|
|
||||||
import de.srsoftware.tools.Mappable;
|
import de.srsoftware.tools.Mappable;
|
||||||
import de.srsoftware.umbrella.core.exceptions.UmbrellaException;
|
import de.srsoftware.umbrella.core.exceptions.UmbrellaException;
|
||||||
import java.util.HashSet;
|
import java.util.*;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.Set;
|
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
public final class Customer implements Mappable {
|
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(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(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(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;
|
var lang = json.has(LANGUAGE) && json.get(LANGUAGE) instanceof String l ? l : FALLBACK_LANG;
|
||||||
return new Customer(id,name,email,taxId,lang);
|
return new Customer(id,name,email,taxId,lang);
|
||||||
}
|
}
|
||||||
@@ -104,11 +102,11 @@ public final class Customer implements Mappable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> toMap() {
|
public Map<String, Object> toMap() {
|
||||||
return Map.of(
|
var map = new HashMap<String,Object>();
|
||||||
"id", id,
|
map.put("id", id);
|
||||||
"name", name,
|
map.put("name", name);
|
||||||
"email", email,
|
map.put("email", email);
|
||||||
"tax_id", taxNumber
|
map.put("tax_id", emptyIfNull(taxNumber));
|
||||||
);
|
return map;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,23 +26,25 @@
|
|||||||
contact.FN = fn(contact.vcard);
|
contact.FN = fn(contact.vcard);
|
||||||
contact.ORG = org(contact.vcard);
|
contact.ORG = org(contact.vcard);
|
||||||
const extras = contact.vcard.match(/^X-.*:.+/gm);
|
const extras = contact.vcard.match(/^X-.*:.+/gm);
|
||||||
for (let ex of extras){
|
if (extras) {
|
||||||
ex = extra(ex);
|
for (let ex of extras){
|
||||||
switch (ex.name){
|
ex = extra(ex);
|
||||||
case 'CUSTOMER-NUMBER':
|
switch (ex.name){
|
||||||
contact.customer_number = ex.value;
|
case 'CUSTOMER-NUMBER':
|
||||||
break;
|
contact.customer_number = ex.value;
|
||||||
case 'TAX-NUMBER':
|
break;
|
||||||
contact.tax_id = ex.value;
|
case 'TAX-NUMBER':
|
||||||
break;
|
contact.tax_id = ex.value;
|
||||||
case 'BANK-ACCOUNT':
|
break;
|
||||||
contact.bank_account = ex.value;
|
case 'BANK-ACCOUNT':
|
||||||
break;
|
contact.bank_account = ex.value;
|
||||||
case 'COURT':
|
break;
|
||||||
contact.local_court = ex.value;
|
case 'COURT':
|
||||||
break;
|
contact.local_court = ex.value;
|
||||||
default:
|
break;
|
||||||
console.log(ex);
|
default:
|
||||||
|
console.log(ex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
delete contact.vcard;
|
delete contact.vcard;
|
||||||
|
|||||||
Reference in New Issue
Block a user