From 65a7c0ed4e158ec9972381d833cac2ed055abdbd Mon Sep 17 00:00:00 2001
From: "S.Listl" <S.Listl@SLISTL.aditosoftware.local>
Date: Tue, 5 Mar 2019 13:53:36 +0100
Subject: [PATCH] =?UTF-8?q?[Projekt:=20Entwicklung=20-=20Neon][TicketNr.:?=
 =?UTF-8?q?=201035104][Beleg=20aus=20Angebot=20erstellen=20und=20Verkn?=
 =?UTF-8?q?=C3=BCpfung=20beim=20Beleg=20zum=20Angebot=20anzeigen]?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 aliasDefinition/Data_alias/Data_alias.aod         | 14 ++++++++++++++
 entity/Order_entity/Order_entity.aod              | 11 +++++++++++
 .../entityfields/offer_id/displayValueProcess.js  |  5 +++++
 .../entityfields/offer_id/valueProcess.js         |  7 +++++++
 neonView/OrderPreview_view/OrderPreview_view.aod  |  4 ++++
 .../basic/2019.2/SalesOrder_source_offer.xml      |  8 ++++++++
 .../data_alias/basic/2019.2/changelog.xml         |  1 +
 process/Offer_lib/process.js                      | 15 +++++++++++++++
 8 files changed, 65 insertions(+)
 create mode 100644 entity/Order_entity/entityfields/offer_id/displayValueProcess.js
 create mode 100644 entity/Order_entity/entityfields/offer_id/valueProcess.js
 create mode 100644 others/db_changes/data_alias/basic/2019.2/SalesOrder_source_offer.xml

diff --git a/aliasDefinition/Data_alias/Data_alias.aod b/aliasDefinition/Data_alias/Data_alias.aod
index 0418326a53..c82ddacd86 100644
--- a/aliasDefinition/Data_alias/Data_alias.aod
+++ b/aliasDefinition/Data_alias/Data_alias.aod
@@ -3300,6 +3300,20 @@
                 <title></title>
                 <description></description>
               </entityFieldDb>
+              <entityFieldDb>
+                <name>OFFER_ID</name>
+                <dbName></dbName>
+                <primaryKey v="false" />
+                <columnType v="1" />
+                <size v="36" />
+                <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/Order_entity/Order_entity.aod b/entity/Order_entity/Order_entity.aod
index 4afb6c516c..8fbf47e00e 100644
--- a/entity/Order_entity/Order_entity.aod
+++ b/entity/Order_entity/Order_entity.aod
@@ -385,6 +385,13 @@
       <onActionProcess>%aditoprj%/entity/Order_entity/entityfields/newactivity/onActionProcess.js</onActionProcess>
       <iconId>NEON:HISTORY</iconId>
     </entityActionField>
+    <entityField>
+      <name>OFFER_ID</name>
+      <title>Offer</title>
+      <linkedContext>Offer</linkedContext>
+      <valueProcess>%aditoprj%/entity/Order_entity/entityfields/offer_id/valueProcess.js</valueProcess>
+      <displayValueProcess>%aditoprj%/entity/Order_entity/entityfields/offer_id/displayValueProcess.js</displayValueProcess>
+    </entityField>
   </entityFields>
   <recordContainers>
     <dbRecordContainer>
@@ -502,6 +509,10 @@
           <name>LANGUAGE.displayValue</name>
           <expression>%aditoprj%/entity/Order_entity/recordcontainers/db/recordfieldmappings/language.displayvalue/expression.js</expression>
         </dbRecordFieldMapping>
+        <dbRecordFieldMapping>
+          <name>OFFER_ID.value</name>
+          <recordfield>SALESORDER.OFFER_ID</recordfield>
+        </dbRecordFieldMapping>
       </recordFieldMappings>
     </dbRecordContainer>
   </recordContainers>
diff --git a/entity/Order_entity/entityfields/offer_id/displayValueProcess.js b/entity/Order_entity/entityfields/offer_id/displayValueProcess.js
new file mode 100644
index 0000000000..cde400be01
--- /dev/null
+++ b/entity/Order_entity/entityfields/offer_id/displayValueProcess.js
@@ -0,0 +1,5 @@
+import("system.vars");
+import("system.result");
+import("Offer_lib");
+
+result.string(OfferUtils.getOfferTitleById(vars.get("$field.OFFER_ID")));
\ No newline at end of file
diff --git a/entity/Order_entity/entityfields/offer_id/valueProcess.js b/entity/Order_entity/entityfields/offer_id/valueProcess.js
new file mode 100644
index 0000000000..aed6796329
--- /dev/null
+++ b/entity/Order_entity/entityfields/offer_id/valueProcess.js
@@ -0,0 +1,7 @@
+import("system.result");
+import("system.vars");
+
+if (vars.exists("$param.OfferId_param")) 
+{
+    result.string(vars.get("$param.OfferId_param"));
+}
\ No newline at end of file
diff --git a/neonView/OrderPreview_view/OrderPreview_view.aod b/neonView/OrderPreview_view/OrderPreview_view.aod
index 64b69fb6a1..f3a585b343 100644
--- a/neonView/OrderPreview_view/OrderPreview_view.aod
+++ b/neonView/OrderPreview_view/OrderPreview_view.aod
@@ -69,6 +69,10 @@
           <name>3317b73e-68e8-41a8-a678-89c7c7c8513e</name>
           <entityField>SALESPROJECT_ID</entityField>
         </entityFieldLink>
+        <entityFieldLink>
+          <name>ca9602d9-03fe-450b-9349-949bf206b4bf</name>
+          <entityField>OFFER_ID</entityField>
+        </entityFieldLink>
       </fields>
     </genericViewTemplate>
     <neonViewReference>
diff --git a/others/db_changes/data_alias/basic/2019.2/SalesOrder_source_offer.xml b/others/db_changes/data_alias/basic/2019.2/SalesOrder_source_offer.xml
new file mode 100644
index 0000000000..3c8b67ae2a
--- /dev/null
+++ b/others/db_changes/data_alias/basic/2019.2/SalesOrder_source_offer.xml
@@ -0,0 +1,8 @@
+<?xml version="1.1" encoding="UTF-8" standalone="no"?>
+<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.6.xsd">
+    <changeSet author="s.listl" id="1dda5c72-2c07-46ff-9fc4-00a364fa5c9f">
+        <addColumn tableName="SALESORDER">
+            <column name="OFFER_ID" type="CHAR(36)"/>
+	</addColumn>
+    </changeSet>
+</databaseChangeLog>
\ No newline at end of file
diff --git a/others/db_changes/data_alias/basic/2019.2/changelog.xml b/others/db_changes/data_alias/basic/2019.2/changelog.xml
index 140a9af7be..ffd6d31f54 100644
--- a/others/db_changes/data_alias/basic/2019.2/changelog.xml
+++ b/others/db_changes/data_alias/basic/2019.2/changelog.xml
@@ -80,4 +80,5 @@
     <include relativeToChangelogFile="true" file="SalesProjectCompetitionPhase.xml"/>
     <include relativeToChangelogFile="true" file="AttributeKeyword.xml"/>
     <include relativeToChangelogFile="true" file="Contact_add_columns.xml"/>
+    <include relativeToChangelogFile="true" file="SalesOrder_source_offer.xml"/>
 </databaseChangeLog>
diff --git a/process/Offer_lib/process.js b/process/Offer_lib/process.js
index 6cf2ac0f16..bbb515daf3 100644
--- a/process/Offer_lib/process.js
+++ b/process/Offer_lib/process.js
@@ -348,6 +348,21 @@ OfferUtils.copyToOrder = function (pOfferId, pSalesprojectId, pContactId, pLangu
     neon.openContext("Order", null, null, neon.OPERATINGSTATE_NEW, params);
 }
 
+/**
+ * gets the title of an offer from the id
+ * 
+ * @param pOfferId {String} offer-id
+ * 
+ * @return {String} offer title 
+ */
+OfferUtils.getOfferTitleById = function (pOfferId)
+{
+    var offerNumber = db.array(db.ROW, SqlCondition.begin()
+        .andPrepare("OFFER.OFFERID", pOfferId)
+        .buildSql("select OFFERCODE, VERSNR from OFFER"));
+    return translate.text("Offer") + " " + offerNumber.join("-");
+}
+
 
 /******************************************************************************/
 
-- 
GitLab