@@ -373,14 +373,23 @@ impl Graph {
373373 )
374374 } ) ;
375375 if info. is_simple ( ) {
376+ let dp = info. dp ( ) ;
376377 let mut avail = Availability :: default ( ) ;
377378
378379 if let Some ( quant) = raw_quants. get ( & product) {
379- avail. quantity = quant. quantity ;
380- avail. reserved = quant. reserved ;
381-
382- avail. incoming = quant. incoming ;
383- avail. outgoing = quant. outgoing ;
380+ avail. quantity = quant
381+ . quantity
382+ . round_dp_with_strategy ( dp, RoundingStrategy :: ToZero ) ;
383+ avail. reserved = quant
384+ . reserved
385+ . round_dp_with_strategy ( dp, RoundingStrategy :: ToZero ) ;
386+
387+ avail. incoming = quant
388+ . incoming
389+ . round_dp_with_strategy ( dp, RoundingStrategy :: ToZero ) ;
390+ avail. outgoing = quant
391+ . outgoing
392+ . round_dp_with_strategy ( dp, RoundingStrategy :: ToZero ) ;
384393 // Required to seed the buildable for future things
385394 // Realistically this isn't actually helpful as a figure for a simple, but this
386395 // is the least impactful solution here
@@ -403,23 +412,41 @@ impl Graph {
403412 for edge in graph. edges_directed ( product, petgraph:: Incoming ) {
404413 let ( dependency, required_qty) = ( edge. source ( ) , * edge. weight ( ) ) ;
405414 if let Some ( dependency_stock) = stock_cache. get ( & dependency) {
406- // only do this work if we need to
407- quantity. push ( dependency_stock. quantity / required_qty) ;
408- reserved. push ( dependency_stock. reserved / required_qty) ;
409-
410- incoming. push ( dependency_stock. incoming / required_qty) ;
411- outgoing. push ( dependency_stock. outgoing / required_qty) ;
412-
413- free_imm. push ( dependency_stock. free_immediately ( ) / required_qty) ;
414- virtual_avail. push ( dependency_stock. virtual_available ( ) / required_qty) ;
415-
416415 let dependency_dp = catalogue. get ( & product) . unwrap_or_else ( || {
417416 panic ! (
418417 "Somehow we have a product in the graph not in the catalogue?!: {:?}" ,
419418 product
420419 )
421420 } ) . dp ( ) ;
422421
422+ // only do this work if we need to
423+ quantity. push (
424+ ( dependency_stock. quantity / required_qty)
425+ . round_dp_with_strategy ( dependency_dp, RoundingStrategy :: ToZero ) ,
426+ ) ;
427+ reserved. push (
428+ ( dependency_stock. reserved / required_qty)
429+ . round_dp_with_strategy ( dependency_dp, RoundingStrategy :: ToZero ) ,
430+ ) ;
431+
432+ incoming. push (
433+ ( dependency_stock. incoming / required_qty)
434+ . round_dp_with_strategy ( dependency_dp, RoundingStrategy :: ToZero ) ,
435+ ) ;
436+ outgoing. push (
437+ ( dependency_stock. outgoing / required_qty)
438+ . round_dp_with_strategy ( dependency_dp, RoundingStrategy :: ToZero ) ,
439+ ) ;
440+
441+ free_imm. push (
442+ ( dependency_stock. free_immediately ( ) / required_qty)
443+ . round_dp_with_strategy ( dependency_dp, RoundingStrategy :: ToZero ) ,
444+ ) ;
445+ virtual_avail. push (
446+ ( dependency_stock. virtual_available ( ) / required_qty)
447+ . round_dp_with_strategy ( dependency_dp, RoundingStrategy :: ToZero ) ,
448+ ) ;
449+
423450 buildable. push (
424451 ( dependency_stock. buildable / required_qty)
425452 . round_dp_with_strategy ( dependency_dp, RoundingStrategy :: ToZero ) ,
0 commit comments