limj
2023-09-21 89c96171bb971dcaed7cf289b58ef44ca689523c
_Main/BL/Type_Lane/StaticMethod_CreateLaneFromJson.qbl
@@ -1,7 +1,8 @@
Quintiq file version 2.0
#parent: #root
StaticMethod CreateLaneFromJson (
  JSON datarow
  JSON datarow,
  MacroPlan macroplan
) as Lane
{
  Description: 'Read the json data and use it to create lane data'
@@ -14,6 +15,11 @@
    userleadtime := datarow.Get( "userleadtime" );
    processingtime := Duration::Zero();
    
    unitofmeasurename := "PCS";
    currencyid := "CNY";
    startdate := Date::Date( 1900, 1, 1 );
    enddate := Date::Date( 9999, 12, 31 );
    capacitytype := "Transport quantity";
    if( userleadtime.IsNull() )
    {
      processingtime := Duration::Zero(); 
@@ -24,6 +30,16 @@
      };
    
    unit := Unit::FindUnitTypeIndex( unitid );
    if( isnull( unit)){
      unit :=macroplan.Unit( relnew,
                 ID := unitid,
                 Name := unitid,
                 UnitOfMeasureName := unitofmeasurename,
                 CurrencyID := currencyid,
                 StartDate := startdate,
                 EndDate := enddate,
                 CapacityType := capacitytype );
    }
    
    result := Lane::CreateLane( unit, id, name, processingtime);