Speichern und Laden von Einheits-Preisen implementiert

This commit is contained in:
2025-07-17 23:48:32 +02:00
parent 67cb0b61b6
commit fc90b94fb2
4 changed files with 8 additions and 10 deletions

View File

@@ -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);

View File

@@ -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);