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

ActionField933

Beschrijving: Create a ContractLineCostMutation for a ContractLine. Custom: Nee

Propertiesbewerken

Property Type Accessor
ContractLine ContractLine Root
AutoAnswerToQuestion RequestResult? Optional
ScreenName String Optional

XMLbewerken

<Workflow Name="ActionField933" Version="2025.07.28" WorkflowType="Standard" xmlns="urn:Ultimo.Framework.Workflow-mapping">
	<Security EditLevel="10" ViewLevel="20" UserContentLevel="30" />
	<Description>Create a ContractLineCostMutation for a ContractLine.</Description>
	<Properties>
		<Property	Name="ContractLine"						Type="ContractLine"						Accessor="Root"		Direction="In" />

		<Property	Name="AutoAnswerToQuestion"				Type="RequestResult?"					Accessor="Optional"	Direction="In"		Default="Empty"							Comment="Set default answer for Question 1810 (Yes/No or Empty). When Empty, the question will be shown" />
		<Property	Name="ScreenName"						Type="String"							Accessor="Optional"	Direction="In"		Default="conlcm01"						Comment="Create ContractLineCostMutation via this screen" />

		<Property	Name="Answer"							Type="RequestResult?"					Accessor="Internal" />
		<Property	Name="ContractLineCostMutations"		Type="List[ContractLineCostMutation]"	Accessor="Internal" />
		<Property	Name="CreatedContractLineCostMutation"	Type="ContractLineCostMutation"			Accessor="Internal" />
		<Property	Name="InternalChargeLineCount"			Type="Int64"							Accessor="Internal" />
		<Property	Name="NewContractLine"					Type="ContractLine"						Accessor="Internal" />
		<Property	Name="Now"								Type="Date"								Accessor="Internal"						Default="#{Environment.CurrentDate}" />
		<Property	Name="PreviousContractLineCostMutation"	Type="ContractLineCostMutation"			Accessor="Internal" />
		<Property	Name="Price"							Type="CompanyMoney"						Accessor="Internal" />
		<Property	Name="StateTimeslots"					Type="List[StateTimeslot]"				Accessor="Internal" />
	</Properties>
	<Execution>
		<UserContent Name="Pre" />

		<When Name="InvoiceOnce ContractLine treated in a special way" Condition="${ContractLine.InvoiceOnce} == True">
			<WorkflowCall Name="Change the current CostMutation" WorkflowName="ContractLine_ModifyCostMutation">
				<Parameter	Name="ContractLine"	Direction="In"		Value="${ContractLine}" />
			</WorkflowCall>

			<Stop Name="Stop" Mode="EndCurrent" Comment="End Workflow" />
		</When>

		<Transaction>
			<Insert Name="CreatedContractLineCostMutation" ObjectType="ContractLineCostMutation" OutputProperty="${CreatedContractLineCostMutation}">
				<Parameter	Name="Status"			Direction="In"		Value="ContractLineCostMutationStatus.Concept" />
				<Parameter	Name="ContractLine"		Direction="In"		Value="${ContractLine}" />
				<Parameter	Name="Employee"			Direction="In"		Value="#{User.EmployeeId}" />
				<Parameter	Name="Price"			Direction="In"		Value="CompanyMoney.Zero" />
				<Parameter	Name="PricePerDay"		Direction="In"		Value="CompanyMoney.Zero" />
				<Parameter	Name="StartDate"		Direction="In"		Value="${Now}" />
				<Parameter	Name="Vat"				Direction="In"		Value="${ContractLine.Vat?}" />
				<Parameter	Name="VatPercentage"	Direction="In"		Value="${ContractLine.Vat.Percentage?}" />
			</Insert>
		</Transaction>

		<SystemDialog Name="Creating a ContractLineCostMutation" DialogName="DataEntryScreen">
			<Parameter	Name="DomainObject"	Direction="In"		Value="${CreatedContractLineCostMutation}" />
			<Parameter	Name="ScreenName"	Direction="In"		Value="${ScreenName}" />
		</SystemDialog>

		<Transaction>
			<Assign Name="Assign Price" Property="${Price}" Value="${CreatedContractLineCostMutation.Price}" />

			<When Name="If price per day then assign it to price" Condition="${CreatedContractLineCostMutation.PricePerDay} != Empty &amp;&amp; ${CreatedContractLineCostMutation.PricePerDay} != CompanyMoney.Zero">
				<Assign Name="Assign Price" Property="${Price}" Value="${CreatedContractLineCostMutation.PricePerDay}" />
			</When>

			<Command Name="CalculateVatPrice" CommandName="CalculateVatPrice">
				<Parameter	Name="InPrice"			Direction="In"		Value="${Price}" />
				<Parameter	Name="InPriceIsTotal"	Direction="In"		Value="False" />
				<Parameter	Name="Percentage"		Direction="In"		Value="${CreatedContractLineCostMutation.VatPercentage}" />
				<Parameter	Name="OutVatPrice"		Direction="Out"																	OutputProperty="${CreatedContractLineCostMutation.VatPrice}" />
			</Command>

			<ChangeStatus Name="Approve mutation" DomainObject="${CreatedContractLineCostMutation}" NewStatus="ContractLineCostMutationStatus.Approved" />

			<GetList Name="Get all mutations for the ContractLine before the current mutation" Type="ContractLineCostMutation" OutputProperty="${ContractLineCostMutations}" OrderBy="StartDate" OrderDirection="Descending">
				<Filters>
					<PropertyFilter	PropertyName="ContractLine.Id"	Operator="="		PropertyValue="${ContractLine.Id}" />
					<CombinedFilter FilterOperator="Or">
						<PropertyFilter	PropertyName="StartDate"	Operator="&lt;"		PropertyValue="${CreatedContractLineCostMutation.StartDate}" />
						<PropertyEmptyFilter PropertyName="StartDate" Comment="the initial mutation will not have a StartDate set, descending will make it come last" />
					</CombinedFilter>
				</Filters>
			</GetList>

			<ForEach Name="Iterate the list (the element with the latest date before the date of the created mutation should be first)" In="${ContractLineCostMutations}" As="FirstContractLineCostMutation">
				<AssignWhenEmpty Name="Get the first ContractLineCostMutation from the list" Property="${PreviousContractLineCostMutation}" Value="${FirstContractLineCostMutation}" />
			</ForEach>

			<When Name="When mutation is found" Condition="${PreviousContractLineCostMutation} != Empty">
				<Assign Name="Set previous price based on previous mutation" Property="${CreatedContractLineCostMutation.PreviousPrice}" Value="${PreviousContractLineCostMutation.Price}" />
				<Assign Name="Set previous VAT price based on previous mutation" Property="${CreatedContractLineCostMutation.PreviousVatPrice}" Value="${PreviousContractLineCostMutation.VatPrice}" />
				<Assign Name="Set previous VAT percentage based on previous mutation" Property="${CreatedContractLineCostMutation.PreviousVatPercentage}" Value="${PreviousContractLineCostMutation.VatPercentage}" />
			</When>

			<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 StartDate of this CreatedContractLineCostMutation" Type="InternalChargeLine" OutputProperty="${InternalChargeLineCount}">
				<Filters>
					<PropertyFilter	PropertyName="PeriodTillDate"	Operator="&gt;="	PropertyValue="${CreatedContractLineCostMutation.StartDate}" />
					<PropertyFilter	PropertyName="ContractLine.Id"	Operator="="		PropertyValue="${ContractLine.Id}" />
					<PropertyFilter	PropertyName="Status"			Operator="="		PropertyValue="InternalChargeLineStatus.Open" />
				</Filters>
			</GetCount>

			<Validation Name="Count of open InternalChargeLines should be zero" Condition="${InternalChargeLineCount} == 0" MessageCode="1826">
				<Parameter	Name="ContractLineCostMutation"	Direction="In"		Value="${CreatedContractLineCostMutation}" />
			</Validation>
			<Validation Name="Price and price per day shouldn't both be filled" Condition="${CreatedContractLineCostMutation.Price} == Empty || ${CreatedContractLineCostMutation.PricePerDay} == Empty || ${CreatedContractLineCostMutation.Price} == CompanyMoney.Zero || ${CreatedContractLineCostMutation.PricePerDay} == CompanyMoney.Zero" MessageCode="1768" />

			<GetList Name="Check whether there are more of these CostMutationLines related to ContractLine" Type="ContractLineCostMutation" OutputProperty="${ContractLineCostMutations}" OrderBy="Id" OrderDirection="Ascending">
				<Filters>
					<PropertyFilter	PropertyName="ContractLine.Id"	Operator="="		PropertyValue="${ContractLine.Id}" />
					<DateFilter PropertyName="StartDate" Operator="=" PropertyValue="${CreatedContractLineCostMutation.StartDate}" />
					<PropertyFilter	PropertyName="Id"				Operator="!="		PropertyValue="${CreatedContractLineCostMutation.Id}" />
					<PropertyFilter	PropertyName="Status"			Operator="="		PropertyValue="ContractLineCostMutationStatus.Approved" />
				</Filters>
			</GetList>

			<Validation Name="There is another ContractLineCostMutation record of the same date" Condition="${ContractLineCostMutations.Count} == 0" MessageCode="1722" />
		</Transaction>

		<When Name="Check date" Condition="${ContractLine.StartDate} &lt; ${ContractLine.StartDateChargePeriod} &amp;&amp; ${CreatedContractLineCostMutation.StartDate} &lt; ${ContractLine.StartDateChargePeriod}" Comment="Is the startdate of this cost mutation smaller than the date of previous invoice, then make correction contract line; if the contract has never been charged (ContractLine.StartDateChargePeriod is not greater than ContractLine.StartDate, this code has to be skipped">
			<Assign Name="Assign Answer" Property="${Answer}" Value="${AutoAnswerToQuestion}" />

			<When Name="AutoAnswerToQuestion has no value?" Condition="${AutoAnswerToQuestion} == Empty">
				<Question Name="Ask whether changes must be applied retroactively" Type="YesNo" MessageCode="1810" Default="Yes" OutputProperty="${Answer}" />
			</When>

			<Transaction>
				<When Name="Answer is yes" Condition="${Answer} == Yes">
					<WorkflowCall Name="Create Correction ContractLine" WorkflowName="ContractLineCostMutation_CreateCorrectionContractLine">
						<Parameter	Name="ContractLineCostMutation"	Direction="In"		Value="${CreatedContractLineCostMutation}" />
					</WorkflowCall>
				</When>
			</Transaction>
		</When>

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