chiark / gitweb /
Fix profit margin
[ypp-sc-tools.db-test.git] / yarrg / web / routetrade
index 91ff421625fd7d4757a6def0a6e471341ac073e1..56a1c38ff1a137ef8a2e618eb994c2af167948b5 100644 (file)
@@ -259,6 +259,11 @@ foreach my $f (@flows) {
        $f->{MaxProfit}= $f->{MaxQty} * $f->{'unitprofit'};
        $f->{MaxCapital}= $f->{MaxQty} * $f->{'org_price'};
 
+       $f->{MarginSortKey}= sprintf "%d",
+               $f->{'dst_price'} * 10000 / $f->{'org_price'};
+       $f->{Margin}= sprintf "%3.1f%%",
+               $f->{'dst_price'} * 100.0 / $f->{'org_price'} - 100.0;
+
        $f->{ExpectedUnitProfit}=
                $f->{'dst_price'} * (1.0 - $loss_per_league) ** $f->{'dist'}
                - $f->{'org_price'};