Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 9557707c

Von Moritz Bunkus vor mehr als 11 Jahren hinzugefügt

  • ID 9557707c3a18daeb9371f2366b8637a7e1f0fa3c
  • Vorgänger c1a8c632
  • Nachfolger ae27679f

Revert "Nutzung der Tabelle currencies"

This reverts commit be776964b83340e69fa2f02eae59b703c0c95b88.

Unterschiede anzeigen:

SL/Form.pm
1490 1490
    $main::lxdebug->leave_sub();
1491 1491
    return;
1492 1492
  }
1493
  $query = qq|SELECT curr FROM currencies WHERE id=(SELECT curr FROM defaults)|;
1493
  $query = qq|SELECT curr FROM defaults|;
1494

  
1495
  my ($currency) = selectrow_query($self, $dbh, $query);
1496
  my ($defaultcurrency) = split m/:/, $currency;
1494 1497

  
1495
  my ($defaultcurrency) = selectrow_query($self, $dbh, $query);
1496 1498

  
1497 1499
  if ($curr eq $defaultcurrency) {
1498 1500
    $main::lxdebug->leave_sub();
......
1500 1502
  }
1501 1503

  
1502 1504
  $query = qq|SELECT e.curr FROM exchangerate e
1503
                 WHERE e.curr = (SELECT cu.id FROM currencies cu WHERE cu.curr=?) AND e.transdate = ?
1505
                 WHERE e.curr = ? AND e.transdate = ?
1504 1506
                 FOR UPDATE|;
1505 1507
  my $sth = prepare_execute_query($self, $dbh, $query, $curr, $transdate);
1506 1508

  
......
1526 1528
  if ($sth->fetchrow_array) {
1527 1529
    $query = qq|UPDATE exchangerate
1528 1530
                SET $set
1529
                WHERE curr = (SELECT id FROM currencies WHERE curr = ?)
1531
                WHERE curr = ?
1530 1532
                AND transdate = ?|;
1531 1533

  
1532 1534
  } else {
1533 1535
    $query = qq|INSERT INTO exchangerate (curr, buy, sell, transdate)
1534
                VALUES ((SELECT id FROM currencies WHERE curr = ?), $buy, $sell, ?)|;
1536
                VALUES (?, $buy, $sell, ?)|;
1535 1537
  }
1536 1538
  $sth->finish;
1537 1539
  do_query($self, $dbh, $query, $curr, $transdate);
......
1571 1573
    return 1;
1572 1574
  }
1573 1575

  
1574
  $query = qq|SELECT curr FROM currencies WHERE id = (SELECT curr FROM defaults)|;
1576
  $query = qq|SELECT curr FROM defaults|;
1575 1577

  
1576
  my ($defaultcurrency) = selectrow_query($self, $dbh, $query);
1578
  my ($currency) = selectrow_query($self, $dbh, $query);
1579
  my ($defaultcurrency) = split m/:/, $currency;
1577 1580

  
1578
  if ($curr eq $defaultcurrency) {
1581
  if ($currency eq $defaultcurrency) {
1579 1582
    $main::lxdebug->leave_sub();
1580 1583
    return 1;
1581 1584
  }
1582 1585

  
1583 1586
  $query = qq|SELECT e.$fld FROM exchangerate e
1584
                 WHERE e.curr = (SELECT id FROM currencies WHERE curr = ?) AND e.transdate = ?|;
1587
                 WHERE e.curr = ? AND e.transdate = ?|;
1585 1588
  my ($exchangerate) = selectrow_query($self, $dbh, $query, $curr, $transdate);
1586 1589

  
1587 1590

  
......
1614 1617

  
1615 1618
  my $dbh   = $self->get_standard_dbh($myconfig);
1616 1619
  my $query = qq|SELECT e.$fld FROM exchangerate e
1617
                 WHERE e.curr = (SELECT id FROM currencies WHERE curr = ?) AND e.transdate = ?|;
1620
                 WHERE e.curr = ? AND e.transdate = ?|;
1618 1621

  
1619 1622
  my ($exchangerate) = selectrow_query($self, $dbh, $query, $currency, $transdate);
1620 1623

  
......
1629 1632
  my $self     = shift;
1630 1633
  my $myconfig = shift || \%::myconfig;
1631 1634
  my $dbh      = $self->get_standard_dbh($myconfig);
1632
  my @currencies =();
1633 1635

  
1634
  my $query = qq|SELECT curr FROM currencies|;
1636
  my $query = qq|SELECT curr FROM defaults|;
1635 1637

  
1636
  my $sth = prepare_execute_query($self, $dbh, $query);
1637

  
1638
  while (my $ref = $sth->fetchrow_hashref()) {
1639
    push(@currencies, $ref->{curr});
1640
  }
1641
  $sth->finish;
1638
  my ($curr)     = selectrow_query($self, $dbh, $query);
1639
  my @currencies = grep { $_ } map { s/\s//g; $_ } split m/:/, $curr;
1642 1640

  
1643 1641
  $main::lxdebug->leave_sub();
1644 1642

  
......
1649 1647
  $main::lxdebug->enter_sub();
1650 1648

  
1651 1649
  my ($self, $myconfig) = @_;
1652
  my $dbh      = $self->get_standard_dbh($myconfig);
1653
  my $query = qq|SELECT curr FROM currencies WHERE id = (SELECT curr FROM defaults)|;
1654

  
1655
  my ($defaultcurrency) = selectrow_query($self, $dbh, $query);
1650
  my @currencies        = $self->get_all_currencies($myconfig);
1656 1651

  
1657 1652
  $main::lxdebug->leave_sub();
1658 1653

  
1659
  return $defaultcurrency;
1654
  return $currencies[0];
1660 1655
}
1661 1656

  
1662 1657
sub set_payment_options {
......
2196 2191

  
2197 2192
  $key = "all_currencies" unless ($key);
2198 2193

  
2199
  $self->{$key} = [$self->get_all_currencies()];
2194
  my $query = qq|SELECT curr AS currency FROM defaults|;
2195

  
2196
  $self->{$key} = [split(/\:/ , selectfirst_hashref_query($self, $dbh, $query)->{currency})];
2200 2197

  
2201 2198
  $main::lxdebug->leave_sub();
2202 2199
}
......
2707 2704
    $query =
2708 2705
      qq|SELECT
2709 2706
           a.cp_id, a.invnumber, a.transdate, a.${table}_id, a.datepaid,
2710
           a.duedate, a.ordnumber, a.taxincluded, (SELECT cu.curr FROM currencies cu WHERE cu.id=a.curr) AS currency, a.notes,
2707
           a.duedate, a.ordnumber, a.taxincluded, a.curr AS currency, a.notes,
2711 2708
           a.intnotes, a.department_id, a.amount AS oldinvtotal,
2712 2709
           a.paid AS oldtotalpaid, a.employee_id, a.gldate, a.type,
2713 2710
           a.globalproject_id, ${extra_columns}
......
2725 2722
      $self->{$key} = $ref->{$key};
2726 2723
    }
2727 2724

  
2725
    # remove any trailing whitespace
2726
    $self->{currency} =~ s/\s*$//;
2727

  
2728 2728
    my $transdate = "current_date";
2729 2729
    if ($self->{transdate}) {
2730 2730
      $transdate = $dbh->quote($self->{transdate});
......
2808 2808
    }
2809 2809

  
2810 2810
    $sth->finish;
2811
    #check das:
2812 2811
    $query =
2813 2812
      qq|SELECT
2814
           d.closedto, d.revtrans,
2815
           (SELECT cu.curr FROM currencies cu WHERE cu.id=d.curr) AS defaultcurrency,
2813
           d.curr AS currencies, d.closedto, d.revtrans,
2816 2814
           (SELECT c.accno FROM chart c WHERE d.fxgain_accno_id = c.id) AS fxgain_accno,
2817 2815
           (SELECT c.accno FROM chart c WHERE d.fxloss_accno_id = c.id) AS fxloss_accno
2818 2816
         FROM defaults d|;
......
2824 2822
    # get date
2825 2823
    $query =
2826 2824
       qq|SELECT
2827
            current_date AS transdate, d.closedto, d.revtrans,
2828
            (SELECT cu.curr FROM currencies cu WHERE cu.id=d.curr) AS defaultcurrency,
2825
            current_date AS transdate, d.curr AS currencies, d.closedto, d.revtrans,
2829 2826
            (SELECT c.accno FROM chart c WHERE d.fxgain_accno_id = c.id) AS fxgain_accno,
2830 2827
            (SELECT c.accno FROM chart c WHERE d.fxloss_accno_id = c.id) AS fxloss_accno
2831 2828
          FROM defaults d|;
......
2835 2832
    if ($self->{"$self->{vc}_id"}) {
2836 2833

  
2837 2834
      # only setup currency
2838
      ($self->{currency}) = $self->{defaultcurrency} if !$self->{currency};
2835
      ($self->{currency}) = split(/:/, $self->{currencies}) if !$self->{currency};
2839 2836

  
2840 2837
    } else {
2841 2838

  
......
2860 2857
  my ($arap, $where);
2861 2858

  
2862 2859
  $table         = $table eq "customer" ? "customer" : "vendor";
2863
  my %column_map = ("a.${table}_id"           => "${table}_id",
2860
  my %column_map = ("a.curr"                  => "currency",
2861
                    "a.${table}_id"           => "${table}_id",
2864 2862
                    "a.department_id"         => "department_id",
2865 2863
                    "d.description"           => "department",
2866 2864
                    "ct.name"                 => $table,
2867
                    "cu.curr"                 => "currency",
2865
                    "ct.curr"                 => "cv_curr",
2868 2866
                    "current_date + ct.terms" => "duedate",
2869 2867
    );
2870 2868

  
2871 2869
  if ($self->{type} =~ /delivery_order/) {
2872 2870
    $arap  = 'delivery_orders';
2873
    delete $column_map{"cu.currency"};
2871
    delete $column_map{"a.curr"};
2872
    delete $column_map{"ct.curr"};
2874 2873

  
2875 2874
  } elsif ($self->{type} =~ /_order/) {
2876 2875
    $arap  = 'oe';
......
2899 2898
                        FROM $arap a
2900 2899
                        LEFT JOIN $table     ct ON (a.${table}_id = ct.id)
2901 2900
                        LEFT JOIN department d  ON (a.department_id = d.id)
2902
                        LEFT JOIN currencies cu ON (cu.id=ct.curr)
2903 2901
                        WHERE a.id = ?|;
2904 2902
  my $ref          = selectfirst_hashref_query($self, $dbh, $query, $trans_id);
2905 2903

  
2906 2904
  map { $self->{$_} = $ref->{$_} } values %column_map;
2907 2905

  
2906
  # remove any trailing whitespace
2907
  $self->{currency} =~ s/\s*$// if $self->{currency};
2908
  $self->{cv_curr} =~ s/\s*$// if $self->{cv_curr};
2909

  
2910
  # if customer/vendor currency is set use this
2911
  $self->{currency} = $self->{cv_curr} if $self->{cv_curr};
2912

  
2908 2913
  $main::lxdebug->leave_sub();
2909 2914
}
2910 2915

  

Auch abrufbar als: Unified diff