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

ActionField937

Beschrijving: Change a ContractPeriod of a RentableRealEstateContract. Custom: Nee

Propertiesbewerken

Property Type Accessor
ContractPeriod ContractPeriod Root
LettableUnitIsRequired Boolean Optional

XMLbewerken

<Workflow Name="ActionField937" Version="2025.07.28" WorkflowType="Standard" xmlns="urn:Ultimo.Framework.Workflow-mapping">
	<Security EditLevel="10" ViewLevel="20" UserContentLevel="30" />
	<Description>Change a ContractPeriod of a RentableRealEstateContract.</Description>
	<Properties>
		<Property	Name="ContractPeriod"							Type="ContractPeriod"		Accessor="Root"		Direction="In" />

		<Property	Name="LettableUnitIsRequired"					Type="Boolean"				Accessor="Optional"	Direction="In"		Default="True"	Comment="Caution: do not use False if you use ActionField937 in the rental administration." />

		<Property	Name="AddContractPeriod"						Type="Boolean"				Accessor="Internal"						Default="False"	Comment="This flag is used to format validation messages, where False means ContractPeriod is changed" />
		<Property	Name="ContractLines"							Type="List[ContractLine]"	Accessor="Internal" />
		<Property	Name="ContractLinesNotMoved"					Type="List[ContractLine]"	Accessor="Internal" />
		<Property	Name="ContractLinesToMove"						Type="List[ContractLine]"	Accessor="Internal" />
		<Property	Name="FirstContractPeriodInList"				Type="List[ContractPeriod]"	Accessor="Internal" />
		<Property	Name="InitialMutationsMovedCount"				Type="Int64"				Accessor="Internal" />
		<Property	Name="InternalChargeLineCount"					Type="Int64"				Accessor="Internal" />
		<Property	Name="RentedPeriod"								Type="StateTimeslot"		Accessor="Internal" />
		<Property	Name="SelectedDateFrom"							Type="Date"					Accessor="Internal" />
		<Property	Name="SelectedDateTill"							Type="Date?"				Accessor="Internal" />
		<Property	Name="SelectedOtherPartyMaximumTerminationDate"	Type="Date?"				Accessor="Internal" />
		<Property	Name="SelectedOurPartyMaximumTerminationDate"	Type="Date?"				Accessor="Internal" />
		<Property	Name="SelectedText"								Type="UltimoString"			Accessor="Internal" />
		<Property	Name="ShowMessage"								Type="Boolean"				Accessor="Internal"						Default="False" />
	</Properties>
	<Execution>
		<UserContent Name="Pre" />

		<Transaction>
			<When Name="When Lettable Unit is required #1" Condition="${LettableUnitIsRequired} == True">
				<Validation Name="RentableObjectIsNotRentable" Condition="${ContractPeriod.ServiceContract.Space.Rentable} == True" MessageCode="1749">
					<Parameter	Name="AddContractPeriod"	Direction="In"		Value="${AddContractPeriod}" />
					<Parameter	Name="Space"				Direction="In"		Value="${ContractPeriod.ServiceContract.Space}" />
				</Validation>
				<Validation Name="RentableRealEstateContractHasEndDate" Condition="${ContractPeriod.ServiceContract.EndDate} == Empty" MessageCode="1785">
					<Parameter	Name="AddContractPeriod"	Direction="In"		Value="${AddContractPeriod}" />
					<Parameter	Name="ServiceContract"		Direction="In"		Value="${ContractPeriod.ServiceContract}" />
				</Validation>
			</When>

			<Comment><![CDATA[
				There may be InternalChargeLines that have not yet been approved, but which might be approved soon. Therefore check whether there are
				any InternalChargeLines that have a PeriodTillDate that lies past the DateTill of this ContractPeriod. The point of this check is that
				the dialog shouldn't popup when the ContractPeriod can't be modified anyhow.
			]]></Comment>

			<GetCount Name="Count unapproved charge lines beyond DateTill" Type="InternalChargeLine" OutputProperty="${InternalChargeLineCount}">
				<Filters>
					<PropertyFilter	PropertyName="ServiceContract.Id"	Operator="="		PropertyValue="${ContractPeriod.ServiceContract.Id}" />
					<WhenFilter Condition="${ContractPeriod.DateTill} != Empty">
						<PropertyFilter	PropertyName="PeriodTillDate"	Operator="&gt;="	PropertyValue="${ContractPeriod.DateTill}" />
					</WhenFilter>
					<WhenFilter Condition="${ContractPeriod.DateFrom} != Empty" Comment="DateFrom should always have a value, but records created with old dialog may not">
						<PropertyFilter	PropertyName="PeriodFromDate"	Operator="&gt;="	PropertyValue="${ContractPeriod.DateFrom}" />
					</WhenFilter>
					<PropertyFilter	PropertyName="Status"				Operator="="		PropertyValue="InternalChargeLineStatus.Open" />
				</Filters>
			</GetCount>

			<Validation Name="There shouldn't be any charge lines in this period" Condition="${InternalChargeLineCount} == 0" MessageCode="1828">
				<Parameter	Name="ContractPeriod"	Direction="In"		Value="${ContractPeriod}" />
			</Validation>
		</Transaction>

		<WorkflowCall Name="Change a ContractPeriod" WorkflowName="Dialog_ContractPeriod_CreateOrChangePeriod">
			<Parameter	Name="ContractPeriodContext"			Direction="In"		Value="ContractPeriodContext.None" />
			<Parameter	Name="IsNew"							Direction="In"		Value="False" />
			<Parameter	Name="DateFrom"							Direction="InOut"	Value="${ContractPeriod.DateFrom}"							OutputProperty="${SelectedDateFrom}" />
			<Parameter	Name="DateTill"							Direction="InOut"	Value="${ContractPeriod.DateTill}"							OutputProperty="${SelectedDateTill}" />
			<Parameter	Name="OtherPartyMaximumTerminationDate"	Direction="InOut"	Value="${ContractPeriod.OtherPartyMaximumTerminationDate}"	OutputProperty="${SelectedOtherPartyMaximumTerminationDate}" />
			<Parameter	Name="OurPartyMaximumTerminationDate"	Direction="InOut"	Value="${ContractPeriod.OurPartyMaximumTerminationDate}"	OutputProperty="${SelectedOurPartyMaximumTerminationDate}" />
			<Parameter	Name="Text"								Direction="InOut"	Value="${ContractPeriod.Text}"								OutputProperty="${SelectedText}" />
		</WorkflowCall>

		<Transaction>
			<WorkflowCall Name="Validate InternalChargeLines" WorkflowName="ContractPeriod_ValidateInternalChargeLine">
				<Parameter	Name="ContractPeriod"	Direction="In"		Value="${ContractPeriod}" />
				<Parameter	Name="SelectedDateFrom"	Direction="In"		Value="${SelectedDateFrom}" />
				<Parameter	Name="SelectedDateTill"	Direction="In"		Value="${SelectedDateTill}" />
				<Parameter	Name="ShowMessage"		Direction="InOut"	Value="${ShowMessage}"		OutputProperty="${ShowMessage}" />
			</WorkflowCall>

			<GetList Name="Get the last recurring ContractLine that has been invoiced" Type="ContractLine" OutputProperty="${ContractLines}" OrderBy="StartDate" OrderDirection="Descending" Top="1">
				<Filters>
					<PropertyFilter	PropertyName="InvoiceOnce"			Operator="="		PropertyValue="False" />
					<PropertyFilter	PropertyName="StartDate"			Operator="!="		PropertyValue="%StartDateChargePeriod" />
					<PropertyFilter	PropertyName="ServiceContract.Id"	Operator="="		PropertyValue="${ContractPeriod.ServiceContract.Id}" />
				</Filters>
			</GetList>

			<When Name="When there is a ContractLine found" Condition="${ContractLines.Count} &gt; 0">
				<When Name="When old DateFrom is not empty, validate it" Condition="${ContractPeriod.DateFrom} != Empty" Comment="This should always be True">
					<Validation Name="if old DateFrom is before ContractLine.StartDateChargePeriod, it cannot be changed" Condition="${SelectedDateFrom} == ${ContractPeriod.DateFrom} || ${ContractPeriod.DateFrom} &gt;= #getpropertyvalue(#elementat(${ContractLines}, 0), 'StartDateChargePeriod')" MessageCode="1817">
						<Parameter	Name="ContractPeriod"	Direction="In"		Value="${ContractPeriod}" />
					</Validation>
				</When>

				<When Name="When Selected DateTill is not empty, validate it" Condition="${SelectedDateTill} != Empty">
					<Validation Name="new DateTill cannot be set to value before ContractLine.StartDateChargePeriod" Condition="#adddays(${SelectedDateTill}, 1) &gt;= #getpropertyvalue(#elementat(${ContractLines}, 0), 'StartDateChargePeriod')" MessageCode="1818">
						<Parameter	Name="ContractPeriod"	Direction="In"		Value="${ContractPeriod}" />
					</Validation>
				</When>
			</When>

			<When Name="StateAgendaExist" Condition="${LettableUnitIsRequired} == True &amp;&amp; ${ContractPeriod.ServiceContract.Space.StateAgenda} != Empty">
				<GetItem Name="GetRelatedRentedPeriod" Type="StateTimeslot" OutputProperty="${RentedPeriod}">
					<Filters>
						<PropertyFilter	PropertyName="StateAgenda"	Operator="="		PropertyValue="${ContractPeriod.ServiceContract.Space.StateAgenda}" />
						<PropertyFilter	PropertyName="Status"		Operator="="		PropertyValue="StateTimeslotStatus.Rented" />
						<PropertyFilter	PropertyName="StartDate"	Operator="="		PropertyValue="${ContractPeriod.DateFrom}" />
						<WhenFilter Condition="${ContractPeriod.DateTill} != Empty">
							<PropertyFilter	PropertyName="EndDate"		Operator="="		PropertyValue="${ContractPeriod.DateTill}" />
						</WhenFilter>
						<WhenFilter Condition="${ContractPeriod.DateTill} == Empty">
							<PropertyEmptyFilter PropertyName="EndDate" />
						</WhenFilter>
					</Filters>
				</GetItem>
			</When>

			<WorkflowCall Name="Validate ContractPeriod" WorkflowName="ServiceContract_ValidateContractPeriod">
				<Parameter	Name="AddContractPeriod"					Direction="In"		Value="${AddContractPeriod}" />
				<Parameter	Name="ContractPeriod"						Direction="In"		Value="${ContractPeriod}" />
				<Parameter	Name="CurrentStateTimeslot"					Direction="In"		Value="${RentedPeriod}" />
				<Parameter	Name="LettableUnitIsRequired"				Direction="In"		Value="${LettableUnitIsRequired}" />
				<Parameter	Name="NewDateFrom"							Direction="In"		Value="${SelectedDateFrom}" />
				<Parameter	Name="NewDateTill"							Direction="In"		Value="${SelectedDateTill}" />
				<Parameter	Name="NewOtherPartyMaximumTerminationDate"	Direction="In"		Value="${SelectedOtherPartyMaximumTerminationDate}" />
				<Parameter	Name="NewOurPartyMaximumTerminationDate"	Direction="In"		Value="${SelectedOurPartyMaximumTerminationDate}" />
				<Parameter	Name="RentableRealEstateContract"			Direction="In"		Value="${ContractPeriod.ServiceContract}" />
				<Parameter	Name="SkipChargeTest"						Direction="In"		Value="True" />
			</WorkflowCall>

			<WorkflowCall Name="Check and move initial ContractLines" WorkflowName="ContractPeriod_CheckAndMoveContractLines">
				<Parameter	Name="SelectedDateFrom"				Direction="In"		Value="${SelectedDateFrom}" />
				<Parameter	Name="ContractPeriod"				Direction="InOut"	Value="${ContractPeriod}"	OutputProperty="${ContractPeriod}" />
				<Parameter	Name="ContractLinesNotMoved"		Direction="Out"									OutputProperty="${ContractLinesNotMoved}" />
				<Parameter	Name="ContractLinesToMove"			Direction="Out"									OutputProperty="${ContractLinesToMove}" />
				<Parameter	Name="InitialMutationsMovedCount"	Direction="Out"									OutputProperty="${InitialMutationsMovedCount}" />
			</WorkflowCall>

			<GetList Name="Get the first ContractPeriod for this Contract in a list" Type="ContractPeriod" OutputProperty="${FirstContractPeriodInList}" OrderBy="DateFrom" OrderDirection="Ascending" Top="1">
				<Filters>
					<PropertyFilter	PropertyName="ServiceContract"	Operator="="		PropertyValue="${ContractPeriod.ServiceContract}" />
				</Filters>
			</GetList>

			<When Name="When this ContractPeriod is the first for this Contract and the StartDate has changed" Condition="${ContractPeriod} == #elementat(${FirstContractPeriodInList}, 0) &amp;&amp; ${ContractPeriod.DateFrom} != ${SelectedDateFrom}">
				<Assign Name="Update the StartDate on the Contract" Property="${ContractPeriod.ServiceContract.StartDate}" Value="${SelectedDateFrom}" />
			</When>

			<Assign Name="After successful validation set SelectedDateFrom" Property="${ContractPeriod.DateFrom}" Value="${SelectedDateFrom}" />
			<Assign Name="After successful validation set SelectedDateTill" Property="${ContractPeriod.DateTill}" Value="${SelectedDateTill}" />
			<Assign Name="After successful validation set SelectedOurPartyMaximumTerminationDate" Property="${ContractPeriod.OurPartyMaximumTerminationDate}" Value="${SelectedOurPartyMaximumTerminationDate}" />
			<Assign Name="After successful validation set SelectedOtherPartyMaximumTerminationDate" Property="${ContractPeriod.OtherPartyMaximumTerminationDate}" Value="${SelectedOtherPartyMaximumTerminationDate}" />
			<Assign Name="After successful validation set SelectedText" Property="${ContractPeriod.Text}" Value="${SelectedText}" />

			<When Name="RentedPeriodExist" Condition="${RentedPeriod} != Empty">
				<Assign Name="Set startdate of rented period" Property="${RentedPeriod.StartDate}" Value="${SelectedDateFrom}" />
				<Assign Name="Set enddate of rented period" Property="${RentedPeriod.EndDate}" Value="${SelectedDateTill}" />
			</When>

			<ForEach Name="For each line that was moved" In="${ContractLinesToMove}" As="ContractLineToMove">
				<WorkflowCall Name="Update ContractLine with applicable values for today" WorkflowName="ContractLine_UpdateSingleLineWithApplicableValuesForToday">
					<Parameter	Name="ContractLine"	Direction="In"		Value="${ContractLineToMove}" />
				</WorkflowCall>
			</ForEach>
		</Transaction>

		<When Name="When message should be shown" Condition="${ShowMessage} == True">
			<Message Name="MessageContactPeriodChangedWithApplicableLinesAndMutations" MessageCode="1789">
				<Parameter	Name="ContractLinesNotMoved"		Direction="In"		Value="${ContractLinesNotMoved}" />
				<Parameter	Name="ContractLinesToMove"			Direction="In"		Value="${ContractLinesToMove}" />
				<Parameter	Name="ContractPeriod"				Direction="In"		Value="${ContractPeriod}" />
				<Parameter	Name="InitialMutationsMovedCount"	Direction="In"		Value="${InitialMutationsMovedCount}" />
			</Message>
		</When>

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