From d6b56ac127686ab8cb23720786aa196cd3ca13c4 Mon Sep 17 00:00:00 2001 From: Stephan Richter Date: Mon, 1 Dec 2025 16:03:40 +0100 Subject: [PATCH] fixing document module to receive unit, price and tax value from stock item, if provided Signed-off-by: Stephan Richter --- .../routes/document/PositionSelector.svelte | 20 ++++++++++++++----- .../srsoftware/umbrella/stock/SqliteDb.java | 2 +- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/frontend/src/routes/document/PositionSelector.svelte b/frontend/src/routes/document/PositionSelector.svelte index 17ffa8e..256dd34 100644 --- a/frontend/src/routes/document/PositionSelector.svelte +++ b/frontend/src/routes/document/PositionSelector.svelte @@ -30,23 +30,33 @@ function itemSelected(item){ let unit_price = null; + let unit = t('pieces'); let description = ''; + let tax = null; for (let prop of item.properties) { - if (prop.name.toLowerCase().indexOf(t('price').toLowerCase())>-1){ - unit_price = 100*prop.value.replace(',','.'); + let lowerName = prop.name.toLowerCase(); + if (lowerName.indexOf(t('price').toLowerCase())>-1){ + unit_price = 100*String(prop.value).replace(',','.'); + } else if (lowerName.indexOf(t('unit').toLowerCase())>-1){ + unit = prop.value; + } else if (lowerName.indexOf(t('tax_rate').toLowerCase())>-1 && prop.unit=='%'){ + tax = prop.value; } else { description += `* ${prop.name}: ${prop.value}\n`; } } - select({ + var data = { item_code : item.code, title : item.name, description : description, amount : 1, - unit : t('pieces'), + unit : unit, unit_price : unit_price - }); + }; + if (tax) data['tax'] = tax; + + select(data); } function timeSelected(time){ diff --git a/stock/src/main/java/de/srsoftware/umbrella/stock/SqliteDb.java b/stock/src/main/java/de/srsoftware/umbrella/stock/SqliteDb.java index 0293db9..143e835 100644 --- a/stock/src/main/java/de/srsoftware/umbrella/stock/SqliteDb.java +++ b/stock/src/main/java/de/srsoftware/umbrella/stock/SqliteDb.java @@ -144,7 +144,7 @@ public class SqliteDb extends BaseDb implements StockDb { private void createPropertiesTable() { try { - var sql = "CREATE TABLE IF NOT EXISTS {0} ( {1} LONG PRIMARY KEY, {2} VARCHAR(255) NOT NULL, {3} INT NOT NULL, {4} VARCHAR(255))"; + var sql = "CREATE TABLE IF NOT EXISTS {0} ( {1} INTEGER PRIMARY KEY, {2} VARCHAR(255) NOT NULL, {3} INT NOT NULL, {4} VARCHAR(255))"; sql = format(sql, TABLE_PROPERTIES, ID, NAME, TYPE, UNIT); db.prepareStatement(sql).execute(); } catch (SQLException e) {