Revision fb37acdc
Von Moritz Bunkus vor mehr als 17 Jahren hinzugefügt
SL/Form.pm | ||
---|---|---|
1127 | 1127 |
if ($curr eq '') { |
1128 | 1128 |
$main::lxdebug->leave_sub(); |
1129 | 1129 |
return; |
1130 |
} |
|
1131 |
my $query = qq|SELECT curr FROM defaults|; |
|
1132 |
|
|
1133 |
my ($currency) = selectrow_query($self, $dbh, $query); |
|
1134 |
my ($defaultcurrency) = split m/:/, $currency; |
|
1135 |
|
|
1136 |
|
|
1137 |
if ($curr eq $defaultcurrency) { |
|
1138 |
$main::lxdebug->leave_sub(); |
|
1139 |
return; |
|
1130 | 1140 |
} |
1131 | 1141 |
|
1132 | 1142 |
my $query = qq|SELECT e.curr FROM exchangerate e |
... | ... | |
1134 | 1144 |
FOR UPDATE|; |
1135 | 1145 |
my $sth = prepare_execute_query($self, $dbh, $query, $curr, $transdate); |
1136 | 1146 |
|
1147 |
if ($buy == 0) { |
|
1148 |
$buy = ""; |
|
1149 |
} |
|
1150 |
if ($sell == 0) { |
|
1151 |
$sell = ""; |
|
1152 |
} |
|
1153 |
|
|
1154 |
$buy = conv_i($buy, "NULL"); |
|
1155 |
$sell = conv_i($sell, "NULL"); |
|
1156 |
|
|
1137 | 1157 |
my $set; |
1138 | 1158 |
if ($buy != 0 && $sell != 0) { |
1139 | 1159 |
$set = "buy = $buy, sell = $sell"; |
... | ... | |
1148 | 1168 |
SET $set |
1149 | 1169 |
WHERE curr = ? |
1150 | 1170 |
AND transdate = ?|; |
1171 |
|
|
1151 | 1172 |
} else { |
1152 | 1173 |
$query = qq|INSERT INTO exchangerate (curr, buy, sell, transdate) |
1153 | 1174 |
VALUES (?, $buy, $sell, ?)|; |
... | ... | |
1165 | 1186 |
|
1166 | 1187 |
my $dbh = $self->dbconnect($myconfig); |
1167 | 1188 |
|
1168 |
my ($buy, $sell) = (0, 0); |
|
1189 |
my ($buy, $sell); |
|
1190 |
|
|
1169 | 1191 |
$buy = $rate if $fld eq 'buy'; |
1170 | 1192 |
$sell = $rate if $fld eq 'sell'; |
1171 | 1193 |
|
1194 |
|
|
1172 | 1195 |
$self->update_exchangerate($dbh, $currency, $transdate, $buy, $sell); |
1173 | 1196 |
|
1197 |
|
|
1174 | 1198 |
$dbh->disconnect; |
1175 | 1199 |
|
1176 | 1200 |
$main::lxdebug->leave_sub(); |
... | ... | |
1186 | 1210 |
return 1; |
1187 | 1211 |
} |
1188 | 1212 |
|
1213 |
my $query = qq|SELECT curr FROM defaults|; |
|
1214 |
|
|
1215 |
my ($currency) = selectrow_query($self, $dbh, $query); |
|
1216 |
my ($defaultcurrency) = split m/:/, $currency; |
|
1217 |
|
|
1218 |
if ($currency eq $defaultcurrency) { |
|
1219 |
$main::lxdebug->leave_sub(); |
|
1220 |
return 1; |
|
1221 |
} |
|
1222 |
|
|
1189 | 1223 |
my $query = qq|SELECT e.$fld FROM exchangerate e |
1190 | 1224 |
WHERE e.curr = ? AND e.transdate = ?|; |
1191 | 1225 |
my ($exchangerate) = selectrow_query($self, $dbh, $query, $curr, $transdate); |
1192 | 1226 |
|
1193 |
if (!$exchangerate) { |
|
1194 |
$exchangerate = 1; |
|
1195 |
} |
|
1227 |
|
|
1196 | 1228 |
|
1197 | 1229 |
$main::lxdebug->leave_sub(); |
1198 | 1230 |
|
... | ... | |
1209 | 1241 |
return ""; |
1210 | 1242 |
} |
1211 | 1243 |
|
1212 |
my $dbh = $self->dbconnect($myconfig); |
|
1244 |
my ($defaultcurrency) = $self->get_default_currency($myconfig); |
|
1245 |
|
|
1246 |
if ($currency eq $defaultcurrency) { |
|
1247 |
$main::lxdebug->leave_sub(); |
|
1248 |
return 1; |
|
1249 |
} |
|
1213 | 1250 |
|
1251 |
my $dbh = $self->get_standard_dbh($myconfig); |
|
1214 | 1252 |
my $query = qq|SELECT e.$fld FROM exchangerate e |
1215 | 1253 |
WHERE e.curr = ? AND e.transdate = ?|; |
1254 |
|
|
1216 | 1255 |
my ($exchangerate) = selectrow_query($self, $dbh, $query, $currency, $transdate); |
1217 |
$dbh->disconnect(); |
|
1218 | 1256 |
|
1219 |
$exchangerate = 1 if ($exchangerate == 0); |
|
1220 | 1257 |
$exchangerate = 1 if ($exchangerate eq ""); |
1221 | 1258 |
|
1222 | 1259 |
$main::lxdebug->leave_sub(); |
... | ... | |
1224 | 1261 |
return $exchangerate; |
1225 | 1262 |
} |
1226 | 1263 |
|
1264 |
sub get_default_currency { |
|
1265 |
$main::lxdebug->enter_sub(); |
|
1266 |
|
|
1267 |
my ($self, $myconfig) = @_; |
|
1268 |
my $dbh = $self->get_standard_dbh($myconfig); |
|
1269 |
|
|
1270 |
my $query = qq|SELECT curr FROM defaults|; |
|
1271 |
|
|
1272 |
my ($curr) = selectrow_query($self, $dbh, $query); |
|
1273 |
my ($defaultcurrency) = split m/:/, $curr; |
|
1274 |
|
|
1275 |
$main::lxdebug->leave_sub(); |
|
1276 |
|
|
1277 |
return $defaultcurrency; |
|
1278 |
} |
|
1279 |
|
|
1280 |
|
|
1227 | 1281 |
sub set_payment_options { |
1228 | 1282 |
$main::lxdebug->enter_sub(); |
1229 | 1283 |
|
Auch abrufbar als: Unified diff
Probleme mit mehreren Währungen und Wechselkursen behoben.