2 # @description: Variable eur umstellen: bitte doc/umstellung_eur.txt lesen
6 # this script relies on $eur still being set in lx_office.conf, and the
7 # variable available in $::lx_office_conf{system}->{eur}
8 # better @depends would be release_2_6_3
13 die("This script cannot be run from the command line.") unless ($main::form);
17 die($dbup_locale->text("Database update error:") .
18 "<br>$msg<br>" . $DBI::errstr);
22 my ($query, $may_fail) = @_;
24 if (!$dbh->do($query)) {
25 mydberror($query) unless ($may_fail);
33 # check if accounting_method has already been set (new database), if so return
34 # only set variables according to eur for update of existing database
37 foreach my $column (qw(accounting_method inventory_system profit_determination)) {
38 # this query will fail if columns already exist (new database)
39 do_query(qq|ALTER TABLE defaults ADD COLUMN ${column} TEXT|, 1);
42 my $accounting_method;
44 my $profit_determination;
46 # check current configuration and set default variables accordingly, so that
47 # Lx-Office behaviour isn't changed by this update
49 if ($::lx_office_conf{system}->{eur} == 0 ) {
50 $accounting_method = 'accrual';
51 $inventory_system = 'perpetual';
52 $profit_determination = 'balance';
53 } elsif ( $::lx_office_conf{system}->{eur} == 1 ) {
54 $accounting_method = 'cash';
55 $inventory_system = 'periodic';
56 $profit_determination = 'income';
58 die "illegal configuration of eur, must be 0 or 1, not " . $::lx_office_conf{system}->{eur} . "\n";
59 # or maybe just return 1, dont do anything, because we assume everything is
60 # already set, or has maybe already been deleted
63 # only set parameters if they haven't already been set (this in only the case
66 my $update_eur = "UPDATE defaults set accounting_method = '$accounting_method' where accounting_method is null;" .
67 "UPDATE defaults set inventory_system = '$inventory_system' where inventory_system is null; " .
68 "UPDATE defaults set profit_determination = '$profit_determination' where profit_determination is null;";
69 do_query($update_eur);