Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision a87dd0ec

Von Sven Schöling vor etwa 14 Jahren hinzugefügt

  • ID a87dd0ec36ef206227750773a4e36e20689a9f57
  • Vorgänger 6f7c3b10
  • Nachfolger ee454f5b

Batchaccounts angewendet.

Ausserdem einen subtilen Bug behoben, und ein Query gecacht.

Unterschiede anzeigen:

SL/IC.pm
1
#=====================================================================
1
  #=====================================================================
2 2
# LX-Office ERP
3 3
# Copyright (C) 2004
4 4
# Based on SQL-Ledger Version 2.1.9
......
1477 1477
}
1478 1478

  
1479 1479
sub retrieve_accounts {
1480
  $main::lxdebug->enter_sub(2);
1480
  $main::lxdebug->enter_sub;
1481 1481

  
1482 1482
  my $self     = shift;
1483 1483
  my $myconfig = shift;
1484 1484
  my $form     = shift;
1485 1485
  my $dbh      = $form->get_standard_dbh;
1486
  my %args     = @_;     # part_id => index
1486
  my %args     = @_;     # index => part_id
1487 1487

  
1488 1488
  $form->{taxzone_id} *= 1;
1489 1489

  
1490
  return unless grep $_, values %args; # shortfuse if no part_id supplied
1491

  
1490 1492
  # transdate madness.
1491 1493
  my $transdate = "";
1492 1494
  if ($form->{type} eq "invoice") {
......
1507 1509
    $transdate = $dbh->quote($transdate);
1508 1510
  }
1509 1511
  #/transdate
1512
  my $inc_exp = $form->{"vc"} eq "customer" ? "income" : "expense";
1513

  
1514
  my @part_ids = grep { $_ } values %args;
1515
  my $in       = join ',', ('?') x @part_ids;
1510 1516

  
1511
  my $sth_accno = prepare_query($::form, $dbh, <<SQL);
1517
  my %accno_by_part = map { $_->{id} => $_ }
1518
    selectall_hashref_query($form, $dbh, <<SQL, @part_ids);
1512 1519
    SELECT
1513
      p.inventory_accno_id AS is_part,
1520
      p.id, p.inventory_accno_id AS is_part,
1514 1521
      bg.inventory_accno_id,
1515 1522
      bg.income_accno_id_$form->{taxzone_id} AS income_accno_id,
1516 1523
      bg.expense_accno_id_$form->{taxzone_id} AS expense_accno_id,
......
1522 1529
    LEFT JOIN chart c1 ON bg.inventory_accno_id = c1.id
1523 1530
    LEFT JOIN chart c2 ON bg.income_accno_id_$form->{taxzone_id} = c2.id
1524 1531
    LEFT JOIN chart c3 ON bg.expense_accno_id_$form->{taxzone_id} = c3.id
1525
    WHERE p.id = ?
1532
    WHERE p.id IN ($in)
1526 1533
SQL
1527 1534

  
1528 1535
  my $sth_tax = prepare_query($::form, $dbh, <<SQL);
......
1536 1543
       ORDER BY startdate DESC LIMIT 1)
1537 1544
SQL
1538 1545

  
1539
  while (my ($part_id, $index) = each %args) {
1540
    $sth_accno->execute($part_id);
1541
    my $ref = $sth_accno->fetchrow_hashref or next;
1546
  while (my ($index => $part_id) = each %args) {
1547
    my $ref = $accno_by_part{$part_id} or next;
1542 1548

  
1543 1549
    $ref->{"inventory_accno_id"} = undef unless $ref->{"is_part"};
1544 1550

  
......
1551 1557

  
1552 1558
    $form->{"${_}_accno_$index"} = $accounts{"${_}_accno"} for qw(inventory income expense);
1553 1559

  
1554
    my $inc_exp = $form->{"vc"} eq "customer" ? "income" : "expense";
1555 1560
    $sth_tax->execute($accounts{"${inc_exp}_accno_id"}, quote_db_date($transdate));
1556 1561
    $ref = $sth_tax->fetchrow_hashref or next;
1557 1562

  
......
1561 1566
    $form->{"$ref->{accno}_${_}"} = $ref->{$_} for qw(rate description taxnumber);
1562 1567
  }
1563 1568

  
1564
  $sth_accno->finish;
1565 1569
  $sth_tax->finish;
1566 1570

  
1567
  $::lxdebug->leave_sub(2);
1571
  $::lxdebug->leave_sub;
1568 1572
}
1569 1573

  
1570 1574
sub get_basic_part_info {

Auch abrufbar als: Unified diff