From 3424bf80214aede7a8318c39b754290738e4aea0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bernd=20Ble=C3=9Fmann?= Date: Fri, 2 Nov 2012 12:17:25 +0100 Subject: [PATCH] =?utf8?q?Option=20f=C3=BCr=20Datev-Check=20in=20Mandanten?= =?utf8?q?konfiguration=20verschoben.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/AP.pm | 2 +- SL/AR.pm | 2 +- SL/Controller/ClientConfig.pm | 8 +++ SL/DB/MetaSetup/Default.pm | 83 ++++++++++++---------- SL/GL.pm | 2 +- SL/IR.pm | 2 +- SL/IS.pm | 2 +- SL/InstanceConfiguration.pm | 45 ++++++++++++ config/kivitendo.conf.default | 21 ------ locale/de/all | 14 +++- locale/de_DE/all | 12 ++++ locale/en/all | 12 ++++ sql/Pg-upgrade2/defaults_datev_check.pl | 54 ++++++++++++++ templates/webpages/client_config/form.html | 35 +++++++++ 14 files changed, 228 insertions(+), 66 deletions(-) create mode 100644 sql/Pg-upgrade2/defaults_datev_check.pl diff --git a/SL/AP.pm b/SL/AP.pm index 839d40be6..95bde38e5 100644 --- a/SL/AP.pm +++ b/SL/AP.pm @@ -355,7 +355,7 @@ 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}) { + if ($::instance_conf->get_datev_check_on_ap_transaction) { my $transdate = $::form->{transdate} ? DateTime->from_lxoffice($::form->{transdate}) : undef; $transdate ||= DateTime->today; diff --git a/SL/AR.pm b/SL/AR.pm index fcf898ea0..1f8a0c0f5 100644 --- a/SL/AR.pm +++ b/SL/AR.pm @@ -276,7 +276,7 @@ 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}) { + if ($::instance_conf->get_datev_check_on_ar_transaction) { my $transdate = $::form->{transdate} ? DateTime->from_lxoffice($::form->{transdate}) : undef; $transdate ||= DateTime->today; diff --git a/SL/Controller/ClientConfig.pm b/SL/Controller/ClientConfig.pm index 97ff15a6d..e6e687806 100644 --- a/SL/Controller/ClientConfig.pm +++ b/SL/Controller/ClientConfig.pm @@ -19,6 +19,12 @@ sub action_edit { $self->{payments_changeable} = SL::DB::Default->get->payments_changeable; $self->{show_bestbefore} = SL::DB::Default->get->show_bestbefore; + map { $self->{$_} = SL::DB::Default->get->$_ } qw(datev_check_on_sales_invoice datev_check_on_purchase_invoice datev_check_on_ar_transaction datev_check_on_ap_transaction datev_check_on_gl_transaction); + # datev check: not implemented yet: + #check_on_cash_and_receipt = 0 + #check_on_dunning = 0 + #check_on_sepa_import = 0 + $self->render('client_config/form', title => $::locale->text('Client Configuration')); } @@ -29,6 +35,8 @@ sub action_save { SL::DB::Default->get->update_attributes('payments_changeable' => $::form->{payments_changeable}); SL::DB::Default->get->update_attributes('show_bestbefore' => $::form->{show_bestbefore}); + map { SL::DB::Default->get->update_attributes($_ => $::form->{$_}); } qw(datev_check_on_sales_invoice datev_check_on_purchase_invoice datev_check_on_ar_transaction datev_check_on_ap_transaction datev_check_on_gl_transaction); + flash_later('info', $::locale->text('Client Configuration saved!')); $self->redirect_to(action => 'edit'); diff --git a/SL/DB/MetaSetup/Default.pm b/SL/DB/MetaSetup/Default.pm index 8920ef582..0822368bf 100644 --- a/SL/DB/MetaSetup/Default.pm +++ b/SL/DB/MetaSetup/Default.pm @@ -10,45 +10,50 @@ __PACKAGE__->meta->setup( table => 'defaults', columns => [ - inventory_accno_id => { type => 'integer' }, - income_accno_id => { type => 'integer' }, - expense_accno_id => { type => 'integer' }, - fxgain_accno_id => { type => 'integer' }, - fxloss_accno_id => { type => 'integer' }, - invnumber => { type => 'text' }, - sonumber => { type => 'text' }, - weightunit => { type => 'varchar', length => 5 }, - businessnumber => { type => 'text' }, - version => { type => 'varchar', length => 8 }, - curr => { type => 'text' }, - closedto => { type => 'date' }, - revtrans => { type => 'boolean', default => 'false' }, - ponumber => { type => 'text' }, - sqnumber => { type => 'text' }, - rfqnumber => { type => 'text' }, - customernumber => { type => 'text' }, - vendornumber => { type => 'text' }, - audittrail => { type => 'boolean', default => 'false' }, - articlenumber => { type => 'text' }, - servicenumber => { type => 'text' }, - coa => { type => 'text' }, - itime => { type => 'timestamp', default => 'now()' }, - mtime => { type => 'timestamp' }, - rmanumber => { type => 'text' }, - cnnumber => { type => 'text' }, - dunning_ar_amount_fee => { type => 'integer' }, - dunning_ar_amount_interest => { type => 'integer' }, - dunning_ar => { type => 'integer' }, - pdonumber => { type => 'text' }, - sdonumber => { type => 'text' }, - ar_paid_accno_id => { type => 'integer' }, - id => { type => 'serial', not_null => 1 }, - accounting_method => { type => 'text' }, - inventory_system => { type => 'text' }, - profit_determination => { type => 'text' }, - language_id => { type => 'integer' }, - payments_changeable => { type => 'integer', default => '0', not_null => 1 }, - show_bestbefore => { type => 'boolean', default => 'false' }, + inventory_accno_id => { type => 'integer' }, + income_accno_id => { type => 'integer' }, + expense_accno_id => { type => 'integer' }, + fxgain_accno_id => { type => 'integer' }, + fxloss_accno_id => { type => 'integer' }, + invnumber => { type => 'text' }, + sonumber => { type => 'text' }, + weightunit => { type => 'varchar', length => 5 }, + businessnumber => { type => 'text' }, + version => { type => 'varchar', length => 8 }, + curr => { type => 'text' }, + closedto => { type => 'date' }, + revtrans => { type => 'boolean', default => 'false' }, + ponumber => { type => 'text' }, + sqnumber => { type => 'text' }, + rfqnumber => { type => 'text' }, + customernumber => { type => 'text' }, + vendornumber => { type => 'text' }, + audittrail => { type => 'boolean', default => 'false' }, + articlenumber => { type => 'text' }, + servicenumber => { type => 'text' }, + coa => { type => 'text' }, + itime => { type => 'timestamp', default => 'now()' }, + mtime => { type => 'timestamp' }, + rmanumber => { type => 'text' }, + cnnumber => { type => 'text' }, + dunning_ar_amount_fee => { type => 'integer' }, + dunning_ar_amount_interest => { type => 'integer' }, + dunning_ar => { type => 'integer' }, + pdonumber => { type => 'text' }, + sdonumber => { type => 'text' }, + ar_paid_accno_id => { type => 'integer' }, + id => { type => 'serial', not_null => 1 }, + accounting_method => { type => 'text' }, + inventory_system => { type => 'text' }, + profit_determination => { type => 'text' }, + language_id => { type => 'integer' }, + payments_changeable => { type => 'integer', default => '0', not_null => 1 }, + show_bestbefore => { type => 'boolean', default => 'false' }, + datev_check_on_sales_invoice => { type => 'boolean', default => 'true' }, + datev_check_on_purchase_invoice => { type => 'boolean', default => 'true' }, + datev_check_on_ar_transaction => { type => 'boolean', default => 'true' }, + datev_check_on_ap_transaction => { type => 'boolean', default => 'true' }, + datev_check_on_gl_transaction => { type => 'boolean', default => 'true' }, ], primary_key_columns => [ 'id' ], diff --git a/SL/GL.pm b/SL/GL.pm index cdd9d406f..c9fcd9c47 100644 --- a/SL/GL.pm +++ b/SL/GL.pm @@ -186,7 +186,7 @@ sub post_transaction { } # safety check datev export - if ($::lx_office_conf{datev_check}{check_on_gl_transaction}) { + if ($::instance_conf->get_datev_check_on_gl_transaction) { my $transdate = $::form->{transdate} ? DateTime->from_lxoffice($::form->{transdate}) : undef; $transdate ||= DateTime->today; diff --git a/SL/IR.pm b/SL/IR.pm index 7be04aef2..04e071e27 100644 --- a/SL/IR.pm +++ b/SL/IR.pm @@ -686,7 +686,7 @@ sub post_invoice { 'table' => 'ap',); # safety check datev export - if ($::lx_office_conf{datev_check}{check_on_purchase_invoice}) { + if ($::instance_conf->get_datev_check_on_purchase_invoice) { my $transdate = $::form->{invdate} ? DateTime->from_lxoffice($::form->{invdate}) : undef; $transdate ||= DateTime->today; diff --git a/SL/IS.pm b/SL/IS.pm index 8f00225be..db18d5a43 100644 --- a/SL/IS.pm +++ b/SL/IS.pm @@ -1077,7 +1077,7 @@ sub post_invoice { 'table' => 'ar',); # safety check datev export - if ($::lx_office_conf{datev_check}{check_on_sales_invoice}) { + if ($::instance_conf->get_datev_check_on_sales_invoice) { my $transdate = $::form->{invdate} ? DateTime->from_lxoffice($::form->{invdate}) : undef; $transdate ||= DateTime->today; diff --git a/SL/InstanceConfiguration.pm b/SL/InstanceConfiguration.pm index 4629e9423..58025ce57 100644 --- a/SL/InstanceConfiguration.pm +++ b/SL/InstanceConfiguration.pm @@ -49,6 +49,31 @@ sub get_profit_determination { return $self->{data}->{profit_determination}; } +sub get_datev_check_on_sales_invoice { + my ($self) = @_; + return $self->{data}->{datev_check_on_sales_invoice}; +} + +sub get_datev_check_on_purchase_invoice { + my ($self) = @_; + return $self->{data}->{datev_check_on_purchase_invoice}; +} + +sub get_datev_check_on_ar_transaction { + my ($self) = @_; + return $self->{data}->{datev_check_on_ar_transaction}; +} + +sub get_datev_check_on_ap_transaction { + my ($self) = @_; + return $self->{data}->{datev_check_on_ap_transaction}; +} + +sub get_datev_check_on_gl_transaction { + my ($self) = @_; + return $self->{data}->{datev_check_on_gl_transaction}; +} + sub get_show_bestbefore { my ($self) = @_; return $self->{data}->{show_bestbefore}; @@ -106,6 +131,26 @@ Returns the default inventory system, perpetual or periodic Returns the default profit determination method, balance or income +=item C + +Returns true if datev check should be performed on sales invoices + +=item C + +Returns true if datev check should be performed on purchase invoices + +=item C + +Returns true if datev check should be performed on ar transactions + +=item C + +Returns true if datev check should be performed on ap transactions + +=item C + +Returns true if datev check should be performed on gl transactions + =item C Returns the default behavior for showing best before date, true or false diff --git a/config/kivitendo.conf.default b/config/kivitendo.conf.default index e3d5adbad..96a7d4290 100644 --- a/config/kivitendo.conf.default +++ b/config/kivitendo.conf.default @@ -198,27 +198,6 @@ email_subject = kivitendo self test report # template. currently txt and html templates are recognized and correctly mime send. email_template = templates/mail/self_test/status_mail.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 = 1 -# check when a purchase invoice or a payment for a purchase invoice is posted -check_on_purchase_invoice = 1 -# check when an ar transaction is posted -check_on_ar_transaction = 1 -# check when an ap transaction is posted -check_on_ap_transaction = 1 -# check when a gl transaction is posted -check_on_gl_transaction = 1 - -# 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 1ee4ea3d6..63a677df8 100644 --- a/locale/de/all +++ b/locale/de/all @@ -399,6 +399,11 @@ $self->{texts} = { 'Check' => 'Scheck', 'Check Details' => 'Bitte Angaben überprüfen', 'Check for duplicates' => 'Dublettencheck', + 'Check on ap transaction' => 'Prüfen bei Kreditorenbuchung', + 'Check on ar transaction' => 'Prüfen bei Debitorenbuchung', + 'Check on gl transaction' => 'Prüfen bei Dialogbuchung', + 'Check on purchase invoice' => 'Prüfen bei Einkaufsrechnung', + 'Check on sales invoice' => 'Prüfen bei Verkaufsrechnung', 'Checks' => 'Schecks', 'Choose Customer' => 'Endkunde wählen:', 'Choose Outputformat' => 'Ausgabeformat auswählen...', @@ -542,6 +547,7 @@ $self->{texts} = { 'DATEV - Export Assistent' => 'DATEV-Exportassistent', 'DATEV Angaben' => 'DATEV-Angaben', 'DATEV Export' => 'DATEV-Export', + 'DATEV check configuration' => 'Einstellungen für DATEV-Prüfung', 'DATEV check returned errors:' => 'Die DATEV Prüfung dieser Buchung ergab Fehler:', 'DATEX - Export Assistent' => 'DATEV-Exportassistent', 'DELETED' => 'Gelöscht', @@ -1036,6 +1042,7 @@ $self->{texts} = { 'It is possible that even after such a correction there is something wrong with this transaction (e.g. taxes that don\'t match the selected taxkey). Therefore you should re-run the general ledger analysis.' => 'Auch nach einer Korrektur kann es mit dieser Buchung noch weitere Probleme geben (z.B. nicht zum Steuerschlüssel passende Steuern), weshalb ein erneutes Ausführen der Hauptbuchanalyse empfohlen wird.', 'It is possible to do this automatically for some Buchungsgruppen, but not for all.' => 'Es ist möglich, dies für einige, aber nicht für alle Buchungsgruppen automatisch zu erledigen.', 'It is possible to do this automatically for some units, but for others the user has to chose the new unit.' => 'Das ist für einige Einheiten automatisch möglich, aber bei anderen muss der Benutzer die neue Einheit auswählen.', + '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.' => 'Es ist möglich, bei jeder Buchung einen schnellen DATEV-Export durchzuführen, um sicherzustellen, dass die Datensätze den DATEV-Anforderungen genügen. Da dies einen kleinen Overhead bedeutet, lässt sich dei Einstellung für jeden Buchungstyp getrennt einstellen.', 'It may optionally be compressed with "gzip".' => 'Sie darf optional mit "gzip" komprimiert sein.', 'It will simply set the taxkey to 0 (meaning "no taxes") which is the correct value for such inventory transactions.' => 'Es wird einfach die Steuerschlüssel auf 0 setzen, was "keine Steuer" bedeutet und für solche Warenbestandsbuchungen der richtige Wert ist.', 'Item deleted!' => 'Artikel gelöscht!', @@ -1375,6 +1382,11 @@ $self->{texts} = { 'Payments' => 'Zahlungsausgänge', 'Payments Changeable' => 'Änderbarkeit von Zahlungen', 'Per. Inv.' => 'Wied. Rech.', + 'Perform check when a gl transaction is posted?' => 'Prüfung durchführen, wenn eine Dialogbuchung gebucht wird?', + 'Perform check when a purchase invoice or a payment for a purchase invoice is posted?' => 'Prüfung durchführen, wenn eine Einkaufsrechnung oder ein Zahlungsausgang hierfür gebucht wird?', + 'Perform check when a sales invoice or a payment for a sales invoice is posted?' => 'Prüfung durchführen, wenn eine Verkaufsrechnung oder ein Zahlungseingang hierfür gebucht wird?', + 'Perform check when an ap transaction is posted?' => 'Prüfung durchführen, wenn Kreditorenbuchung gebucht wird?', + 'Perform check when an ar transaction is posted?' => 'Prüfung durchführen, wenn Debiotorenbuchung gebucht wird?', 'Period' => 'Zeitraum', 'Period:' => 'Zeitraum:', 'Periodic Invoices' => 'Wiederkehrende Rechnungen', @@ -2353,8 +2365,8 @@ $self->{texts} = { 'not yet executed' => 'Noch nicht ausgeführt', 'number' => 'Nummer', 'oe.pl::search called with unknown type' => 'oe.pl::search mit unbekanntem Typ aufgerufen', - 'one-time execution' => 'einmalige Ausführung', 'on the same day' => 'am selben Tag', + 'one-time execution' => 'einmalige Ausführung', 'only OB Transactions' => 'nur EB-Buchungen', 'open' => 'Offen', 'order' => 'Reihenfolge', diff --git a/locale/de_DE/all b/locale/de_DE/all index f90ecaf1e..cd9ba9097 100644 --- a/locale/de_DE/all +++ b/locale/de_DE/all @@ -390,6 +390,11 @@ $self->{texts} = { 'Check' => 'Scheck', 'Check Details' => 'Bitte Angaben überprüfen', 'Check for duplicates' => 'Dublettencheck', + 'Check on ap transaction' => 'Prüfen bei Kreditorenbuchung', + 'Check on ar transaction' => 'Prüfen bei Debitorenbuchung', + 'Check on gl transaction' => 'Prüfen bei Dialogbuchung', + 'Check on purchase invoice' => 'Prüfen bei Einkaufsrechnung', + 'Check on sales invoice' => 'Prüfen bei Verkaufsrechnung', 'Checks' => 'Schecks', 'Choose Customer' => 'Endkunde wählen:', 'Choose Outputformat' => 'Ausgabeformat auswählen...', @@ -520,6 +525,7 @@ $self->{texts} = { 'Customers' => 'Kunden', 'Customers and vendors' => 'Kunden und Lieferanten', 'Customized Report' => 'Vorgewählte Zeiträume', + 'DATEV check configuration' => 'Einstellungen für DATEV-Prüfung', 'DATEV - Export Assistent' => 'DATEV-Exportassistent', 'DATEV Angaben' => 'DATEV-Angaben', 'DATEV Export' => 'DATEV-Export', @@ -1004,6 +1010,7 @@ $self->{texts} = { 'It is possible that even after such a correction there is something wrong with this transaction (e.g. taxes that don\'t match the selected taxkey). Therefore you should re-run the general ledger analysis.' => 'Auch nach einer Korrektur kann es mit dieser Buchung noch weitere Probleme geben (z.B. nicht zum Steuerschlüssel passende Steuern), weshalb ein erneutes Ausführen der Hauptbuchanalyse empfohlen wird.', 'It is possible to do this automatically for some Buchungsgruppen, but not for all.' => 'Es ist möglich, dies für einige, aber nicht für alle Buchungsgruppen automatisch zu erledigen.', 'It is possible to do this automatically for some units, but for others the user has to chose the new unit.' => 'Das ist für einige Einheiten automatisch möglich, aber bei anderen muss der Benutzer die neue Einheit auswählen.', + '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.' => 'Es ist möglich, bei jeder Buchung einen schnellen DATEV-Export durchzuführen, um sicherzustellen, dass die Datensätze den DATEV-Anforderungen genügen. Da dies einen kleinen Overhead bedeutet, lässt sich dei Einstellung für jeden Buchungstyp getrennt einstellen.', 'It may optionally be compressed with "gzip".' => 'Sie darf optional mit "gzip" komprimiert sein.', 'It will simply set the taxkey to 0 (meaning "no taxes") which is the correct value for such inventory transactions.' => 'Es wird einfach die Steuerschlüssel auf 0 setzen, was "keine Steuer" bedeutet und für solche Warenbestandsbuchungen der richtige Wert ist.', 'Item deleted!' => 'Artikel gelöscht!', @@ -1339,6 +1346,11 @@ $self->{texts} = { 'Payments' => 'Zahlungsausgänge', 'Payments Changeable' => 'Änderbarkeit von Zahlungen', 'Per. Inv.' => 'Wied. Rech.', + 'Perform check when a gl transaction is posted?' => 'Prüfung durchführen, wenn eine Dialogbuchung gebucht wird?', + 'Perform check when a purchase invoice or a payment for a purchase invoice is posted?' => 'Prüfung durchführen, wenn eine Einkaufsrechnung oder ein Zahlungsausgang hierfür gebucht wird?', + 'Perform check when a sales invoice or a payment for a sales invoice is posted?' => 'Prüfung durchführen, wenn eine Verkaufsrechnung oder ein Zahlungseingang hierfür gebucht wird?', + 'Perform check when an ap transaction is posted?' => 'Prüfung durchführen, wenn Kreditorenbuchung gebucht wird?', + 'Perform check when an ar transaction is posted?' => 'Prüfung durchführen, wenn Debiotorenbuchung gebucht wird?', 'Period' => 'Zeitraum', 'Period:' => 'Zeitraum:', 'Periodic Invoices' => 'Wiederkehrende Rechnungen', diff --git a/locale/en/all b/locale/en/all index e76c86695..87ec31769 100644 --- a/locale/en/all +++ b/locale/en/all @@ -391,6 +391,11 @@ $self->{texts} = { 'Check' => 'Cheque', 'Check Details' => '', 'Check for duplicates' => '', + 'Check on ap transaction' => '', + 'Check on ar transaction' => '', + 'Check on gl transaction' => '', + 'Check on purchase invoice' => '', + 'Check on sales invoice' => '', 'Checks' => '', 'Choose Customer' => '', 'Choose Outputformat' => '', @@ -531,6 +536,7 @@ $self->{texts} = { 'DATEV - Export Assistent' => '', 'DATEV Angaben' => '', 'DATEV Export' => '', + 'DATEV check configuration' => '', 'DATEV check returned errors:' => '', 'DATEX - Export Assistent' => '', 'DELETED' => '', @@ -1020,6 +1026,7 @@ $self->{texts} = { 'It is possible that even after such a correction there is something wrong with this transaction (e.g. taxes that don\'t match the selected taxkey). Therefore you should re-run the general ledger analysis.' => '', 'It is possible to do this automatically for some Buchungsgruppen, but not for all.' => '', 'It is possible to do this automatically for some units, but for others the user has to chose the new unit.' => '', + '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.' => '', 'It may optionally be compressed with "gzip".' => '', 'It will simply set the taxkey to 0 (meaning "no taxes") which is the correct value for such inventory transactions.' => '', 'Item deleted!' => '', @@ -1355,6 +1362,11 @@ $self->{texts} = { 'Payments' => '', 'Payments Changeable' => '', 'Per. Inv.' => '', + 'Perform check when a gl transaction is posted?' => '', + 'Perform check when a purchase invoice or a payment for a purchase invoice is posted?' => '', + 'Perform check when a sales invoice or a payment for a sales invoice is posted?' => '', + 'Perform check when an ap transaction is posted?' => '', + 'Perform check when an ar transaction is posted?' => '', 'Period' => '', 'Period:' => '', 'Periodic Invoices' => '', diff --git a/sql/Pg-upgrade2/defaults_datev_check.pl b/sql/Pg-upgrade2/defaults_datev_check.pl new file mode 100644 index 000000000..50772810b --- /dev/null +++ b/sql/Pg-upgrade2/defaults_datev_check.pl @@ -0,0 +1,54 @@ +# @tag: defaults_datev_check +# @description: Einstellung für DATEV-Überprüfungen (datev_check) vom Config-File in die DB verlagern. +# @depends: release_2_7_0 +# @charset: utf-8 + +use utf8; +use strict; + +die("This script cannot be run from the command line.") unless ($main::form); + +sub mydberror { + my ($msg) = @_; + die($dbup_locale->text("Database update error:") . + "
$msg
" . $DBI::errstr); +} + +sub do_query { + my ($query, $may_fail) = @_; + + if (!$dbh->do($query)) { + mydberror($query) unless ($may_fail); + $dbh->rollback(); + $dbh->begin_work(); + } +} + +sub do_update { + + # this query will fail if column already exist (new database) + do_query(qq|ALTER TABLE defaults ADD COLUMN datev_check_on_sales_invoice boolean DEFAULT true|, 1); + do_query(qq|ALTER TABLE defaults ADD COLUMN datev_check_on_purchase_invoice boolean DEFAULT true|, 1); + do_query(qq|ALTER TABLE defaults ADD COLUMN datev_check_on_ar_transaction boolean DEFAULT true|, 1); + do_query(qq|ALTER TABLE defaults ADD COLUMN datev_check_on_ap_transaction boolean DEFAULT true|, 1); + do_query(qq|ALTER TABLE defaults ADD COLUMN datev_check_on_gl_transaction boolean DEFAULT true|, 1); + + # check current configuration and set default variables accordingly, so that + # kivitendo's behaviour isn't changed by this update + # if checks are not set in config set it to true + foreach my $check (qw(check_on_sales_invoice check_on_purchase_invoice check_on_ar_transaction check_on_ap_transaction check_on_gl_transaction)) { + my $check_set = 1; + if (!$::lx_office_conf{datev_check}->{$check}) { + $check_set = 0; + } + + my $update_column = "UPDATE defaults SET datev_$check = '$check_set';"; + do_query($update_column); + } + + + return 1; +} + +return do_update(); + diff --git a/templates/webpages/client_config/form.html b/templates/webpages/client_config/form.html index 448c244e6..416d66d0b 100644 --- a/templates/webpages/client_config/form.html +++ b/templates/webpages/client_config/form.html @@ -20,6 +20,41 @@ + + [% 'DATEV check configuration' | $T8 %] + + + [% '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.' | $T8 %] + + + [% 'Check on sales invoice' | $T8 %] + [% L.yes_no_tag('datev_check_on_sales_invoice', SELF.datev_check_on_sales_invoice) %] + [% 'Perform check when a sales invoice or a payment for a sales invoice is posted?' | $T8 %] + + + [% 'Check on purchase invoice' | $T8 %] + [% L.yes_no_tag('datev_check_on_purchase_invoice', SELF.datev_check_on_purchase_invoice) %] + [% 'Perform check when a purchase invoice or a payment for a purchase invoice is posted?' | $T8 %] + + + [% 'Check on ar transaction' | $T8 %] + [% L.yes_no_tag('datev_check_on_ar_transaction', SELF.datev_check_on_ar_transaction) %] + [% 'Perform check when an ar transaction is posted?' | $T8 %] + + + [% 'Check on ap transaction' | $T8 %] + [% L.yes_no_tag('datev_check_on_ap_transaction', SELF.datev_check_on_ap_transaction) %] + [% 'Perform check when an ap transaction is posted?' | $T8 %] + + + [% 'Check on gl transaction' | $T8 %] + [% L.yes_no_tag('datev_check_on_gl_transaction', SELF.datev_check_on_gl_transaction) %] + [% 'Perform check when a gl transaction is posted?' | $T8 %] + + + + + [% 'Warehouse' | $T8 %] -- 2.20.1