my $dbh = $form->dbconnect($myconfig);
my $cv = $form->{db} eq "customer" ? "customer" : "vendor";
+ my $join_records = $form->{l_invnumber} || $form->{l_ordnumber} || $form->{l_quonumber};
my $where = "1 = 1";
my @values;
$form->{sort} = $sortorder;
my $sortdir = !defined $form->{sortdir} ? 'ASC' : $form->{sortdir} ? 'ASC' : 'DESC';
- if ($sortorder !~ /(business|id)/ && 1 >= scalar grep { $form->{$_} } qw(l_ordnumber l_quonumber l_invnumber )) {
+ if ($sortorder !~ /(business|id)/ && !$join_records) {
$sortorder = "lower($sortorder) ${sortdir}";
} else {
$sortorder .= " ${sortdir}";
my $query =
qq|SELECT ct.*, b.description AS business | .
+ (qq|, NULL AS invnumber, NULL AS ordnumber, NULL AS quonumber, NULL AS invid, NULL AS module, NULL AS formtype, NULL AS closed | x!! $join_records) .
qq|FROM $cv ct | .
qq|LEFT JOIN business b ON (ct.business_id = b.id) | .
qq|WHERE $where|;
my @saved_values = @values;
# redo for invoices, orders and quotations
- if ($form->{l_invnumber} || $form->{l_ordnumber} || $form->{l_quonumber}) {
- my ($ar, $union, $module);
- $query = "";
+ if ($join_records) {
+ my $union = "UNION";
if ($form->{l_invnumber}) {
my $ar = $cv eq 'customer' ? 'ar' : 'ap';
my $module = $ar eq 'ar' ? 'is' : 'ir';
-
- $query =
+ push(@values, @saved_values);
+ $query .=
+ qq| UNION | .
qq|SELECT ct.*, b.description AS business, | .
qq| a.invnumber, a.ordnumber, a.quonumber, a.id AS invid, | .
qq| '$module' AS module, 'invoice' AS formtype, | .
qq|JOIN $ar a ON (a.${cv}_id = ct.id) | .
qq|LEFT JOIN business b ON (ct.business_id = b.id) | .
qq|WHERE $where AND (a.invoice = '1')|;
-
- $union = qq|UNION|;
}
if ( $form->{l_ordnumber} ) {
- if ($union eq "UNION") {
- push(@values, @saved_values);
- }
+ push(@values, @saved_values);
$query .=
- qq| $union | .
+ qq| UNION | .
qq|SELECT ct.*, b.description AS business,| .
qq| ' ' AS invnumber, o.ordnumber, o.quonumber, o.id AS invid, | .
qq| 'oe' AS module, 'order' AS formtype, o.closed | .
qq|JOIN oe o ON (o.${cv}_id = ct.id) | .
qq|LEFT JOIN business b ON (ct.business_id = b.id) | .
qq|WHERE $where AND (o.quotation = '0')|;
-
- $union = qq|UNION|;
}
if ( $form->{l_quonumber} ) {
- if ($union eq "UNION") {
- push(@values, @saved_values);
- }
+ push(@values, @saved_values);
$query .=
- qq| $union | .
+ qq| UNION | .
qq|SELECT ct.*, b.description AS business, | .
qq| ' ' AS invnumber, o.ordnumber, o.quonumber, o.id AS invid, | .
qq| 'oe' AS module, 'quotation' AS formtype, o.closed | .
$self->{payment_options} = [ { title => $::locale->text("never"), value => 0 },
{ title => $::locale->text("every time"), value => 1 },
{ title => $::locale->text("on the same day"), value => 2 }, ];
- $self->{accounting_options} = [ { title => $::locale->text("accrual"), value => "accrual" },
+ $self->{accounting_options} = [ { title => $::locale->text("Accrual"), value => "accrual" },
{ title => $::locale->text("cash"), value => "cash" }, ];
$self->{inventory_options} = [ { title => $::locale->text("perpetual"), value => "perpetual" },
{ title => $::locale->text("periodic"), value => "periodic" }, ];
$params{path_suffix} ||= '';
$params{schema} ||= '';
+ $params{path} = "sql/" . $params{dbdriver} . "-upgrade2" . $params{path_suffix};
map { $self->{$_} = $params{$_} } keys %params;
return $self;
}
+sub path {
+ $_[0]{path};
+}
+
sub parse_dbupdate_controls {
$::lxdebug->enter_sub();
local *IN;
my %all_controls;
- my $path = "sql/" . $self->{dbdriver} . "-upgrade2" . $self->{path_suffix};
+ my $path = $self->path;
foreach my $file_name (<$path/*.sql>, <$path/*.pl>) {
next unless (open(IN, $file_name));
} else {
$transdate = $form->{deliverydate};
}
+ } elsif (($form->{type} eq "credit_note") and $form->{deliverydate}) {
+ # if credit_note has a deliverydate, use this instead of invdate
+ # useful for credit_notes of invoices from an old period with different tax
+ # if there is no deliverydate then invdate is used, old default (see next elsif)
+ $transdate = $form->{deliverydate};
} elsif (($form->{type} eq "credit_note") || ($form->{script} eq 'ir.pl')) {
$transdate = $form->{invdate};
} else {
# default language
my $all_languages = SL::DB::Manager::Language->get_all;
-# EÜR = cash, Bilanzierung = accrual
+# cash = IST-Versteuerung, accrual = SOLL-Versteuerung
foreach my $key (keys %{ $form->{IC} }) {
foreach my $accno (sort keys %{ $form->{IC}->{$key} }) {
#html-menu div.s2 { padding-left: 16px }
body { margin: 0 }
+
+@media print {
+ #menuv3, #menuv4, #html-menu, #frame-header, #js-menu { /* items with this class won't print */
+ display: none;
+ }
+ #content.html-menu { margin-left: 0; }
+}
#html-menu div.s2 { padding-left: 16px }
body { margin: 0 }
+
+
+@media print {
+ #menuv3, #menuv4, #html-menu, #frame-header, #js-menu { /* items with this class won't print */
+ display: none;
+ }
+ #content.html-menu { margin-left: 0; }
+}
'Accounting Group deleted!' => 'Buchungsgruppe gelöscht!',
'Accounting Group saved!' => 'Buchungsgruppe gespeichert!',
'Accounting method' => 'Versteuerungsart',
- 'Accrual' => 'Bilanzierung',
+ 'Accrual' => 'Soll-Versteuerung',
'Active' => 'Aktiv',
'Active?' => 'Aktiviert?',
'Add' => 'Erfassen',
'Accounting Group deleted!' => 'Buchungsgruppe gelöscht!',
'Accounting Group saved!' => 'Buchungsgruppe gespeichert!',
'Accounting method' => 'Versteuerungsart',
- 'Accrual' => 'Bilanzierung',
+ 'Accrual' => 'Soll-Versteuerung',
'Active' => 'Aktiv',
'Active?' => 'Aktiviert?',
'Add' => 'Erfassen',
'[email]' => '[email]',
'absolute' => 'absolut',
'account_description' => 'Beschreibung',
- 'accrual' => 'Bilanzierung (Soll-Versteuerung)',
+ 'accrual' => 'Soll-Versteuerung',
'action= not defined!' => 'action= nicht definiert!',
'active' => 'aktiv',
'all entries' => 'alle Einträge',
my ($opt_list, $opt_tree, $opt_rtree, $opt_nodeps, $opt_graphviz, $opt_help);
my ($opt_user, $opt_apply, $opt_applied, $opt_unapplied, $opt_format, $opt_test_utf8);
-my ($opt_dbhost, $opt_dbport, $opt_dbname, $opt_dbuser, $opt_dbpassword);
+my ($opt_dbhost, $opt_dbport, $opt_dbname, $opt_dbuser, $opt_dbpassword, $opt_create, $opt_type);
+my ($opt_description, $opt_encoding, @opt_depends);
our (%myconfig, $form, $user, $auth, $locale, $controls, $dbupgrader);
"\n\n";
}
+sub create_upgrade {
+ my (%params) = @_;
+
+ my $filename = $params{filename};
+ my $dbupgrader = $params{dbupgrader};
+ my $type = $params{type} || '';
+ my $description = $params{description} || '';
+ my $encoding = $params{encoding} || 'utf-8';
+ my @depends = @{ $params{depends} };
+
+ if (!@depends) {
+ my @releases = grep { /^release_/ } keys %$controls;
+ @depends = ((sort @releases)[-1]);
+ }
+
+ my $comment;
+ if ($type eq 'sql') {
+ $comment = '--';
+ } elsif ($type eq 'pl') {
+ $comment = '#';
+ } elsif (!$type) {
+ die 'Error: No --type was given but is required for --create.';
+ } else {
+ die 'Error: Unknown --type. Try "sql" or "pl".';
+ }
+
+ my $full_filename = $dbupgrader->path . '/' . $filename . '.' . $type;
+
+ die "file '$full_filename' already exists, aborting" if -f $full_filename;
+
+
+ open my $fh, ">:encoding($encoding)", $full_filename or die "can't open $full_filename";
+ print $fh "$comment \@tag: $filename\n";
+ print $fh "$comment \@description: $description\n";
+ print $fh "$comment \@depends: @depends\n";
+ print $fh "$comment \@encoding: $encoding\n";
+ close $fh;
+
+ system("\$EDITOR $full_filename");
+ exit 0;
+}
+
sub apply_upgrade {
my $name = shift;
"user=s" => \$opt_user,
"apply=s" => \$opt_apply,
"applied" => \$opt_applied,
+ "create=s" => \$opt_create,
+ "type=s" => \$opt_type,
+ "encoding=s" => \$opt_encoding,
+ "description=s" => \$opt_description,
+ "depends=s" => \@opt_depends,
"unapplied" => \$opt_unapplied,
"test-utf8" => \$opt_test_utf8,
"dbhost:s" => \$opt_dbhost,
dump_graphviz('file_name' => $opt_graphviz,
'format' => $opt_format) if (defined $opt_graphviz);
dump_nodeps() if ($opt_nodeps);
+create_upgrade(filename => $opt_create,
+ dbupgrader => $dbupgrader,
+ type => $opt_type,
+ description => $opt_description,
+ encoding => $opt_encoding,
+ depends => \@opt_depends) if ($opt_create);
if ($opt_user) {
$auth = SL::Auth->new();
dump_unapplied();
}
+
if ($opt_test_utf8) {
$form->error("--test-utf8 used but no database name given with --dbname.") if (!$opt_dbname);
<th align="right" nowrap>[% 'Delivery Order Number' | $T8 %]</th>
<td colspan="3"><input size='11' name="donumber" value="[% HTML.escape(donumber) %]"></td>
</tr>
+[%- END %]
<tr>
<th align="right">[% 'Delivery Date' | $T8 %]</th>
<td>[% L.date_tag('deliverydate', deliverydate, cal_align='BL') %]</td>
</tr>
-[%- END %]
-
<tr>
<th align="right" nowrap>[% 'Order Number' | $T8 %]</th>
<td colspan="3"><input size='11' name="ordnumber" value="[% HTML.escape(ordnumber) %]"></td>
<th align=left>[% 'Method' | $T8 %]</th>
<td colspan=3>
[% L.radio_button_tag('method', value='accrual', checked=accrual, label=LxERP.t8('Accrual')) %]
- [% L.radio_button_tag('method', value='cash', checked=cash, label=LxERP.t8('EUR')) %]
+ [% L.radio_button_tag('method', value='cash', checked=cash, label=LxERP.t8('cash')) %]
</td>
</tr>
[%- END %]