diff --git a/documents/src/main/java/de/srsoftware/umbrella/documents/DocumentApi.java b/documents/src/main/java/de/srsoftware/umbrella/documents/DocumentApi.java index cb962b2..87f15b8 100644 --- a/documents/src/main/java/de/srsoftware/umbrella/documents/DocumentApi.java +++ b/documents/src/main/java/de/srsoftware/umbrella/documents/DocumentApi.java @@ -224,7 +224,6 @@ public class DocumentApi extends BaseHandler { } catch (UmbrellaException e) { LOG.log(WARNING,e); } - LOG.log(WARNING,"Updating settings of company-customer-document combination not implemented!"); var attachment = new Attachment(doc.number()+".pdf",rendered.mimeType(),rendered.bytes()); var message = new Message(user,subject,content,null,List.of(attachment)); var envelope = new Envelope(message,new User(doc.customer().shortName(),new EmailAddress(email),doc.customer().language())); @@ -504,7 +503,10 @@ public class DocumentApi extends BaseHandler { if (!(json.has(FIELD_ITEM_CODE) && json.get(FIELD_ITEM_CODE) instanceof String itemCode)) throw missingFieldException(FIELD_ITEM_CODE); if (!(json.has(TITLE) && json.get(TITLE) instanceof String title)) throw missingFieldException(TITLE); if (!(json.has(FIELD_UNIT) && json.get(FIELD_UNIT) instanceof String unit)) throw missingFieldException(FIELD_UNIT); - var unitPrice =json.has(FIELD_UNIT_PRICE) && json.get(FIELD_UNIT_PRICE) instanceof Number num ? num : 0L; + var unitPrice = json.has(FIELD_UNIT_PRICE) && json.get(FIELD_UNIT_PRICE) instanceof Number num ? num : 0L; + try { + unitPrice = db.getCustomerPrice(doc.companyId(),doc.customer().id(),itemCode); + } catch (UmbrellaException ignored) {} int tax = json.has(FIELD_TAX) && json.get(FIELD_TAX) instanceof Number t ? t.intValue() : 19; // TODO should not be hard-coded Long timeId = json.has(FIELD_TIME_ID) && json.get(FIELD_TIME_ID) instanceof Number t ? t.longValue() : null; var pos = new Position(doc.positions().size()+1,itemCode,amount.doubleValue(),unit,title,description,unitPrice.longValue(),tax,timeId,false); diff --git a/documents/src/main/java/de/srsoftware/umbrella/documents/model/Position.java b/documents/src/main/java/de/srsoftware/umbrella/documents/model/Position.java index 4dbd96a..2fd81be 100644 --- a/documents/src/main/java/de/srsoftware/umbrella/documents/model/Position.java +++ b/documents/src/main/java/de/srsoftware/umbrella/documents/model/Position.java @@ -122,9 +122,7 @@ public final class Position implements Mappable { case FIELD_TAX: tax = json.getInt(key); break; case TITLE: title = json.getString(key); break; case FIELD_UNIT: unit = json.getString(key); break; - case FIELD_UNIT_PRICE: unitPrice = json.getLong(key); - LOG.log(WARNING,"Updating unit price for customer in company settings not implemented!"); - break; + case FIELD_UNIT_PRICE: unitPrice = json.getLong(key); break; default: key = null; } if (key != null) dirtyFields.add(key); diff --git a/frontend/src/routes/document/PositionList.svelte b/frontend/src/routes/document/PositionList.svelte index 3691489..bdc7765 100644 --- a/frontend/src/routes/document/PositionList.svelte +++ b/frontend/src/routes/document/PositionList.svelte @@ -68,10 +68,10 @@