From 9d4b8b47aec52fe8619661225823f569d4760246 Mon Sep 17 00:00:00 2001
From: Johannes Hoermann <j.hoermann@adito.de>
Date: Wed, 3 Apr 2019 12:59:27 +0200
Subject: [PATCH] angebot: Lieferbedingungen / Zahlungsbedingungen vorbelegen

---
 .../deliveryterms/valueProcess.js             | 11 +++++++++-
 .../entityfields/paymentterms/valueProcess.js | 22 ++++++++++++++-----
 .../data/example_attribute/Attribute.xml      |  4 ++--
 3 files changed, 28 insertions(+), 9 deletions(-)

diff --git a/entity/Offer_entity/entityfields/deliveryterms/valueProcess.js b/entity/Offer_entity/entityfields/deliveryterms/valueProcess.js
index 911cd325a0..c3d8c920ee 100644
--- a/entity/Offer_entity/entityfields/deliveryterms/valueProcess.js
+++ b/entity/Offer_entity/entityfields/deliveryterms/valueProcess.js
@@ -1,8 +1,17 @@
-import("system.logging");
+import("system.neon");
 import("system.result");
 import("system.vars");
+import("Attribute_lib");
 
 if (vars.exists("$param.OfferDeliveryTerm_param") && vars.get("$param.OfferDeliveryTerm_param")) 
 {
     result.string(vars.get("$param.OfferDeliveryTerm_param"));
+} 
+else if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW)
+{
+    var contactId = vars.getString("$field.CONTACT_ID");
+    if (contactId)
+    {                                         // Lieferkondition
+        result.string(AttributeRelationUtils.getAttribute("3a6e11fc-b00a-4cf3-975a-a5e8b60fc5cb", contactId));
+    }
 }
\ No newline at end of file
diff --git a/entity/Offer_entity/entityfields/paymentterms/valueProcess.js b/entity/Offer_entity/entityfields/paymentterms/valueProcess.js
index 298cb1a859..35d02f62ca 100644
--- a/entity/Offer_entity/entityfields/paymentterms/valueProcess.js
+++ b/entity/Offer_entity/entityfields/paymentterms/valueProcess.js
@@ -1,7 +1,17 @@
-import("system.result");
-import("system.vars");
-
-if (vars.exists("$param.OfferPaymentTerm_param") && vars.get("$param.OfferPaymentTerm_param")) 
-{
-    result.string(vars.get("$param.OfferPaymentTerm_param"));
+import("system.neon");
+import("system.result");
+import("system.vars");
+import("Attribute_lib");
+
+if (vars.exists("$param.OfferPaymentTerm_param") && vars.get("$param.OfferPaymentTerm_param")) 
+{
+    result.string(vars.get("$param.OfferPaymentTerm_param"));
+}
+else if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW)
+{
+    var contactId = vars.getString("$field.CONTACT_ID");
+    if (contactId)
+    {                                         // Zahlungskondition
+        result.string(AttributeRelationUtils.getAttribute("292fae38-6557-466d-8843-3b1b4a1f6599", contactId));
+    }
 }
\ No newline at end of file
diff --git a/others/db_changes/Data_alias/basic/2019.2/data/example_attribute/Attribute.xml b/others/db_changes/Data_alias/basic/2019.2/data/example_attribute/Attribute.xml
index 28ca84e85f..632b9c9749 100644
--- a/others/db_changes/Data_alias/basic/2019.2/data/example_attribute/Attribute.xml
+++ b/others/db_changes/Data_alias/basic/2019.2/data/example_attribute/Attribute.xml
@@ -871,7 +871,7 @@
 </insert>
 <insert tableName="AB_ATTRIBUTE">
 	<column name="AB_ATTRIBUTEID" value="292fae38-6557-466d-8843-3b1b4a1f6599"/>
-	<column name="ATTRIBUTE_ACTIVE" valueNumeric="0"/>
+	<column name="ATTRIBUTE_ACTIVE" valueNumeric="1"/>
 	<column name="ATTRIBUTE_LEVEL" valueNumeric="1"/>
 	<column name="ATTRIBUTE_NAME" value="Zahlungskondition"/>
 	<column name="ATTRIBUTE_PARENT_ID" value="ab545654-1fce-4993-b763-0ec469781302"/>
@@ -880,7 +880,7 @@
 </insert>
 <insert tableName="AB_ATTRIBUTE">
 	<column name="AB_ATTRIBUTEID" value="3a6e11fc-b00a-4cf3-975a-a5e8b60fc5cb"/>
-	<column name="ATTRIBUTE_ACTIVE" valueNumeric="0"/>
+	<column name="ATTRIBUTE_ACTIVE" valueNumeric="1"/>
 	<column name="ATTRIBUTE_LEVEL" valueNumeric="1"/>
 	<column name="ATTRIBUTE_NAME" value="Lieferkondition"/>
 	<column name="ATTRIBUTE_PARENT_ID" value="ab545654-1fce-4993-b763-0ec469781302"/>
-- 
GitLab