Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision dd011621

Von Sven Schöling vor mehr als 14 Jahren hinzugefügt

  • ID dd01162144167f57d67e5af7d0085367c72bbc18
  • Vorgänger 5052b6f9
  • Nachfolger 1228aa97

Kosmetik in IC->retrieve_accounts

Unterschiede anzeigen:

SL/IC.pm
1481 1481

  
1482 1482
  my ($self, $myconfig, $form, $parts_id, $index) = @_;
1483 1483

  
1484
  my ($query, $sth, $dbh);
1484
  my ($query, $sth);
1485 1485

  
1486
  $form->{"taxzone_id"} *= 1;
1486
  $form->{taxzone_id} *= 1;
1487 1487

  
1488
  $dbh = $form->get_standard_dbh($myconfig);
1488
  my $dbh = $form->get_standard_dbh;
1489 1489

  
1490 1490
  my $transdate = "";
1491 1491
  if ($form->{type} eq "invoice") {
......
1506 1506
    $transdate = $dbh->quote($transdate);
1507 1507
  }
1508 1508

  
1509
  $query =
1510
    qq|SELECT | .
1511
    qq|  p.inventory_accno_id AS is_part, | .
1512
    qq|  bg.inventory_accno_id, | .
1513
    qq|  bg.income_accno_id_$form->{taxzone_id} AS income_accno_id, | .
1514
    qq|  bg.expense_accno_id_$form->{taxzone_id} AS expense_accno_id, | .
1515
    qq|  c1.accno AS inventory_accno, | .
1516
    qq|  c2.accno AS income_accno, | .
1517
    qq|  c3.accno AS expense_accno | .
1518
    qq|FROM parts p | .
1519
    qq|LEFT JOIN buchungsgruppen bg ON p.buchungsgruppen_id = bg.id | .
1520
    qq|LEFT JOIN chart c1 ON bg.inventory_accno_id = c1.id | .
1521
    qq|LEFT JOIN chart c2 ON bg.income_accno_id_$form->{taxzone_id} = c2.id | .
1522
    qq|LEFT JOIN chart c3 ON bg.expense_accno_id_$form->{taxzone_id} = c3.id | .
1523
    qq|WHERE p.id = ?|;
1509
  $query = <<SQL;
1510
    SELECT
1511
      p.inventory_accno_id AS is_part,
1512
      bg.inventory_accno_id,
1513
      bg.income_accno_id_$form->{taxzone_id} AS income_accno_id,
1514
      bg.expense_accno_id_$form->{taxzone_id} AS expense_accno_id,
1515
      c1.accno AS inventory_accno,
1516
      c2.accno AS income_accno,
1517
      c3.accno AS expense_accno
1518
    FROM parts p
1519
    LEFT JOIN buchungsgruppen bg ON p.buchungsgruppen_id = bg.id
1520
    LEFT JOIN chart c1 ON bg.inventory_accno_id = c1.id
1521
    LEFT JOIN chart c2 ON bg.income_accno_id_$form->{taxzone_id} = c2.id
1522
    LEFT JOIN chart c3 ON bg.expense_accno_id_$form->{taxzone_id} = c3.id
1523
    WHERE p.id = ?
1524
SQL
1524 1525
  my $ref = selectfirst_hashref_query($form, $dbh, $query, $parts_id);
1525 1526

  
1526 1527
  return $main::lxdebug->leave_sub(2) if (!$ref);
......
1536 1537
                                  $ref->{"${type}_accno"});
1537 1538
  }
1538 1539

  
1539
  map({ $form->{"${_}_accno_$index"} = $accounts{"${_}_accno"} }
1540
      qw(inventory income expense));
1540
  map { $form->{"${_}_accno_$index"} = $accounts{"${_}_accno"} }
1541
      qw(inventory income expense);
1541 1542

  
1542 1543
  my $inc_exp = $form->{"vc"} eq "customer" ? "income" : "expense";
1543 1544
  my $accno_id = $accounts{"${inc_exp}_accno_id"};
1544 1545

  
1545
  $query =
1546
    qq|SELECT c.accno, t.taxdescription AS description, t.rate, t.taxnumber | .
1547
    qq|FROM tax t | .
1548
    qq|LEFT JOIN chart c ON c.id = t.chart_id | .
1549
    qq|WHERE t.id IN | .
1550
    qq|  (SELECT tk.tax_id | .
1551
    qq|   FROM taxkeys tk | .
1552
    qq|   WHERE tk.chart_id = ? AND startdate <= | . quote_db_date($transdate) .
1553
    qq|   ORDER BY startdate DESC LIMIT 1) |;
1554
  $ref = selectfirst_hashref_query($form, $dbh, $query, $accno_id);
1546
  $query = <<SQL;
1547
    SELECT c.accno, t.taxdescription AS description, t.rate, t.taxnumber
1548
    FROM tax t
1549
    LEFT JOIN chart c ON c.id = t.chart_id
1550
    WHERE t.id IN
1551
      (SELECT tk.tax_id
1552
       FROM taxkeys tk
1553
       WHERE tk.chart_id = ? AND startdate <= ?
1554
       ORDER BY startdate DESC LIMIT 1)
1555
SQL
1556
  $ref = selectfirst_hashref_query($form, $dbh, $query, $accno_id, quote_db_date($transdate));
1555 1557

  
1556 1558
  unless ($ref) {
1557
    $main::lxdebug->leave_sub(2);
1559
    $::lxdebug->leave_sub(2);
1558 1560
    return;
1559 1561
  }
1560 1562

  
......
1562 1564
  if ($form->{"taxaccounts"} !~ /$ref->{accno}/) {
1563 1565
    $form->{"taxaccounts"} .= "$ref->{accno} ";
1564 1566
  }
1565
  map({ $form->{"$ref->{accno}_${_}"} = $ref->{$_}; }
1566
      qw(rate description taxnumber));
1567

  
1568
#   $main::lxdebug->message(0, "formvars: rate " . $form->{"$ref->{accno}_rate"} .
1569
#                           " description " . $form->{"$ref->{accno}_description"} .
1570
#                           " taxnumber " . $form->{"$ref->{accno}_taxnumber"} .
1571
#                           " || taxaccounts_$index " . $form->{"taxaccounts_$index"} .
1572
#                           " || taxaccounts " . $form->{"taxaccounts"});
1567
  map { $form->{"$ref->{accno}_${_}"} = $ref->{$_}; } qw(rate description taxnumber);
1573 1568

  
1574
  $main::lxdebug->leave_sub(2);
1569
  $::lxdebug->leave_sub(2);
1575 1570
}
1576 1571

  
1577 1572
sub get_basic_part_info {

Auch abrufbar als: Unified diff