diff --git a/entity/Contract_entity/Contract_entity.aod b/entity/Contract_entity/Contract_entity.aod index a2fadd13231477fc2cb32e3897fa9d337bc9bd32..c56de3ea1037c9b87888819798877d8c543db49e 100644 --- a/entity/Contract_entity/Contract_entity.aod +++ b/entity/Contract_entity/Contract_entity.aod @@ -13,6 +13,8 @@ <documentation>%aditoprj%/entity/Contract_entity/entityfields/contractcode/documentation.adoc</documentation> <title>Contract number</title> <mandatory v="true" /> + <state>READONLY</state> + <valueProcess>%aditoprj%/entity/Contract_entity/entityfields/contractcode/valueProcess.js</valueProcess> <onValidation>%aditoprj%/entity/Contract_entity/entityfields/contractcode/onValidation.js</onValidation> </entityField> <entityField> diff --git a/entity/Contract_entity/entityfields/contractcode/documentation.adoc b/entity/Contract_entity/entityfields/contractcode/documentation.adoc index fd63d0f0f336b7fa30a7710db6df032e8f91227f..ec170d7ddfe1f7c61e7bdfcef601ab46b25338fd 100644 --- a/entity/Contract_entity/entityfields/contractcode/documentation.adoc +++ b/entity/Contract_entity/entityfields/contractcode/documentation.adoc @@ -1,4 +1,5 @@ = CONTRACTCODE :hardbreaks: -Unique identification number of the contract. (max. 30 characters, not automatically generated) \ No newline at end of file +Unique identification number of the contract. +It's automatically generated from the starting number _1000_. \ No newline at end of file diff --git a/entity/Contract_entity/entityfields/contractcode/onValidation.js b/entity/Contract_entity/entityfields/contractcode/onValidation.js index 8d2de85d894a32c92d53fd9e16cffb2b1fd153fb..c9c46837558c4f545d61a8861b63a8a3d32dd0df 100644 --- a/entity/Contract_entity/entityfields/contractcode/onValidation.js +++ b/entity/Contract_entity/entityfields/contractcode/onValidation.js @@ -1,16 +1,11 @@ -import("system.translate"); -import("system.result"); import("system.vars"); -import("system.db"); -import("Util_lib"); +import("system.result"); +import("system.neon"); +import("Contract_lib"); import("Entity_lib"); -var contractCode, codeCount; - -contractCode = ProcessHandlingUtils.getOnValidationValue(vars.get("$field.CONTRACTCODE")); -codeCount = db.cell("select count(CONTRACTCODE) from CONTRACT where CONTRACTCODE = '" + contractCode + "'" - + " and CONTRACTID <> '" + vars.get("$field.CONTRACTID") + "'"); -if(codeCount > 0) +if(vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW + && !ContractUtils.validateContractNumber(ProcessHandlingUtils.getOnValidationValue(vars.get("$field.CONTRACTCODE")))) { - result.string(translate.text("The contract number already exists!")); + vars.set("$field.CONTRACTCODE", ContractUtils.getNextContractNumber().toString()); } \ No newline at end of file diff --git a/entity/Contract_entity/entityfields/contractcode/valueProcess.js b/entity/Contract_entity/entityfields/contractcode/valueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..be926defac630885c9949d6e770f76c7bc226a55 --- /dev/null +++ b/entity/Contract_entity/entityfields/contractcode/valueProcess.js @@ -0,0 +1,9 @@ +import("system.vars"); +import("system.result"); +import("system.neon"); +import("Contract_lib"); + +if(vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW) +{ + result.string(ContractUtils.getNextContractNumber()); +} \ No newline at end of file diff --git a/entity/Order_entity/entityfields/salesordercode/onValidation.js b/entity/Order_entity/entityfields/salesordercode/onValidation.js index 9b98fac0e7b4722b8dcf714669dbf75ca524db7c..7913eec27eac7305ad380c20034691581d7fd08e 100644 --- a/entity/Order_entity/entityfields/salesordercode/onValidation.js +++ b/entity/Order_entity/entityfields/salesordercode/onValidation.js @@ -2,8 +2,6 @@ import("system.vars"); import("system.result"); import("system.neon"); import("Order_lib"); -import("Salesproject_lib"); -import("Util_lib"); import("Entity_lib"); if(vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW diff --git a/others/db_changes/data_alias/data/example_contract/CONTRACT_42154311.xml b/others/db_changes/data_alias/data/example_contract/CONTRACT_1000.xml similarity index 96% rename from others/db_changes/data_alias/data/example_contract/CONTRACT_42154311.xml rename to others/db_changes/data_alias/data/example_contract/CONTRACT_1000.xml index f0dbcb7fb2fa47acb5117370288541b86cc55fe8..9927a52e97c92ee9841262bf97bc1925ef9c6622 100644 --- a/others/db_changes/data_alias/data/example_contract/CONTRACT_42154311.xml +++ b/others/db_changes/data_alias/data/example_contract/CONTRACT_1000.xml @@ -4,7 +4,7 @@ <insert tableName="CONTRACT"> <column name="CONTRACTID" value="384c9d31-9923-4e6a-8a7f-2d2890470b70"/> <column name="CONTACT_ID" value="b219b58a-f120-42d8-9a64-0b176501eac7"/> - <column name="CONTRACTCODE" value="42154311"/> + <column name="CONTRACTCODE" value="1000"/> <column name="PAYMENT" value="ca4d845b-f299-40c8-ace5-174bcfbb2d12"/> <column name="CONTRACTTYPE" value="612f49d7-66c9-4304-ac3f-0ea19bb50948"/> <column name="CONTRACTSTATUS" value="3579eb0c-d8ca-4b6b-85ee-f1800a9301eb"/> diff --git a/others/db_changes/data_alias/data/example_contract/CONTRACT_42154312.xml b/others/db_changes/data_alias/data/example_contract/CONTRACT_1001.xml similarity index 96% rename from others/db_changes/data_alias/data/example_contract/CONTRACT_42154312.xml rename to others/db_changes/data_alias/data/example_contract/CONTRACT_1001.xml index d097059613e5959da8368d56982d34b9303c41de..b37673fcca6e2de324e470008ce8334a5619e2d0 100644 --- a/others/db_changes/data_alias/data/example_contract/CONTRACT_42154312.xml +++ b/others/db_changes/data_alias/data/example_contract/CONTRACT_1001.xml @@ -4,7 +4,7 @@ <insert tableName="CONTRACT"> <column name="CONTRACTID" value="8b95a074-086e-44c8-bd45-fb8e33803da3"/> <column name="CONTACT_ID" value="b219b58a-f120-42d8-9a64-0b176501eac7"/> - <column name="CONTRACTCODE" value="42154312"/> + <column name="CONTRACTCODE" value="1001"/> <column name="PAYMENT" value="ca4d845b-f299-40c8-ace5-174bcfbb2d12"/> <column name="CONTRACTTYPE" value="612f49d7-66c9-4304-ac3f-0ea19bb50948"/> <column name="CONTRACTSTATUS" value="3579eb0c-d8ca-4b6b-85ee-f1800a9301eb"/> diff --git a/others/db_changes/data_alias/data/example_contract/CONTRACT_42154313.xml b/others/db_changes/data_alias/data/example_contract/CONTRACT_1002.xml similarity index 96% rename from others/db_changes/data_alias/data/example_contract/CONTRACT_42154313.xml rename to others/db_changes/data_alias/data/example_contract/CONTRACT_1002.xml index c4b7c76337ec5d649ce020ce82059e857749de0e..440e9ce6423f53a4c7be2b39e6967de9539623c9 100644 --- a/others/db_changes/data_alias/data/example_contract/CONTRACT_42154313.xml +++ b/others/db_changes/data_alias/data/example_contract/CONTRACT_1002.xml @@ -4,7 +4,7 @@ <insert tableName="CONTRACT"> <column name="CONTRACTID" value="eb182167-1e33-4290-a160-a86d09685cba"/> <column name="CONTACT_ID" value="b219b58a-f120-42d8-9a64-0b176501eac7"/> - <column name="CONTRACTCODE" value="42154313"/> + <column name="CONTRACTCODE" value="1002"/> <column name="PAYMENT" value="ca4d845b-f299-40c8-ace5-174bcfbb2d12"/> <column name="CONTRACTTYPE" value="612f49d7-66c9-4304-ac3f-0ea19bb50948"/> <column name="CONTRACTSTATUS" value="3579eb0c-d8ca-4b6b-85ee-f1800a9301eb"/> diff --git a/others/db_changes/data_alias/data/example_contract/CONTRACT_42154314.xml b/others/db_changes/data_alias/data/example_contract/CONTRACT_1003.xml similarity index 96% rename from others/db_changes/data_alias/data/example_contract/CONTRACT_42154314.xml rename to others/db_changes/data_alias/data/example_contract/CONTRACT_1003.xml index 759d52ba01082a983405bbdf641a7323492872d1..f474cb79b4e5720fbe6b6af141b45e439657f3fb 100644 --- a/others/db_changes/data_alias/data/example_contract/CONTRACT_42154314.xml +++ b/others/db_changes/data_alias/data/example_contract/CONTRACT_1003.xml @@ -4,7 +4,7 @@ <insert tableName="CONTRACT"> <column name="CONTRACTID" value="6fc9483c-fcfc-48fb-b48f-18e6b11f31fc"/> <column name="CONTACT_ID" value="e6da1393-f46b-41a4-826b-2c7d22de2246"/> - <column name="CONTRACTCODE" value="42154314"/> + <column name="CONTRACTCODE" value="1003"/> <column name="PAYMENT" value="ca4d845b-f299-40c8-ace5-174bcfbb2d12"/> <column name="CONTRACTTYPE" value="612f49d7-66c9-4304-ac3f-0ea19bb50948"/> <column name="CONTRACTSTATUS" value="3579eb0c-d8ca-4b6b-85ee-f1800a9301eb"/> diff --git a/others/db_changes/data_alias/data/example_contract/CONTRACT_42154315.xml b/others/db_changes/data_alias/data/example_contract/CONTRACT_1004.xml similarity index 96% rename from others/db_changes/data_alias/data/example_contract/CONTRACT_42154315.xml rename to others/db_changes/data_alias/data/example_contract/CONTRACT_1004.xml index 384a9580f825492f3fe919ea4530f0253851f8d3..8ba106ae449019ea6caaeac2e405a7d6fe2259a4 100644 --- a/others/db_changes/data_alias/data/example_contract/CONTRACT_42154315.xml +++ b/others/db_changes/data_alias/data/example_contract/CONTRACT_1004.xml @@ -4,7 +4,7 @@ <insert tableName="CONTRACT"> <column name="CONTRACTID" value="a944b07c-aaed-4bcf-820c-9e6031bc3d6c"/> <column name="CONTACT_ID" value="e6da1393-f46b-41a4-826b-2c7d22de2246"/> - <column name="CONTRACTCODE" value="42154315"/> + <column name="CONTRACTCODE" value="1004"/> <column name="PAYMENT" value="ca4d845b-f299-40c8-ace5-174bcfbb2d12"/> <column name="CONTRACTTYPE" value="612f49d7-66c9-4304-ac3f-0ea19bb50948"/> <column name="CONTRACTSTATUS" value="3579eb0c-d8ca-4b6b-85ee-f1800a9301eb"/> diff --git a/others/db_changes/masterChangelog.xml b/others/db_changes/masterChangelog.xml index 94cb020b23c1cb427399047909a35af4d35111d6..da00a762ef6d8f228aa7e9887c598fda38c4b3dd 100644 --- a/others/db_changes/masterChangelog.xml +++ b/others/db_changes/masterChangelog.xml @@ -51,11 +51,11 @@ <include file="data_alias/data/example_person/PERSON_obermeier.xml"/> <include file="data_alias/data/example_person/PERSON_smith.xml"/> <include file="data_alias/data/example_person/PERSON_lustig.xml"/> - <include file="data_alias/data/example_contract/CONTRACT_42154311.xml"/> - <include file="data_alias/data/example_contract/CONTRACT_42154312.xml"/> - <include file="data_alias/data/example_contract/CONTRACT_42154313.xml"/> - <include file="data_alias/data/example_contract/CONTRACT_42154314.xml"/> - <include file="data_alias/data/example_contract/CONTRACT_42154315.xml"/> + <include file="data_alias/data/example_contract/CONTRACT_1000.xml"/> + <include file="data_alias/data/example_contract/CONTRACT_1001.xml"/> + <include file="data_alias/data/example_contract/CONTRACT_1002.xml"/> + <include file="data_alias/data/example_contract/CONTRACT_1003.xml"/> + <include file="data_alias/data/example_contract/CONTRACT_1004.xml"/> <include file="data_alias/data/example_product/PRODUCT_42154311.xml"/> <include file="data_alias/data/example_salesproject/SALESPROJECT_gfk.xml"/> <include file="data_alias/data/example_salesproject/SALESPROJECT_jkl.xml"/> diff --git a/preferences/_____PREFERENCES_PROJECT/_____PREFERENCES_PROJECT.aod b/preferences/_____PREFERENCES_PROJECT/_____PREFERENCES_PROJECT.aod index 3f9daeb173f0de1d87682e389317618aba75d421..336d6b092bda8ab38166821c8d50c82ace586ceb 100644 --- a/preferences/_____PREFERENCES_PROJECT/_____PREFERENCES_PROJECT.aod +++ b/preferences/_____PREFERENCES_PROJECT/_____PREFERENCES_PROJECT.aod @@ -2,7 +2,7 @@ <preferences xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="3.0.3" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/preferences/3.0.3"> <name>_____PREFERENCES_PROJECT</name> <majorModelMode>DISTRIBUTED</majorModelMode> - <projectName>basic 2019</projectName> + <projectName>xRM-Basic2019</projectName> <jditoMaxContentSize v="57671680" /> <calendarCategoriesEvent> <entry> diff --git a/process/Contract_lib/Contract_lib.aod b/process/Contract_lib/Contract_lib.aod new file mode 100644 index 0000000000000000000000000000000000000000..234bef611cb14e0b410737c12c22ca3cdf8dd3de --- /dev/null +++ b/process/Contract_lib/Contract_lib.aod @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8"?> +<process xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.1.7" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/process/1.1.7"> + <name>Contract_lib</name> + <majorModelMode>DISTRIBUTED</majorModelMode> + <process>%aditoprj%/process/Contract_lib/process.js</process> + <variants> + <element>LIBRARY</element> + </variants> +</process> diff --git a/process/Contract_lib/process.js b/process/Contract_lib/process.js new file mode 100644 index 0000000000000000000000000000000000000000..292b26d66dff5ea3839086e8448b03b8644dd5b0 --- /dev/null +++ b/process/Contract_lib/process.js @@ -0,0 +1,46 @@ +import("system.vars"); +import("system.util"); +import("system.datetime"); +import("system.text"); +import("system.neon"); +import("system.db"); +import("system.translate"); +import("system.eMath"); +import("Util_lib"); +import("Sql_lib"); +import("Keyword_lib"); +import("Product_lib"); +import("Report_lib"); +import("OfferOrder_lib"); + +/** + * Methods used by Contract. + * Do not create an instance of this! + * + * @class + */ +function ContractUtils() {} + +/** + * Delivers the next valid contract number (has to be unique) + * + * @return {String} next valid contract number + */ +ContractUtils.getNextContractNumber = function() { + return NumberSequencingUtils.getNextUniqueNumber("CONTRACTCODE", "CONTRACT"); +} + +/** + * Checks if the passed order number is valid (has to be unique) + * + * @param {String} pContractNumber order number to check + * + * @return {Boolean} passed number is valid + */ +ContractUtils.validateContractNumber = function(pContractNumber) { + return NumberSequencingUtils.validateUniqueNumber(pContractNumber, "CONTRACTCODE", "CONTRACT"); +} + +ContractUtils.getContractNumberValidationFailString = function() { + return translate.text("The contract number already exists!"); +} \ No newline at end of file