Revision 607163f5
Von Jan Büren vor mehr als 1 Jahr hinzugefügt
bin/mozilla/ir.pl | ||
---|---|---|
181 | 181 |
$form->{"memo_$i"} = $form->{acc_trans}{$key}->[$i - 1]->{memo}; |
182 | 182 |
|
183 | 183 |
$form->{paidaccounts} = $i; |
184 |
# hook for calc of of fx_paid and check if banktransaction has a record exchangerate |
|
185 |
if ($form->{"exchangerate_$i"}) { |
|
186 |
my $bt_acc_trans; |
|
187 |
my $bt_acc_trans = SL::DB::Manager::BankTransactionAccTrans->find_by(acc_trans_id => $form->{"acc_trans_id_$i"}); |
|
188 |
if ($bt_acc_trans) { |
|
189 |
if ($bt_acc_trans->bank_transaction->exchangerate > 0) { |
|
190 |
$form->{"exchangerate_$i"} = $bt_acc_trans->bank_transaction->exchangerate; |
|
191 |
$form->{"forex_$i"} = $form->{"exchangerate_$i"}; |
|
192 |
$form->{"record_forex_$i"} = 1; |
|
193 |
} |
|
194 |
} |
|
195 |
$form->{"fx_paid_$i"} = $form->{"paid_$i"} / $form->{"exchangerate_$i"}; |
|
196 |
$form->{"fx_totalpaid"} += $form->{"fx_paid_$i"}; |
|
197 |
} # end hook fx_paid |
|
184 | 198 |
} |
185 | 199 |
} else { |
186 | 200 |
$form->{$key} = |
... | ... | |
668 | 682 |
if (($form->{previous_vendor_id} || $form->{vendor_id}) != $form->{vendor_id}) { |
669 | 683 |
IR->get_vendor(\%myconfig, $form); |
670 | 684 |
} |
671 |
|
|
672 |
if (!$form->{forex}) { # read exchangerate from input field (not hidden) |
|
673 |
$form->{exchangerate} = $form->parse_amount(\%myconfig, $form->{exchangerate}); |
|
685 |
# |
|
686 |
$form->{defaultcurrency} = $form->get_default_currency(\%myconfig); |
|
687 |
if ($form->{defaultcurrency} ne $form->{currency}) { |
|
688 |
if ($form->{exchangerate}) { # user input OR first default -> leave this value |
|
689 |
$form->{exchangerate} = $form->parse_amount(\%myconfig, $form->{exchangerate}); |
|
690 |
# does this differ from daily default? |
|
691 |
my $current_daily_rate = $form->check_exchangerate(\%myconfig, $form->{currency}, $form->{invdate}, 'sell'); |
|
692 |
$form->{record_forex} = $current_daily_rate > 0 && $current_daily_rate != $form->{exchangerate} |
|
693 |
? 1 : 0; |
|
694 |
} else { # no value, but get defaults -> maybe user changes invdate as well ... |
|
695 |
($form->{exchangerate}, $form->{record_forex}) = $form->check_exchangerate(\%myconfig, $form->{currency}, |
|
696 |
$form->{invdate}, 'sell', $form->{id}, 'ap'); |
|
697 |
} |
|
674 | 698 |
} |
675 |
$form->{forex} = $form->check_exchangerate(\%myconfig, $form->{currency}, $form->{invdate}, 'sell'); |
|
676 |
$form->{exchangerate} = $form->{forex} if $form->{forex}; |
|
677 |
|
|
678 | 699 |
for my $i (1 .. $form->{paidaccounts}) { |
679 | 700 |
next unless $form->{"paid_$i"}; |
680 | 701 |
map { $form->{"${_}_$i"} = $form->parse_amount(\%myconfig, $form->{"${_}_$i"}) } qw(paid exchangerate); |
681 |
$form->{"forex_$i"} = $form->check_exchangerate(\%myconfig, $form->{currency}, $form->{"datepaid_$i"}, 'sell'); |
|
702 |
$form->{"forex_$i"} = $form->check_exchangerate(\%myconfig, $form->{currency}, $form->{"datepaid_$i"}, 'sell') unless $form->{"record_forex_$i"};
|
|
682 | 703 |
$form->{"exchangerate_$i"} = $form->{"forex_$i"} if $form->{"forex_$i"}; |
683 | 704 |
} |
684 | 705 |
|
Auch abrufbar als: Unified diff
Wechselkurse für Zahlungen in Einkauf- und Verkaufsrechnung anzeigen