admin
2025-01-22 7e31442f0e9b07764e9c6a9680d3d4aeba5fe1de
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
Quintiq file version 2.0
#parent: #root
StaticMethod SynchronizeToNewSupply (
  MacroPlan macroPlan,
  NewOfflinePlanTable nopt,
  NewOfflinePlanRows selectedRows
)
{
  TextBody:
  [*
    traverse ( selectedRows, Elements.NewOfflinePlanCell, cell, 
               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 ) 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(), true );
        }
      } else if ( not isnull( pto ) ) {
        if ( [Number]cell.Quantity() <> [Number]pto.Quantity() ) {
          pto.Update( cell.Quantity(), true );
        }
      }
      
    }
  *]
}