Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision be776964

Von Niclas Zimmermann vor mehr als 11 Jahren hinzugefügt

  • ID be776964b83340e69fa2f02eae59b703c0c95b88
  • Vorgänger 6d06b178
  • Nachfolger 014161b8

Nutzung der Tabelle currencies

Dieser Commmit passt den Code an, um die Tabelle currencies zu nutzen.

Unterschiede anzeigen:

SL/CP.pm
93 93
  }
94 94
  $sth->finish;
95 95

  
96
  # get currencies and closedto
97
  $query = qq|SELECT curr, closedto FROM defaults|;
98
  ($form->{currencies}, $form->{closedto}) =
99
    selectrow_query($form, $dbh, $query);
96
  # get closedto
97
  $query = qq|SELECT closedto FROM defaults|;
98
  ($form->{closedto}) = selectrow_query($form, $dbh, $query);
100 99

  
101 100
  $dbh->disconnect;
102 101

  
......
150 149
  my $arap = $form->{arap} eq "ar" ? "ar" : "ap";
151 150

  
152 151
  my $query =
153
     qq|SELECT a.id, a.invnumber, a.transdate, a.amount, a.paid, a.curr | .
152
     qq|SELECT a.id, a.invnumber, a.transdate, a.amount, a.paid, cu.curr | .
154 153
     qq|FROM $arap a | .
155
     qq|WHERE (a.${vc}_id = ?) AND (COALESCE(a.curr, '') = ?) AND NOT (a.amount = a.paid)| .
154
     qq|LEFT JOIN currencies cu ON (cu.id=a.curr)| .
155
     qq|WHERE (a.${vc}_id = ?) AND cu.curr = ? AND NOT (a.amount = a.paid)| .
156 156
     qq|ORDER BY a.id|;
157 157
  my $sth = prepare_execute_query($form, $dbh, $query,
158 158
                                  conv_i($form->{"${vc}_id"}),
......
174 174
    SELECT COUNT(*)
175 175
    FROM $arap
176 176
    WHERE (${vc}_id = ?)
177
      AND (COALESCE(curr, '') <> ?)
177
      AND ((SELECT cu.curr FROM currencies cu WHERE cu.id=${arap}.curr) <> ?)
178 178
      AND (amount <> paid)
179 179
SQL
180 180
  ($form->{openinvoices_other_currencies}) = selectfirst_array_query($form, $dbh, $query, conv_i($form->{"${vc}_id"}), "$form->{currency}");
......
250 250
        qq|SELECT $buysell | .
251 251
        qq|FROM exchangerate e | .
252 252
        qq|JOIN ${arap} a ON (a.transdate = e.transdate) | .
253
        qq|WHERE (e.curr = ?) AND (a.id = ?)|;
253
        qq|WHERE (e.curr = (SELECT id FROM currencies WHERE curr = ?)) AND (a.id = ?)|;
254 254
      my ($exchangerate) =
255 255
        selectrow_query($form, $dbh, $query,
256 256
                        $form->{currency}, $form->{"id_$i"});

Auch abrufbar als: Unified diff