From 9b4d3cf2b625fed68438a66e35f701a77e09222e Mon Sep 17 00:00:00 2001 From: Johannes Hoermann <j.hoermann@adito.de> Date: Thu, 10 Jan 2019 08:51:42 +0100 Subject: [PATCH] =?UTF-8?q?[Projekt:=20Entwicklung=20-=20Neon][TicketNr.:?= =?UTF-8?q?=201030772][Angebotsposten=20-=20Bemerkung=20hinzuf=C3=BCgen]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- aliasDefinition/Data_alias/Data_alias.aod | 14 +++++ entity/Offeritem_entity/Offeritem_entity.aod | 11 ++++ .../entityfields/info/documentation.adoc | 1 + .../entityfields/info/valueProcess.js | 12 +++++ entity/Prod2prod_entity/Prod2prod_entity.aod | 2 +- .../_____LANGUAGE_EXTRA.aod | 51 ++++++++++++++++++ .../_____LANGUAGE_de/_____LANGUAGE_de.aod | 52 +++++++++++++++++++ .../_____LANGUAGE_en/_____LANGUAGE_en.aod | 51 ++++++++++++++++++ .../OfferitemPreview_view.aod | 4 ++ others/db_changes/struct/create_offeritem.xml | 1 + process/OfferOrder_lib/process.js | 20 +++++-- process/Offer_lib/process.js | 2 +- process/Product_lib/process.js | 24 +++++++-- 13 files changed, 233 insertions(+), 12 deletions(-) create mode 100644 entity/Offeritem_entity/entityfields/info/documentation.adoc create mode 100644 entity/Offeritem_entity/entityfields/info/valueProcess.js diff --git a/aliasDefinition/Data_alias/Data_alias.aod b/aliasDefinition/Data_alias/Data_alias.aod index 5d94da608c..952462eb66 100644 --- a/aliasDefinition/Data_alias/Data_alias.aod +++ b/aliasDefinition/Data_alias/Data_alias.aod @@ -2613,6 +2613,20 @@ <title></title> <description></description> </entityFieldDb> + <entityFieldDb> + <name>INFO</name> + <dbName></dbName> + <primaryKey v="false" /> + <columnType v="2005" /> + <size v="2147483647" /> + <scale v="0" /> + <notNull v="false" /> + <isUnique v="false" /> + <index v="false" /> + <documentation></documentation> + <title></title> + <description></description> + </entityFieldDb> </entityFields> </entityDb> <entityDb> diff --git a/entity/Offeritem_entity/Offeritem_entity.aod b/entity/Offeritem_entity/Offeritem_entity.aod index d9120e5fd5..46b68d0898 100644 --- a/entity/Offeritem_entity/Offeritem_entity.aod +++ b/entity/Offeritem_entity/Offeritem_entity.aod @@ -168,6 +168,13 @@ </entityDependency> </dependencies> </entityIncomingField> + <entityField> + <name>INFO</name> + <documentation>%aditoprj%/entity/Offeritem_entity/entityfields/info/documentation.adoc</documentation> + <title>Description</title> + <contentType>LONG_TEXT</contentType> + <valueProcess>%aditoprj%/entity/Offeritem_entity/entityfields/info/valueProcess.js</valueProcess> + </entityField> </entityFields> <recordContainers> <dbRecordContainer> @@ -265,6 +272,10 @@ <name>VAT.value</name> <recordfield>OFFERITEM.VAT</recordfield> </dbRecordFieldMapping> + <dbRecordFieldMapping> + <name>INFO.value</name> + <recordfield>OFFERITEM.INFO</recordfield> + </dbRecordFieldMapping> </recordFieldMappings> </dbRecordContainer> </recordContainers> diff --git a/entity/Offeritem_entity/entityfields/info/documentation.adoc b/entity/Offeritem_entity/entityfields/info/documentation.adoc new file mode 100644 index 0000000000..8c8b222cff --- /dev/null +++ b/entity/Offeritem_entity/entityfields/info/documentation.adoc @@ -0,0 +1 @@ +The INFO field is copied from the product if in NEW-mode. \ No newline at end of file diff --git a/entity/Offeritem_entity/entityfields/info/valueProcess.js b/entity/Offeritem_entity/entityfields/info/valueProcess.js new file mode 100644 index 0000000000..584fb9fb5f --- /dev/null +++ b/entity/Offeritem_entity/entityfields/info/valueProcess.js @@ -0,0 +1,12 @@ +import("system.db"); +import("system.result"); +import("system.vars"); +import("system.neon"); +import("Sql_lib"); + +if (vars.get("$sys.operatingstate") == neon.OPERATINGSTATE_NEW) +{ + // TODO: loading from db until loading from dfo is possible. + var productId = vars.get("$field.PRODUCT_ID"); + result.string(db.cell(SqlCondition.begin().andPrepareVars("PRODUCT.PRODUCTID", "$field.PRODUCT_ID").buildSelect("select INFO from PRODUCT", "1=2"))); +} \ No newline at end of file diff --git a/entity/Prod2prod_entity/Prod2prod_entity.aod b/entity/Prod2prod_entity/Prod2prod_entity.aod index b435ec40b1..29507f9fe4 100644 --- a/entity/Prod2prod_entity/Prod2prod_entity.aod +++ b/entity/Prod2prod_entity/Prod2prod_entity.aod @@ -49,7 +49,7 @@ <entityField> <name>TAKEPRICE</name> <documentation>%aditoprj%/entity/Prod2prod_entity/entityfields/takeprice/documentation.adoc</documentation> - <title>Price</title> + <title>Take price</title> <contentType>BOOLEAN</contentType> <possibleItemsProcess>%aditoprj%/entity/Prod2prod_entity/entityfields/takeprice/possibleItemsProcess.js</possibleItemsProcess> </entityField> diff --git a/language/_____LANGUAGE_EXTRA/_____LANGUAGE_EXTRA.aod b/language/_____LANGUAGE_EXTRA/_____LANGUAGE_EXTRA.aod index 4b37e9feec..2b5f0dbfd1 100644 --- a/language/_____LANGUAGE_EXTRA/_____LANGUAGE_EXTRA.aod +++ b/language/_____LANGUAGE_EXTRA/_____LANGUAGE_EXTRA.aod @@ -1362,6 +1362,57 @@ <entry> <key>Open salesprojects</key> </entry> + <entry> + <key>July</key> + </entry> + <entry> + <key>ADITO Facebook Feed</key> + </entry> + <entry> + <key>ADITO Twitter Feed</key> + </entry> + <entry> + <key>June</key> + </entry> + <entry> + <key>October</key> + </entry> + <entry> + <key>Take price</key> + </entry> + <entry> + <key>Twitter Feed</key> + </entry> + <entry> + <key>November</key> + </entry> + <entry> + <key>December</key> + </entry> + <entry> + <key>May</key> + </entry> + <entry> + <key>April</key> + </entry> + <entry> + <key>January</key> + </entry> + <entry> + <key>March</key> + </entry> + <entry> + <key>September</key> + </entry> + <entry> + <key>August</key> + </entry> + <entry> + <key>Category</key> + </entry> + <entry> + <key>February</key> + </entry> </keyValueMap> <font name="Dialog" style="0" size="11" /> <sqlModels> diff --git a/language/_____LANGUAGE_de/_____LANGUAGE_de.aod b/language/_____LANGUAGE_de/_____LANGUAGE_de.aod index 3d984a421e..fa29bffd2c 100644 --- a/language/_____LANGUAGE_de/_____LANGUAGE_de.aod +++ b/language/_____LANGUAGE_de/_____LANGUAGE_de.aod @@ -1685,6 +1685,58 @@ <key>New activity</key> <value>Aktivität erstellen</value> </entry> + <entry> + <key>July</key> + </entry> + <entry> + <key>ADITO Facebook Feed</key> + </entry> + <entry> + <key>ADITO Twitter Feed</key> + </entry> + <entry> + <key>June</key> + </entry> + <entry> + <key>October</key> + </entry> + <entry> + <key>Take price</key> + <value>Preis übernehmen</value> + </entry> + <entry> + <key>Twitter Feed</key> + </entry> + <entry> + <key>November</key> + </entry> + <entry> + <key>December</key> + </entry> + <entry> + <key>May</key> + </entry> + <entry> + <key>April</key> + </entry> + <entry> + <key>January</key> + </entry> + <entry> + <key>March</key> + </entry> + <entry> + <key>September</key> + </entry> + <entry> + <key>August</key> + </entry> + <entry> + <key>Category</key> + </entry> + <entry> + <key>February</key> + </entry> </keyValueMap> <font name="Dialog" style="0" size="11" /> </language> diff --git a/language/_____LANGUAGE_en/_____LANGUAGE_en.aod b/language/_____LANGUAGE_en/_____LANGUAGE_en.aod index 8de5af1799..58cc1a94ed 100644 --- a/language/_____LANGUAGE_en/_____LANGUAGE_en.aod +++ b/language/_____LANGUAGE_en/_____LANGUAGE_en.aod @@ -1379,6 +1379,57 @@ <entry> <key>Open salesprojects</key> </entry> + <entry> + <key>July</key> + </entry> + <entry> + <key>ADITO Facebook Feed</key> + </entry> + <entry> + <key>ADITO Twitter Feed</key> + </entry> + <entry> + <key>June</key> + </entry> + <entry> + <key>October</key> + </entry> + <entry> + <key>Take price</key> + </entry> + <entry> + <key>Twitter Feed</key> + </entry> + <entry> + <key>November</key> + </entry> + <entry> + <key>December</key> + </entry> + <entry> + <key>May</key> + </entry> + <entry> + <key>April</key> + </entry> + <entry> + <key>January</key> + </entry> + <entry> + <key>March</key> + </entry> + <entry> + <key>September</key> + </entry> + <entry> + <key>August</key> + </entry> + <entry> + <key>Category</key> + </entry> + <entry> + <key>February</key> + </entry> </keyValueMap> <font name="Dialog" style="0" size="11" /> </language> diff --git a/neonView/OfferitemPreview_view/OfferitemPreview_view.aod b/neonView/OfferitemPreview_view/OfferitemPreview_view.aod index 4d5047d334..3f8fb1b11d 100644 --- a/neonView/OfferitemPreview_view/OfferitemPreview_view.aod +++ b/neonView/OfferitemPreview_view/OfferitemPreview_view.aod @@ -32,6 +32,10 @@ <name>e25386dc-a740-4f93-a1f0-32317cf5a36a</name> <entityField>OPTIONAL</entityField> </entityFieldLink> + <entityFieldLink> + <name>4b1853d4-1fc8-4c14-a5e2-1c5d0468442c</name> + <entityField>INFO</entityField> + </entityFieldLink> </fields> </genericViewTemplate> </children> diff --git a/others/db_changes/struct/create_offeritem.xml b/others/db_changes/struct/create_offeritem.xml index 0f62e8ccbc..627ba98c09 100644 --- a/others/db_changes/struct/create_offeritem.xml +++ b/others/db_changes/struct/create_offeritem.xml @@ -25,6 +25,7 @@ </column> <column name="DISCOUNT" type="NUMERIC(14,2)"/> <column name="ITEMPOSITION" type="VARCHAR(30)"/> + <column name="INFO" type="NCLOB"/> <column name="DATE_EDIT" type="TIMESTAMP"/> <column name="DATE_NEW" type="TIMESTAMP"> <constraints nullable="false"/> diff --git a/process/OfferOrder_lib/process.js b/process/OfferOrder_lib/process.js index a1dde7990a..c75347a393 100644 --- a/process/OfferOrder_lib/process.js +++ b/process/OfferOrder_lib/process.js @@ -244,17 +244,21 @@ ItemUtils.prototype.roundPrice = function(price) { /** * Inserts parts list of the passed product into database. * - * @param {String[]} columns req Array of Item DB Columns + * @param {String[]} columns req Array of Item DB Columns * @param {String} productId req UID of root product (selected product) * @param {String} assignedTo opt UID of parent item * @param {String} currency opt currency for price list to use * @param {String} relationId opt relationid for price list to use (custom price list) + * @param {String[][]} additionalProductInfo additional product info, which has to be copied from the product. (e.g. INFO field is only used by offer) + * has to be in the form: [["DESTINATION-DB-FIELD", "PRODUCT-DB-FIELD"], ...] * * @return {String[]} Array of inserted ItemIDs * * @abstract */ -ItemUtils.prototype.insertPartsList = function(columns, productId, assignedTo, currency, relationId) { +ItemUtils.prototype.insertPartsList = function(columns, productId, assignedTo, currency, relationId, additionalProductInfo) { + if (additionalProductInfo == undefined) { additionalProductInfo = [] } + var insertedItemIds = []; //save address for this here to call methods in recursive sub function __itemInsertStatement var self = this; @@ -274,6 +278,7 @@ ItemUtils.prototype.insertPartsList = function(columns, productId, assignedTo, c var statements = []; + columns = columns.concat(additionalProductInfo.map(function(item) {return item[0]})); var colTypes = db.getColumnTypes(table, columns); __itemInsertStatement(partsList.root, assignedTo, currency, relationId); @@ -295,8 +300,11 @@ ItemUtils.prototype.insertPartsList = function(columns, productId, assignedTo, c var p2pid = partsListObj.ids[i]; var P2pObject = partsList[p2pid]; var prodid = partsList[p2pid].sourceid; - var ProductDetails = ProductUtils.getProductDetails(prodid, { currency: currency, quantity: P2pObject.quantity, relationId: relationId } ) - + var ProductDetails = ProductUtils.getProductDetails( + prodid, + { currency: currency, quantity: P2pObject.quantity, relationId: relationId }, + additionalProductInfo.map(function(item) {return item[1]})); + var price = ""; var vat = ""; if (P2pObject.takeprice && ProductDetails.productId && ProductDetails.PriceListToUse) { @@ -318,7 +326,9 @@ ItemUtils.prototype.insertPartsList = function(columns, productId, assignedTo, c , pos , itemsort , datetime.date() - , vars.get("$sys.user")]; + , vars.get("$sys.user")] + // add aditional details + .concat(additionalProductInfo.map(function(item) {return ProductDetails[item[1]]})); statements.push([table, columns, colTypes, vals]); insertedItemIds.push(newid); diff --git a/process/Offer_lib/process.js b/process/Offer_lib/process.js index 9876c3b210..ec78bc02a4 100644 --- a/process/Offer_lib/process.js +++ b/process/Offer_lib/process.js @@ -286,7 +286,7 @@ OfferItemUtils.prototype.insertPartsList = function(pProductId, pAssignedTo, pCu , "DATE_NEW" , "USER_NEW"]; - return ItemUtils.prototype.insertPartsList.apply(this, [cols, pProductId, pAssignedTo, pCurrency, pRelationId]); + return ItemUtils.prototype.insertPartsList.apply(this, [cols, pProductId, pAssignedTo, pCurrency, pRelationId, [["INFO", "INFO"]]]); } OfferItemUtils.prototype.deletePartsList = function(pItemId) { diff --git a/process/Product_lib/process.js b/process/Product_lib/process.js index 9b1d043f5d..6122cd8b2b 100644 --- a/process/Product_lib/process.js +++ b/process/Product_lib/process.js @@ -1,4 +1,3 @@ -import("system.logging"); import("system.util"); import("system.SQLTYPES"); import("system.datetime"); @@ -88,6 +87,8 @@ ProductUtils.getStockCount = function(pid) { * * @param {String} pid req ProductID * @param {Object} priceListFilter opt { currency: "currencyValue", quantity: "quantityValue", relationId: "relationIdValue (for custom price lists)" } + * @param {String[]} additionalProductInfoFields additional fields from Product + * They are added to the result with the Fieldname as key. e.g. if the array is ["INFO"] the result will contain the key "INFO" * * @example //Product_entity, Field: PRODUCT_ID, Process: onValueChange * var pid = ProcessHandlingUtils.getOnValidationValue(vars.get("$field.PRODUCT_ID")); @@ -95,7 +96,7 @@ ProductUtils.getStockCount = function(pid) { * var relid = vars.exists("$param.RelationId_param") ? vars.get("$param.RelationId_param") : ""; * var pUtils = new ProductUtils(); * var PriceListFilter = { currency: curr, quantity: vars.get("$field.QUANTITY"), relationId: relid }; - * var ProductDetails = pUtils.getProductDetails(pid, PriceListFilter); + * var ProductDetails = pUtils.getProductDetails(pid, PriceListFilter, ["INFO"]); * * @return {Object} { <br> * productId: "productid" <br> @@ -137,15 +138,20 @@ ProductUtils.getStockCount = function(pid) { * , buySell: "SP" / "PP" <br> * , fromQuantity: "fromquantity" <br> * , currency: "keyvalue of keyword 'CURRENCY'" <br> - * } } <br> + * } }, <br> + * INFO: "the productinfo" * } */ -ProductUtils.getProductDetails = function(pid, priceListFilter) +ProductUtils.getProductDetails = function(pid, priceListFilter, additionalProductInfoFields) { + if (additionalProductInfoFields == undefined) {additionalProductInfoFields = []} var ProductDetails = {}; var cols = []; var colsProduct = ["PRODUCT.PRODUCTID", "PRODUCT.PRODUCTNAME", "PRODUCT.GROUPCODEID", "PRODUCT.UNIT"]; + var defaultProductFieldCount = colsProduct.length; + colsProduct = colsProduct.concat(additionalProductInfoFields.map(function(item) {return "PRODUCT." + item})); + cols = cols.concat(colsProduct); var joins = []; @@ -190,7 +196,7 @@ ProductUtils.getProductDetails = function(pid, priceListFilter) .buildSelect("select " + cols.join(", ") + " from PRODUCT " + joins.join(" "), "1 = 2", "order by " + orderby.join(", ")) -logging.log(ProductDataSql.toSource()) + var ProductData = db.table(ProductDataSql); for (var i = 0; i < ProductData.length; i++) @@ -207,6 +213,14 @@ logging.log(ProductDataSql.toSource()) , CurrentValidPriceLists: {} , PriceListToUse: null }; + + // add additional fields to the details + var countPos = defaultProductFieldCount; + additionalProductInfoFields.forEach(function(productField) + { + this[productField] = ProductData[i][countPos]; + countPos++; + }, ProductDetails); } //Pricelist (all) var colIdx = colsProduct.length; -- GitLab