diff --git a/entity/Offer_entity/Offer_entity.aod b/entity/Offer_entity/Offer_entity.aod index 1edca325613c32476ad13c1158c54a8bf9fecaf5..d05d665513bb7c33fa543da457d4237ec471e676 100644 --- a/entity/Offer_entity/Offer_entity.aod +++ b/entity/Offer_entity/Offer_entity.aod @@ -5,6 +5,8 @@ <majorModelMode>DISTRIBUTED</majorModelMode> <alias>Data_alias</alias> <conditionProcess>%aditoprj%/entity/Offer_entity/conditionProcess.js</conditionProcess> + <grantUpdateProcess>%aditoprj%/entity/Offer_entity/grantUpdateProcess.js</grantUpdateProcess> + <grantDeleteProcess>%aditoprj%/entity/Offer_entity/grantDeleteProcess.js</grantDeleteProcess> <recordContainerType>DB</recordContainerType> <caption>Offer</caption> <entityFields> @@ -163,6 +165,13 @@ <triggerRecalculation v="true" /> <mandatory v="true" /> </entityParameter> + <entityParameter> + <name>OfferStatus_param</name> + <code>%aditoprj%/entity/Offer_entity/entityfields/offerofferitem_dfo/children/offerstatus_param/code.js</code> + <expose v="true" /> + <triggerRecalculation v="true" /> + <mandatory v="true" /> + </entityParameter> </children> </entityOutgoingField> <entityActionField> diff --git a/entity/Offer_entity/entityfields/offerofferitem_dfo/children/offerstatus_param/code.js b/entity/Offer_entity/entityfields/offerofferitem_dfo/children/offerstatus_param/code.js new file mode 100644 index 0000000000000000000000000000000000000000..c077bf5964a863059f2629603660d7d7eda02492 --- /dev/null +++ b/entity/Offer_entity/entityfields/offerofferitem_dfo/children/offerstatus_param/code.js @@ -0,0 +1,4 @@ +import("system.vars"); +import("system.result"); + +result.string(vars.get("$field.STATUS")); \ No newline at end of file diff --git a/entity/Offer_entity/grantDeleteProcess.js b/entity/Offer_entity/grantDeleteProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..1d03536547d440e7d624bcfe337c802c4cfacd5e --- /dev/null +++ b/entity/Offer_entity/grantDeleteProcess.js @@ -0,0 +1,6 @@ +import("system.vars"); +import("system.result"); +import("Offer_lib"); + +var oUtils = new OfferUtils(); +result.string(oUtils.isEditable(vars.get("$field.STATUS"))); \ No newline at end of file diff --git a/entity/Offer_entity/grantUpdateProcess.js b/entity/Offer_entity/grantUpdateProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..1d03536547d440e7d624bcfe337c802c4cfacd5e --- /dev/null +++ b/entity/Offer_entity/grantUpdateProcess.js @@ -0,0 +1,6 @@ +import("system.vars"); +import("system.result"); +import("Offer_lib"); + +var oUtils = new OfferUtils(); +result.string(oUtils.isEditable(vars.get("$field.STATUS"))); \ No newline at end of file diff --git a/entity/Offeritem_entity/Offeritem_entity.aod b/entity/Offeritem_entity/Offeritem_entity.aod index 206e426134b28f34b15c6b34a01f84f74246e0cc..c28e322e3bdf2c00d7a2fe7f240b4bb7129a8ee0 100644 --- a/entity/Offeritem_entity/Offeritem_entity.aod +++ b/entity/Offeritem_entity/Offeritem_entity.aod @@ -8,6 +8,9 @@ <onDBInsert>%aditoprj%/entity/Offeritem_entity/onDBInsert.js</onDBInsert> <onDBUpdate>%aditoprj%/entity/Offeritem_entity/onDBUpdate.js</onDBUpdate> <onDBDelete>%aditoprj%/entity/Offeritem_entity/onDBDelete.js</onDBDelete> + <grantCreateProcess>%aditoprj%/entity/Offeritem_entity/grantCreateProcess.js</grantCreateProcess> + <grantUpdateProcess>%aditoprj%/entity/Offeritem_entity/grantUpdateProcess.js</grantUpdateProcess> + <grantDeleteProcess>%aditoprj%/entity/Offeritem_entity/grantDeleteProcess.js</grantDeleteProcess> <recordContainerType>DB</recordContainerType> <caption>Offeritem</caption> <entityFields> @@ -184,6 +187,12 @@ <contentType>IMAGE</contentType> <valueProcess>%aditoprj%/entity/Offeritem_entity/entityfields/image/valueProcess.js</valueProcess> </entityField> + <entityParameter> + <name>OfferStatus_param</name> + <expose v="true" /> + <triggerRecalculation v="true" /> + <description>PARAMETER</description> + </entityParameter> </entityFields> <linkInformation> <linkInformation> diff --git a/entity/Offeritem_entity/grantCreateProcess.js b/entity/Offeritem_entity/grantCreateProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..5d45e991a5d09799e02589b926edf9236cabfc9c --- /dev/null +++ b/entity/Offeritem_entity/grantCreateProcess.js @@ -0,0 +1,6 @@ +import("system.vars"); +import("system.result"); +import("Offer_lib"); + +var oUtils = new OfferUtils(); +result.string(oUtils.isEditable(vars.get("$param.OfferStatus_param"))); \ No newline at end of file diff --git a/entity/Offeritem_entity/grantDeleteProcess.js b/entity/Offeritem_entity/grantDeleteProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..5d45e991a5d09799e02589b926edf9236cabfc9c --- /dev/null +++ b/entity/Offeritem_entity/grantDeleteProcess.js @@ -0,0 +1,6 @@ +import("system.vars"); +import("system.result"); +import("Offer_lib"); + +var oUtils = new OfferUtils(); +result.string(oUtils.isEditable(vars.get("$param.OfferStatus_param"))); \ No newline at end of file diff --git a/entity/Offeritem_entity/grantUpdateProcess.js b/entity/Offeritem_entity/grantUpdateProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..5d45e991a5d09799e02589b926edf9236cabfc9c --- /dev/null +++ b/entity/Offeritem_entity/grantUpdateProcess.js @@ -0,0 +1,6 @@ +import("system.vars"); +import("system.result"); +import("Offer_lib"); + +var oUtils = new OfferUtils(); +result.string(oUtils.isEditable(vars.get("$param.OfferStatus_param"))); \ No newline at end of file diff --git a/process/Offer_lib/process.js b/process/Offer_lib/process.js index b7c05285b8fb45833a699b54a8901fae47fab9e7..fa042cdc3445448cadb7e4de3a2080de616d95cb 100644 --- a/process/Offer_lib/process.js +++ b/process/Offer_lib/process.js @@ -1,6 +1,7 @@ import("system.translate"); import("system.db"); import("system.eMath"); +import("system.tools"); import("Util_lib"); function OfferUtils(){ @@ -51,6 +52,14 @@ function OfferUtils(){ return [sum, vat]; } + + this.isEditable = function(pStatus){ + + //TODO: Administrator darf immer ändern, warten auf neue Berechtigungslogik? + + //Offer should be editable if offer state not equals "Sent", "Won" or "Lost" + return pStatus != "2" && pStatus != "3" && pStatus != "4"; + } } function OfferItemUtils(){