From 7e7a13692ac4dd952cf85a972d2919eed80edca1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Thu, 24 May 2012 12:34:04 +0200 Subject: [PATCH] DATEV check in die 5 haupt buchungsmasken verlinkt --- SL/AP.pm | 22 ++++++++++++++++++++++ SL/AR.pm | 22 ++++++++++++++++++++++ SL/GL.pm | 22 ++++++++++++++++++++++ SL/IR.pm | 22 ++++++++++++++++++++++ SL/IS.pm | 22 ++++++++++++++++++++++ config/lx_office.conf.default | 21 +++++++++++++++++++++ locale/de/all | 6 ++---- 7 files changed, 133 insertions(+), 4 deletions(-) diff --git a/SL/AP.pm b/SL/AP.pm index 3c29ca85d..eda1e71f4 100644 --- a/SL/AP.pm +++ b/SL/AP.pm @@ -34,6 +34,7 @@ package AP; +use SL::DATEV qw(:CONSTANTS); use SL::DBUtils; use SL::IO; use SL::MoreCommon; @@ -353,6 +354,27 @@ sub post_transaction { IO->set_datepaid(table => 'ap', id => $form->{id}, dbh => $dbh); + # safety check datev export + if ($::lx_office_conf{datev_check}{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, + from => $transdate, + to => $transdate, + ); + + $datev->export; + + if ($datev->errors) { + $dbh->rollback; + die join "\n", $::locale->text('DATEV check returned errors:'), $datev->errors; + } + } + if (!$provided_dbh) { $dbh->commit(); $dbh->disconnect(); diff --git a/SL/AR.pm b/SL/AR.pm index e1501b7f7..002041ecf 100644 --- a/SL/AR.pm +++ b/SL/AR.pm @@ -35,6 +35,7 @@ package AR; use Data::Dumper; +use SL::DATEV qw(:CONSTANTS); use SL::DBUtils; use SL::IO; use SL::MoreCommon; @@ -273,6 +274,27 @@ sub post_transaction { IO->set_datepaid(table => 'ar', id => $form->{id}, dbh => $dbh); + # safety check datev export + if ($::lx_office_conf{datev_check}{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, + from => $transdate, + to => $transdate, + ); + + $datev->export; + + if ($datev->errors) { + $dbh->rollback; + die join "\n", $::locale->text('DATEV check returned errors:'), $datev->errors; + } + } + my $rc = 1; if (!$provided_dbh) { $rc = $dbh->commit(); diff --git a/SL/GL.pm b/SL/GL.pm index f538bc359..cdd9d406f 100644 --- a/SL/GL.pm +++ b/SL/GL.pm @@ -39,6 +39,7 @@ package GL; use Data::Dumper; +use SL::DATEV qw(:CONSTANTS); use SL::DBUtils; use strict; @@ -184,6 +185,27 @@ sub post_transaction { do_query($form, $dbh, qq|UPDATE gl SET storno = 't' WHERE id = ?|, conv_i($form->{storno_id})); } + # safety check datev export + if ($::lx_office_conf{datev_check}{check_on_gl_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, + from => $transdate, + to => $transdate, + ); + + $datev->export; + + if ($datev->errors) { + $dbh->rollback; + die join "\n", $::locale->text('DATEV check returned errors:'), $datev->errors; + } + } + # commit and redirect my $rc = $dbh->commit; $dbh->disconnect; diff --git a/SL/IR.pm b/SL/IR.pm index edf55f16a..d8569acaa 100644 --- a/SL/IR.pm +++ b/SL/IR.pm @@ -38,6 +38,7 @@ use SL::AM; use SL::ARAP; use SL::Common; use SL::CVar; +use SL::DATEV qw(:CONSTANTS); use SL::DBUtils; use SL::DO; use SL::GenericTranslations; @@ -683,6 +684,27 @@ sub post_invoice { 'arap_id' => $form->{id}, 'table' => 'ap',); + # safety check datev export + if ($::lx_office_conf{datev_check}{check_on_purchase_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, + from => $transdate, + to => $transdate, + ); + + $datev->export; + + if ($datev->errors) { + $dbh->rollback; + die join "\n", $::locale->text('DATEV check returned errors:'), $datev->errors; + } + } + my $rc = 1; if (!$provided_dbh) { $rc = $dbh->commit(); diff --git a/SL/IS.pm b/SL/IS.pm index 0c3b4c82c..d6acb2b31 100644 --- a/SL/IS.pm +++ b/SL/IS.pm @@ -40,6 +40,7 @@ use SL::AM; use SL::ARAP; use SL::CVar; use SL::Common; +use SL::DATEV qw(:CONSTANTS); use SL::DBUtils; use SL::DO; use SL::GenericTranslations; @@ -1080,6 +1081,27 @@ sub post_invoice { 'arap_id' => $form->{id}, 'table' => 'ar',); + # safety check datev export + if ($::lx_office_conf{datev_check}{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, + from => $transdate, + to => $transdate, + ); + + $datev->export; + + if ($datev->errors) { + $dbh->rollback; + die join "\n", $::locale->text('DATEV check returned errors:'), $datev->errors; + } + } + my $rc = 1; $dbh->commit if !$provided_dbh; diff --git a/config/lx_office.conf.default b/config/lx_office.conf.default index 396c5760d..53bacffbf 100644 --- a/config/lx_office.conf.default +++ b/config/lx_office.conf.default @@ -163,6 +163,27 @@ email_subject = Benachrichtigung: automatisch erstellte Rechnungen # The template file used for the email's body. email_template = templates/webpages/oe/periodic_invoices_email.txt +[datev_check] +# it is possible to make a quick DATEV export everytime you post a record to ensure things +# work nicely with their data requirements. This will result in a slight overhead though +# you can enable this for each type of record independantly. + +# check when a sales invoice or a payment for a sales invoice is posted +check_on_sales_invoice = 0 +# check when a purchase invoice or a payment for a purchase invoice is posted +check_on_purchase_invoice = 0 +# check when an ar transaction is posted +check_on_ar_transaction = 0 +# check when an ap transaction is posted +check_on_ap_transaction = 0 +# check when a gl transaction is posted +check_on_gl_transaction = 0 + +# not implemented yet: +#check_on_cash_and_receipt = 0 +#check_on_dunning = 0 +#check_on_sepa_import = 0 + [console] # autologin to use if none is given login = diff --git a/locale/de/all b/locale/de/all index 7b16fc0f0..9e1d62aef 100644 --- a/locale/de/all +++ b/locale/de/all @@ -523,6 +523,7 @@ $self->{texts} = { 'DATEV - Export Assistent' => 'DATEV-Exportassistent', 'DATEV Angaben' => 'DATEV-Angaben', 'DATEV Export' => 'DATEV-Export', + 'DATEV check returned errors:' => 'Die DATEV Prüfung dieser Buchung ergab Fehler:', 'DATEX - Export Assistent' => 'DATEV-Exportassistent', 'DELETED' => 'Gelöscht', 'DFV-Kennzeichen' => 'DFV-Kennzeichen', @@ -593,11 +594,8 @@ $self->{texts} = { 'Delivery Order created' => 'Lieferschein erstellt', 'Delivery Order deleted!' => 'Lieferschein gelöscht!', 'Delivery Orders' => 'Lieferscheine', - 'Delivery Orders for this document' => 'Lieferscheine für dieses Dokument', 'Delivery Plan' => 'Lieferplan', 'Delivery Plan for currently outstanding sales orders' => 'Lieferplan für offene Verkaufsaufträge', - 'Delivery information deleted.' => 'Lieferinformation gelöscht.', - 'Delivery information saved.' => 'Lieferinformation gespeichert.', 'Department' => 'Abteilung', 'Department 1' => 'Abteilung (1)', 'Department 2' => 'Abteilung (2)', @@ -1142,6 +1140,7 @@ $self->{texts} = { 'Missing amount' => 'Fehlbetrag', 'Missing parameter #1 in call to sub #2.' => 'Fehlernder Parameter \'#1\' in Funktionsaufruf \'#2\'.', 'Missing parameter (at least one of #1) in call to sub #2.' => 'Fehlernder Parameter (mindestens einer aus \'#1\') in Funktionsaufruf \'#2\'.', + 'Missing qty' => '', 'Missing taxkeys in invoices with taxes.' => 'Fehlende Steuerschlüssel in Rechnungen mit Steuern', 'Missing user id!' => 'Benutzer ID fehlt!', 'Mitarbeiter' => 'Mitarbeiter', @@ -1250,7 +1249,6 @@ $self->{texts} = { 'Number pages' => 'Seiten nummerieren', 'Number variables: \'PRECISION=n\' forces numbers to be shown with exactly n decimal places.' => 'Zahlenvariablen: Mit \'PRECISION=n\' erzwingt man, dass Zahlen mit n Nachkommastellen formatiert werden.', 'OB Transaction' => 'EB-Buchung', - 'OBE-Export erfolgreich!' => 'OBE-Export erfolgreich!', 'Objects have been imported.' => 'Objekte wurden importiert.', 'Obsolete' => 'Ungültig', 'Oct' => 'Okt', -- 2.20.1