Revision 2a4fb1bf
Von Jan Büren vor etwa 2 Jahren hinzugefügt
bin/mozilla/ir.pl | ||
---|---|---|
176 | 176 |
$form->{"memo_$i"} = $form->{acc_trans}{$key}->[$i - 1]->{memo}; |
177 | 177 |
|
178 | 178 |
$form->{paidaccounts} = $i; |
179 |
# hook for calc of of fx_paid and check if banktransaction has a record exchangerate |
|
180 |
if ($form->{"exchangerate_$i"}) { |
|
181 |
my $bt_acc_trans; |
|
182 |
my $bt_acc_trans = SL::DB::Manager::BankTransactionAccTrans->find_by(acc_trans_id => $form->{"acc_trans_id_$i"}); |
|
183 |
if ($bt_acc_trans) { |
|
184 |
if ($bt_acc_trans->bank_transaction->exchangerate > 0) { |
|
185 |
$form->{"exchangerate_$i"} = $bt_acc_trans->bank_transaction->exchangerate; |
|
186 |
$form->{"forex_$i"} = $form->{"exchangerate_$i"}; |
|
187 |
$form->{"record_forex_$i"} = 1; |
|
188 |
} |
|
189 |
} |
|
190 |
$form->{"fx_paid_$i"} = $form->{"paid_$i"} / $form->{"exchangerate_$i"}; |
|
191 |
$form->{"fx_totalpaid"} += $form->{"fx_paid_$i"}; |
|
192 |
} # end hook fx_paid |
|
179 | 193 |
} |
180 | 194 |
} else { |
181 | 195 |
$form->{$key} = |
... | ... | |
636 | 650 |
if (($form->{previous_vendor_id} || $form->{vendor_id}) != $form->{vendor_id}) { |
637 | 651 |
IR->get_vendor(\%myconfig, $form); |
638 | 652 |
} |
639 |
|
|
640 |
if (!$form->{forex}) { # read exchangerate from input field (not hidden) |
|
641 |
$form->{exchangerate} = $form->parse_amount(\%myconfig, $form->{exchangerate}); |
|
653 |
# |
|
654 |
$form->{defaultcurrency} = $form->get_default_currency(\%myconfig); |
|
655 |
if ($form->{defaultcurrency} ne $form->{currency}) { |
|
656 |
if ($form->{exchangerate}) { # user input OR first default -> leave this value |
|
657 |
$form->{exchangerate} = $form->parse_amount(\%myconfig, $form->{exchangerate}); |
|
658 |
# does this differ from daily default? |
|
659 |
my $current_daily_rate = $form->check_exchangerate(\%myconfig, $form->{currency}, $form->{invdate}, 'sell'); |
|
660 |
$form->{record_forex} = $current_daily_rate > 0 && $current_daily_rate != $form->{exchangerate} |
|
661 |
? 1 : 0; |
|
662 |
} else { # no value, but get defaults -> maybe user changes invdate as well ... |
|
663 |
($form->{exchangerate}, $form->{record_forex}) = $form->check_exchangerate(\%myconfig, $form->{currency}, |
|
664 |
$form->{invdate}, 'sell', $form->{id}, 'ap'); |
|
665 |
} |
|
642 | 666 |
} |
643 |
$form->{forex} = $form->check_exchangerate(\%myconfig, $form->{currency}, $form->{invdate}, 'sell'); |
|
644 |
$form->{exchangerate} = $form->{forex} if $form->{forex}; |
|
645 |
|
|
646 | 667 |
for my $i (1 .. $form->{paidaccounts}) { |
647 | 668 |
next unless $form->{"paid_$i"}; |
648 | 669 |
map { $form->{"${_}_$i"} = $form->parse_amount(\%myconfig, $form->{"${_}_$i"}) } qw(paid exchangerate); |
649 |
$form->{"forex_$i"} = $form->check_exchangerate(\%myconfig, $form->{currency}, $form->{"datepaid_$i"}, 'sell'); |
|
670 |
$form->{"forex_$i"} = $form->check_exchangerate(\%myconfig, $form->{currency}, $form->{"datepaid_$i"}, 'sell') unless $form->{"record_forex_$i"};
|
|
650 | 671 |
$form->{"exchangerate_$i"} = $form->{"forex_$i"} if $form->{"forex_$i"}; |
651 | 672 |
} |
652 | 673 |
|
Auch abrufbar als: Unified diff
Wechselkurse für Zahlungen in Einkauf- und Verkaufsrechnung anzeigen