lazhen
2024-11-07 98666fb3add2c1b2529318d1aec463c7360f2be3
_Main/BL/Type_CC_EngineRackCell/StaticMethod_CreateData.qbl
@@ -60,17 +60,21 @@
        
        // 空料架数量:【350bar MQB料架总数量 - 所有350bar MQB总库存 / 包装容量-客户库料架数量】* 长春外租库空料架比例
        plannedInventory := sum( macroPlan, Product_MP.ProductInStockingPoint_MP.ProductInStockingPointInPeriod, tempPISPIP,
                                 tempPISPIP.ProductInStockingPoint_MP().Product_MP().IsLeaf()                                                                 and
                                 exists( tempPISPIP.ProductInStockingPoint_MP().Product_MP(), AllParent.AsParent, tempPMP, tempPMP.ID() =  "发动机" )         and
                                 tempPISPIP.ProductInStockingPoint_MP().StockingPointID()                                               =  "长春外租库"       and
                                 tempPISPIP.ProductInStockingPoint_MP().Product_MP().Generation()                                       =  ccerr.Generation() and
                                 tempPISPIP.ProductInStockingPoint_MP().Product_MP().MQBMLB()                                           =  ccerr.MLB_MQB()    and
                                 tempPISPIP.Start().Date()                                                                              >= ccerc.StartDate()  and
                                 tempPISPIP.End().Date()                                                                                <= lastDayOfThisMonth,
                                 tempPISPIP.PlannedInventoryLevelEnd() );
                                 tempPISPIP.ProductInStockingPoint_MP().Product_MP().IsLeaf()                                                                       and
                                 exists( tempPISPIP.ProductInStockingPoint_MP().Product_MP(), AllParent.AsParent, tempPMP, tempPMP.ID() = "发动机" )                and
                                 //tempPISPIP.ProductInStockingPoint_MP().StockingPointID()                                             = "大连发动机的长春外租库"  and
                                 tempPISPIP.ProductInStockingPoint_MP().Product_MP().Generation()                                       = ccerr.Generation()        and
                                 tempPISPIP.ProductInStockingPoint_MP().Product_MP().MQBMLB()                                           = ccerr.MLB_MQB()           and
                                 tempPISPIP.Start().Date().Year()                                                                       = ccerc.StartDate().Year()  and
                                 tempPISPIP.Start().Date().Month()                                                                      = ccerc.StartDate().Month(),
                                 tempPISPIP.PlannedInventoryLevelEnd() ) / ( ccerc.StartDate().StartOfNextMonth() - ccerc.StartDate() );
        cell.PackagingCapacity( guard( lce.PackagingCapacity(), 1 ) );
        cell.PlannedInventory( plannedInventory );
        cell.NumberOfEmptyShelves( [Number] guard( ( cell.TotalQuantityOfMaterialRacks() - ( plannedInventory / lce.PackagingCapacity() ) - guard( mrcc.Quantity(), 0 ) ) * guard( mrpc.Quantity(), 1 ), 0 ) );
        if ( ccerr.Generation() = "350bar" and ccerr.MLB_MQB() = "MQB" ) {
          cell.NumberOfEmptyShelves( [Number] guard( ( cell.TotalQuantityOfMaterialRacks() - ( plannedInventory / lce.PackagingCapacity() ) - guard( mrcc.Quantity(), 0 ) ) * guard( mrpc.Quantity(), 1 ), 0 ) );
        } else {
          cell.NumberOfEmptyShelves( [Number] guard( cell.TotalQuantityOfMaterialRacks() - ( plannedInventory / lce.PackagingCapacity() ), 0 ) );
        }
        
        // 外租库入库费用(发动机销量 / 包装容量[向上取整] * 料架入库单价)
        engineSales := sum( macroPlan, FSImportData, tempFSID, 
@@ -107,7 +111,11 @@
             
        // 外租库仓储费用:【350bar MQB料架总数量 - 所有350bar MQB总库存 / 包装容量 - 客户库料架数量】* 长春外租库空料架比例*料架仓储单价。发动机库存取Actual inventories里取到长春外租库该发动机的仓储量,料架总数量需要手动维护。
        cell.UnitPriceOfEmptyShelfStorage( lcmr.StoragePrice() );
        cell.RentalWarehouseStorageFees( [Number] guard( ( cell.TotalQuantityOfMaterialRacks() - [Number]( plannedInventory / lce.PackagingCapacity() ) - guard( mrcc.Quantity(), 0 ) ) * guard( mrpc.Quantity(), 1 ) * lcmr.StoragePrice(), 0 ) );
        if ( ccerr.Generation() = "350bar" and ccerr.MLB_MQB() = "MQB" ) {
          cell.RentalWarehouseStorageFees( [Number] guard( ( cell.TotalQuantityOfMaterialRacks() - ceil( plannedInventory / lce.PackagingCapacity() ) - guard( mrcc.Quantity(), 0 ) ) * guard( mrpc.Quantity(), 1 ) * lcmr.StoragePrice() * ( ccerc.StartDate().StartOfNextMonth() - ccerc.StartDate() ), 0 ) );
        } else {
          cell.RentalWarehouseStorageFees( [Number] guard( ( cell.TotalQuantityOfMaterialRacks() - ceil( plannedInventory / lce.PackagingCapacity() ) ) * lcmr.StoragePrice()* ( ccerc.StartDate().StartOfNextMonth() - ccerc.StartDate() ), 0 ) );
        }
        
        // 清洗费用:发动机入库量 / 包装容量 * 料架清洗单价。发动机入库量取发动机销量,包装容量取自发动机成本表。料架清洗单价取料架成本表。
        cell.CleaningCost( [Number] ( engineProductions / guard( lce.PackagingCapacity(), 1 ) * lcmr.CleanPrice() ) );