From 0a64ac3db8c430756ab6260399816714e44ec16d Mon Sep 17 00:00:00 2001 From: "G. Richardson" Date: Sun, 12 Feb 2017 13:30:42 +0100 Subject: [PATCH] DATEV-Checks beim Buchen nutzen nun generate_datev_data --- SL/AP.pm | 8 +------- SL/AR.pm | 7 +------ SL/DB/Helper/Payment.pm | 5 +---- SL/GL.pm | 7 ++----- SL/IR.pm | 8 +------- SL/IS.pm | 6 +----- t/ar/ar.t | 5 ++--- 7 files changed, 9 insertions(+), 37 deletions(-) diff --git a/SL/AP.pm b/SL/AP.pm index 095f22743..f03fb63e8 100644 --- a/SL/AP.pm +++ b/SL/AP.pm @@ -368,17 +368,11 @@ sub _post_transaction { # safety check datev export if ($::instance_conf->get_datev_check_on_ap_transaction) { - my $transdate = $::form->{transdate} ? DateTime->from_lxoffice($::form->{transdate}) : undef; - $transdate ||= DateTime->today; - my $datev = SL::DATEV->new( - exporttype => DATEV_ET_BUCHUNGEN, - format => DATEV_FORMAT_KNE, dbh => $dbh, trans_id => $form->{id}, ); - - $datev->export; + $datev->generate_datev_data; if ($datev->errors) { die join "\n", $::locale->text('DATEV check returned errors:'), $datev->errors; diff --git a/SL/AR.pm b/SL/AR.pm index 2ca302258..56f2da9df 100644 --- a/SL/AR.pm +++ b/SL/AR.pm @@ -312,17 +312,12 @@ sub _post_transaction { # safety check datev export if ($::instance_conf->get_datev_check_on_ar_transaction) { - my $transdate = $::form->{transdate} ? DateTime->from_lxoffice($::form->{transdate}) : undef; - $transdate ||= DateTime->today; - my $datev = SL::DATEV->new( - exporttype => DATEV_ET_BUCHUNGEN, - format => DATEV_FORMAT_KNE, dbh => $dbh, trans_id => $form->{id}, ); - $datev->export; + $datev->generate_datev_data; if ($datev->errors) { die join "\n", $::locale->text('DATEV check returned errors:'), $datev->errors; diff --git a/SL/DB/Helper/Payment.pm b/SL/DB/Helper/Payment.pm index 89fc6e453..ae7fa5366 100644 --- a/SL/DB/Helper/Payment.pm +++ b/SL/DB/Helper/Payment.pm @@ -294,14 +294,11 @@ sub pay_invoice { if ( $datev_check ) { my $datev = SL::DATEV->new( - exporttype => DATEV_ET_BUCHUNGEN, - format => DATEV_FORMAT_KNE, dbh => $db->dbh, trans_id => $self->{id}, ); - $datev->clean_temporary_directories; - $datev->export; + $datev->generate_datev_data; if ($datev->errors) { # this exception should be caught by with_transaction, which handles the rollback diff --git a/SL/GL.pm b/SL/GL.pm index ec6b4a467..cd63ec0f6 100644 --- a/SL/GL.pm +++ b/SL/GL.pm @@ -197,17 +197,14 @@ sub _post_transaction { # safety check datev export if ($::instance_conf->get_datev_check_on_gl_transaction) { - my $transdate = $::form->{transdate} ? DateTime->from_lxoffice($::form->{transdate}) : undef; - $transdate ||= DateTime->today; + # create datev object my $datev = SL::DATEV->new( - exporttype => DATEV_ET_BUCHUNGEN, - format => DATEV_FORMAT_KNE, dbh => $dbh, trans_id => $form->{id}, ); - $datev->export; + $datev->generate_datev_data; if ($datev->errors) { die join "\n", $::locale->text('DATEV check returned errors:'), $datev->errors; diff --git a/SL/IR.pm b/SL/IR.pm index a424ab990..f3f1fd0ca 100644 --- a/SL/IR.pm +++ b/SL/IR.pm @@ -817,19 +817,13 @@ SQL # safety check datev export if ($::instance_conf->get_datev_check_on_purchase_invoice) { - # if we need department for kostenstelle in DATEV check - $form->{department} = SL::DB::Manager::Department->find_by(id => $form->{department_id})->description if $form->{department_id}; - my $transdate = $::form->{invdate} ? DateTime->from_lxoffice($::form->{invdate}) : undef; - $transdate ||= DateTime->today; my $datev = SL::DATEV->new( - exporttype => DATEV_ET_BUCHUNGEN, - format => DATEV_FORMAT_KNE, dbh => $dbh, trans_id => $form->{id}, ); - $datev->export; + $datev->generate_datev_data; if ($datev->errors) { die join "\n", $::locale->text('DATEV check returned errors:'), $datev->errors; diff --git a/SL/IS.pm b/SL/IS.pm index d5e028067..bbf53e31a 100644 --- a/SL/IS.pm +++ b/SL/IS.pm @@ -1409,17 +1409,13 @@ SQL # safety check datev export if ($::instance_conf->get_datev_check_on_sales_invoice) { - my $transdate = $::form->{invdate} ? DateTime->from_lxoffice($::form->{invdate}) : undef; - $transdate ||= DateTime->today; my $datev = SL::DATEV->new( - exporttype => DATEV_ET_BUCHUNGEN, - format => DATEV_FORMAT_KNE, dbh => $dbh, trans_id => $form->{id}, ); - $datev->export; + $datev->generate_datev_data; if ($datev->errors) { die join "\n", $::locale->text('DATEV check returned errors:'), $datev->errors; diff --git a/t/ar/ar.t b/t/ar/ar.t index 7a97738ec..a936761a8 100644 --- a/t/ar/ar.t +++ b/t/ar/ar.t @@ -195,13 +195,12 @@ sub _save_and_pay_and_check { if ($datev_check) { my $datev = SL::DATEV->new( - exporttype => DATEV_ET_BUCHUNGEN, - format => DATEV_FORMAT_KNE, dbh => $invoice->db->dbh, trans_id => $invoice->id, ); - $datev->export; + $datev->generate_datev_data; + if ($datev->errors) { $invoice->db->dbh->rollback; die join "\n", $::locale->text('DATEV check returned errors:'), $datev->errors; -- 2.20.1