diff --git a/entity/Address_entity/Address_entity.aod b/entity/Address_entity/Address_entity.aod index f3b70c507fa6e79e51b7680348e5016927de1b27..f5f260207f525b44e6edf580571fcc1242956ff8 100644 --- a/entity/Address_entity/Address_entity.aod +++ b/entity/Address_entity/Address_entity.aod @@ -11,6 +11,7 @@ <name>ADDRESS</name> <title>Address</title> <mandatoryProcess>%aditoprj%/entity/Address_entity/entityfields/address/mandatoryProcess.js</mandatoryProcess> + <valueProcess>%aditoprj%/entity/Address_entity/entityfields/address/valueProcess.js</valueProcess> </entityField> <entityField> <name>ADDRESSADDITION</name> diff --git a/entity/Address_entity/entityfields/addr_type/possibleItemsProcess.js b/entity/Address_entity/entityfields/addr_type/possibleItemsProcess.js index 9b37906c7bd5f390db426ce1dd22861676e9474f..018ea70fb3e9e317dda4d331f6519bf32b252f88 100644 --- a/entity/Address_entity/entityfields/addr_type/possibleItemsProcess.js +++ b/entity/Address_entity/entityfields/addr_type/possibleItemsProcess.js @@ -16,12 +16,14 @@ switch (type) { break; } -result.object(KeywordUtils.getStandardArrayProps("ADDRESS.TYPE").filter(function (pKeyword) { +var resultKeywords = []; +KeywordUtils.getStandardArrayProps("ADDRESS.TYPE").forEach(function(pKeyword) { for (let i = 0; i < fields.length; i++) { if (pKeyword[2][fields[i]]) { - return true; + resultKeywords.push([pKeyword[0], pKeyword[1]]); + break; } } - - return false; -})); \ No newline at end of file +}); + +result.object(resultKeywords); \ No newline at end of file diff --git a/entity/Address_entity/entityfields/address/valueProcess.js b/entity/Address_entity/entityfields/address/valueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/entity/Address_entity/entityfields/relation_id/valueProcess.js b/entity/Address_entity/entityfields/relation_id/valueProcess.js index 61a5ce97dd4ee046ca818ee01aaca846e966e3be..d2e1b432aef07fb4a0da589e632414a43f9c39c4 100644 --- a/entity/Address_entity/entityfields/relation_id/valueProcess.js +++ b/entity/Address_entity/entityfields/relation_id/valueProcess.js @@ -1,9 +1,12 @@ +import("system.logging"); import("system.result"); import("system.neon"); import("system.vars"); -if(vars.get("$sys.operatingstate") == neon.OPERATINGSTATE_NEW) +if(vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW) { if(vars.exists("$param.RelId_param") && vars.getString("$param.RelId_param")) + { result.string(vars.getString("$param.RelId_param")); -} \ No newline at end of file + } +} diff --git a/entity/Offer_entity/Offer_entity.aod b/entity/Offer_entity/Offer_entity.aod index 78334abd582cda5f178045a7efa8512757a49821..883ea09314d1cc52257cc5f4064d3a2325231daa 100644 --- a/entity/Offer_entity/Offer_entity.aod +++ b/entity/Offer_entity/Offer_entity.aod @@ -329,10 +329,19 @@ </entityOutgoingField> <entityField> <name>ADDRESS</name> + <documentation>%aditoprj%/entity/Offer_entity/entityfields/address/documentation.adoc</documentation> + <title>address</title> + <description></description> + <contentType>LONG_TEXT</contentType> </entityField> <entityField> - <name>PossibleAddresses</name> - <possibleItemsProcess>%aditoprj%/entity/Offer_entity/entityfields/possibleaddresses/possibleItemsProcess.js</possibleItemsProcess> + <name>ChosenAddress</name> + <title>Choose address</title> + <possibleItemsProcess>%aditoprj%/entity/Offer_entity/entityfields/chosenaddress/possibleItemsProcess.js</possibleItemsProcess> + <onValueChange>%aditoprj%/entity/Offer_entity/entityfields/chosenaddress/onValueChange.js</onValueChange> + <onValueChangeTypes> + <element>MASK</element> + </onValueChangeTypes> </entityField> </entityFields> <recordContainers> diff --git a/entity/Offer_entity/entityfields/address/documentation.adoc b/entity/Offer_entity/entityfields/address/documentation.adoc new file mode 100644 index 0000000000000000000000000000000000000000..25ac2910909e454e0baf5781a310de3f7976d342 --- /dev/null +++ b/entity/Offer_entity/entityfields/address/documentation.adoc @@ -0,0 +1,3 @@ +The Address is a free text field, because it should not be connected to the original address. + +The field is set also by the ChosenAddress field \ No newline at end of file diff --git a/entity/Offer_entity/entityfields/chosenaddress/onValueChange.js b/entity/Offer_entity/entityfields/chosenaddress/onValueChange.js new file mode 100644 index 0000000000000000000000000000000000000000..e27804413bf71f873429b24b7a2865b03a23475b --- /dev/null +++ b/entity/Offer_entity/entityfields/chosenaddress/onValueChange.js @@ -0,0 +1,11 @@ +import("system.vars"); +import("system.neon"); +import("PostalAddress_lib"); +import("Entity_lib"); + +var newAddressId = ProcessHandlingUtils.getOnValidationValue(vars.get("$field.ChosenAddress")); + +if (newAddressId) +{ + neon.setFieldValue("$field.ADDRESS", AddressUtils.getAddressById(newAddressId)); +} \ No newline at end of file diff --git a/entity/Offer_entity/entityfields/chosenaddress/possibleItemsProcess.js b/entity/Offer_entity/entityfields/chosenaddress/possibleItemsProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..5672ce8b163cbab66339b9c3fb164b65c9ac1995 --- /dev/null +++ b/entity/Offer_entity/entityfields/chosenaddress/possibleItemsProcess.js @@ -0,0 +1,5 @@ +import("system.vars"); +import("system.result"); +import("PostalAddress_lib"); + +result.object(AddressUtils.getAllPossibleAddresses(vars.get("$field.RELATION_ID"))); \ No newline at end of file diff --git a/entity/Offer_entity/entityfields/possibleaddresses/possibleItemsProcess.js b/entity/Offer_entity/entityfields/possibleaddresses/possibleItemsProcess.js deleted file mode 100644 index fbbb4f0c71b025110aefb5413cdbc2634c009608..0000000000000000000000000000000000000000 --- a/entity/Offer_entity/entityfields/possibleaddresses/possibleItemsProcess.js +++ /dev/null @@ -1,4 +0,0 @@ -import("system.result"); -import("Keyword_lib"); - -result.object(KeywordUtils.getStandardArray("ADDRESS.TYPE")); \ No newline at end of file diff --git a/neonView/AddressList_view/AddressList_view.aod b/neonView/AddressList_view/AddressList_view.aod index 83e0b2e6bd8fba7c3c9ea51a1b1c3815dd8a1ab1..e947fb863feb2b6ce28009ea7936885c386dec3c 100644 --- a/neonView/AddressList_view/AddressList_view.aod +++ b/neonView/AddressList_view/AddressList_view.aod @@ -1,6 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <neonView xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.0.1" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/neonView/1.0.1"> <name>AddressList_view</name> + <description>Org addresses</description> <majorModelMode>DISTRIBUTED</majorModelMode> <layout> <noneLayout> diff --git a/neonView/OfferEdit_view/OfferEdit_view.aod b/neonView/OfferEdit_view/OfferEdit_view.aod index e8f8de7cf5ad4cf4fb0afa3d715c01d3672f3c96..5c83f5e936d2c289179fe3bbe7996af5c641c35b 100644 --- a/neonView/OfferEdit_view/OfferEdit_view.aod +++ b/neonView/OfferEdit_view/OfferEdit_view.aod @@ -56,6 +56,14 @@ <name>c4b3c8ed-4625-4785-abc6-c726171ff7f4</name> <entityField>FOOTER</entityField> </entityFieldLink> + <entityFieldLink> + <name>833e6193-fde6-4990-8a26-eaeb0f60de48</name> + <entityField>ChosenAddress</entityField> + </entityFieldLink> + <entityFieldLink> + <name>930dc6e3-a19f-4780-9553-9cfd4a158fd5</name> + <entityField>ADDRESS</entityField> + </entityFieldLink> </fields> </genericViewTemplate> <neonViewReference> diff --git a/neonView/OfferPreview_view/OfferPreview_view.aod b/neonView/OfferPreview_view/OfferPreview_view.aod index f01c49bdfa8ab31fd31b83ad153df5fb837ff841..1186c6543584f8175bf581387622154fe72f52c9 100644 --- a/neonView/OfferPreview_view/OfferPreview_view.aod +++ b/neonView/OfferPreview_view/OfferPreview_view.aod @@ -34,6 +34,10 @@ <name>49e446b5-015e-45ad-9417-c5c50f9756f1</name> <entityField>LANGUAGE</entityField> </entityFieldLink> + <entityFieldLink> + <name>447f5c6e-3653-49dd-ba8b-18c21a9bd6f9</name> + <entityField>ADDRESS</entityField> + </entityFieldLink> </fields> </genericViewTemplate> <genericViewTemplate> diff --git a/others/db_changes/data/PERS_data.xml b/others/db_changes/data/PERS_data.xml deleted file mode 100644 index 75d901d6354d259cdf44083504e16cf918328ce4..0000000000000000000000000000000000000000 --- a/others/db_changes/data/PERS_data.xml +++ /dev/null @@ -1,24 +0,0 @@ -<?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="e.pollinger" id="efc45d88-a40d-49e0-a24c-afcb6095d1cb"> - <insert tableName="PERS"> - <column name="PERSID" value="efc45d88-a40d-49e0-a24c-afcb6095d1cb"/> - <column name="DATE_NEW" valueDate="2018-07-02T00:00:00"/> - <column name="DATEOFBIRTH" valueDate="1991-02-01"/> - <column name="USER_NEW" value="admin"/> - <column name="FIRSTNAME" value="Heribert"/> - <column name="MIDDLENAME" value="Anton"/> - <column name="LASTNAME" value="Untermeier"/> - <column name="GENDER" value="m"/> - <column name="SALUTATION" value="Herr"/> - </insert> - <rollback> - <delete tableName="PERS"> - <where>PERSID = ?</where> - <whereParams> - <param value="efc45d88-a40d-49e0-a24c-afcb6095d1cb" /> - </whereParams> - </delete> - </rollback> -</changeSet> -</databaseChangeLog> \ No newline at end of file diff --git a/others/db_changes/data/PERS_extendeddata.xml b/others/db_changes/data/PERS_extendeddata.xml deleted file mode 100644 index 03ae509a34602799fedb9fbad727c1c9e75fbcba..0000000000000000000000000000000000000000 --- a/others/db_changes/data/PERS_extendeddata.xml +++ /dev/null @@ -1,21 +0,0 @@ -<?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="j.goderbauer" id="bcd51581-424d-40c0-b060-5abe8fe1efb2"> - <insert tableName="RELATION"> - <column name="RELATIONID" value="a8e084e2-d68a-4f1e-a7bb-f8d46ad6293d"/> - <column name="PERS_ID" value="efc45d88-a40d-49e0-a24c-afcb6095d1cb"/> - <column name="ORG_ID" value="29990305-4ac6-4876-94b9-0300ce5cefaa"/> - <column name="DATE_NEW" valueDate="2018-07-02T00:00:00"/> - <column name="USER_NEW" value="Lisa Sommer"/> - <column name="STATUS" valueNumeric="1"/> - </insert> - <rollback> - <delete tableName="RELATION"> - <where>RELATIONID = ?</where> - <whereParams> - <param value="a8e084e2-d68a-4f1e-a7bb-f8d46ad6293d" /> - </whereParams> - </delete> - </rollback> - </changeSet> -</databaseChangeLog> \ No newline at end of file diff --git a/others/db_changes/data/example_address/1535612802325_addresses.xml b/others/db_changes/data/example_address/1535612802325_addresses.xml deleted file mode 100644 index 711d28a71b8874d90a9178a370064f09e9e9c2f9..0000000000000000000000000000000000000000 --- a/others/db_changes/data/example_address/1535612802325_addresses.xml +++ /dev/null @@ -1,27 +0,0 @@ -<?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="j.goderbauer" id="b77db18b-ecc9-439b-a0bd-df86e63a413f"> - <insert tableName="ADDRESS"> - <column name="ADDRESSID" value="97d37aea-d7f8-4436-bb31-875439f5f7f1"/> - <column name="USER_NEW" value="Raphael"/> - <column name="DATE_NEW" valueDate="2018-08-13T02:06:43"/> - <column name="RELATION_ID" value="bdb6e38a-b227-455b-ae48-f8febd622e03"/> - - <column name="ADDR_TYPE" valueNumeric="1"/> - <column name="ADDRESS" value="Musterstraße"/> - <column name="BUILDINGNO" value="9"/> - <column name="ZIP" value="5018"/> - <column name="CITY" value="Bergen"/> - <column name="COUNTRY" value="DE"/> - </insert> - - <rollback> - <delete tableName="ADDRESS"> - <where>ADDRESSID = ?</where> - <whereParams> - <param value="97d37aea-d7f8-4436-bb31-875439f5f7f1"/> - </whereParams> - </delete> - </rollback> - </changeSet> -</databaseChangeLog> \ No newline at end of file diff --git a/others/db_changes/data/example_comm/1535614428250_comm.xml b/others/db_changes/data/example_comm/1535614428250_comm.xml deleted file mode 100644 index cd8636d11639936e41ab3b536df774a5dd8c3ef9..0000000000000000000000000000000000000000 --- a/others/db_changes/data/example_comm/1535614428250_comm.xml +++ /dev/null @@ -1,24 +0,0 @@ -<?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="j.goderbauer" id="e452c5ee-dfe5-4aee-9eec-c3a397fa2ab2"> - <insert tableName="COMM"> - <column name="COMMID" value="cdd02d37-845d-40be-9b8c-08f99afa985f"/> - <column name="USER_NEW" value="Raphael"/> - <column name="DATE_NEW" valueDate="2018-08-13T03:14:22"/> - <column name="RELATION_ID" value="bdb6e38a-b227-455b-ae48-f8febd622e03"/> - - <column name="MEDIUM_ID" valueNumeric="3"/> - <column name="STANDARD" valueNumeric="1"/> - <column name="ADDR" value="http://www.brod-bergen.no/"/> - </insert> - - <rollback> - <delete tableName="COMM"> - <where>COMMID = ?</where> - <whereParams> - <param value="cdd02d37-845d-40be-9b8c-08f99afa985f"/> - </whereParams> - </delete> - </rollback> - </changeSet> -</databaseChangeLog> \ No newline at end of file diff --git a/others/db_changes/data/example_org.xml b/others/db_changes/data/example_org.xml deleted file mode 100644 index b2d8f2b8ca6702f09aa477826b1acf2dcfea7859..0000000000000000000000000000000000000000 --- a/others/db_changes/data/example_org.xml +++ /dev/null @@ -1,67 +0,0 @@ -<?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="j.goderbauer" id="1528875814543-1"> - <insert tableName="ORG"> - <column name="ORGID" value="198b8a8b-c053-447a-bc69-17965b6a60ae"/> - <column name="USER_NEW" value="Gwendoline"/> - <column name="DATE_NEW" valueDate="2018-06-13T09:03:43"/> - <column name="NAME" value="Bitfox Ltd."/> - <column name="CUSTOMERCODE" value="01189998819991197253"/> - <column name="TYPE" valueNumeric="0"/> - </insert> - <insert tableName="RELATION"> - <column name="RELATIONID" value="a589b58a-f120-42d8-9a64-0b176501eac7"/> - <column name="USER_NEW" value="Gwendoline"/> - <column name="DATE_NEW" valueDate="2018-06-13T09:03:43"/> - <column name="ORG_ID" value="198b8a8b-c053-447a-bc69-17965b6a60ae"/> - <column name="LANGUAGE" value="en-GB"/> - <column name="STATUS" valueNumeric="0"/> - </insert> - <rollback> - <delete tableName="RELATION"> - <where>RELATIONID = ?</where> - <whereParams> - <param value="a589b58a-f120-42d8-9a64-0b176501eac7" /> - </whereParams> - </delete> - <delete tableName="ORG"> - <where>ORGID = ?</where> - <whereParams> - <param value="198b8a8b-c053-447a-bc69-17965b6a60ae" /> - </whereParams> - </delete> - - </rollback> - </changeSet> - <changeSet author="j.goderbauer" id="1528875814543-2"> - <insert tableName="ORG"> - <column name="ORGID" value="29990305-4ac6-4876-94b9-0300ce5cefaa"/> - <column name="USER_NEW" value="Gwendoline"/> - <column name="DATE_NEW" valueDate="2018-06-13T14:02:53"/> - <column name="NAME" value="Brød og mer ᛗ AS"/> - <column name="TYPE" valueNumeric="0"/> - </insert> - <insert tableName="RELATION"> - <column name="RELATIONID" value="bdb6e38a-b227-455b-ae48-f8febd622e03"/> - <column name="USER_NEW" value="Gwendoline"/> - <column name="DATE_NEW" valueDate="2018-06-13T14:02:54"/> - <column name="ORG_ID" value="29990305-4ac6-4876-94b9-0300ce5cefaa"/> - <column name="LANGUAGE" value="no-NO"/> - <column name="STATUS" valueNumeric="0"/> - </insert> - <rollback> - <delete tableName="RELATION"> - <where>RELATIONID = ?</where> - <whereParams> - <param value="bdb6e38a-b227-455b-ae48-f8febd622e03" /> - </whereParams> - </delete> - <delete tableName="ORG"> - <where>ORGID = ?</where> - <whereParams> - <param value="29990305-4ac6-4876-94b9-0300ce5cefaa" /> - </whereParams> - </delete> - </rollback> - </changeSet> -</databaseChangeLog> \ No newline at end of file diff --git a/others/db_changes/data/example_pers/PERS_leicht.xml b/others/db_changes/data/example_pers/PERS_leicht.xml index ad4e5664ec8fe2b1a570eb4bcbeb0f2fa0a2f50e..bcc0d96c585a84844f7a3ae77bc64388e43d0f64 100644 --- a/others/db_changes/data/example_pers/PERS_leicht.xml +++ b/others/db_changes/data/example_pers/PERS_leicht.xml @@ -22,6 +22,40 @@ <column name="USER_NEW" value="admin"/> <column name="STATUS" valueNumeric="1"/> </insert> + <insert tableName="ADDRESS"> + <column name="STATE" value="Bayern"/> + <column name="ADDR_TYPE" valueNumeric="2"/> + <column name="DATE_NEW" valueDate="2018-07-02T00:00:00"/> + <column name="CITY" value="Landshut"/> + <column name="COUNTRY" value="DE"/> + <column name="RELATION_ID" value="73d72f18-e7f5-11e8-9f32-f2801f1b9fd1"/> + <column name="USER_NEW" value="admin"/> + <column name="ADDRIDENTIFIER" value=""/> + <column name="REGION" value="Niederbayern"/> + <column name="ADDRESSID" value="ce990566-3b86-48fe-bd0c-1167142e584b"/> + <column name="BUILDINGNO" value="12"/> + <column name="ADDRESSADDITION"/> + <column name="ZIP" value="84034"/> + <column name="ADDRESS" value="Neustadt"/> + <column name="DISTRICT" value="Niederbayern"/> + </insert> + <insert tableName="ADDRESS"> + <column name="STATE" value="Bayern"/> + <column name="ADDR_TYPE" valueNumeric="3"/> + <column name="DATE_NEW" valueDate="2018-07-02T00:00:00"/> + <column name="CITY" value="Landshut"/> + <column name="COUNTRY" value="DE"/> + <column name="RELATION_ID" value="73d72f18-e7f5-11e8-9f32-f2801f1b9fd1"/> + <column name="USER_NEW" value="admin"/> + <column name="ADDRIDENTIFIER" value=""/> + <column name="REGION" value="Niederbayern"/> + <column name="ADDRESSID" value="43b8aea1-2444-448f-87c5-f12fe1ef4ca0"/> + <column name="BUILDINGNO" value="13"/> + <column name="ADDRESSADDITION"/> + <column name="ZIP" value="84034"/> + <column name="ADDRESS" value="Neustadt"/> + <column name="DISTRICT" value="Niederbayern"/> + </insert> <rollback> <delete tableName="RELATION"> <where>RELATIONID = ?</where> @@ -35,6 +69,12 @@ <param value="73d72bf8-e7f5-11e8-9f32-f2801f1b9fd1" /> </whereParams> </delete> + <delete tableName="ADDRESS"> + <where>RELATION_ID = ?</where> + <whereParams> + <param value="73d72bf8-e7f5-11e8-9f32-f2801f1b9fd1" /> + </whereParams> + </delete> </rollback> </changeSet> diff --git a/others/db_changes/masterChangelog.xml b/others/db_changes/masterChangelog.xml index 4059bb9fac56b9366d8df6794db77ce4f7f32f7d..17b5f69cde54cd0f58bef8287a3ef840a47ab378 100644 --- a/others/db_changes/masterChangelog.xml +++ b/others/db_changes/masterChangelog.xml @@ -25,7 +25,6 @@ <include file="struct/create_salesorderitem.xml"/> <include file="struct/create_countryinfo.xml"/> <include file="struct/create_timetracking.xml"/> - <include file="data/example_address/1535612802325_addresses.xml"/> <include file="data/example_org/ORG_privat.xml"/> <include file="data/example_org/ORG_gfk.xml"/> <include file="data/example_org/ORG_mnf.xml"/> diff --git a/process/PostalAddress_lib/process.js b/process/PostalAddress_lib/process.js index d3e6ed3ff18d3fe08539288c6d64e6b0e80d20ec..394f05bac8a0dc643dbe3e945c106c5cce47f4ea 100644 --- a/process/PostalAddress_lib/process.js +++ b/process/PostalAddress_lib/process.js @@ -1,7 +1,7 @@ import("system.db"); import("Sql_lib"); import("Relation_lib"); - +import("Keyword_lib"); /** * Methods for addresses. * Todo: evtl. übernahme / anpassung der Adresslib aus altem Basic. 1030856 @@ -59,26 +59,88 @@ AddressUtils.getAddress = function(pRelationId) { } var type = RelationUtils.getRelationTypeByRelation(pRelationId); + return AddressUtils.formatAddress(type, address[1], address[2], address[3], address[4], address[5], address[6], address[7], address[8]); +} + +/** + * Returns the formatted address. + * + * TODO: Dummy method! Ãœbernahme der Adresslib aus altem Basic + * + * @return {String} + */ +AddressUtils.getAddressById = function(pAddressId) { + var address = db.array(db.ROW, SqlCondition.begin() + .andPrepare("ADDRESS.ADDRESSID", pAddressId) + .buildSelect("select RELATION_ID, ADDRESS, BUILDINGNO, ZIP, CITY from " + + "ADDRESS", "1=0")); + + // TODO: currently there are some relations without standard address. Use Hardcoded one. + if (!address[1]) { + var dummyAddress = db.array(db.ROW, SqlCondition.begin().andPrepare("ADDRESS.ADDRESSID", '97d37aea-d7f8-4436-bb31-875439f5f7f1').buildSelect('select RELATION_ID, ADDRESS, BUILDINGNO, ZIP, CITY from ADDRESS', "1=0")); + address[0] = dummyAddress[0]; + address[1] = dummyAddress[1]; + address[2] = dummyAddress[2]; + address[3] = dummyAddress[3]; + address[4] = dummyAddress[4]; + + } + var type = RelationUtils.getRelationTypeByRelation(address[0]); + + var names = db.array(db.ROW, SqlCondition.begin() + .andPrepare("RELATION.RELATIONID", address[0]) + .buildSelect("select ORG.NAME, FIRSTNAME, LASTNAME, TITLE from RELATION left join PERS on PERSID = PERS_ID left join ORG on ORGID = ORG_ID" + , "1=0")); + return AddressUtils.formatAddress(type, address[1], address[2], address[3], address[4], names[0], names[1], names[2], names[3]); +} + +/** + * TODO: Dummy method! + * + * Returns the formatted address. + * + * TODO: Dummy method! Ãœbernahme der Adresslib aus altem Basic und Nutzung von den Platzhaltern in Zukunft! + * + * @return {String} + */ +AddressUtils.formatAddress = function(pAddrType, pAddress, pBuildingno, pZip, pCity, pOrgname, pFirstname, pLastname, pTitle) { var resultAddr = ""; + // 1 if organisation <br> // 2 if privat person <br> - // 3 if person of an organisation <br>*/ - switch (type) + // 3 if person of an organisation <br> + switch (pAddrType) { case 1: - resultAddr = address[5] + "\n" + address[1] + " " + address[2] + "\n" + address[3] + " " + address[4]; + resultAddr = pOrgname + "\n" + pAddress + " " + pBuildingno + "\n" + pZip + " " + pCity; break; case 2: - resultAddr = address[8] + " " + address[6] + " " + address[7] + "\n" + address[1] + " " + address[2] + "\n" + address[3] + " " + address[4]; + resultAddr = pTitle + " " + pFirstname + " " + pLastname + "\n" + pAddress + " " + pBuildingno + "\n" + pZip + " " + pCity; break; case 3: - resultAddr = address[5] + "\n" + address[6] + " " + address[7] + "\n" + address[1] + " " + address[2] + "\n" + address[3] + " " + address[4]; + resultAddr = pOrgname + "\n" + (pTitle && pFirstname && pLastname ? pTitle + " " + pFirstname + " " + pLastname + "\n" : "") + pAddress + " " + pBuildingno + "\n" + pZip + " " + pCity; break; } return resultAddr; } +/** + * Returns the formatted addresses for the relation. + * + * TODO: Dummy method! Ãœbernahme der Adresslib aus altem Basic + * + * @return {String} + */ +AddressUtils.getAllPossibleAddresses = function(pRelationId) { + var addresses = db.table(SqlCondition.begin().andPrepare("RELATION.RELATIONID", pRelationId) + .buildSelect("select ADDRESSID, ADDR_TYPE, ADDRIDENTIFIER from ADDRESS join RELATION on RELATIONID = RELATION_ID or RELATION_ID = ORG_ID", "1=0")); + + return addresses.map(function(pAddress) { + return [pAddress[0], KeywordUtils.get("ADDRESS.TYPE", pAddress[1])[1] + " " + pAddress[2]] + }); +} + /** * Returns a letter salutation. *