From: Ian Jackson Date: Sun, 23 Aug 2009 12:32:47 +0000 (+0100) Subject: Rationalise various ids X-Git-Tag: 3.4~137 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?p=ypp-sc-tools.db-test.git;a=commitdiff_plain;h=5c74b3871323fe2d06d5fcbdcd6c248a88a9ca00 Rationalise various ids --- diff --git a/yarrg/web/routetrade b/yarrg/web/routetrade index 0edcca5..597f9ee 100644 --- a/yarrg/web/routetrade +++ b/yarrg/web/routetrade @@ -162,14 +162,39 @@ push @columns, qw(commodname % } -% { <& dumptable:start, qa => $qa, sth => $sth &> -% my $flow; -% while ($flow= $sth->fetchrow_hashref()) { -% $flow->{Ix}= @flows; -% $flow->{Var}= "f$flow->{Ix}"; -% push @flows, $flow; -<& dumptable:row, qa => $qa, sth => $sth, row => $flow &> +% { +% my $f; +% while ($f= $sth->fetchrow_hashref()) { +<%perl> + + $f->{Ix}= @flows; + $f->{Var}= "f$f->{Ix}"; + + $f->{MaxQty}= $f->{'org_qty'} < $f->{'dst_qty'} + ? $f->{'org_qty'} : $f->{'dst_qty'}; + $f->{MaxProfit}= $f->{MaxQty} * $f->{'unitprofit'}; + $f->{MaxCapital}= $f->{MaxQty} * $f->{'org_price'}; + + $f->{PctProfit}= sprintf "%3.1f%%", + $f->{'dst_price'} * 100.0 / $f->{'org_price'} - 100.0; + + $f->{"org_stallid"}= $f->{"dst_stallid"}= 'all' + if !$qa->{ShowStalls}; + + my @uid= $f->{commodid}; + foreach my $od (qw(org dst)) { + push @uid, + $f->{"${od}_id"}, + $f->{"${od}_price"}, + $f->{"${od}_stallid"}; + } + $f->{Uid}= join '_', @uid; + + push @flows, $f; + + +<& dumptable:row, qa => $qa, sth => $sth, row => $f &> % } <& dumptable:end, qa => $qa &> % } @@ -206,12 +231,15 @@ Subject To my %avail_csts; foreach my $flow (@flows) { foreach my $od (qw(org dst)) { - my $cstname= join '_', + my $cstname= join '_', ( 'avail', $flow->{'commodid'}, $od, $flow->{"${od}_id"}, - $flow->{"${od}_price"}; + $flow->{"${od}_price"}, + $flow->{"${od}_stallid"}, + ); + push @{ $avail_csts{$cstname}{Flows} }, $flow->{Var}; $avail_csts{$cstname}{Qty}= $flow->{"${od}_qty"}; } @@ -319,13 +347,6 @@ push @columns, qw(OptQty OptCapital OptProfit); % foreach my $flow (@flows) { % foreach my $col (@columns) { -% $flow->{MaxQty}= $flow->{'org_qty'} < $flow->{'dst_qty'} -% ? $flow->{'org_qty'} : $flow->{'dst_qty'}; -% $flow->{MaxProfit}= $flow->{MaxQty} * $flow->{'unitprofit'}; -% $flow->{PctProfit}= sprintf "%3.1f%%", -% $flow->{'dst_price'} * 100.0 / $flow->{'org_price'} -% - 100.0; -% $flow->{MaxCapital}= $flow->{MaxQty} * $flow->{'org_price'}; <% $flow->{$col} |h %> % } % }