xiaoding721
2024-11-20 7fccbbd4d9982aaa349b36cf8031cddac610e57f
_Main/BL/Type_NewOfflinePlanCell/StaticMethod_SynchronizeToNewSupply.qbl
@@ -9,28 +9,25 @@
  TextBody:
  [*
    traverse ( selectedRows, Elements.NewOfflinePlanCell, cell, 
               cell.NewOfflinePlanRow().Type() = "1" and cell.Quantity() > 0.0
               cell.NewOfflinePlanRow().Type() = "1" and cell.Quantity() >= 0.0
    //           and cell.NewOfflinePlanRow().ProductionLine() = "eMotor Assy (France)" and cell.NewOfflinePlanColumn().StartDate() = Date::Construct( 2020, 4, 4 )
             ) 
    {
     pto := select( macroPlan, Unit.Operation.PeriodTaskOperation, tempPTO,
                    exists( tempPTO, NewSupply, tempNS, tempNS.ProductInStockingPointInPeriodPlanningLeaf().ProductInStockingPoint_MP().ProductID() = cell.NewOfflinePlanRow().ProductID() ) and
                    tempPTO.Operation().UnitID() = cell.NewOfflinePlanRow().ProductionLine()                                                                                                 and
                    tempPTO.Start().Date()       = cell.NewOfflinePlanColumn().StartDate() );
      if ( isnull( pto ) ) {
      pto := select( macroPlan, Unit.Operation.PeriodTaskOperation, tempPTO,
                     exists( tempPTO, NewSupply, tempNS, tempNS.ProductInStockingPointInPeriodPlanningLeaf().ProductInStockingPoint_MP().ProductID() = cell.NewOfflinePlanRow().ProductID() ) and
                     tempPTO.Operation().UnitID() = cell.NewOfflinePlanRow().ProductionLine()                                                                                                 and
                     tempPTO.Start().Date()       = cell.NewOfflinePlanColumn().StartDate() );
      if ( isnull( pto ) and cell.Quantity() > 0 ) {
        o  := select( macroPlan, Unit.Operation, tempO, tempO.ID() = cell.NewOfflinePlanRow().OperationID() );
        up := select( macroPlan, Unit.UnitPeriod, tempUP, tempUP.UnitID() = cell.NewOfflinePlanRow().ProductionLine() and tempUP.StartDate() = cell.NewOfflinePlanColumn().StartDate() );
        if ( not isnull( o ) and not isnull( up ) ) {
          PeriodTaskOperation::Create( o, up, cell.Quantity(), false );
        }
      } else {
      } else if ( not isnull( pto ) ) {
        if ( [Number]cell.Quantity() <> [Number]pto.Quantity() ) {
          pto.Update( cell.Quantity(), false );
        }
      }
      
    }
  *]