4 if(/\G\"([^\"]*)\"\s+/gc) {
6 } elsif(/\G(\S+)\s+/gc) {
14 if(!open IF, $ARGV[0]) {
29 $prts{$id} = {"name" => gettok, "items" => {}};
33 if(!exists $prts{$prt}) {
34 die "invalid participant $prt in item line";
38 if($t =~ /^\d+(\.\d+)?$/) {
42 $i = $prts{$prt}->{"items"};
51 if(/^freight\s+(\d+)/) {
54 if(/^realprice\s+(\d+)/) {
62 for $p (sort keys %prts) {
63 $I = $prts{$p}->{"items"};
66 $yt += $I->{$i} * $prod{$i}->{"p"};
67 $wt += $I->{$i} * $prod{$i}->{"w"};
68 $sp += $I->{$i} * $prod{$i}->{"p"};
69 $sw += $I->{$i} * $prod{$i}->{"w"};
71 $prts{$p}->{"sp"} = $sp;
72 $prts{$p}->{"sw"} = $sw;
74 $er = (($yt + $fc) / $rp);
76 while($cmd = shift @ARGV) {
78 print "Total: $yt ($rp SEK), $wt g\n";
79 print "Freight: $fc\n";
80 print ("Ratio: " . $er . "\n");
81 } elsif($cmd eq "judgement") {
82 for $prt (keys %prts) {
83 print "$prts{$prt}->{name}:\n";
84 $sp = $prts{$prt}->{"sp"};
85 $sw = $prts{$prt}->{"sw"};
86 printf "\tProducts ¥%i (%i SEK), %i g\n", $sp, ($sp / $er), $sw;
89 printf "\tFreight ¥%i (%.1f%%, %i SEK)\n", $sfc, (100 * $ff), ($sfc / $er);
91 printf "\tTotal: ¥%i (%i SEK)\n", $st, ($st / $er);
93 } elsif($cmd eq "rcpt-txt") {
95 $I = $prts{$prt}->{"items"};
97 printf "%.1f %s\t\t%i (%i SEK)\t%i g\n", $I->{$i}, $prod{$i}->{"s"}, $I->{$i} * $prod{$i}->{"p"}, $I->{$i} * $prod{$i}->{"p"} / $er, $I->{$i} * $prod{$i}->{"w"};
99 } elsif($cmd eq "rcpt-tex") {
101 \\documentclass[a4paper,11pt]{article}
102 \\usepackage[swedish]{babel}
103 \\usepackage[T1]{fontenc}
104 \\usepackage[utf8x]{inputenc}
105 \\usepackage{longtable}
108 \\begin{longtable}{lllllll}
109 Artikel & Antal & \\\'{A}-pris & Pris & Pris (SEK) & Vikt \\\\
114 $I = $prts{$prt}->{"items"};
117 printf "%s & ", $prod{$i}->{"s"};
118 printf "%.1f & ", $I->{$i};
119 printf "%i & ", $prod{$i}->{"p"};
120 printf "%i & ", $prod{$i}->{"p"} * $I->{$i};
121 printf "%.2f & ", $prod{$i}->{"p"} * $I->{$i} / $er;
122 printf "%i & ", $prod{$i}->{"w"} * $I->{$i};
123 #printf "%.1f %s\t\t%i (%i SEK)\t%i g", $I->{$i}, $prod{$i}->{"s"}, $I->{$i} * $prod{$i}->{"p"}, $I->{$i} * $prod{$i}->{"p"} / $er, $I->{$i} * $prod{$i}->{"w"};
127 print "\\hline\nDelsumma & ";
128 printf "%i & & ", $ni;
129 printf "%i & ", $prts{$prt}->{"sp"};
130 printf "%.2f & ", $prts{$prt}->{"sp"} / $er;
131 printf "%i & ", $prts{$prt}->{"sw"};
133 $ff = $prts{$prt}->{"sw"} / $wt;
134 printf "Frakt & %.1f\\%% & ", 100 * $ff;
136 printf "%i & ", $fc * $ff;
137 printf "%.2f", $fc * $ff / $er;
139 print "\\hline\nTotalt & & & ";
140 printf "%i & ", $fc * $ff + $prts{$prt}->{"sp"};
141 printf "\\textbf{%.2f} & ", ($fc * $ff + $prts{$prt}->{"sp"}) / $er;
143 print "\\end{longtable}\n";
145 print "\\end{document}\n";
147 print STDERR "usage: ordershare DESCFILE... COMMAND...\n";
148 print STDERR "\tcommands:\n";
149 print STDERR "\tstat General statistics\n";
150 print STDERR "\tjudgement Overview for each participant\n";
151 print STDERR "\trcpt-txt PARTICIPANT Receipt in text format\n";
152 print STDERR "\trcpt-tex PARTICIPANT Receipt in LaTeX format\n";