improved handling of null values when mapping entities to json

This commit is contained in:
2025-07-25 23:02:54 +02:00
parent 01a7389665
commit 3d81ddd3c5
15 changed files with 81 additions and 124 deletions

View File

@@ -3,6 +3,7 @@ package de.srsoftware.umbrella.documents.model;
import static de.srsoftware.umbrella.core.Constants.*;
import static de.srsoftware.umbrella.core.ResponseCode.HTTP_UNPROCESSABLE;
import static de.srsoftware.umbrella.core.Util.mapMarkdown;
import static de.srsoftware.umbrella.core.Util.markdown;
import static de.srsoftware.umbrella.documents.Constants.*;
import static de.srsoftware.umbrella.documents.Constants.FIELD_CUSTOMER;
@@ -218,8 +219,8 @@ public final class Document implements Mappable {
map.put(DATE, date);
map.put(STATE, state.code);
map.put(FIELD_DELIVERY, delivery == null ? "" : delivery);
map.put(FIELD_HEAD, Map.of(SOURCE,head,RENDERED,markdown(head)));
map.put(FIELD_FOOTER, Map.of(SOURCE,footer,RENDERED,markdown(footer)));
map.put(FIELD_HEAD, mapMarkdown(head));
map.put(FIELD_FOOTER, mapMarkdown(footer));
map.put(FIELD_CURRENCY, currency);
map.put(SENDER, sender.toMap());
map.put(FIELD_CUSTOMER, customer.toMap());

View File

@@ -3,6 +3,7 @@ package de.srsoftware.umbrella.documents.model;
import static de.srsoftware.umbrella.core.Constants.*;
import static de.srsoftware.umbrella.core.Util.mapMarkdown;
import static de.srsoftware.umbrella.core.Util.markdown;
import static de.srsoftware.umbrella.documents.Constants.*;
@@ -188,7 +189,6 @@ public final class Position implements Mappable {
}
public Map<String, Object> renderToMap() {
var descr = Map.of(SOURCE,description,RENDERED,markdown(description));
var map = new HashMap<String, Object>();
map.put(FIELD_DOCUMENT_ID, docId);
map.put(NUMBER, num);
@@ -196,7 +196,7 @@ public final class Position implements Mappable {
map.put(FIELD_AMOUNT, amount);
map.put(FIELD_UNIT, unit);
map.put(TITLE, title);
map.put(DESCRIPTION, descr);
map.put(DESCRIPTION, mapMarkdown(description));
map.put(FIELD_UNIT_PRICE, unitPrice);
map.put(FIELD_TAX, tax);
map.put(FIELD_TIME_ID, timeId);