Categorie: reference Bijgewerkt: 2026-04-08 actionfield workflow actionfield1574

ActionField1574

Beschrijving: Start dialog to insert ExchangeRate. Custom: Nee

Propertiesbewerken

Property Type Accessor
ExchangeCurrency ExchangeCurrency Root
ApproveNewExchangeCurrency Boolean Optional
Percentage Int16 Optional

XMLbewerken

<Workflow Name="ActionField1574" Version="2025.07.28" WorkflowType="Standard" xmlns="urn:Ultimo.Framework.Workflow-mapping">
	<Security EditLevel="10" ViewLevel="20" UserContentLevel="30" />
	<Description>Start dialog to insert ExchangeRate.</Description>
	<Properties>
		<Property	Name="ExchangeCurrency"				Type="ExchangeCurrency"		Accessor="Root"		Direction="In" />

		<Property	Name="ApproveNewExchangeCurrency"	Type="Boolean"				Accessor="Optional"	Direction="In"		Default="True"										Comment="Approve the new ExchangeCurrency or insert it with status Concept" />
		<Property	Name="Percentage"					Type="Int16"				Accessor="Optional"	Direction="In"		Default="5"											Comment="The difference between the new (Rate*ConversionFactor) and the last (Rate*ConversionFactor) may not be greater then this Percentage" />

		<Property	Name="AddExchangeRateYesNo"			Type="RequestResult"		Accessor="Internal"						Default="Yes" />
		<Property	Name="CalcConversionFactor"			Type="Int16"				Accessor="Internal"						Default="0" />
		<Property	Name="CalcRate"						Type="Decimal"				Accessor="Internal"						Default="0" />
		<Property	Name="CheckDate"					Type="DateTime"				Accessor="Internal" />
		<Property	Name="ConversionFactor"				Type="Int16"				Accessor="Internal"						Default="1" />
		<Property	Name="Count"						Type="Int64"				Accessor="Internal" />
		<Property	Name="CurrentExchangeRate"			Type="ExchangeRate"			Accessor="Internal"						Default="${ExchangeCurrency.CurrentExchangeRate}" />
		<Property	Name="DateTime"						Type="DateTime"				Accessor="Internal"						Default="#{Environment.CurrentDateTime}" />
		<Property	Name="DateTimeCheck"				Type="DateTime"				Accessor="Internal"						Default="#{Environment.CurrentDateTime}" />
		<Property	Name="ExchangeRate"					Type="ExchangeRate"			Accessor="Internal" />
		<Property	Name="ExchangeRates"				Type="List[ExchangeRate]"	Accessor="Internal"						Default="Empty" />
		<Property	Name="IsOk"							Type="Boolean"				Accessor="Internal"						Default="False" />
		<Property	Name="NewValue"						Type="Decimal"				Accessor="Internal"						Default="0" />
		<Property	Name="OldValue"						Type="Decimal"				Accessor="Internal"						Default="0" />
		<Property	Name="PercOldValue"					Type="Decimal"				Accessor="Internal"						Default="0" />
		<Property	Name="Rate"							Type="Decimal"				Accessor="Internal"						Default="1" />
	</Properties>
	<Execution>
		<UserContent Name="Pre" />

		<When Name="CurrentExchangeRate != null" Condition="${CurrentExchangeRate} != Empty">
			<Assign Name="Set ConversionFactor" Property="${ConversionFactor}" Value="${CurrentExchangeRate.ConversionFactor}" />
			<Assign Name="Set Rate" Property="${Rate}" Value="${CurrentExchangeRate.Rate}" />
		</When>

		<While Name="Start Dialog as long as not ok" Condition="${IsOk} == False">
			<When Name="DateTime smaller then CurrentDate" Condition="${DateTime} &lt; #{Environment.CurrentDateTime}">
				<Assign Name="Set DateTime" Property="${DateTime}" Value="#{Environment.CurrentDateTime}" />
				<Assign Name="Set DateTimeCheck" Property="${DateTimeCheck}" Value="${DateTime}" />
			</When>

			<Dialog Name="AddExchangeRateDialog" TitleCode="EXCHANGERATE_ADD">
				<Container>
					<Text Name="BaseCurrency" Value="=#concat(${ExchangeCurrency.Id.BaseCurrency.Id}, ' - ', ${ExchangeCurrency.Id.BaseCurrency.Description})" ReadOnly="True" LabelCode="EXCHANGERATE_BASECURRENCY" />

					<Text Name="CounterCurrency" Value="=#concat(${ExchangeCurrency.Id.CounterCurrency.Id}, ' - ', ${ExchangeCurrency.Id.CounterCurrency.Description})" ReadOnly="True" LabelCode="EXCHANGERATE_COUNTERCURRENCY" />

					<DateTime Name="ExchangeRateDateTime" Value="${DateTime}" OutputProperty="${DateTime}" Required="True" LabelCode="EXCHANGERATE_DATETIME" MinValue="#{Environment.CurrentDateTime}" />

					<Number Name="Rate" Value="${Rate}" OutputProperty="${Rate}" LabelCode="EXCHANGERATE_RATE" MinValue="0" DecimalPrecision="5" />

					<Number Name="ConversionFactor" Value="${ConversionFactor}" OutputProperty="${ConversionFactor}" LabelCode="EXCHANGERATE_CONVERSIONFACTOR" MinValue="0" DecimalPrecision="5" />
				</Container>
			</Dialog>

			<When Name="DateTime is not changed" Condition="${DateTime} == ${DateTimeCheck}">
				<Assign Name="Set DateTime to Current" Property="${DateTime}" Value="#{Environment.CurrentDateTime}" />
			</When>

			<Assign Name="Round DateTime to Minutes" Property="${DateTime}" Value="=#settime(${DateTime}, #gethours(${DateTime}), #getminutes(${DateTime}) )" />

			<Transaction>
				<GetList Name="Get Last Approved ExchangeRate" Type="ExchangeRate" OutputProperty="${ExchangeRates}" OrderBy="Date" OrderDirection="Descending" Top="1">
					<Filters>
						<CombinedFilter FilterOperator="And">
							<PropertyFilter	PropertyName="Id.ExchangeCurrency.Id.BaseCurrency"		Operator="="		PropertyValue="${ExchangeCurrency.Id.BaseCurrency}" />
							<PropertyFilter	PropertyName="Id.ExchangeCurrency.Id.CounterCurrency"	Operator="="		PropertyValue="${ExchangeCurrency.Id.CounterCurrency}" />
							<PropertyFilter	PropertyName="Status"									Operator="="		PropertyValue="ExchangeRateStatus.Approved" />
							<PropertyFilter	PropertyName="Date"										Operator="&lt;="	PropertyValue="${DateTime}" />
						</CombinedFilter>
					</Filters>
				</GetList>

				<GetCount Name="Count" Type="ExchangeRate" OutputProperty="${Count}">
					<Filters>
						<PropertyFilter	PropertyName="Id.ExchangeCurrency"	Operator="="		PropertyValue="${ExchangeCurrency}" />
						<PropertyFilter	PropertyName="Date"					Operator="="		PropertyValue="${DateTime}" />
					</Filters>
				</GetCount>
			</Transaction>

			<Assign Name="Set AddExchangeRateYesNo to Yes" Property="${AddExchangeRateYesNo}" Value="Yes" />

			<When Name="When there is a ExchangeRate found" Condition="${ExchangeRates.Count} &gt; 0">
				<Assign Name="Set CalcConversionFactor" Property="${CalcConversionFactor}" Value="=#getpropertyvalue(#elementat(${ExchangeRates}, 0), 'ConversionFactor')" />
				<Assign Name="Set CalcRate" Property="${CalcRate}" Value="=#getpropertyvalue(#elementat(${ExchangeRates}, 0), 'Rate')" />
				<Assign Name="Set NewValue" Property="${NewValue}" Value="=${ConversionFactor} * ${Rate}" />
				<Assign Name="Set OldValue" Property="${OldValue}" Value="=${CalcConversionFactor} * ${CalcRate}" />
				<Assign Name="Calculate 5% of OldValue" Property="${PercOldValue}" Value="=(${OldValue}/100) * ${Percentage}" />

				<When Name="When Difference is too great" Condition="${NewValue} &gt; (${OldValue}+${PercOldValue}) || ${NewValue} &lt; (${OldValue}-${PercOldValue})">
					<Question Name="Continue with Approving ExchangeRate" Type="YesNo" MessageCode="2914" Default="Yes" OutputProperty="${AddExchangeRateYesNo}">
						<Parameter	Name="Percentage"	Direction="In"		Value="${Percentage}" />
					</Question>
				</When>
			</When>

			<When Name="AnswerIsYes" Condition="${AddExchangeRateYesNo} == Yes">
				<Assign Name="Calculate CheckDate" Property="${CheckDate}" Value="=#addminutes(#{Environment.CurrentDateTime},-1)" />

				<Choose Name="Check Date">
					<When Name="When Date is not correct" Condition="${DateTime} &lt; ${CheckDate}">
						<Message Name="Validate date" MessageCode="2920" />
					</When>


					<When Name="Date already exists" Condition="${Count} != 0">
						<Message Name="Already exists date" MessageCode="2921">
							<Parameter	Name="Date"	Direction="In"		Value="${DateTime}" />
						</Message>
					</When>

					<Otherwise Name="Date is correct, insert ExchangeRate">
						<Transaction>
							<Insert Name="Insert ExchangeRate" ObjectType="ExchangeRate" OutputProperty="${ExchangeRate}">
								<Parameter	Name="Id.ExchangeCurrency"	Direction="In"		Value="${ExchangeCurrency}" />
								<Parameter	Name="Status"				Direction="In"		Value="ExchangeRateStatus.Concept" />
								<Parameter	Name="ConversionFactor"		Direction="In"		Value="${ConversionFactor}" />
								<Parameter	Name="Date"					Direction="In"		Value="${DateTime}" />
								<Parameter	Name="Rate"					Direction="In"		Value="${Rate}" />
							</Insert>

							<When Name="ApproveNewExchangeCurrency" Condition="${ApproveNewExchangeCurrency} == True">
								<ChangeStatus Name="Change ExchangeRate Status To Approved" DomainObject="${ExchangeRate}" NewStatus="ExchangeRateStatus.Approved" />
							</When>

							<Assign Name="Set to True" Property="${IsOk}" Value="True" />
						</Transaction>
					</Otherwise>
				</Choose>
			</When>
		</While>

		<UserContent Name="Post" />
	</Execution>
</Workflow>