projects
/
kivitendo-erp.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
e8784e4
)
SEPA: single-dbh
author
Sven Schöling
<s.schoeling@linet-services.de>
Mon, 1 Aug 2016 09:27:12 +0000
(11:27 +0200)
committer
Sven Schöling
<s.schoeling@linet-services.de>
Fri, 2 Sep 2016 12:21:29 +0000
(14:21 +0200)
SL/SEPA.pm
patch
|
blob
|
history
diff --git
a/SL/SEPA.pm
b/SL/SEPA.pm
index
2809063
..
0746732
100644
(file)
--- a/
SL/SEPA.pm
+++ b/
SL/SEPA.pm
@@
-8,6
+8,7
@@
use Data::Dumper;
use SL::DBUtils;
use SL::DB::Invoice;
use SL::DB::PurchaseInvoice;
use SL::DBUtils;
use SL::DB::Invoice;
use SL::DB::PurchaseInvoice;
+use SL::DB;
use SL::Locale::String qw(t8);
use DateTime;
use SL::Locale::String qw(t8);
use DateTime;
@@
-87,8
+88,16
@@
sub retrieve_open_invoices {
}
sub create_export {
}
sub create_export {
+ my ($self, %params) = @_;
$main::lxdebug->enter_sub();
$main::lxdebug->enter_sub();
+ my $rc = SL::DB->client->with_transaction(\&_create_export, $self, %params);
+
+ $::lxdebug->leave_sub;
+ return $rc;
+}
+
+sub _create_export {
my $self = shift;
my %params = @_;
my $self = shift;
my %params = @_;
@@
-100,7
+109,7
@@
sub create_export {
my $vc = $params{vc} eq 'customer' ? 'customer' : 'vendor';
my $ARAP = uc $arap;
my $vc = $params{vc} eq 'customer' ? 'customer' : 'vendor';
my $ARAP = uc $arap;
- my $dbh = $params{dbh} ||
$form->get_standard_dbh($myconfig)
;
+ my $dbh = $params{dbh} ||
SL::DB->client->dbh
;
my ($export_id) = selectfirst_array_query($form, $dbh, qq|SELECT nextval('sepa_export_id_seq')|);
my $query =
my ($export_id) = selectfirst_array_query($form, $dbh, qq|SELECT nextval('sepa_export_id_seq')|);
my $query =
@@
-189,10
+198,6
@@
sub create_export {
$h_insert->finish();
$h_item_id->finish();
$h_insert->finish();
$h_item_id->finish();
- $dbh->commit() unless ($params{dbh});
-
- $main::lxdebug->leave_sub();
-
return $export_id;
}
return $export_id;
}
@@
-267,15
+272,15
@@
sub close_export {
my $myconfig = \%main::myconfig;
my $form = $main::form;
my $myconfig = \%main::myconfig;
my $form = $main::form;
- my $dbh = $params{dbh} || $form->get_standard_dbh($myconfig);
+ SL::DB->client->with_transaction(sub {
+ my $dbh = $params{dbh} || SL::DB->client->dbh;
- my @ids = ref $params{id} eq 'ARRAY' ? @{ $params{id} } : ($params{id});
- my $placeholders = join ', ', ('?') x scalar @ids;
- my $query = qq|UPDATE sepa_export SET closed = TRUE WHERE id IN ($placeholders)|;
+
my @ids = ref $params{id} eq 'ARRAY' ? @{ $params{id} } : ($params{id});
+
my $placeholders = join ', ', ('?') x scalar @ids;
+
my $query = qq|UPDATE sepa_export SET closed = TRUE WHERE id IN ($placeholders)|;
- do_query($form, $dbh, $query, map { conv_i($_) } @ids);
-
- $dbh->commit() unless ($params{dbh});
+ do_query($form, $dbh, $query, map { conv_i($_) } @ids);
+ });
$main::lxdebug->leave_sub();
}
$main::lxdebug->leave_sub();
}
@@
-402,8
+407,16
@@
SQL
}
sub post_payment {
}
sub post_payment {
+ my ($self, %params) = @_;
$main::lxdebug->enter_sub();
$main::lxdebug->enter_sub();
+ my $rc = SL::DB->client->with_transaction(\&_post_payment, $self, %params);
+
+ $::lxdebug->leave_sub;
+ return $rc;
+}
+
+sub _post_payment {
my $self = shift;
my %params = @_;
my $self = shift;
my %params = @_;
@@
-416,7
+429,7
@@
sub post_payment {
my $mult = $params{vc} eq 'customer' ? -1 : 1;
my $ARAP = uc $arap;
my $mult = $params{vc} eq 'customer' ? -1 : 1;
my $ARAP = uc $arap;
- my $dbh = $params{dbh} ||
$form->get_standard_dbh($myconfig)
;
+ my $dbh = $params{dbh} ||
SL::DB->client->dbh
;
my @items = ref $params{items} eq 'ARRAY' ? @{ $params{items} } : ($params{items});
my @items = ref $params{items} eq 'ARRAY' ? @{ $params{items} } : ($params{items});
@@
-502,9
+515,7
@@
sub post_payment {
map { $_->[0]->finish() } values %handles;
map { $_->[0]->finish() } values %handles;
- $dbh->commit() unless ($params{dbh});
-
- $main::lxdebug->leave_sub();
+ return 1;
}
1;
}
1;