Categorie: reference
Bijgewerkt: 2026-04-08
actionfield workflow actionfield938
ActionField938
Beschrijving: Delete a ContractPeriod of a RentableRealEstateContract. Custom: Nee
Propertiesbewerken
| Property | Type | Accessor |
|---|---|---|
| ContractPeriod | ContractPeriod | Root |
XMLbewerken
<Workflow Name="ActionField938" Version="2025.07.28" WorkflowType="Standard" xmlns="urn:Ultimo.Framework.Workflow-mapping">
<Security EditLevel="10" ViewLevel="20" UserContentLevel="30" />
<Description>Delete a ContractPeriod of a RentableRealEstateContract.</Description>
<Properties>
<Property Name="ContractPeriod" Type="ContractPeriod" Accessor="Root" Direction="In" />
<Property Name="ContractLines" Type="List[ContractLine]" Accessor="Internal" />
<Property Name="ContractPeriodCount" Type="Int64" Accessor="Internal" />
<Property Name="ContractPeriods" Type="List[ContractPeriod]" Accessor="Internal" />
<Property Name="DeleteContractPeriodAnswer" Type="RequestResult" Accessor="Internal" />
<Property Name="InternalChargeLineCount" Type="Int64" Accessor="Internal" />
<Property Name="RentedPeriod" Type="StateTimeslot" Accessor="Internal" />
<Property Name="StartDate" Type="Date" Accessor="Internal" />
</Properties>
<Execution>
<UserContent Name="Pre" />
<Transaction>
<GetCount Name="GetNumberOfRentedPeriods" Type="ContractPeriod" OutputProperty="${ContractPeriodCount}">
<Filters>
<PropertyFilter PropertyName="ServiceContract" Operator="=" PropertyValue="${ContractPeriod.ServiceContract}" />
</Filters>
</GetCount>
<Validation Name="Last ContractPeriod cannot not be deleted" Condition="${ContractPeriodCount} > 1" MessageCode="1761">
<Parameter Name="ContractPeriod" Direction="In" Value="${ContractPeriod}" />
<Parameter Name="ServiceContract" Direction="In" Value="${ContractPeriod.ServiceContract}" />
</Validation>
<GetList Name="Get list of ContractLines" Type="ContractLine" OutputProperty="${ContractLines}" OrderBy="StartDateChargePeriod" OrderDirection="Descending">
<Filters>
<PropertyFilter PropertyName="InvoiceOnce" Operator="=" PropertyValue="False" />
<PropertyFilter PropertyName="ServiceContract.Id" Operator="=" PropertyValue="${ContractPeriod.ServiceContract.Id}" />
</Filters>
</GetList>
<ForEach Name="Loop through the list of ContractLines" In="${ContractLines}" As="ContractLine">
<Validation Name="StartDateChargePeriod of ContractLine should be smaller than period's DateFrom or StartDateChargePeriod == StartDate (not been charged yet)" Condition="${ContractLine.StartDateChargePeriod} == Empty || ${ContractLine.StartDate} == ${ContractLine.StartDateChargePeriod} || ${ContractPeriod.DateFrom} == Empty || ${ContractLine.StartDateChargePeriod} <= ${ContractPeriod.DateFrom}" MessageCode="1819">
<Parameter Name="ContractPeriod" Direction="In" Value="${ContractPeriod}" />
<Parameter Name="ServiceContract" Direction="In" Value="${ContractPeriod.ServiceContract}" Comment="ignore periods having an Empty DateFrom, these are invalid" />
</Validation>
</ForEach>
<GetCount Name="There may be InternalChargeLines that have not yet been approved (but might be approved soon). So check whether there are any InternalChargeLines that have a PeriodTillDate that lies past the DateFrom of this period" Type="InternalChargeLine" OutputProperty="${InternalChargeLineCount}">
<Filters>
<PropertyFilter PropertyName="PeriodTillDate" Operator=">=" PropertyValue="${ContractPeriod.DateFrom}" />
<PropertyFilter PropertyName="ServiceContract.Id" Operator="=" PropertyValue="${ContractPeriod.ServiceContract.Id}" />
<PropertyFilter PropertyName="Status" Operator="=" PropertyValue="InternalChargeLineStatus.Open" />
</Filters>
</GetCount>
<Validation Name="Count of open InternalChargeLines should be zero" Condition="${InternalChargeLineCount} == 0" MessageCode="1823">
<Parameter Name="ContractPeriod" Direction="In" Value="${ContractPeriod}" />
</Validation>
</Transaction>
<Question Name="ContractPeriodDelete?" Type="YesNo" MessageCode="1773" OutputProperty="${DeleteContractPeriodAnswer}">
<Parameter Name="ContractPeriod" Direction="In" Value="${ContractPeriod}" />
</Question>
<Transaction>
<When Name="AnswerIsYes" Condition="${DeleteContractPeriodAnswer} == Yes">
<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}" />
<PropertyFilter PropertyName="EndDate" Operator="=" PropertyValue="${ContractPeriod.DateTill}" />
</Filters>
</GetItem>
<GetList Name="Get ContractPeriod following the one to be deleted" Type="ContractPeriod" OutputProperty="${ContractPeriods}" OrderBy="DateFrom" OrderDirection="Ascending" Top="1">
<Filters>
<PropertyFilter PropertyName="ServiceContract" Operator="=" PropertyValue="${ContractPeriod.ServiceContract}" />
<PropertyFilter PropertyName="DateFrom" Operator=">" PropertyValue="${ContractPeriod.DateFrom}" />
</Filters>
</GetList>
<DeleteObject Name="Delete contractPeriod" DomainObject="${ContractPeriod}" />
<When Name="RentableRealEstateContract is active" Condition="${ContractPeriod.ServiceContract.Status} == ServiceContractStatus.Active && ${RentedPeriod} != Empty">
<DeleteObject Name="Delete rented period" DomainObject="${RentedPeriod}" />
</When>
<When Name="If later ContractPeriod found" Condition="${ContractPeriods.Count} > 0">
<Assign Name="Assign StartDate of newly found ContractPeriod" Property="${StartDate}" Value="=#getpropertyvalue(#elementat(${ContractPeriods}, 0), 'DateFrom')" />
<ForEach Name="Loop through the list of ContractLines" In="${ContractLines}" As="ContractLine">
<When Name="See comment below" Condition="${ContractLine.StartDateChargePeriod} != Empty && ${ContractLine.StartDateChargePeriod} >= ${ContractPeriod.DateFrom}">
<Comment><![CDATA[
We've got three possible situations here:
- the StartDateChargePeriod of the ContractLine was before the DateFrom of the deleted ContractPeriod. In that case, nothing needs to be done.
- the StartDateChargePeriod was in the ContractPeriod (at the start of it, else it can't be deleted) to be deleted. In that case it will be set to the start
of the next ContractPeriod.
- the StartDateChargePeriod was in a ContractPeriod following the one to be deleted. That case is caught by a validation higher up, so it will not occur.
]]></Comment>
<Assign Name="Assign StartDateChargePeriod" Property="${ContractLine.StartDateChargePeriod}" Value="${StartDate}" />
<Command Name="ContractLine_CalculateDatesRelevantToCharging" CommandName="ContractLine_CalculateDatesRelevantToCharging">
<Parameter Name="ContractLine" Direction="In" Value="${ContractLine}" />
<Parameter Name="RecalculateStartDateChargePeriod" Direction="In" Value="False" />
</Command>
</When>
</ForEach>
</When>
</When>
</Transaction>
<UserContent Name="Post" />
</Execution>
</Workflow>