From: Moritz Bunkus
Date: Wed, 12 Jan 2011 13:40:44 +0000 (+0100)
Subject: Bearbeiten der Konfiguration für wiederkehrende Rechnungen implementiert
X-Git-Tag: release-2.6.3~61^2~7^2~1^2~2^2~103
X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=92331b8e3417f4a28db17f7af1b8154e985c4da1;p=kivitendo-erp.git
Bearbeiten der Konfiguration für wiederkehrende Rechnungen implementiert
Zzgl. der Suchfunktionserweiterung bei Aufträgen
---
diff --git a/SL/Form.pm b/SL/Form.pm
index f0ad1a17b..2dcd31f7c 100644
--- a/SL/Form.pm
+++ b/SL/Form.pm
@@ -48,6 +48,7 @@ use SL::Auth;
use SL::Auth::DB;
use SL::Auth::LDAP;
use SL::AM;
+use SL::DB;
use SL::Common;
use SL::DBUtils;
use SL::Mailer;
@@ -1580,7 +1581,7 @@ sub get_standard_dbh {
undef $standard_dbh;
}
- $standard_dbh ||= $self->dbconnect_noauto($myconfig);
+ $standard_dbh ||= SL::DB::create->dbh;
$main::lxdebug->leave_sub(2);
diff --git a/SL/OE.pm b/SL/OE.pm
index 677a78b39..996262005 100644
--- a/SL/OE.pm
+++ b/SL/OE.pm
@@ -35,9 +35,12 @@
package OE;
use List::Util qw(max first);
+use YAML;
+
use SL::AM;
use SL::Common;
use SL::CVar;
+use SL::DB::PeriodicInvoicesConfig;
use SL::DBUtils;
use SL::IC;
@@ -58,11 +61,17 @@ sub transactions {
my @values;
my $where;
+ my ($periodic_invoices_columns, $periodic_invoices_joins);
+
my $rate = ($form->{vc} eq 'customer') ? 'buy' : 'sell';
if ($form->{type} =~ /_quotation$/) {
$quotation = '1';
$ordnumber = 'quonumber';
+
+ } elsif ($form->{type} eq 'sales_order') {
+ $periodic_invoices_columns = qq| , COALESCE(pcfg.active, 'f') AS periodic_invoices |;
+ $periodic_invoices_joins = qq| LEFT JOIN periodic_invoices_configs pcfg ON (o.id = pcfg.oe_id) |;
}
my $vc = $form->{vc} eq "customer" ? "customer" : "vendor";
@@ -77,6 +86,7 @@ sub transactions {
qq| pr.projectnumber AS globalprojectnumber, | .
qq| e.name AS employee, s.name AS salesman, | .
qq| ct.${vc}number AS vcnumber, ct.country, ct.ustid | .
+ $periodic_invoices_columns .
qq|FROM oe o | .
qq|JOIN $vc ct ON (o.${vc}_id = ct.id) | .
qq|LEFT JOIN employee e ON (o.employee_id = e.id) | .
@@ -84,6 +94,7 @@ sub transactions {
qq|LEFT JOIN exchangerate ex ON (ex.curr = o.curr | .
qq| AND ex.transdate = o.transdate) | .
qq|LEFT JOIN project pr ON (o.globalproject_id = pr.id) | .
+ qq|$periodic_invoices_joins | .
qq|WHERE (o.quotation = ?) |;
push(@values, $quotation);
@@ -178,6 +189,11 @@ SQL
push(@values, '%' . $form->{transaction_description} . '%');
}
+ if ($form->{periodic_invoices_active} ne $form->{periodic_invoices_inactive}) {
+ my $not = 'NOT' if ($form->{periodic_invoices_inactive});
+ $query .= qq| AND ${not} COALESCE(pcfg.active, 'f')|;
+ }
+
my $sortdir = !defined $form->{sortdir} ? 'ASC' : $form->{sortdir} ? 'ASC' : 'DESC';
my $sortorder = join(', ', map { "${_} ${sortdir} " } ("o.id", $form->sort_columns("transdate", $ordnumber, "name")));
my %allowed_sort_columns = (
@@ -259,7 +275,7 @@ sub save {
my ($self, $myconfig, $form) = @_;
# connect to database, turn off autocommit
- my $dbh = $form->dbconnect_noauto($myconfig);
+ my $dbh = $form->get_standard_dbh;
my ($query, @values, $sth, $null);
my $exchangerate = 0;
@@ -543,19 +559,36 @@ sub save {
}
}
+ $self->save_periodic_invoices_config(dbh => $dbh,
+ oe_id => $form->{id},
+ config_yaml => $form->{periodic_invoices_config})
+ if ($form->{type} eq 'sales_order');
+
$form->{saved_xyznumber} = $form->{$form->{type} =~ /_quotation$/ ?
"quonumber" : "ordnumber"};
Common::webdav_folder($form) if ($main::webdav);
my $rc = $dbh->commit;
- $dbh->disconnect;
$main::lxdebug->leave_sub();
return $rc;
}
+sub save_periodic_invoices_config {
+ my ($self, %params) = @_;
+
+ return if !$params{oe_id};
+
+ my $config = $params{config_yaml} ? YAML::Load($params{config_yaml}) : undef;
+ return if 'HASH' ne ref $config;
+
+ my $obj = SL::DB::Manager::PeriodicInvoicesConfig->find_by(oe_id => $params{oe_id})
+ || SL::DB::PeriodicInvoicesConfig->new(oe_id => $params{oe_id});
+ $obj->update_attributes(%{ $config });
+}
+
sub _close_quotations_rfqs {
$main::lxdebug->enter_sub();
@@ -628,6 +661,10 @@ sub delete {
# delete-values
@values = (conv_i($form->{id}));
+ # periodic invoices and their configuration
+ do_query($form, $dbh, qq|DELETE FROM periodic_invoices WHERE config_id IN (SELECT id FROM periodic_invoices_configs WHERE oe_id = ?)|, @values);
+ do_query($form, $dbh, qq|DELETE FROM periodic_invoices_configs WHERE oe_id = ?|, @values);
+
# delete status entries
$query = qq|DELETE FROM status | .
qq|WHERE trans_id = ?|;
@@ -928,6 +965,14 @@ sub retrieve {
}
$sth->finish;
+ delete $form->{periodic_invoices_config};
+ if ($form->{id} && ($form->{type} eq 'sales_order')) {
+ $query = qq|SELECT periodicity, start_date, print, printer_id, copies, active, ar_chart_id FROM periodic_invoices_configs WHERE oe_id = ? LIMIT 1|;
+ $ref = selectfirst_hashref_query($form, $dbh, $query, conv_i($form->{id}));
+
+ $form->{periodic_invoices_config} = YAML::Dump($ref) if ($ref);
+ }
+
} else {
# get last name used
@@ -941,7 +986,6 @@ sub retrieve {
Common::webdav_folder($form) if ($main::webdav);
my $rc = $dbh->commit;
- $dbh->disconnect;
$main::lxdebug->leave_sub();
diff --git a/bin/mozilla/oe.pl b/bin/mozilla/oe.pl
index b7d86538c..20206d6b3 100644
--- a/bin/mozilla/oe.pl
+++ b/bin/mozilla/oe.pl
@@ -41,6 +41,7 @@ use SL::IS;
use SL::MoreCommon qw(ary_diff);
use SL::PE;
use SL::ReportGenerator;
+use List::MoreUtils qw(any none);
use List::Util qw(max reduce sum);
use Data::Dumper;
@@ -396,6 +397,16 @@ sub form_header {
$onload .= qq|;setupPoints('|. $myconfig{numberformat} .qq|', '|. $locale->text("wrongformat") .qq|')|;
$TMPL_VAR{onload} = $onload;
+ if ($form->{type} eq 'sales_order') {
+ if (!$form->{periodic_invoices_config}) {
+ $form->{periodic_invoices_status} = $locale->text('not configured');
+
+ } else {
+ my $config = YAML::Load($form->{periodic_invoices_config});
+ $form->{periodic_invoices_status} = $config->{active} ? $locale->text('active') : $locale->text('inactive');
+ }
+ }
+
$form->{javascript} .= qq||;
$form->{javascript} .= qq||;
$form->{javascript} .= qq||;
@@ -747,7 +758,8 @@ sub orders {
"salesman",
"shipvia", "globalprojectnumber",
"transaction_description", "open",
- "delivered", "marge_total", "marge_percent",
+ "delivered", "periodic_invoices",
+ "marge_total", "marge_percent",
"vcnumber", "ustid",
"country",
);
@@ -758,8 +770,9 @@ sub orders {
unshift @columns, "ids";
}
- $form->{l_open} = $form->{l_closed} = "Y" if ($form->{open} && $form->{closed});
- $form->{l_delivered} = "Y" if ($form->{delivered} && $form->{notdelivered});
+ $form->{l_open} = $form->{l_closed} = "Y" if ($form->{open} && $form->{closed});
+ $form->{l_delivered} = "Y" if ($form->{delivered} && $form->{notdelivered});
+ $form->{l_periodic_invoices} = "Y" if ($form->{periodic_invoices_active} && $form->{periodic_invoices_inactive});
my $attachment_basename;
if ($form->{vc} eq 'vendor') {
@@ -786,7 +799,7 @@ sub orders {
my @hidden_variables = map { "l_${_}" } @columns;
push @hidden_variables, "l_subtotal", $form->{vc}, qw(l_closed l_notdelivered open closed delivered notdelivered ordnumber quonumber
transaction_description transdatefrom transdateto type vc employee_id salesman_id
- reqdatefrom reqdateto projectnumber project_id);
+ reqdatefrom reqdateto projectnumber project_id periodic_invoices_active periodic_invoices_inactive);
my $href = build_std_url('action=orders', grep { $form->{$_} } @hidden_variables);
@@ -814,6 +827,7 @@ sub orders {
'vcnumber' => { 'text' => $form->{vc} eq 'customer' ? $locale->text('Customer Number') : $locale->text('Vendor Number'), },
'country' => { 'text' => $locale->text('Country'), },
'ustid' => { 'text' => $locale->text('USt-IdNr.'), },
+ 'periodic_invoices' => { 'text' => $locale->text('Per. Inv.'), },
);
foreach my $name (qw(id transdate reqdate quonumber ordnumber name employee salesman shipvia transaction_description)) {
@@ -855,6 +869,7 @@ sub orders {
push @options, $locale->text('Closed') if $form->{closed};
push @options, $locale->text('Delivered') if $form->{delivered};
push @options, $locale->text('Not delivered') if $form->{notdelivered};
+ push @options, $locale->text('Periodic invoices active') if $form->{periodic_invoices_actibe};
$report->set_options('top_info_text' => join("\n", @options),
'raw_top_info_text' => $form->parse_html_template('oe/orders_top'),
@@ -884,9 +899,10 @@ sub orders {
foreach my $oe (@{ $form->{OE} }) {
map { $oe->{$_} *= $oe->{exchangerate} } @subtotal_columns;
- $oe->{tax} = $oe->{amount} - $oe->{netamount};
- $oe->{open} = $oe->{closed} ? $locale->text('No') : $locale->text('Yes');
- $oe->{delivered} = $oe->{delivered} ? $locale->text('Yes') : $locale->text('No');
+ $oe->{tax} = $oe->{amount} - $oe->{netamount};
+ $oe->{open} = $oe->{closed} ? $locale->text('No') : $locale->text('Yes');
+ $oe->{delivered} = $oe->{delivered} ? $locale->text('Yes') : $locale->text('No');
+ $oe->{periodic_invoices} = $oe->{periodic_invoices} ? $locale->text('On') : $locale->text('Off');
map { $subtotals{$_} += $oe->{$_};
$totals{$_} += $oe->{$_} } @subtotal_columns;
@@ -1936,6 +1952,66 @@ sub report_for_todo_list {
return $content;
}
+sub edit_periodic_invoices_config {
+ $::lxdebug->enter_sub();
+
+ $::form->{type} = 'sales_order';
+
+ check_oe_access();
+
+ my $config;
+ $config = YAML::Load($::form->{periodic_invoices_config}) if $::form->{periodic_invoices_config};
+
+ if ('HASH' ne ref $config) {
+ $config = {
+ periodicity => 'm',
+ start_date => $::form->{transdate},
+ active => 1,
+ };
+ }
+
+ $config->{periodicity} = 'm' if none { $_ eq $config->{periodicity} } qw(m q y);
+
+ $::form->get_lists(printers => "ALL_PRINTERS",
+ charts => { key => 'ALL_CHARTS',
+ transdate => 'current_date' });
+
+ $::form->{AR} = [ grep { $_->{link} =~ m/(?:^|:)AR(?::|$)/ } @{ $::form->{ALL_CHARTS} } ];
+ $::form->{title} = $::locale->text('Edit the configuration for periodic invoices');
+
+ $::form->header();
+ print $::form->parse_html_template('oe/edit_periodic_invoices_config', $config);
+
+ $::lxdebug->leave_sub();
+}
+
+sub save_periodic_invoices_config {
+ $::lxdebug->enter_sub();
+
+ $::form->{type} = 'sales_order';
+
+ check_oe_access();
+
+ $::form->isblank('start_date', $::locale->text('The start date is missing.'));
+
+ my $config = { active => $::form->{active} ? 1 : 0,
+ periodicity => (any { $_ eq $::form->{periodicity} } qw(m q y)) ? $::form->{periodicity} : 'm',
+ start_date => $::form->{start_date},
+ print => $::form->{print} ? 1 : 0,
+ printer_id => $::form->{print} ? $::form->{printer_id} * 1 : undef,
+ copies => $::form->{copies} * 1 ? $::form->{copies} : 1,
+ ar_chart_id => $::form->{ar_chart_id} * 1,
+ };
+
+ $::form->{periodic_invoices_config} = YAML::Dump($config);
+
+ $::form->{title} = $::locale->text('Edit the configuration for periodic invoices');
+ $::form->header;
+ print $::form->parse_html_template('oe/save_periodic_invoices_config', $config);
+
+ $::lxdebug->leave_sub();
+}
+
sub dispatcher {
my $form = $main::form;
my $locale = $main::locale;
diff --git a/js/edit_periodic_invoices_config.js b/js/edit_periodic_invoices_config.js
new file mode 100644
index 000000000..7899f3d9b
--- /dev/null
+++ b/js/edit_periodic_invoices_config.js
@@ -0,0 +1,16 @@
+function edit_periodic_invoices_config() {
+ var width = 750;
+ var height = 550;
+ var parm = centerParms(width, height) + ",width=" + width + ",height=" + height + ",status=yes,scrollbars=yes";
+
+ var config = $('#periodic_invoices_config').attr('value');
+ var transdate = $('#transdate').attr('value');
+
+ var url = "oe.pl?" +
+ "action=edit_periodic_invoices_config&" +
+ "periodic_invoices_config=" + encodeURIComponent(config) + "&" +
+ "transdate=" + encodeURIComponent(transdate);
+
+ // alert(url);
+ window.open(url, "_new_generic", parm);
+}
diff --git a/locale/de/all b/locale/de/all
index f00c0307f..d6e500628 100644
--- a/locale/de/all
+++ b/locale/de/all
@@ -382,6 +382,7 @@ $self->{texts} = {
'Company Name' => 'Firmenname',
'Compare to' => 'Gegenüberstellen zu',
'Configuration of individual TODO items' => 'Konfiguration für die einzelnen Aufgabenlistenpunkte',
+ 'Configure' => 'Konfigurieren',
'Confirm' => 'Bestätigen',
'Confirm!' => 'Bestätigen Sie!',
'Confirmation' => 'Auftragsbestätigung',
@@ -675,6 +676,7 @@ $self->{texts} = {
'Edit rights' => 'Rechte bearbeiten',
'Edit templates' => 'Vorlagen bearbeiten',
'Edit the Delivery Order' => 'Lieferschein bearbeiten',
+ 'Edit the configuration for periodic invoices' => 'Konfiguration für wiederkehrende Rechnungen bearbeiten',
'Edit the membership of all users in all groups:' => 'Bearbeiten der Mitgliedschaft aller Benutzer in allen Gruppen:',
'Edit the purchase_order' => 'Bearbeiten des Lieferantenauftrags',
'Edit the request_quotation' => 'Bearbeiten der Preisanfrage',
@@ -1198,8 +1200,13 @@ $self->{texts} = {
'Payment posted!' => 'Zahlung gebucht!',
'Payment terms deleted!' => 'Zahlungskonditionen gelöscht!',
'Payments' => 'Zahlungsausgänge',
+ 'Per. Inv.' => 'Wied. Rech.',
'Period' => 'Zeitraum',
'Period:' => 'Zeitraum:',
+ 'Periodic Invoices' => 'Wiederkehrende Rechnungen',
+ 'Periodic invoices active' => 'Wiederkehrende Rechnungen aktiv',
+ 'Periodic invoices inactive' => 'Wiederkehrende Rechnungen inaktiv',
+ 'Periodicity' => 'Periodizität',
'Personal settings' => 'Persönliche Einstellungen',
'Pg Database Administration' => 'Datenbankadministration',
'Phone' => 'Telefon',
@@ -1265,6 +1272,7 @@ $self->{texts} = {
'Pricegroups' => 'Preisgruppen',
'Print' => 'Drucken',
'Print and Post' => 'Drucken und Buchen',
+ 'Print automatically' => 'Automatisch ausdrucken',
'Print dunnings' => 'Mahnungen drucken',
'Print list' => 'Liste ausdrucken',
'Print options' => 'Druckoptionen',
@@ -1500,6 +1508,7 @@ $self->{texts} = {
'Spoolfile' => 'Druckdatei',
'Start Dunning Process' => 'Mahnprozess starten',
'Start analysis' => 'Analyse beginnen',
+ 'Start date' => 'Startdatum',
'Start the correction assistant' => 'Korrekturassistenten starten',
'Startdate_coa' => 'Gültig ab',
'Starting Balance' => 'Eröffnungsbilanzwerte',
@@ -1685,6 +1694,7 @@ $self->{texts} = {
'The selected warehouse is empty.' => 'Das ausgewählte Lager ist leer.',
'The session is invalid or has expired.' => 'Sie sind von Lx-Office abgemeldet.',
'The source warehouse does not contain any bins.' => 'Das Quelllager enthält keine Lagerplätze.',
+ 'The start date is missing.' => 'Das Startdatum fehlt.',
'The subject is missing.' => 'Der Betreff fehlt.',
'The tables for user management and authentication do not exist. They will be created in the next step in the following database:' => 'Die Tabellen zum Speichern der Benutzerdaten und zur Benutzerauthentifizierung wurden nicht gefunden. Sie werden in der folgenden Datenbank angelegt:',
'The tabulator character' => 'Das Tabulator-Symbol',
@@ -1945,6 +1955,7 @@ $self->{texts} = {
'[email]' => '[email]',
'account_description' => 'Beschreibung',
'accrual' => 'Bilanzierung (Soll-Versteuerung)',
+ 'active' => 'aktiv',
'all entries' => 'alle Einträge',
'ap_aging_list' => 'liste_offene_verbindlichkeiten',
'ar_aging_list' => 'liste_offene_forderungen',
@@ -1999,6 +2010,7 @@ $self->{texts} = {
'general_ledger_list' => 'buchungsjournal',
'history' => 'Historie',
'history search engine' => 'Historien Suchmaschine',
+ 'inactive' => 'inaktiv',
'invoice' => 'Rechnung',
'invoice_list' => 'debitorenbuchungsliste',
'lead deleted!' => 'Kundenquelle gelöscht',
@@ -2012,11 +2024,13 @@ $self->{texts} = {
'mark as paid' => 'als bezahlt markieren',
'missing' => 'Fehlbestand',
'month' => 'Monatliche Abgabe',
+ 'monthly' => 'monatlich',
'new Window' => 'neues Fenster',
'no' => 'nein',
'no bestbefore' => 'keine Mindesthaltbarkeit',
'no chargenumber' => 'keine Chargennummer',
'none (pricegroup)' => 'keine',
+ 'not configured' => 'nicht konfiguriert',
'not executed' => 'nicht ausgeführt',
'not transferred in yet' => 'noch nicht eingelagert',
'not transferred out yet' => 'noch nicht ausgelagert',
@@ -2041,6 +2055,7 @@ $self->{texts} = {
'purchase_order' => 'Auftrag',
'purchase_order_list' => 'lieferantenauftragsliste',
'quarter' => 'Vierteljährliche (quartalsweise) Abgabe',
+ 'quarterly' => 'quartalsweise',
'quotation_list' => 'angebotsliste',
'release_material' => 'Materialausgabebe',
'report_generator_dispatch_to is not defined.' => 'report_generator_dispatch_to ist nicht definiert.',
@@ -2086,6 +2101,7 @@ $self->{texts} = {
'warehouse_journal_list' => 'lagerbuchungsliste',
'warehouse_report_list' => 'lagerbestandsliste',
'wrongformat' => 'Falsches Format',
+ 'yearly' => 'jährlich',
'yes' => 'ja',
};
diff --git a/templates/webpages/oe/edit_periodic_invoices_config.html b/templates/webpages/oe/edit_periodic_invoices_config.html
new file mode 100644
index 000000000..dda18f169
--- /dev/null
+++ b/templates/webpages/oe/edit_periodic_invoices_config.html
@@ -0,0 +1,82 @@
+[% USE HTML %]
+[% USE LxERP %]
+[% USE L %]
+
+
+ [% title %]
+
+
+
+ [% L.hidden_tag('action', 'save_periodic_invoices_config') %]
+
+
+ [% L.submit_tag('', LxERP.t8('Close')) %]
+ [% L.submit_tag('', LxERP.t8('Cancel'), onclick => "self.close(); return false;") %]
+
+
+
+
+
+
+