Дамы и господа, как вы считаете, можно ли запрограммировать следующий код в AX2012 лаконичнее:
X++:
public static void setStopped(
InventItemOrderSetupMap _inventItemOrderSetupMap,
ItemStopped _stopped,
date _effectiveDate = systemDateGet())
{
InventItemSetupStopped record;
ttsBegin;
record = InventItemSetupStopped::find(_inventItemOrderSetupMap.TableId, _inventItemOrderSetupMap.RecId, _effectiveDate);
record.validTimeStateUpdateMode(ValidTimeStateUpdate::Correction);
if (record && record.Stopped != _stopped)
{
while select forUpdate validTimeState(_effectiveDate) record
where record.InventItemSetupRecId == _inventItemOrderSetupMap.RecId
&& record.InventItemSetupTableId == _inventItemOrderSetupMap.TableId
&& record.ValidTo != _effectiveDate
{
record.ValidTo = max(_effectiveDate-1, record.ValidFrom);
if (record.validateWrite())
record.update();
}
}
select forUpdate validTimeState(_effectiveDate) record
where record.InventItemSetupRecId == _inventItemOrderSetupMap.RecId
&& record.InventItemSetupTableId == _inventItemOrderSetupMap.TableId
&& record.ValidTo == _effectiveDate;
record.initFromInventItemOrderSetupMap(_inventItemOrderSetupMap);
record.ValidFrom = _effectiveDate;
record.ValidTo = dateMax();
record.Stopped = _stopped;
if (record.validateWrite())
record.write();
ttsCommit;
}