fixing document module to receive unit, price and tax value from stock item, if provided

Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
2025-12-01 16:03:40 +01:00
parent a3bcc66b73
commit d6b56ac127
2 changed files with 16 additions and 6 deletions

View File

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

View File

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