Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision c9fdd205

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

  • ID c9fdd2059d2ab6f7802ef76ad65b8eda4f8860db
  • Vorgänger 6919adb8
  • Nachfolger cf07eb6e

Wechselkurse für Belege oder Zahlungen für ar und ap holen und berechnen

Unterschiede anzeigen:

bin/mozilla/ap.pl
396 396

  
397 397
  # currencies
398 398
  $form->{defaultcurrency} = $form->get_default_currency(\%myconfig);
399
  if ($form->{currency} ne $form->{defaultcurrency}) {
400
    ($form->{exchangerate}, $form->{record_forex}) = $form->check_exchangerate(\%myconfig, $form->{currency}, $form->{transdate}, "sell", $form->{id}, 'ap');
399
  if ($form->{currency} ne $form->{defaultcurrency} && !$form->{exchangerate}) {
400
    ($form->{exchangerate}, $form->{record_forex}) = $form->{id}
401
                                                  ?  $form->check_exchangerate(\%myconfig, $form->{currency}, $form->{transdate}, "sell", $form->{id}, 'ap')
402
                                                  :  $form->check_exchangerate(\%myconfig, $form->{currency}, $form->{transdate}, "sell");
401 403
  }
402 404

  
403 405
  # format amounts
......
533 535
  $form->{accno_arap} = IS->get_standard_accno_current_assets(\%myconfig, \%$form);
534 536

  
535 537
  for my $i (1 .. $form->{paidaccounts}) {
538
    # hook for calc of of fx_paid and check if banktransaction has a record exchangerate
539
    if ($form->{"exchangerate_$i"}) {
540
      my $bt_acc_trans;
541
      my $bt_acc_trans = SL::DB::Manager::BankTransactionAccTrans->find_by(acc_trans_id => $form->{"acc_trans_id_$i"});
542
      if ($bt_acc_trans) {
543
        if ($bt_acc_trans->bank_transaction->exchangerate > 0) {
544
          $form->{"exchangerate_$i"} = $bt_acc_trans->bank_transaction->exchangerate;
545
          $form->{"forex_$i"}        = $form->{"exchangerate_$i"};
546
          $form->{"record_forex_$i"} = 1;
547
        }
548
      }
549
      $form->{"fx_paid_$i"} = $form->{"paid_$i"} / $form->{"exchangerate_$i"};
550
      $form->{"fx_totalpaid"} +=  $form->{"fx_paid_$i"};
551
    } # end hook fx_paid
536 552
    # format amounts
537 553
    if ($form->{"paid_$i"}) {
538 554
      $form->{"paid_$i"} = $form->format_amount(\%myconfig, $form->{"paid_$i"}, 2);
......
567 583
       $form->{'AP_paid_' . $i} . " " . SL::DB::Manager::Chart->find_by(accno => $form->{'AP_paid_' . $i})->description
568 584
     : '';
569 585
  }
570

  
571
  $form->{paid_missing} = $form->{invtotal_unformatted} - $form->{totalpaid};
586
  $form->{paid_missing} =  $::form->{is_linked_bank_transaction} && $form->{invoice_obj}->forex ?
587
                           $form->{invoice_obj}->open_amount
588
                        :  $form->{invtotal_unformatted} - $form->{totalpaid};
572 589

  
573 590
  $form->{payment_id} = $form->{invoice_obj}->{payment_id} // $form->{payment_id};
574 591
  print $form->parse_html_template('ap/form_header', {
......
1407 1424
                      : $is_linked_bank_transaction                 ? 1
1408 1425
                      : $has_sepa_exports                           ? 1
1409 1426
                      : 0;
1427
  # and is_linked_bank_transaction
1428
  $::form->{is_linked_bank_transaction} = $is_linked_bank_transaction;
1410 1429

  
1411 1430
  my $create_post_action = sub {
1412 1431
    # $_[0]: description
1413 1432
    # $_[1]: after_action
1414 1433
    action => [
1434

  
1415 1435
      $_[0],
1416 1436
      submit   => [ '#form', { action => "post", after_action => $_[1] } ],
1417 1437
      checks   => [ 'kivi.validate_form', 'kivi.AP.check_fields_before_posting', 'kivi.AP.check_duplicate_invnumber' ],

Auch abrufbar als: Unified diff