| Quintiq file version 2.0 | 
| #parent: #root | 
| StaticMethod CreateOrUpdateForUnitPeriod ( | 
|   UnitPeriod unitperiod, | 
|   Boolean isbatchedit, | 
|   Boolean isbatcheditpercentage, | 
|   Real actualutilizationpercentage, | 
|   Boolean isbatcheditquantity, | 
|   Real actualtotalavailablequantity, | 
|   Boolean isbatcheditduration, | 
|   Duration actualtotalavailableduration, | 
|   Boolean isbatcheditdescription, | 
|   String description | 
| ) | 
| { | 
|   Description: 'Update the unit period ActualUtilizationPercentage or ActualTotalAvailableCapacity' | 
|   TextBody: | 
|   [* | 
|     actual := unitperiod.ActualUnitPeriod(); | 
|     hasactual := not isnull( actual ); | 
|      | 
|     // If multiple ActualUnitPeriods are selected for batch editing | 
|     if( isbatchedit ) | 
|     { | 
|       // If ActualUtilizationPercentage is not selected to be batch editted | 
|       if( not isbatcheditpercentage ) | 
|       { | 
|         actualutilizationpercentage := 0.0; | 
|      | 
|         if( hasactual ) | 
|         { | 
|           actualutilizationpercentage := actual.ActualUtilizationPercentage(); | 
|         } | 
|       } | 
|        | 
|       // If ActualTotalAvailableQuantity is not selected to be batch editted | 
|       if( not isbatcheditquantity ) | 
|       { | 
|         actualtotalavailablequantity := 0.0; | 
|      | 
|         if( hasactual ) | 
|         { | 
|           actualtotalavailablequantity := actual.ActualTotalAvailableQuantity(); | 
|         } | 
|       } | 
|        | 
|       // If ActualTotalAvailableDuration is not selected to be batch editted | 
|       if( not isbatcheditduration ) | 
|       { | 
|         actualtotalavailableduration := Duration::Zero(); | 
|      | 
|         if( hasactual ) | 
|         { | 
|           actualtotalavailableduration := actual.ActualTotalAvailableDuration(); | 
|         } | 
|       } | 
|        | 
|       // If Description is not selected to be batch editted | 
|       if( not isbatcheditdescription ) | 
|       { | 
|         description := ''; | 
|      | 
|         if( hasactual ) | 
|         { | 
|           description := actual.Description(); | 
|         } | 
|       } | 
|     } | 
|      | 
|     // If ActualUnitPeriod already exists, then update the values | 
|     if( hasactual ) | 
|     { | 
|       actual.Update( actualutilizationpercentage, | 
|                      actualtotalavailablequantity, | 
|                      actualtotalavailableduration, | 
|                      description, | 
|                      false ); | 
|      | 
|     } | 
|     // Else, create new ActualUnitPeriod | 
|     else | 
|     { | 
|       ActualUnitPeriod::Create( unitperiod, | 
|                                 actualutilizationpercentage, | 
|                                 actualtotalavailablequantity, | 
|                                 actualtotalavailableduration, | 
|                                 description ); | 
|     } | 
|   *] | 
| } |