Revision a4d74009
Von Niclas Zimmermann vor mehr als 11 Jahren hinzugefügt
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 name AS curr FROM currencies WHERE id=(SELECT currency_id FROM defaults)|;
|
|
1494 | 1494 |
|
1495 | 1495 |
my ($defaultcurrency) = selectrow_query($self, $dbh, $query); |
1496 | 1496 |
|
... | ... | |
1499 | 1499 |
return; |
1500 | 1500 |
} |
1501 | 1501 |
|
1502 |
$query = qq|SELECT e.curr FROM exchangerate e |
|
1503 |
WHERE e.curr = (SELECT cu.id FROM currencies cu WHERE cu.curr=?) AND e.transdate = ?
|
|
1502 |
$query = qq|SELECT e.currency_id FROM exchangerate e
|
|
1503 |
WHERE e.currency_id = (SELECT cu.id FROM currencies cu WHERE cu.name=?) AND e.transdate = ?
|
|
1504 | 1504 |
FOR UPDATE|; |
1505 | 1505 |
my $sth = prepare_execute_query($self, $dbh, $query, $curr, $transdate); |
1506 | 1506 |
|
... | ... | |
1526 | 1526 |
if ($sth->fetchrow_array) { |
1527 | 1527 |
$query = qq|UPDATE exchangerate |
1528 | 1528 |
SET $set |
1529 |
WHERE curr = (SELECT id FROM currencies WHERE curr = ?)
|
|
1529 |
WHERE currency_id = (SELECT id FROM currencies WHERE name = ?)
|
|
1530 | 1530 |
AND transdate = ?|; |
1531 | 1531 |
|
1532 | 1532 |
} else { |
1533 |
$query = qq|INSERT INTO exchangerate (curr, buy, sell, transdate) |
|
1534 |
VALUES ((SELECT id FROM currencies WHERE curr = ?), $buy, $sell, ?)|;
|
|
1533 |
$query = qq|INSERT INTO exchangerate (currency_id, buy, sell, transdate)
|
|
1534 |
VALUES ((SELECT id FROM currencies WHERE name = ?), $buy, $sell, ?)|;
|
|
1535 | 1535 |
} |
1536 | 1536 |
$sth->finish; |
1537 | 1537 |
do_query($self, $dbh, $query, $curr, $transdate); |
... | ... | |
1571 | 1571 |
return 1; |
1572 | 1572 |
} |
1573 | 1573 |
|
1574 |
$query = qq|SELECT curr FROM currencies WHERE id = (SELECT curr FROM defaults)|;
|
|
1574 |
$query = qq|SELECT name AS curr FROM currencies WHERE id = (SELECT currency_id FROM defaults)|;
|
|
1575 | 1575 |
|
1576 | 1576 |
my ($defaultcurrency) = selectrow_query($self, $dbh, $query); |
1577 | 1577 |
|
... | ... | |
1581 | 1581 |
} |
1582 | 1582 |
|
1583 | 1583 |
$query = qq|SELECT e.$fld FROM exchangerate e |
1584 |
WHERE e.curr = (SELECT id FROM currencies WHERE curr = ?) AND e.transdate = ?|;
|
|
1584 |
WHERE e.currency_id = (SELECT id FROM currencies WHERE name = ?) AND e.transdate = ?|;
|
|
1585 | 1585 |
my ($exchangerate) = selectrow_query($self, $dbh, $query, $curr, $transdate); |
1586 | 1586 |
|
1587 | 1587 |
|
... | ... | |
1614 | 1614 |
|
1615 | 1615 |
my $dbh = $self->get_standard_dbh($myconfig); |
1616 | 1616 |
my $query = qq|SELECT e.$fld FROM exchangerate e |
1617 |
WHERE e.curr = (SELECT id FROM currencies WHERE curr = ?) AND e.transdate = ?|;
|
|
1617 |
WHERE e.currency_id = (SELECT id FROM currencies WHERE name = ?) AND e.transdate = ?|;
|
|
1618 | 1618 |
|
1619 | 1619 |
my ($exchangerate) = selectrow_query($self, $dbh, $query, $currency, $transdate); |
1620 | 1620 |
|
... | ... | |
1631 | 1631 |
my $dbh = $self->get_standard_dbh($myconfig); |
1632 | 1632 |
my @currencies =(); |
1633 | 1633 |
|
1634 |
my $query = qq|SELECT curr FROM currencies|; |
|
1634 |
my $query = qq|SELECT name AS curr FROM currencies|;
|
|
1635 | 1635 |
|
1636 | 1636 |
my $sth = prepare_execute_query($self, $dbh, $query); |
1637 | 1637 |
|
... | ... | |
1650 | 1650 |
|
1651 | 1651 |
my ($self, $myconfig) = @_; |
1652 | 1652 |
my $dbh = $self->get_standard_dbh($myconfig); |
1653 |
my $query = qq|SELECT curr FROM currencies WHERE id = (SELECT curr FROM defaults)|;
|
|
1653 |
my $query = qq|SELECT name AS curr FROM currencies WHERE id = (SELECT currency_id FROM defaults)|;
|
|
1654 | 1654 |
|
1655 | 1655 |
my ($defaultcurrency) = selectrow_query($self, $dbh, $query); |
1656 | 1656 |
|
... | ... | |
2707 | 2707 |
$query = |
2708 | 2708 |
qq|SELECT |
2709 | 2709 |
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,
|
|
2710 |
a.duedate, a.ordnumber, a.taxincluded, (SELECT cu.name FROM currencies cu WHERE cu.id=a.currency_id) AS currency, a.notes,
|
|
2711 | 2711 |
a.intnotes, a.department_id, a.amount AS oldinvtotal, |
2712 | 2712 |
a.paid AS oldtotalpaid, a.employee_id, a.gldate, a.type, |
2713 | 2713 |
a.globalproject_id, ${extra_columns} |
... | ... | |
2812 | 2812 |
$query = |
2813 | 2813 |
qq|SELECT |
2814 | 2814 |
d.closedto, d.revtrans, |
2815 |
(SELECT cu.curr FROM currencies cu WHERE cu.id=d.curr) AS defaultcurrency,
|
|
2815 |
(SELECT cu.name FROM currencies cu WHERE cu.id=d.currency_id) AS defaultcurrency,
|
|
2816 | 2816 |
(SELECT c.accno FROM chart c WHERE d.fxgain_accno_id = c.id) AS fxgain_accno, |
2817 | 2817 |
(SELECT c.accno FROM chart c WHERE d.fxloss_accno_id = c.id) AS fxloss_accno |
2818 | 2818 |
FROM defaults d|; |
... | ... | |
2825 | 2825 |
$query = |
2826 | 2826 |
qq|SELECT |
2827 | 2827 |
current_date AS transdate, d.closedto, d.revtrans, |
2828 |
(SELECT cu.curr FROM currencies cu WHERE cu.id=d.curr) AS defaultcurrency,
|
|
2828 |
(SELECT cu.name FROM currencies cu WHERE cu.id=d.currency_id) AS defaultcurrency,
|
|
2829 | 2829 |
(SELECT c.accno FROM chart c WHERE d.fxgain_accno_id = c.id) AS fxgain_accno, |
2830 | 2830 |
(SELECT c.accno FROM chart c WHERE d.fxloss_accno_id = c.id) AS fxloss_accno |
2831 | 2831 |
FROM defaults d|; |
... | ... | |
2864 | 2864 |
"a.department_id" => "department_id", |
2865 | 2865 |
"d.description" => "department", |
2866 | 2866 |
"ct.name" => $table, |
2867 |
"cu.curr" => "currency",
|
|
2867 |
"cu.name AS curr" => "currency",
|
|
2868 | 2868 |
"current_date + ct.terms" => "duedate", |
2869 | 2869 |
); |
2870 | 2870 |
|
... | ... | |
2899 | 2899 |
FROM $arap a |
2900 | 2900 |
LEFT JOIN $table ct ON (a.${table}_id = ct.id) |
2901 | 2901 |
LEFT JOIN department d ON (a.department_id = d.id) |
2902 |
LEFT JOIN currencies cu ON (cu.id=ct.curr) |
|
2902 |
LEFT JOIN currencies cu ON (cu.id=ct.currency_id)
|
|
2903 | 2903 |
WHERE a.id = ?|; |
2904 | 2904 |
my $ref = selectfirst_hashref_query($self, $dbh, $query, $trans_id); |
2905 | 2905 |
|
Auch abrufbar als: Unified diff
Verbesserungen in Upgrade-Scripten
In den Scripten currencies.pl rm_whitespaces wurden einige Ver-
besserungen durchgeführt:
1. Umbenennung von Spalten curr in currency_id in allen Tabellen
außer currencies.
2. Umbenennung von Spalte curr in name in Tabelle currencies.
3. Update in rm_whitespaces wird jetzt in einer Schleife erledigt
anstatt für jede Tabelle eigenen Code zu schreiben.
4. Tabelle currencies hat jetzt id als Primärschlüssel und nicht
mehr curr.
Die oben aufgeführten Änderungen führen natürlich auch zu notwendigen
Änderungen im Programm, welche dieses Commit ebenfalls enthält.