- my $query = qq|UPDATE defaults SET coa = ?, accounting_method = ?, profit_determination = ?, inventory_system = ?, curr = ?|;
- do_query($form, $dbh, $query, map { $form->{$_} } qw(chart accounting_method profit_determination inventory_system defaultcurrency));
+ $query = qq|UPDATE defaults SET coa = ?|;
+ do_query($form, $dbh, $query, map { $form->{$_} } qw(chart));
+
+ $dbh->disconnect;
+
+ # update new database
+ $self->dbupdate2(form => $form, updater => $dbupdater, database => $form->{db}, silent => 1);
+
+ $dbh = SL::DBConnect->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd}, SL::DBConnect->get_options)
+ or $form->dberror;
+
+ $query = "SELECT * FROM currencies WHERE name = ?";
+ my $curr = selectfirst_hashref_query($form, $dbh, $query, $form->{defaultcurrency});
+ if (!$curr->{id}) {
+ do_query($form, $dbh, "INSERT INTO currencies (name) VALUES (?)", $form->{defaultcurrency});
+ $curr = selectfirst_hashref_query($form, $dbh, $query, $form->{defaultcurrency});
+ }
+
+ $query = qq|UPDATE defaults SET
+ accounting_method = ?,
+ profit_determination = ?,
+ inventory_system = ?,
+ precision = ?,
+ currency_id = ?,
+ feature_balance = ?,
+ feature_datev = ?,
+ feature_erfolgsrechnung = ?,
+ feature_eurechnung = ?,
+ feature_ustva = ?
+ |;
+ do_query($form, $dbh, $query,
+ $form->{accounting_method},
+ $form->{profit_determination},
+ $form->{inventory_system},
+ $form->parse_amount(\%::myconfig, $form->{precision_as_number}),
+ $curr->{id},
+ $form->{feature_balance},
+ $form->{feature_datev},
+ $form->{feature_erfolgsrechnung},
+ $form->{feature_eurechnung},
+ $form->{feature_ustva}
+ );