Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 61e1b31e

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

  • ID 61e1b31e9cf65507aaaa17a751b0da97ef31e5ca
  • Vorgänger d54196a3
  • Nachfolger efe9b725

Beleg-Wechselkurs speichern, falls gesetzt und abweichend vom Tageskurs

Für alle 4 Buchungsmaske - Etwas zuviel in dem Commit, da die
form->id schon vorhanden sein muss und ich die Aufteilung an 2
Stellen von _post_invoice|post für das Holen und Setzen auf eine
reduzieren wollte.

Unterschiede anzeigen:

SL/IR.pm
100 100
      do_query($form, $dbh, qq|INSERT INTO ap (id, invnumber, currency_id, taxzone_id) VALUES (?, '', (SELECT id FROM currencies WHERE name=?), ?)|, $form->{id}, $form->{currency}, $form->{taxzone_id});
101 101
    }
102 102
  }
103

  
104 103
  if ($form->{currency} eq $defaultcurrency) {
105 104
    $form->{exchangerate} = 1;
106 105
  } else {
107
    $exchangerate = $form->check_exchangerate($myconfig, $form->{currency}, $form->{invdate}, 'sell');
106
    $exchangerate         = $form->check_exchangerate($myconfig, $form->{currency}, $form->{invdate}, 'sell');
107
    $form->{exchangerate} = $form->parse_amount($myconfig, $form->{exchangerate}, 5);
108

  
109
    # if default exchangerate is not defined, define one
110
    unless ($exchangerate) {
111
      $form->update_exchangerate($dbh, $form->{currency}, $form->{invdate}, 0,  $form->{exchangerate});
112
      # delete records exchangerate -> if user sets new invdate for record
113
      $query = qq|UPDATE ap set exchangerate = NULL where id = ?|;
114
      do_query($form, $dbh, $query, $form->{"id"});
115
    }
116
    # update record exchangerate, if the default is set and differs from current
117
    if ($exchangerate && ($form->{exchangerate} != $exchangerate)) {
118
      $form->update_exchangerate($dbh, $form->{currency}, $form->{invdate},
119
                                 0, $form->{exchangerate}, $form->{id}, 'ap');
120
    }
108 121
  }
109

  
110
  $form->{exchangerate} = $exchangerate || $form->parse_amount($myconfig, $form->{exchangerate});
111
  $form->{exchangerate} = 1 unless ($form->{exchangerate} * 1);
112

  
113 122
  my %item_units;
114 123
  my $q_item_unit = qq|SELECT unit FROM parts WHERE id = ?|;
115 124
  my $h_item_unit = prepare_query($form, $dbh, $q_item_unit);
......
543 552

  
544 553
  $form->{paid} = $form->round_amount($form->{paid} * $form->{exchangerate} + $paiddiff, 2) if $form->{paid} != 0;
545 554

  
546
# update exchangerate
547

  
548
  $form->update_exchangerate($dbh, $form->{currency}, $form->{invdate}, 0, $form->{exchangerate})
549
    if ($form->{currency} ne $defaultcurrency) && !$exchangerate;
550

  
551
# record acc_trans transactions
555
  # record acc_trans transactions
552 556
  my $taxdate = $form->{tax_point} || $form->{deliverydate} || $form->{invdate};
553 557
  foreach my $trans_id (keys %{ $form->{amount} }) {
554 558
    foreach my $accno (keys %{ $form->{amount}{$trans_id} }) {

Auch abrufbar als: Unified diff