Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 2a4fb1bf

Von Jan Büren vor etwa 2 Jahren hinzugefügt

  • ID 2a4fb1bf079e0fb869fcf7feabd82bb9d856a528
  • Vorgänger a105aa8b
  • Nachfolger 74ddad54

Wechselkurse für Zahlungen in Einkauf- und Verkaufsrechnung anzeigen

Unterschiede anzeigen:

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

  
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}";
......
857 871

  
858 872
  $form->{taxincluded} ||= $taxincluded;
859 873

  
860
  if (!$form->{forex}) {        # read exchangerate from input field (not hidden)
861
    $form->{exchangerate} = $form->parse_amount(\%myconfig, $form->{exchangerate}) unless $recursive_call;
874
  $form->{defaultcurrency} = $form->get_default_currency(\%myconfig);
875
  if ($form->{defaultcurrency} ne $form->{currency}) {
876
    if ($form->{exchangerate}) { # user input OR first default ->  leave this value
877
      $form->{exchangerate} = $form->parse_amount(\%myconfig, $form->{exchangerate}) unless $recursive_call;
878
      # does this differ from daily default?
879
      my $current_daily_rate = $form->check_exchangerate(\%myconfig, $form->{currency}, $form->{invdate}, 'buy');
880
      $form->{record_forex}  = $current_daily_rate > 0 && $current_daily_rate != $form->{exchangerate}
881
                           ?   1 : 0;
882
    } else {                     # no value, but get defaults -> maybe user changes invdate as well ...
883
      ($form->{exchangerate}, $form->{record_forex}) = $form->check_exchangerate(\%myconfig, $form->{currency},
884
                                                                                 $form->{invdate}, 'buy', $form->{id}, 'ar');
885
    }
862 886
  }
863
  ($form->{forex}, $form->{record_forex}) = $form->check_exchangerate(\%myconfig, $form->{currency},
864
                                                                      $form->{invdate}, 'buy', $form->{id}, 'ar');
865
  $form->{exchangerate} = $form->{forex} if $form->{forex};
866 887
  for my $i (1 .. $form->{paidaccounts}) {
867 888
    next unless $form->{"paid_$i"};
868 889
    map { $form->{"${_}_$i"}   = $form->parse_amount(\%myconfig, $form->{"${_}_$i"}) } qw(paid exchangerate);

Auch abrufbar als: Unified diff