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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,23 +26,25 @@
|
||||
contact.FN = fn(contact.vcard);
|
||||
contact.ORG = org(contact.vcard);
|
||||
const extras = contact.vcard.match(/^X-.*:.+/gm);
|
||||
for (let ex of extras){
|
||||
ex = extra(ex);
|
||||
switch (ex.name){
|
||||
case 'CUSTOMER-NUMBER':
|
||||
contact.customer_number = ex.value;
|
||||
break;
|
||||
case 'TAX-NUMBER':
|
||||
contact.tax_id = ex.value;
|
||||
break;
|
||||
case 'BANK-ACCOUNT':
|
||||
contact.bank_account = ex.value;
|
||||
break;
|
||||
case 'COURT':
|
||||
contact.local_court = ex.value;
|
||||
break;
|
||||
default:
|
||||
console.log(ex);
|
||||
if (extras) {
|
||||
for (let ex of extras){
|
||||
ex = extra(ex);
|
||||
switch (ex.name){
|
||||
case 'CUSTOMER-NUMBER':
|
||||
contact.customer_number = ex.value;
|
||||
break;
|
||||
case 'TAX-NUMBER':
|
||||
contact.tax_id = ex.value;
|
||||
break;
|
||||
case 'BANK-ACCOUNT':
|
||||
contact.bank_account = ex.value;
|
||||
break;
|
||||
case 'COURT':
|
||||
contact.local_court = ex.value;
|
||||
break;
|
||||
default:
|
||||
console.log(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
delete contact.vcard;
|
||||
|
||||
Reference in New Issue
Block a user