DATEV-Checks beim Buchen nutzen nun generate_datev_data
authorG. Richardson <information@kivitendo-premium.de>
Sun, 12 Feb 2017 12:30:42 +0000 (13:30 +0100)
committerG. Richardson <information@kivitendo-premium.de>
Tue, 28 Mar 2017 15:16:00 +0000 (17:16 +0200)
SL/AP.pm
SL/AR.pm
SL/DB/Helper/Payment.pm
SL/GL.pm
SL/IR.pm
SL/IS.pm
t/ar/ar.t

index 095f227..f03fb63 100644 (file)
--- 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;
index 2ca3022..56f2da9 100644 (file)
--- 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;
index 89fc6e4..ae7fa53 100644 (file)
@@ -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
index ec6b4a4..cd63ec0 100644 (file)
--- 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;
index a424ab9..f3f1fd0 100644 (file)
--- 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;
index d5e0280..bbf53e3 100644 (file)
--- 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;
index 7a97738..a936761 100644 (file)
--- 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;