2 # @description: Variable eur umstellen: bitte in doc/dokumentation.pdf das entsprechende Kapitel zur Konfiguration von EUR lesen
3 # @depends: release_2_6_3
6 # this script relies on $eur still being set in kivitendo.conf, and the
7 # variable available in $::lx_office_conf{system}->{eur}
12 die("This script cannot be run from the command line.") unless ($main::form);
16 die($dbup_locale->text("Database update error:") .
17 "<br>$msg<br>" . $DBI::errstr);
21 my ($query, $may_fail) = @_;
23 if (!$dbh->do($query)) {
24 mydberror($query) unless ($may_fail);
32 # check if accounting_method has already been set (new database), if so return
33 # only set variables according to eur for update of existing database
36 foreach my $column (qw(accounting_method inventory_system profit_determination)) {
37 # this query will fail if columns already exist (new database)
38 do_query(qq|ALTER TABLE defaults ADD COLUMN ${column} TEXT|, 1);
41 my $accounting_method;
43 my $profit_determination;
45 # check current configuration and set default variables accordingly, so that
46 # kivitendo behaviour isn't changed by this update
48 if ($::lx_office_conf{system}->{eur} == 0 ) {
49 $accounting_method = 'accrual';
50 $inventory_system = 'perpetual';
51 $profit_determination = 'balance';
52 } elsif ( $::lx_office_conf{system}->{eur} == 1 ) {
53 $accounting_method = 'cash';
54 $inventory_system = 'periodic';
55 $profit_determination = 'income';
57 die "illegal configuration of eur, must be 0 or 1, not " . $::lx_office_conf{system}->{eur} . "\n";
58 # or maybe just return 1, dont do anything, because we assume everything is
59 # already set, or has maybe already been deleted
62 # only set parameters if they haven't already been set (this in only the case
65 my $update_eur = "UPDATE defaults set accounting_method = '$accounting_method' where accounting_method is null;" .
66 "UPDATE defaults set inventory_system = '$inventory_system' where inventory_system is null; " .
67 "UPDATE defaults set profit_determination = '$profit_determination' where profit_determination is null;";
68 do_query($update_eur);