Revision e4efda35
Von Jan Büren vor fast 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} = |
... | ... | |
656 | 670 |
if (($form->{previous_vendor_id} || $form->{vendor_id}) != $form->{vendor_id}) { |
657 | 671 |
IR->get_vendor(\%myconfig, $form); |
658 | 672 |
} |
659 |
|
|
660 |
if (!$form->{forex}) { # read exchangerate from input field (not hidden) |
|
661 |
$form->{exchangerate} = $form->parse_amount(\%myconfig, $form->{exchangerate}); |
|
673 |
# |
|
674 |
$form->{defaultcurrency} = $form->get_default_currency(\%myconfig); |
|
675 |
if ($form->{defaultcurrency} ne $form->{currency}) { |
|
676 |
if ($form->{exchangerate}) { # user input OR first default -> leave this value |
|
677 |
$form->{exchangerate} = $form->parse_amount(\%myconfig, $form->{exchangerate}); |
|
678 |
# does this differ from daily default? |
|
679 |
my $current_daily_rate = $form->check_exchangerate(\%myconfig, $form->{currency}, $form->{invdate}, 'sell'); |
|
680 |
$form->{record_forex} = $current_daily_rate > 0 && $current_daily_rate != $form->{exchangerate} |
|
681 |
? 1 : 0; |
|
682 |
} else { # no value, but get defaults -> maybe user changes invdate as well ... |
|
683 |
($form->{exchangerate}, $form->{record_forex}) = $form->check_exchangerate(\%myconfig, $form->{currency}, |
|
684 |
$form->{invdate}, 'sell', $form->{id}, 'ap'); |
|
685 |
} |
|
662 | 686 |
} |
663 |
$form->{forex} = $form->check_exchangerate(\%myconfig, $form->{currency}, $form->{invdate}, 'sell'); |
|
664 |
$form->{exchangerate} = $form->{forex} if $form->{forex}; |
|
665 |
|
|
666 | 687 |
for my $i (1 .. $form->{paidaccounts}) { |
667 | 688 |
next unless $form->{"paid_$i"}; |
668 | 689 |
map { $form->{"${_}_$i"} = $form->parse_amount(\%myconfig, $form->{"${_}_$i"}) } qw(paid exchangerate); |
669 |
$form->{"forex_$i"} = $form->check_exchangerate(\%myconfig, $form->{currency}, $form->{"datepaid_$i"}, 'sell'); |
|
690 |
$form->{"forex_$i"} = $form->check_exchangerate(\%myconfig, $form->{currency}, $form->{"datepaid_$i"}, 'sell') unless $form->{"record_forex_$i"};
|
|
670 | 691 |
$form->{"exchangerate_$i"} = $form->{"forex_$i"} if $form->{"forex_$i"}; |
671 | 692 |
} |
672 | 693 |
|
bin/mozilla/is.pl | ||
---|---|---|
234 | 234 |
$form->{"memo_$i"} = $form->{acc_trans}{$key}->[$i - 1]->{memo}; |
235 | 235 |
|
236 | 236 |
$form->{paidaccounts} = $i; |
237 |
# hook for calc of of fx_paid and check if banktransaction has a record exchangerate |
|
238 |
if ($form->{"exchangerate_$i"}) { |
|
239 |
my $bt_acc_trans; |
|
240 |
my $bt_acc_trans = SL::DB::Manager::BankTransactionAccTrans->find_by(acc_trans_id => $form->{"acc_trans_id_$i"}); |
|
241 |
if ($bt_acc_trans) { |
|
242 |
if ($bt_acc_trans->bank_transaction->exchangerate > 0) { |
|
243 |
$form->{"exchangerate_$i"} = $bt_acc_trans->bank_transaction->exchangerate; |
|
244 |
$form->{"forex_$i"} = $form->{"exchangerate_$i"}; |
|
245 |
$form->{"record_forex_$i"} = 1; |
|
246 |
} |
|
247 |
} |
|
248 |
$form->{"fx_paid_$i"} = $form->{"paid_$i"} / $form->{"exchangerate_$i"}; |
|
249 |
$form->{"fx_totalpaid"} += $form->{"fx_paid_$i"}; |
|
250 |
} # end hook fx_paid |
|
237 | 251 |
} |
238 | 252 |
} else { |
239 | 253 |
$form->{$key} = "$form->{acc_trans}{$key}->[0]->{accno}--$form->{acc_trans}{$key}->[0]->{description}"; |
... | ... | |
856 | 870 |
|
857 | 871 |
$form->{taxincluded} ||= $taxincluded; |
858 | 872 |
|
859 |
if (!$form->{forex}) { # read exchangerate from input field (not hidden) |
|
860 |
$form->{exchangerate} = $form->parse_amount(\%myconfig, $form->{exchangerate}) unless $recursive_call; |
|
873 |
$form->{defaultcurrency} = $form->get_default_currency(\%myconfig); |
|
874 |
if ($form->{defaultcurrency} ne $form->{currency}) { |
|
875 |
if ($form->{exchangerate}) { # user input OR first default -> leave this value |
|
876 |
$form->{exchangerate} = $form->parse_amount(\%myconfig, $form->{exchangerate}) unless $recursive_call; |
|
877 |
# does this differ from daily default? |
|
878 |
my $current_daily_rate = $form->check_exchangerate(\%myconfig, $form->{currency}, $form->{invdate}, 'buy'); |
|
879 |
$form->{record_forex} = $current_daily_rate > 0 && $current_daily_rate != $form->{exchangerate} |
|
880 |
? 1 : 0; |
|
881 |
} else { # no value, but get defaults -> maybe user changes invdate as well ... |
|
882 |
($form->{exchangerate}, $form->{record_forex}) = $form->check_exchangerate(\%myconfig, $form->{currency}, |
|
883 |
$form->{invdate}, 'buy', $form->{id}, 'ar'); |
|
884 |
} |
|
861 | 885 |
} |
862 |
($form->{forex}, $form->{record_forex}) = $form->check_exchangerate(\%myconfig, $form->{currency}, |
|
863 |
$form->{invdate}, 'buy', $form->{id}, 'ar'); |
|
864 |
$form->{exchangerate} = $form->{forex} if $form->{forex}; |
|
865 | 886 |
for my $i (1 .. $form->{paidaccounts}) { |
866 | 887 |
next unless $form->{"paid_$i"}; |
867 | 888 |
map { $form->{"${_}_$i"} = $form->parse_amount(\%myconfig, $form->{"${_}_$i"}) } qw(paid exchangerate); |
Auch abrufbar als: Unified diff
Wechselkurse für Zahlungen in Einkauf- und Verkaufsrechnung anzeigen