Merge remote-tracking branch 'origin/feature/items_stock_integration' into feature/items_stock_integration

This commit is contained in:
2025-12-02 11:23:53 +01:00
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) {