Skip to content
Snippets Groups Projects
Commit 47cf446d authored by Johannes Hörmann's avatar Johannes Hörmann
Browse files

fixes for offer productitem list

parent 5cd32174
No related branches found
No related tags found
No related merge requests found
......@@ -17,5 +17,5 @@ if(oid != "")
db.updateData("OFFER", cols, null, vals, SqlCondition.equals("OFFER.OFFERID", oid, "1 = 2"));
neon.refresh("Offer_entity");
neon.refresh();
}
\ No newline at end of file
......@@ -22,5 +22,5 @@ if(oid != "")
db.updateData("OFFER", cols, null, vals, SqlCondition.equals("OFFER.OFFERID", oid, "1 = 2"));
neon.refresh("Offer_entity");
neon.refresh();
}
\ No newline at end of file
......@@ -12,5 +12,5 @@ if(oid != "")
db.updateData("OFFER", cols, null, vals, SqlCondition.equals("OFFER.OFFERID", oid, "1 = 2"));
neon.refresh("Offer_entity");
neon.refresh();
}
\ No newline at end of file
......@@ -19,5 +19,5 @@ if(oid != "")
db.updateData("OFFER", cols, null, vals, SqlCondition.equals("OFFER.OFFERID", oid, "1 = 2"));
neon.refresh("Offer_entity");
neon.refresh();
}
\ No newline at end of file
......@@ -23,5 +23,5 @@ if(oid != "")
db.updateData("OFFER", cols, null, vals, SqlCondition.equals("OFFER.OFFERID", oid, "1 = 2"));
neon.refresh("Offer_entity");
neon.refresh();
}
\ No newline at end of file
......@@ -12,5 +12,5 @@ if(oid != "")
db.updateData("OFFER", cols, null, oiUtils.getNetAndVat(), SqlCondition.equals("OFFER.OFFERID", oid, "1 = 2"));
neon.refresh("Offer_entity");
neon.refresh();
}
\ No newline at end of file
......@@ -18,5 +18,5 @@ if(oid != "")
db.updateData("SALESORDER", cols, null, vals, SqlCondition.equals("SALESORDER.SALESORDERID", oid, "1 = 2"));
neon.refresh("Order_entity");
neon.refresh();
}
\ No newline at end of file
......@@ -23,5 +23,5 @@ if(oid != "")
db.updateData("SALESORDER", cols, null, vals, SqlCondition.equals("SALESORDER.SALESORDERID", oid, "1 = 2"));
neon.refresh("Order_entity");
neon.refresh();
}
\ No newline at end of file
......@@ -13,5 +13,5 @@ if(oid != "")
db.updateData("SALESORDER", cols, null, vals, SqlCondition.equals("SALESORDER.SALESORDERID", oid, "1 = 2"));
neon.refresh("Order_entity");
neon.refresh();
}
\ No newline at end of file
import("system.logging");
import("system.translate");
import("system.text");
import("system.vars");
......@@ -140,12 +141,16 @@ function ItemUtils(pOfferOrderId, pTableName) {
* get a new SqlCondition Object with tablename + "ITEM." + tablename + "ITEMID" = pItemId
*
* @param {String} pItemId item id
* @param {String} [pTableName=this.tableName] table name, if this is not available
*
* @return {SqlCondition}
*/
ItemUtils.prototype.getNewItemIdCondition = function(pItemId)
ItemUtils.prototype.getNewItemIdCondition = function(pItemId, pTableName)
{
return SqlCondition.begin().andPrepare(this.tableName + "ITEM." + this.tableName + "ITEMID", pItemId);
if (pTableName == undefined)
pTableName = this.tableName;
logging.log("hää" + pTableName)
return SqlCondition.begin().andPrepare(pTableName + "ITEM." + pTableName + "ITEMID", pItemId);
}
/**
......@@ -168,7 +173,7 @@ ItemUtils.prototype.getNetAndVat = function(itemIds) {
itemIds.forEach(function(pItem)
{
condition.andPrepare(this.tableName + "ITEM." + this.tableName + "ITEMID", pItem, "# <> ?");
});
}, this);
}
var orderItems = db.table(condition.buildSql("select QUANTITY, PRICE, DISCOUNT, VAT, OPTIONAL from " + this.tableName + "ITEM", "1 = 0"));
......@@ -280,8 +285,9 @@ ItemUtils.prototype.insertPartsList = function(columns, productId, assignedTo, c
columns = columns.concat(additionalProductInfo.map(function(item) {return item[0]}));
var colTypes = db.getColumnTypes(table, columns);
__itemInsertStatement(partsList.root, assignedTo, currency, relationId);
logging.log(partsList.toSource())
// partsList[rootProdId] = root node
__itemInsertStatement(partsList[rootProdId], assignedTo, currency, relationId);
if (statements.length > 0)
db.inserts(statements);
......@@ -332,7 +338,8 @@ ItemUtils.prototype.insertPartsList = function(columns, productId, assignedTo, c
statements.push([table, columns, colTypes, vals]);
insertedItemIds.push(newid);
logging.log(p2pid)
__itemInsertStatement(partsList[p2pid], newid);
}
}
......@@ -352,7 +359,7 @@ ItemUtils.prototype.deletePartsList = function(itemId) {
//save address for this here to get class variables in recursive sub function __itemDeleteStatement
var self = this;
logging.log("1 " + self.tableName)
var statements = [];
__itemDeleteStatement(itemId);
......@@ -366,11 +373,15 @@ ItemUtils.prototype.deletePartsList = function(itemId) {
//recursive function for building item delete statements
function __itemDeleteStatement(itemId) {
var itemsToDelete = self.ItemTree[itemId].ids;
logging.log("2 " + self.tableName)
var itemsToDelete = self.ItemTree[itemId].ids;
logging.log("__ " + self.tableName)
logging.log(itemsToDelete.toSource())
for (var i = 0; i < itemsToDelete.length; i++) {
//unshift due to foreign key constraints (Delete hierarchically starting at the bottom)
statements.unshift(self.getNewItemIdCondition(itemsToDelete[i]).build("1 = 2"));
logging.log("3 " + self.tableName)
statements.unshift(self.getNewItemIdCondition(itemsToDelete[i], self.tableName).build("1 = 2"));
deletedItemIds.push(itemsToDelete[i]);
__itemDeleteStatement(itemsToDelete[i]);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment