From 6bb03f4e047bb8cf1e04a03d0eca8e502e33f575 Mon Sep 17 00:00:00 2001 From: Stephan Richter Date: Mon, 24 Nov 2025 12:49:24 +0100 Subject: [PATCH] implemented adding stock items to documents Signed-off-by: Stephan Richter --- frontend/src/Components/Item.svelte | 9 +++++++-- .../routes/document/PositionSelector.svelte | 18 ++++++++++++++---- .../srsoftware/umbrella/stock/StockModule.java | 8 ++++++-- 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/frontend/src/Components/Item.svelte b/frontend/src/Components/Item.svelte index 917f466..11f9177 100644 --- a/frontend/src/Components/Item.svelte +++ b/frontend/src/Components/Item.svelte @@ -1,4 +1,5 @@ @@ -7,6 +8,12 @@ {#if item.properties} + {#if item.location.name} + + + + + {/if} {#each Object.entries(item.properties) as [idx,prop]} @@ -16,6 +23,4 @@
{t('location')}{item.location.name}
{prop.name}
{/if} - - diff --git a/frontend/src/routes/document/PositionSelector.svelte b/frontend/src/routes/document/PositionSelector.svelte index b14a954..2a25e64 100644 --- a/frontend/src/routes/document/PositionSelector.svelte +++ b/frontend/src/routes/document/PositionSelector.svelte @@ -29,14 +29,24 @@ } function itemSelected(item){ + let unit_price = null; + let description = ''; + for (let prop of item.properties) { + if (prop.name.toLowerCase().indexOf(t('price').toLowerCase())>-1){ + unit_price = 100*prop.value.replace(',','.'); + } else { + description += `* ${prop.name}: ${prop.value}\n`; + } + } + select({ item_code : item.code, title : item.name, - description : item.description.source, + description : description, amount : 1, - unit : item.unit, - unit_price : item.unit_price, - tax : item.tax + unit : t('pieces'), + unit_price : unit_price, + tax : 0 }); } diff --git a/stock/src/main/java/de/srsoftware/umbrella/stock/StockModule.java b/stock/src/main/java/de/srsoftware/umbrella/stock/StockModule.java index 2a8fd4a..f1c1763 100644 --- a/stock/src/main/java/de/srsoftware/umbrella/stock/StockModule.java +++ b/stock/src/main/java/de/srsoftware/umbrella/stock/StockModule.java @@ -325,8 +325,12 @@ public class StockModule extends BaseHandler implements StockService { if (!json.has(COMPANY_ID) || !(json.get(COMPANY_ID) instanceof Number company_id)) throw missingFieldException(COMPANY_ID); var company = companyService().get(company_id.longValue()); if (!companyService().membership(company_id.longValue(),user.id())) throw forbidden("You are not a member of {0}!", company.name()); - var items = stockDb.listItemsOf(company); - return sendContent(ex,items.stream().sorted(byName).map(Item::toMap)); + var map = new HashMap(); + var items = stockDb.listItemsOf(company) + .stream() + .peek(item -> item.location(map.computeIfAbsent(item.location().id(), k -> item.location().resolve()))).sorted(byName) + .map(Item::toMap); + return sendContent(ex,items); } private boolean postLocation(UmbrellaUser user, HttpExchange ex) throws IOException {