Revision dde086a3
Von Sven Schöling vor etwa 15 Jahren hinzugefügt
SL/CP.pm | ||
---|---|---|
42 | 42 |
|
43 | 43 |
my ($type, $countrycode) = @_; |
44 | 44 |
|
45 |
$self = {}; |
|
45 |
my $self = {};
|
|
46 | 46 |
|
47 | 47 |
if ($countrycode) { |
48 | 48 |
if (-f "locale/$countrycode/Num2text") { |
... | ... | |
79 | 79 |
$form->{PR}{ $form->{ARAP} } = (); |
80 | 80 |
$form->{PR}{"$form->{ARAP}_paid"} = (); |
81 | 81 |
|
82 |
while (my $ref = $sth->fetchrow_hashref(NAME_lc)) {
|
|
82 |
while (my $ref = $sth->fetchrow_hashref("NAME_lc")) {
|
|
83 | 83 |
foreach my $item (split(/:/, $ref->{link})) { |
84 | 84 |
if ($item eq $form->{ARAP}) { |
85 | 85 |
push(@{ $form->{PR}{ $form->{ARAP} } }, $ref); |
... | ... | |
163 | 163 |
my $query = |
164 | 164 |
qq|SELECT a.id, a.invnumber, a.transdate, a.amount, a.paid, a.curr | . |
165 | 165 |
qq|FROM $arap a | . |
166 |
qq|WHERE (a.${vc}_id = ?) AND (a.curr = ? $curr_null) AND NOT (a.amount = paid)|;
|
|
166 |
qq|WHERE (a.${vc}_id = ?) AND (a.curr = ? $curr_null) AND NOT (a.amount = paid)| .
|
|
167 | 167 |
qq|ORDER BY a.id|; |
168 | 168 |
my $sth = prepare_execute_query($form, $dbh, $query, |
169 | 169 |
conv_i($form->{"${vc}_id"}), |
170 | 170 |
$form->{currency}); |
171 | 171 |
|
172 | 172 |
$form->{PR} = []; |
173 |
while ($ref = $sth->fetchrow_hashref(NAME_lc)) {
|
|
173 |
while (my $ref = $sth->fetchrow_hashref("NAME_lc")) {
|
|
174 | 174 |
|
175 | 175 |
# if this is a foreign currency transaction get exchangerate |
176 | 176 |
$ref->{exchangerate} = |
... | ... | |
189 | 189 |
$main::lxdebug->enter_sub(); |
190 | 190 |
|
191 | 191 |
my ($self, $myconfig, $form) = @_; |
192 |
my $amount; |
|
192 | 193 |
|
193 | 194 |
# connect to database, turn AutoCommit off |
194 | 195 |
my $dbh = $form->dbconnect_noauto($myconfig); |
... | ... | |
201 | 202 |
$form->parse_amount($myconfig, $form->{exchangerate}); |
202 | 203 |
|
203 | 204 |
if ($form->{vc} eq 'customer') { |
204 |
$form->update_exchangerate($dbh, $form->{currency}, $form->{datepaid}, |
|
205 |
$form->{exchangerate}, 0); |
|
205 |
$form->update_exchangerate($dbh, $form->{currency}, $form->{datepaid}, $form->{exchangerate}, 0); |
|
206 | 206 |
} else { |
207 |
$form->update_exchangerate($dbh, $form->{currency}, $form->{datepaid}, 0, |
|
208 |
$form->{exchangerate}); |
|
207 |
$form->update_exchangerate($dbh, $form->{currency}, $form->{datepaid}, 0, $form->{exchangerate}); |
|
209 | 208 |
} |
210 | 209 |
} else { |
211 | 210 |
$form->{exchangerate} = 1; |
212 | 211 |
} |
213 | 212 |
|
214 |
my $query = |
|
215 |
qq|SELECT fxgain_accno_id, fxloss_accno_id FROM defaults|; |
|
216 |
my ($fxgain_accno_id, $fxloss_accno_id) = |
|
217 |
selectrow_query($form, $dbh, $query); |
|
213 |
my $query = qq|SELECT fxgain_accno_id, fxloss_accno_id FROM defaults|; |
|
214 |
my ($fxgain_accno_id, $fxloss_accno_id) = selectrow_query($form, $dbh, $query); |
|
218 | 215 |
|
219 | 216 |
my $buysell = $form->{vc} eq "customer" ? "buy" : "sell"; |
220 | 217 |
my $arap = $form->{arap} eq "ar" ? "ar" : "ap"; |
... | ... | |
233 | 230 |
qq| (c.link LIKE '%:AP:%')) |; |
234 | 231 |
} |
235 | 232 |
|
236 |
$paymentamount = $form->{amount}; |
|
233 |
my $paymentamount = $form->{amount};
|
|
237 | 234 |
|
238 |
# $paymentamount = $form->{amount}; |
|
239 | 235 |
my $null; |
240 | 236 |
($null, $form->{department_id}) = split(/--/, $form->{department}); |
241 | 237 |
$form->{department_id} *= 1; |
... | ... | |
254 | 250 |
$form->{"due_$i"} = $form->parse_amount($myconfig, $form->{"due_$i"}); |
255 | 251 |
|
256 | 252 |
if ($form->{"checked_$i"} && $form->{"paid_$i"}) { |
257 |
$paymentamount = |
|
258 |
(($paymentamount * 1000) - ($form->{"paid_$i"} * 1000)) / 1000; |
|
253 |
$paymentamount = (($paymentamount * 1000) - ($form->{"paid_$i"} * 1000)) / 1000; |
|
259 | 254 |
|
260 | 255 |
# get exchangerate for original |
261 | 256 |
$query = |
... | ... | |
298 | 293 |
do_query($form, $dbh, $query, @values); |
299 | 294 |
|
300 | 295 |
# add exchangerate difference if currency ne defaultcurrency |
301 |
$amount = |
|
302 |
$form->round_amount($form->{"paid_$i"} * ($form->{exchangerate} - 1), |
|
296 |
$amount = $form->round_amount($form->{"paid_$i"} * ($form->{exchangerate} - 1), |
|
303 | 297 |
2); |
304 | 298 |
if ($amount != 0) { |
305 | 299 |
|
... | ... | |
339 | 333 |
|
340 | 334 |
$amount += $form->{"paid_$i"}; |
341 | 335 |
|
336 |
my $paid; |
|
342 | 337 |
# BUG 324 |
343 | 338 |
if ($form->{arap} eq 'ap') { |
344 | 339 |
$paid = "paid = paid + $amount"; |
... | ... | |
357 | 352 |
$form->{addition} = "POSTED"; |
358 | 353 |
$form->save_history($form->dbconnect($myconfig)); |
359 | 354 |
} |
360 |
# /saving the history
|
|
355 |
# /saving the history |
|
361 | 356 |
} |
362 | 357 |
} |
363 | 358 |
|
... | ... | |
367 | 362 |
OP::overpayment("", $myconfig, $form, $dbh, $paymentamount, $ml, 1); |
368 | 363 |
} |
369 | 364 |
|
365 |
my $rc; |
|
370 | 366 |
if ($form->round_amount($paymentamount, 2) < 0) { |
371 | 367 |
$dbh->rollback; |
372 | 368 |
$rc = 0; |
Auch abrufbar als: Unified diff
strictness, und einige perltidy Verbrechen behoben.