implemented adding stock items to documents
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
<script>
|
||||
import { t } from '../translations.svelte';
|
||||
let { item, onclick } = $props();
|
||||
</script>
|
||||
|
||||
@@ -7,6 +8,12 @@
|
||||
{#if item.properties}
|
||||
<table>
|
||||
<tbody>
|
||||
{#if item.location.name}
|
||||
<tr>
|
||||
<th>{t('location')}</th>
|
||||
<td>{item.location.name}</td>
|
||||
</tr>
|
||||
{/if}
|
||||
{#each Object.entries(item.properties) as [idx,prop]}
|
||||
<tr>
|
||||
<th>{prop.name}</th>
|
||||
@@ -16,6 +23,4 @@
|
||||
</tbody>
|
||||
</table>
|
||||
{/if}
|
||||
<!--<div>{@html item.description.rendered}</div> -->
|
||||
<!-- <span>{item.unit_price/100} {item.currency} / {item.unit}</span> -->
|
||||
</fieldset>
|
||||
|
||||
@@ -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
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user