Revision a9da5102
Von Sven Schöling vor fast 9 Jahren hinzugefügt
SL/DBUpgrade2/Base.pm | ||
---|---|---|
11 | 11 |
use File::Copy (); |
12 | 12 |
use File::Path (); |
13 | 13 |
use List::MoreUtils qw(uniq); |
14 |
use SL::DBUtils qw(selectfirst_hashref_query); |
|
14 | 15 |
use version; |
15 | 16 |
|
16 | 17 |
use Rose::Object::MakeMethods::Generic ( |
... | ... | |
97 | 98 |
croak "File '${src_dir}/$_' does not exist" unless -f "${src_dir}/$_"; |
98 | 99 |
} |
99 | 100 |
|
100 |
return 1 unless my $template_dir = $::instance_conf->reload->get_templates; |
|
101 |
# can't use Rose or InstanceConf here because defaults might not be fully upgraded yet. |
|
102 |
my $defaults = selectfirst_hashref_query($::form, $::form->get_standard_dbh, "SELECT * FROM defaults"); |
|
103 |
return 1 unless my $template_dir = $defaults->{template}; |
|
101 | 104 |
$::lxdebug->message(LXDebug::DEBUG1(), "add_print_templates: template_dir $template_dir"); |
102 | 105 |
|
103 | 106 |
foreach my $src_file (@files) { |
SL/User.pm | ||
---|---|---|
277 | 277 |
|
278 | 278 |
&dbconnect_vars($form, $form->{db}); |
279 | 279 |
|
280 |
# make a shim myconfig so that rose db connections work |
|
281 |
$::myconfig{$_} = $form->{$_} for qw(dbhost dbport dbuser dbpasswd); |
|
282 |
$::myconfig{dbname} = $form->{db}; |
|
283 |
|
|
280 | 284 |
$dbh = SL::DBConnect->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd}, SL::DBConnect->get_options) |
281 | 285 |
or $form->dberror; |
282 | 286 |
|
283 |
my $dbupdater = SL::DBUpgrade2->new(form => $form);
|
|
287 |
my $dbupdater = SL::DBUpgrade2->new(form => $form, return_on_error => 1, silent => 1)->parse_dbupdate_controls;
|
|
284 | 288 |
# create the tables |
285 | 289 |
$dbupdater->process_query($dbh, "sql/lx-office.sql"); |
290 |
$dbupdater->process_query($dbh, "sql/$form->{chart}-chart.sql"); |
|
286 | 291 |
|
287 |
# process update-scripts needed before 1st user-login |
|
288 |
$self->create_schema_info_table($form, $dbh); |
|
289 |
$dbupdater->process_query($dbh, "sql/Pg-upgrade2/defaults_add_precision.sql"); |
|
290 |
$dbh->do("INSERT INTO schema_info (tag, login) VALUES ('defaults_add_precision', 'admin')"); |
|
292 |
$query = qq|UPDATE defaults SET coa = ?|; |
|
293 |
do_query($form, $dbh, $query, map { $form->{$_} } qw(chart)); |
|
291 | 294 |
|
292 |
# load chart of accounts |
|
293 |
$dbupdater->process_query($dbh, "sql/$form->{chart}-chart.sql"); |
|
295 |
$dbh->disconnect; |
|
296 |
|
|
297 |
# update new database |
|
298 |
$self->dbupdate2(form => $form, updater => $dbupdater, database => $form->{db}, silent => 1); |
|
294 | 299 |
|
295 |
$query = qq|UPDATE defaults SET coa = ?, accounting_method = ?, profit_determination = ?, inventory_system = ?, curr = ?, precision = ?|; |
|
296 |
do_query($form, $dbh, $query, map { $form->{$_} } qw(chart accounting_method profit_determination inventory_system defaultcurrency precision countrymode)); |
|
300 |
$dbh = SL::DBConnect->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd}, SL::DBConnect->get_options) |
|
301 |
or $form->dberror; |
|
302 |
|
|
303 |
$query = "SELECT * FROM currencies WHERE name = ?"; |
|
304 |
my $curr = selectfirst_hashref_query($form, $dbh, $query, $form->{defaultcurrency}); |
|
305 |
if (!$curr->{id}) { |
|
306 |
do_query($form, $dbh, "INSERT INTO currencies (name) VALUES (?)", $form->{defaultcurrency}); |
|
307 |
$curr = selectfirst_hashref_query($form, $dbh, $query, $form->{defaultcurrency}); |
|
308 |
} |
|
309 |
|
|
310 |
$query = qq|UPDATE defaults SET accounting_method = ?, profit_determination = ?, inventory_system = ?, precision = ?, currency_id = ?|; |
|
311 |
do_query($form, $dbh, $query, |
|
312 |
$form->{accounting_method}, |
|
313 |
$form->{profit_determination}, |
|
314 |
$form->{inventory_system}, |
|
315 |
$form->parse_amount(\%::myconfig, $form->{precision_as_number}), |
|
316 |
$curr->{id}, |
|
317 |
); |
|
297 | 318 |
|
298 | 319 |
$dbh->disconnect; |
299 | 320 |
|
... | ... | |
385 | 406 |
my $form = $params{form}; |
386 | 407 |
my $dbupdater = $params{updater}; |
387 | 408 |
my $db = $params{database}; |
409 |
my $silent = $params{silent}; |
|
388 | 410 |
|
389 | 411 |
map { $_->{description} = SL::Iconv::convert($_->{charset}, 'UTF-8', $_->{description}) } values %{ $dbupdater->{all_controls} }; |
390 | 412 |
|
391 | 413 |
&dbconnect_vars($form, $db); |
392 | 414 |
|
393 | 415 |
# Flush potentially held database locks. |
394 |
$form->get_standard_dbh->commit; |
|
416 |
# $form->get_standard_dbh->commit;
|
|
395 | 417 |
|
396 | 418 |
my $dbh = SL::DBConnect->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd}, SL::DBConnect->get_options) or $form->dberror; |
397 | 419 |
|
... | ... | |
406 | 428 |
# been applied correctly and if the update has not requested user |
407 | 429 |
# interaction. |
408 | 430 |
$main::lxdebug->message(LXDebug->DEBUG2(), "Applying Update $control->{file}"); |
409 |
print $form->parse_html_template("dbupgrade/upgrade_message2", $control); |
|
431 |
print $form->parse_html_template("dbupgrade/upgrade_message2", $control) unless $silent;
|
|
410 | 432 |
|
411 | 433 |
$dbupdater->process_file($dbh, "sql/Pg-upgrade2/$control->{file}", $control); |
412 | 434 |
} |
sql/Pg-upgrade2/chart_pos_er.sql | ||
---|---|---|
2 | 2 |
-- @description: pos_er Feld in Konten für die Position ind er Erfolgsrechnung |
3 | 3 |
-- @depends: release_3_3_0 |
4 | 4 |
-- @encoding: utf-8 |
5 |
-- @may_fail: 1 |
|
5 | 6 |
|
6 | 7 |
ALTER TABLE chart ADD COLUMN pos_er INTEGER; |
sql/Pg-upgrade2/steuerfilterung.pl | ||
---|---|---|
36 | 36 |
} |
37 | 37 |
|
38 | 38 |
my @well_known_taxes = ( |
39 |
# German SKR03 |
|
39 | 40 |
{ taxkey => 0, rate => 0, taxdescription => qr{keine.*steuer}i, categories => 'ALQCIE' }, |
40 | 41 |
{ taxkey => 1, rate => 0, taxdescription => qr{frei}i, categories => 'ALQCIE' }, |
41 | 42 |
{ taxkey => 2, rate => 0.07, taxdescription => qr{umsatzsteuer}i, categories => 'I' }, |
... | ... | |
56 | 57 |
{ taxkey => 18, rate => 0.07, taxdescription => qr{innergem.*erwerb.*erm}i, categories => 'E' }, |
57 | 58 |
{ taxkey => 19, rate => 0.16, taxdescription => qr{innergem.*erwerb.*voll}i, categories => 'E' }, |
58 | 59 |
{ taxkey => 19, rate => 0.19, taxdescription => qr{innergem.*erwerb.*voll}i, categories => 'E' }, |
59 |
); |
|
60 |
|
|
61 |
# Swiss |
|
62 |
{ taxkey => 2, rate => 0.08, taxdescription => qr{mwst}i, categories => 'I' }, |
|
63 |
{ taxkey => 3, rate => 0.025, taxdescription => qr{mwst}i, categories => 'I' }, |
|
64 |
{ taxkey => 4, rate => 0.08, taxdescription => qr{mwst}i, categories => 'E' }, |
|
65 |
{ taxkey => 5, rate => 0.025, taxdescription => qr{mwst}i, categories => 'E' }, |
|
66 |
{ taxkey => 6, rate => 0.08, taxdescription => qr{mwst}i, categories => 'E' }, |
|
67 |
{ taxkey => 7, rate => 0.025, taxdescription => qr{mwst}i, categories => 'E' }, |
|
68 |
); |
|
60 | 69 |
|
61 | 70 |
$query = qq|SELECT taxkey, taxdescription, rate, id AS tax_id FROM tax order by taxkey, rate;|; |
62 | 71 |
|
sql/Switzerland-deutsch-MWST-2014-chart.sql | ||
---|---|---|
3 | 3 |
-- Korrigiert: November 2015 |
4 | 4 |
-- Grundlage: Revision OR Stand 1.1.2013, insbesondere Art. 957a Abs. 2 |
5 | 5 |
|
6 |
ALTER TABLE chart ADD COLUMN pos_er INTEGER; |
|
7 |
|
|
6 | 8 |
DELETE FROM chart; |
7 | 9 |
|
8 | 10 |
INSERT INTO chart (accno, description, charttype, category, link, gifi_accno, taxkey_id, pos_ustva, pos_bwa, pos_bilanz, pos_er, datevautomatik, valid_from) VALUES |
sql/Switzerland-deutsch-ohneMWST-2014-chart.sql | ||
---|---|---|
3 | 3 |
-- Korrigiert: November 2015 |
4 | 4 |
-- Grundlage: Revision OR Stand 1.1.2013, insbesondere Art. 957a Abs. 2 |
5 | 5 |
|
6 |
ALTER TABLE chart ADD COLUMN pos_er INTEGER; |
|
7 |
|
|
6 | 8 |
DELETE FROM chart; |
7 | 9 |
|
8 | 10 |
INSERT INTO chart (accno, description, charttype, category, link, gifi_accno, taxkey_id, pos_ustva, pos_bwa, pos_bilanz, pos_er, datevautomatik, valid_from) VALUES |
templates/webpages/admin/create_dataset.html | ||
---|---|---|
33 | 33 |
|
34 | 34 |
<tr> |
35 | 35 |
<th align="right" nowrap>[% LxERP.t8('Precision') %]</th> |
36 |
<td>[% L.input_tag('precision', FORM.precision) %]</td>
|
|
36 |
<td>[% L.input_tag('precision_as_number', LxERP.format_amount(FORM.precision, 2)) %]</td>
|
|
37 | 37 |
</tr> |
38 | 38 |
|
39 | 39 |
<tr> |
Auch abrufbar als: Unified diff
swiss: Datenbankupgrades verschoben