lazhen
2025-01-08 74ac81ac91be18a076a27ecee4045aac0d9b5ad9
_Main/BL/Type_MachiningPipelineSource0/StaticMethod_Initialize.qbl
@@ -9,6 +9,7 @@
    // 甄兰鸽 Jun-24-2024 (created)
    owner.FinancialProductionSource( relflush );
    startinventorydate        := owner.StartOfPlanning() - Duration::Days( 1 );
    startyearmonth            := owner.StartOfPlanning().StartOfMonth().Date();
    productparent             := MachiningPipelineReport::GetDefaultProductParent();
    source                    := owner.MachiningPipelineSource( relnew, Name := MachiningPipelineReport::GetDefaultName() );
    table                     := source.Report( relnew, ID := source.Name(), Name := source.Name() );
@@ -140,12 +141,30 @@
      }
    }
    
    //rows := selectsortedset( table, Row, row, row.Name() );
    //i    := 0;
    //traverse( rows, Elements, e ){
    //  e.RowNr( i );
    //  i := i + 1;
    //}
    traverse( table, Row, row ){
      traverse( table, Column, column, column.TimeUnit() = Translations::MP_GlobalParameters_Day() ){
        maxinventory        := selectobject( row, Cell, cell, cell.Column() = column );
        ccinventoryqty      := 0.0;
        dlinventoryqty      := 0.0;
        if( column.StartDate() = startyearmonth ){//当日期是计划开始第一个月时,计算库存是实际库存
          ccinventoryqty    := row.CCInventoryQty() + maxinventory.CCProductionQty() - maxinventory.CCToDLDepartureQty() + maxinventory.DLToCCArrivalQty() - maxinventory.CCAssemblyPlanQty();
          dlinventoryqty    := row.DLInventoryQty() + maxinventory.DLProductionQty() - maxinventory.DLToCCDepartureQty() + maxinventory.CCToDLArrivalQty() - maxinventory.DLAssemblyPlanQty();
        }else{
          beforecolumn      := column.PreviousColumn();
          beforeinventory   := selectobject( row, Cell, c, c.Column() = beforecolumn );
          beCCinventoryqty  := 0.0;
          beDLinventoryqty  := 0.0;
          if( not isnull( beforeinventory ) ){
            beCCinventoryqty := beforeinventory.CCInventoryQty();
            beDLinventoryqty := beforeinventory.DLInventoryQty();
          }
          ccinventoryqty    := beCCinventoryqty + maxinventory.CCProductionQty() - maxinventory.CCToDLDepartureQty() + maxinventory.DLToCCArrivalQty() - maxinventory.CCAssemblyPlanQty();
          dlinventoryqty    := beDLinventoryqty + maxinventory.DLProductionQty() - maxinventory.DLToCCDepartureQty() + maxinventory.CCToDLArrivalQty() - maxinventory.DLAssemblyPlanQty();
        }
        maxinventory.CCInventoryQty( ccinventoryqty );
        maxinventory.DLInventoryQty( dlinventoryqty );
      }
    }
    showtable.Generate( search, products );
  *]
}