Quintiq file version 2.0
#parent: MatrixEditorTransportCapacities
Response OnUpdateValue (
  UnitPeriodTransportQuantity cell,
  String value,
  String oldvalue
) id:Response_MatrixEditorTransportCapacities_OnUpdateValue_557
{
  #keys: '[139394.1.92916806]'
  CanBindMultiple: false
  DefinitionID: 'Responsedef_WebMatrixEditor_OnUpdateValue'
  QuillAction
  {
    Body:
    [*
      // Create or update time unit or 2nd UoM
      istimeunit := focusedattribute = attribute( UnitPeriodTransportQuantity, TimeUnitForCapacitiesCalculation ).Name();
      is2ndUOM := focusedattribute = typeof( TransportCapacity ).Name() + '.' + attribute( TransportCapacity, SecondaryUnitOfMeasureName ).Name();
      cond := PeriodSpecification_MP::GetHasValidTimeUnit( value )
              or exists( cell.MacroPlan(), UnitOfMeasure_MP, uom, uom.Name() <> cell.MacroPlan().DefaultUnitOfMeasure().Name(), uom.Name() = value );
      if( cond )
      {
        unitperiodtransportquantities := construct( UnitPeriodTransportQuantitys );
        unitperiodtransportquantities.Add( cell );
        TransportCapacity::CreateOrUpdateForUnitPeriodTransports( unitperiodtransportquantities,
                                                                  ifexpr( istimeunit, value, cell.TimeUnitForCapacitiesCalculation() ),
                                                                  false /*isbatcheditlot*/,
                                                                  cell.LotSize(),
                                                                  istimeunit /*isbatcheditcapacity*/,
                                                                  cell.MinCapacityPerTimeUnit(),
                                                                  cell.MaxCapacityPerTimeUnit(),
                                                                  is2ndUOM /*isbatcheditsecondary*/,
                                                                  cell.HasSecondaryCapacity(),
                                                                  cell.SecondaryLotSize(),
                                                                  guard( cell.TransportCapacity().SecondaryMaximumCapacity(), 0.0 ),
                                                                  guard( cell.TransportCapacity().SecondaryMinimumCapacity(), 0.0 ),
                                                                  ifexpr( is2ndUOM, value, cell.SecondaryUnitOfMeasureName() ),
                                                                  false /*this period onwards*/
                                                                );
      }
      else
      {
        if( istimeunit )
        {
          cell.TimeUnitForCapacitiesCalculation( oldvalue );
        }
      }
    *]
    GroupServerCalls: false
  }
}
