From 055bc828a65b3d02168e7905e9c7acc5a209e14d Mon Sep 17 00:00:00 2001 From: "S.Listl" <S.Listl@SLISTL.aditosoftware.local> Date: Thu, 21 Feb 2019 14:11:28 +0100 Subject: [PATCH] =?UTF-8?q?[Projekt:=20Entwicklung=20-=20Neon][TicketNr.:?= =?UTF-8?q?=201034882][Angebot=20kopieren=20-=20Im=20Neuanlagemodus=20?= =?UTF-8?q?=C3=B6ffnen]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entity/Offer_entity/Offer_entity.aod | 38 ++++++++++++++++- .../entityfields/copyoffer/onActionProcess.js | 12 ++++++ .../currency/displayValueProcess.js | 9 ++++ .../entityfields/currency/valueProcess.js | 7 ++++ .../entityfields/header/valueProcess.js | 7 ++++ .../language/displayValueProcess.js | 15 +++++++ .../entityfields/language/valueProcess.js | 7 ++++ .../entityfields/newoffer/onActionProcess.js | 26 ------------ .../recordcontainers/db/onDBInsert.js | 6 +++ .../currency/displayValueProcess.js | 2 - process/Neon_lib/process.js | 3 +- process/Offer_lib/process.js | 41 +++++++++++++++++++ 12 files changed, 142 insertions(+), 31 deletions(-) create mode 100644 entity/Offer_entity/entityfields/copyoffer/onActionProcess.js create mode 100644 entity/Offer_entity/entityfields/currency/displayValueProcess.js create mode 100644 entity/Offer_entity/entityfields/currency/valueProcess.js create mode 100644 entity/Offer_entity/entityfields/header/valueProcess.js create mode 100644 entity/Offer_entity/entityfields/language/displayValueProcess.js create mode 100644 entity/Offer_entity/entityfields/language/valueProcess.js delete mode 100644 entity/Offer_entity/entityfields/newoffer/onActionProcess.js create mode 100644 entity/Offer_entity/recordcontainers/db/onDBInsert.js diff --git a/entity/Offer_entity/Offer_entity.aod b/entity/Offer_entity/Offer_entity.aod index 003c2e6a3c..b956bffb57 100644 --- a/entity/Offer_entity/Offer_entity.aod +++ b/entity/Offer_entity/Offer_entity.aod @@ -15,6 +15,8 @@ <name>CURRENCY</name> <title>Currency</title> <consumer>KeywordCurrencies</consumer> + <valueProcess>%aditoprj%/entity/Offer_entity/entityfields/currency/valueProcess.js</valueProcess> + <displayValueProcess>%aditoprj%/entity/Offer_entity/entityfields/currency/displayValueProcess.js</displayValueProcess> </entityField> <entityField> <name>OFFERCODE</name> @@ -87,6 +89,7 @@ <name>HEADER</name> <title>Cover letter</title> <contentType>HTML</contentType> + <valueProcess>%aditoprj%/entity/Offer_entity/entityfields/header/valueProcess.js</valueProcess> </entityField> <entityConsumer> <name>Offeritems</name> @@ -181,12 +184,14 @@ <title>Language</title> <consumer>Languages</consumer> <mandatory v="true" /> + <valueProcess>%aditoprj%/entity/Offer_entity/entityfields/language/valueProcess.js</valueProcess> + <displayValueProcess>%aditoprj%/entity/Offer_entity/entityfields/language/displayValueProcess.js</displayValueProcess> </entityField> <entityActionField> - <name>newOffer</name> + <name>copyOffer</name> <fieldType>ACTION</fieldType> <title>Copy offer</title> - <onActionProcess>%aditoprj%/entity/Offer_entity/entityfields/newoffer/onActionProcess.js</onActionProcess> + <onActionProcess>%aditoprj%/entity/Offer_entity/entityfields/copyoffer/onActionProcess.js</onActionProcess> </entityActionField> <entityField> <name>VERSNR</name> @@ -418,6 +423,34 @@ </entityParameter> </children> </entityProvider> + <entityParameter> + <name>OfferCurrency_param</name> + <expose v="true" /> + <triggerRecalculation v="true" /> + <mandatory v="false" /> + <description>PARAMETER</description> + </entityParameter> + <entityParameter> + <name>OfferLanguage_param</name> + <expose v="true" /> + <triggerRecalculation v="true" /> + <mandatory v="false" /> + <description>PARAMETER</description> + </entityParameter> + <entityParameter> + <name>OfferHeader_param</name> + <expose v="true" /> + <triggerRecalculation v="true" /> + <mandatory v="false" /> + <description>PARAMETER</description> + </entityParameter> + <entityParameter> + <name>OfferOriginal_Id_param</name> + <expose v="true" /> + <triggerRecalculation v="true" /> + <mandatory v="false" /> + <description>PARAMETER</description> + </entityParameter> </entityFields> <recordContainers> <dbRecordContainer> @@ -426,6 +459,7 @@ <maximumDbRows v="0" /> <fromClauseProcess>%aditoprj%/entity/Offer_entity/recordcontainers/db/fromClauseProcess.js</fromClauseProcess> <conditionProcess>%aditoprj%/entity/Offer_entity/recordcontainers/db/conditionProcess.js</conditionProcess> + <onDBInsert>%aditoprj%/entity/Offer_entity/recordcontainers/db/onDBInsert.js</onDBInsert> <onDBDelete>%aditoprj%/entity/Offer_entity/recordcontainers/db/onDBDelete.js</onDBDelete> <linkInformation> <linkInformation> diff --git a/entity/Offer_entity/entityfields/copyoffer/onActionProcess.js b/entity/Offer_entity/entityfields/copyoffer/onActionProcess.js new file mode 100644 index 0000000000..4957b1ff84 --- /dev/null +++ b/entity/Offer_entity/entityfields/copyoffer/onActionProcess.js @@ -0,0 +1,12 @@ +import("system.vars"); +import("system.neon"); +import("Offer_lib"); + +var contactId = vars.getString("$field.CONTACT_ID"); +var currency = vars.getString("$field.CURRENCY"); +var language = vars.getString("$field.LANGUAGE"); +var header = vars.getString("$field.HEADER"); +var offerId = vars.getString("$field.OFFERID"); + +OfferUtils.copyOffer(offerId, contactId, language, currency, header); + \ No newline at end of file diff --git a/entity/Offer_entity/entityfields/currency/displayValueProcess.js b/entity/Offer_entity/entityfields/currency/displayValueProcess.js new file mode 100644 index 0000000000..0b37c8e450 --- /dev/null +++ b/entity/Offer_entity/entityfields/currency/displayValueProcess.js @@ -0,0 +1,9 @@ +import("system.result"); +import("system.vars"); +import("Keyword_lib"); + +if (vars.exists("$param.OfferCurrency_param")) +{ + var currency = KeywordUtils.getViewValue($KeywordRegistry.get.Currency, vars.get("$param.OfferCurrency_param")); + result.string(currency); +} \ No newline at end of file diff --git a/entity/Offer_entity/entityfields/currency/valueProcess.js b/entity/Offer_entity/entityfields/currency/valueProcess.js new file mode 100644 index 0000000000..260f47d133 --- /dev/null +++ b/entity/Offer_entity/entityfields/currency/valueProcess.js @@ -0,0 +1,7 @@ +import("system.result"); +import("system.vars"); + +if (vars.exists("$param.OfferCurrency_param")) +{ + result.string(vars.get("$param.OfferCurrency_param")); +} \ No newline at end of file diff --git a/entity/Offer_entity/entityfields/header/valueProcess.js b/entity/Offer_entity/entityfields/header/valueProcess.js new file mode 100644 index 0000000000..6dcb1ead4d --- /dev/null +++ b/entity/Offer_entity/entityfields/header/valueProcess.js @@ -0,0 +1,7 @@ +import("system.result"); +import("system.vars"); + +if (vars.exists("$param.OfferHeader_param")) +{ + result.string(vars.get("$param.OfferHeader_param")); +} \ No newline at end of file diff --git a/entity/Offer_entity/entityfields/language/displayValueProcess.js b/entity/Offer_entity/entityfields/language/displayValueProcess.js new file mode 100644 index 0000000000..a9f344b0ee --- /dev/null +++ b/entity/Offer_entity/entityfields/language/displayValueProcess.js @@ -0,0 +1,15 @@ +import("system.db"); +import("system.translate"); +import("system.result"); +import("system.vars"); +import("Sql_lib"); + +if (vars.exists("$param.OfferLanguage_param")) +{ + var iso3 = vars.get("$param.OfferLanguage_param"); + var latinName = db.cell(SqlCondition.begin() + .andPrepare("AB_LANGUAGE.ISO3", iso3) + .buildSql("select NAME_LATIN from AB_LANGUAGE", "1=0")); + latinName = translate.text(latinName); + result.string(latinName); +} \ No newline at end of file diff --git a/entity/Offer_entity/entityfields/language/valueProcess.js b/entity/Offer_entity/entityfields/language/valueProcess.js new file mode 100644 index 0000000000..7bb63ab86b --- /dev/null +++ b/entity/Offer_entity/entityfields/language/valueProcess.js @@ -0,0 +1,7 @@ +import("system.result"); +import("system.vars"); + +if (vars.exists("$param.OfferLanguage_param")) +{ + result.string(vars.get("$param.OfferLanguage_param")); +} \ No newline at end of file diff --git a/entity/Offer_entity/entityfields/newoffer/onActionProcess.js b/entity/Offer_entity/entityfields/newoffer/onActionProcess.js deleted file mode 100644 index 1991c7036f..0000000000 --- a/entity/Offer_entity/entityfields/newoffer/onActionProcess.js +++ /dev/null @@ -1,26 +0,0 @@ -import("system.vars"); -import("system.neon"); -import("Util_lib"); -import("Neon_lib"); -import("Offer_lib"); - -var InputMapping = { - - "OFFER": { - condition: "OFFERID = '" + vars.get("$field.OFFERID") + "'" - , ValueMapping: { - "OFFER_ID": "" - , "OFFERCODE": OfferUtils.getNextOfferNumber() - , "VERSNR": "1" - } - , SubModules:{ - "OFFERITEM": { - condition: "OFFER_ID = '" + vars.get("$field.OFFERID") + "' order by ITEMSORT" - } - } - } -} - -var ModulesMapping = CopyModuleUtils.copyModule(InputMapping); - -CopyModuleUtils.openNewModules("Offer", ModulesMapping); \ No newline at end of file diff --git a/entity/Offer_entity/recordcontainers/db/onDBInsert.js b/entity/Offer_entity/recordcontainers/db/onDBInsert.js new file mode 100644 index 0000000000..5630d92a29 --- /dev/null +++ b/entity/Offer_entity/recordcontainers/db/onDBInsert.js @@ -0,0 +1,6 @@ +import("system.neon"); +import("system.vars"); +import("Offer_lib"); + +if (vars.get("$sys.operatingstate") == neon.OPERATINGSTATE_NEW && vars.exists("$param.OfferOriginal_Id_param")) + OfferUtils.copyOfferItems(vars.getString("$param.OfferOriginal_Id_param"), vars.get("$field.OFFERID")); \ No newline at end of file diff --git a/entity/Order_entity/entityfields/currency/displayValueProcess.js b/entity/Order_entity/entityfields/currency/displayValueProcess.js index 6be00b9378..2519786ebe 100644 --- a/entity/Order_entity/entityfields/currency/displayValueProcess.js +++ b/entity/Order_entity/entityfields/currency/displayValueProcess.js @@ -1,5 +1,3 @@ -import("system.db"); -import("system.translate"); import("system.result"); import("system.vars"); import("Keyword_lib"); diff --git a/process/Neon_lib/process.js b/process/Neon_lib/process.js index c811a8f7be..65e019d7c4 100644 --- a/process/Neon_lib/process.js +++ b/process/Neon_lib/process.js @@ -153,6 +153,7 @@ CopyModuleUtils.copyModule = function(pInputMapping) var rootModule = Object.keys(pInputMapping)[0]; var ModuleMapping = _ModuleMapping(rootModule, pInputMapping[rootModule]); var ModuleData = _getModuleData(rootModule, pInputMapping[rootModule].condition); + ModulesMapping[rootModule] = ModuleMapping; for(var row in ModuleData) { @@ -282,7 +283,7 @@ CopyModuleUtils.copyModule = function(pInputMapping) case "OFFERITEM": { //OFFER_ID mappen - if(ModuleRowMapping.ParentModuleMapping.name == "OFFER") + if(ModuleRowMapping.ParentModuleMapping != null && ModuleRowMapping.ParentModuleMapping.name == "OFFER") { ModuleRowMapping.ColumnMapping["OFFER_ID"].newValue = ModulesMapping[ModuleRowMapping.ParentModuleMapping.name].DataRows[ModuleRowMapping.ColumnMapping["OFFER_ID"].oldValue].newPrimaryKey; } diff --git a/process/Offer_lib/process.js b/process/Offer_lib/process.js index 6f7515d103..9ab33e49c0 100644 --- a/process/Offer_lib/process.js +++ b/process/Offer_lib/process.js @@ -13,6 +13,7 @@ import("Product_lib"); import("Report_lib"); import("OfferOrder_lib"); import("PostalAddress_lib"); +import("Neon_lib"); /** * Methods used by Offer. @@ -273,6 +274,46 @@ OfferUtils.openOfferReport = function(pOfferID) offerReport.openReport(); } +/** + * opens an offer in NEW mode with values from an offer + * + * @param pOfferId {String} id of the offer + * @param pContactId {String} contact id + * @param pLanguage {String} language + * @param pCurrency {String} [currency=""] + * @param pHeader {String} [header=""] + */ +OfferUtils.copyOffer = function (pOfferId, pContactId, pLanguage, pCurrency, pHeader) +{ + var params = { + "ContactId_param" : pContactId, + "OfferLanguage_param" : pLanguage, + "OfferOriginal_Id_param" : pOfferId, + "OfferCurrency_param" : pCurrency || "", + "OfferHeader_param" : pHeader || "" + }; + neon.openContext("Offer", null, null, neon.OPERATINGSTATE_NEW, params); +} + +/** + * copies all offerItems from one offer to another + * + * @param {String} pSourceOfferId + * @param {String} pTargetOfferId + */ +OfferUtils.copyOfferItems = function (pSourceOfferId, pTargetOfferId) +{ + var InputMapping = { + "OFFERITEM": { + condition: "OFFER_ID = '" + pSourceOfferId + "' order by ITEMSORT", + ValueMapping: { + "OFFER_ID" : pTargetOfferId + } + } + }; + CopyModuleUtils.copyModule(InputMapping); +} + /** * opens an order in NEW mode with values from an offer * -- GitLab