implemented adding stock items to documents

Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
2025-11-24 12:49:24 +01:00
parent 438d8d4aad
commit 6bb03f4e04
3 changed files with 27 additions and 8 deletions

View File

@@ -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<Long,Location>();
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 {