Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision b9442827

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

  • ID b944282768f7d90bf6bdf8db576fe539bb88481d
  • Vorgänger 2df28e2b
  • Nachfolger 4812c084

IS: single-dbh

Unterschiede anzeigen:

SL/IS.pm
54 54
use SL::DB::Tax;
55 55
use SL::DB::TaxZone;
56 56
use SL::TransNumber;
57
use SL::DB;
57 58
use Data::Dumper;
58 59

  
59 60
use strict;
......
655 656
}
656 657

  
657 658
sub post_invoice {
659
  my ($self, $myconfig, $form, $provided_dbh, $payments_only) = @_;
658 660
  $main::lxdebug->enter_sub();
659 661

  
662
  my $rc = SL::DB->client->with_transaction(\&_post_invoice, $self, $myconfig, $form, $provided_dbh, $payments_only);
663

  
664
  $::lxdebug->leave_sub;
665
  return $rc;
666
}
667

  
668
sub _post_invoice {
660 669
  my ($self, $myconfig, $form, $provided_dbh, $payments_only) = @_;
661 670

  
662
  # connect to database, turn off autocommit
663
  my $dbh = $provided_dbh ? $provided_dbh : $form->get_standard_dbh;
671
  my $dbh = $provided_dbh || SL::DB->client->dbh;
664 672
  my $restricter = SL::HTML::Restrict->create;
665 673

  
666 674
  my ($query, $sth, $null, $project_id, @values);
......
1257 1265

  
1258 1266
    $form->new_lastmtime('ar');
1259 1267

  
1260
    $dbh->commit if !$provided_dbh;
1261

  
1262
    $main::lxdebug->leave_sub();
1263 1268
    return;
1264 1269
  }
1265 1270

  
......
1398 1403
    $datev->export;
1399 1404

  
1400 1405
    if ($datev->errors) {
1401
      $dbh->rollback;
1402 1406
      die join "\n", $::locale->text('DATEV check returned errors:'), $datev->errors;
1403 1407
    }
1404 1408
  }
1405 1409

  
1406
  my $rc = 1;
1407
  $dbh->commit if !$provided_dbh;
1408

  
1409
  $main::lxdebug->leave_sub();
1410

  
1411
  return $rc;
1410
  return 1;
1412 1411
}
1413 1412

  
1414 1413
sub transfer_out {
......
1580 1579
}
1581 1580

  
1582 1581
sub post_payment {
1582
  my ($self, $myconfig, $form, $locale) = @_;
1583 1583
  $main::lxdebug->enter_sub();
1584 1584

  
1585
  my $rc = SL::DB->client->with_transaction(\&_post_payment, $self, $myconfig, $form, $locale);
1586

  
1587
  $::lxdebug->leave_sub;
1588
  return $rc;
1589
}
1590

  
1591
sub _post_payment {
1585 1592
  my ($self, $myconfig, $form, $locale) = @_;
1586 1593

  
1587
  # connect to database, turn off autocommit
1588
  my $dbh = $form->get_standard_dbh;
1594
  my $dbh = SL::DB->client->dbh;
1589 1595

  
1590 1596
  my (%payments, $old_form, $row, $item, $query, %keep_vars);
1591 1597

  
......
1641 1647

  
1642 1648
  restore_form($old_form);
1643 1649

  
1644
  my $rc = $dbh->commit();
1645

  
1646
  $main::lxdebug->leave_sub();
1647

  
1648
  return $rc;
1650
  return 1;
1649 1651
}
1650 1652

  
1651 1653
sub process_assembly {
......
1843 1845
}
1844 1846

  
1845 1847
sub delete_invoice {
1848
  my ($self, $myconfig, $form) = @_;
1846 1849
  $main::lxdebug->enter_sub();
1847 1850

  
1851
  my $rc = SL::DB->client->with_transaction(\&_delete_invoice, $self, $myconfig, $form);
1852

  
1853
  $::lxdebug->leave_sub;
1854
  return $rc;
1855
}
1856

  
1857
sub _delete_invoice {
1848 1858
  my ($self, $myconfig, $form) = @_;
1849 1859

  
1850
  # connect to database
1851
  my $dbh = $form->get_standard_dbh;
1860
  my $dbh = SL::DB->client->dbh;
1852 1861

  
1853 1862
  &reverse_invoice($dbh, $form);
1854 1863
  _delete_transfers($dbh, $form, $form->{id});
......
1881 1890

  
1882 1891
  map { do_query($form, $dbh, $_, @values) } @queries;
1883 1892

  
1884
  my $rc = $dbh->commit;
1893
  my $spool = $::lx_office_conf{paths}->{spool};
1894
  map { unlink "$spool/$_" if -f "$spool/$_"; } @spoolfiles;
1885 1895

  
1886
  if ($rc) {
1887
    my $spool = $::lx_office_conf{paths}->{spool};
1888
    map { unlink "$spool/$_" if -f "$spool/$_"; } @spoolfiles;
1889
  }
1890

  
1891
  $main::lxdebug->leave_sub();
1892

  
1893
  return $rc;
1896
  return 1;
1894 1897
}
1895 1898

  
1896 1899
sub retrieve_invoice {
1900
  my ($self, $myconfig, $form) = @_;
1897 1901
  $main::lxdebug->enter_sub();
1898 1902

  
1903
  my $rc = SL::DB->client->with_transaction(\&_retrieve_invoice, $self, $myconfig, $form);
1904

  
1905
  $::lxdebug->leave_sub;
1906
  return $rc;
1907
}
1908

  
1909
sub _retrieve_invoice {
1899 1910
  my ($self, $myconfig, $form) = @_;
1900 1911

  
1901
  # connect to database
1902
  my $dbh = $form->get_standard_dbh;
1912
  my $dbh = SL::DB->client->dbh;
1903 1913

  
1904 1914
  my ($sth, $ref, $query);
1905 1915

  
......
2086 2096
    Common::webdav_folder($form);
2087 2097
  }
2088 2098

  
2089
  my $rc = $dbh->commit;
2090

  
2091
  $main::lxdebug->leave_sub();
2092

  
2093
  return $rc;
2099
  return 1;
2094 2100
}
2095 2101

  
2096 2102
sub get_customer {

Auch abrufbar als: Unified diff