Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 43f9b1c5

Von G. Richardson vor mehr als 13 Jahren hinzugefügt

  • ID 43f9b1c512be9bc2199369c2f5accea32b8bd423
  • Vorgänger 45de0008
  • Nachfolger 306fad80

Umstellung von eur zu 3 Variablen in defaults

accounting_method inventory_system profit_determination

Details siehe doc/umstellung_eur.txt

Unterschiede anzeigen:

SL/DB/Helper/PriceTaxCalculator.pm
sub _calculate_assembly_item {
my ($self, $data, $part, $total_qty, $base_factor) = @_;
return 0 if $::lx_office_conf{system}->{eur} || !$data->{is_invoice};
return 0 if $::instance_conf->get_inventory_system eq 'periodic' || !$data->{is_invoice};
foreach my $assembly_entry (@{ $part->assemblies }) {
push @{ $data->{assembly_items}->[-1] }, { part => $assembly_entry->part,
......
_dbg("cpsi tq " . $total_qty);
return 0 if $::lx_office_conf{system}->{eur} || !$data->{is_invoice} || !$total_qty;
return 0 if $::instance_conf->get_inventory_system eq 'periodic' || !$data->{is_invoice} || !$total_qty;
my ($entry);
$base_factor ||= 1;
SL/DB/MetaSetup/Default.pm
sdonumber => { type => 'text' },
ar_paid_accno_id => { type => 'integer' },
id => { type => 'serial', not_null => 1 },
accounting_method => { type => 'text' },
inventory_system => { type => 'text' },
profit_determination => { type => 'text' },
],
primary_key_columns => [ 'id' ],
SL/IR.pm
$form->{"qty_$i"} = $form->parse_amount($myconfig, $form->{"qty_$i"});
$form->{"qty_$i"} *= -1 if $form->{storno};
$form->{"inventory_accno_$i"} = $form->{"expense_accno_$i"} if $::lx_office_conf{system}->{eur};
if ( $::instance_conf->get_inventory_system eq 'periodic') {
# inventory account number is overwritten with expense account number, so
# never book incoming to inventory account but always to expense account
$form->{"inventory_accno_$i"} = $form->{"expense_accno_$i"}
};
# get item baseunit
if (!$item_units{$form->{"id_$i"}}) {
......
# check if we sold the item already and
# make an entry for the expense and inventory
$query =
qq|SELECT i.id, i.qty, i.allocated, i.trans_id,
qq|SELECT i.id, i.qty, i.allocated, i.trans_id, i.base_qty,
p.inventory_accno_id, p.expense_accno_id, a.transdate
FROM invoice i, ar a, parts p
WHERE (i.parts_id = p.id)
......
AND ((i.base_qty + i.allocated) > 0)
AND (i.trans_id = a.id)
ORDER BY transdate|;
# ORDER BY transdate guarantees FIFO
# sold two items without having bought them yet, example result of query:
# id | qty | allocated | trans_id | inventory_accno_id | expense_accno_id | transdate
# ---+-----+-----------+----------+--------------------+------------------+------------
# 9 | 2 | 0 | 9 | 15 | 151 | 2011-01-05
# base_qty + allocated > 0 if article has already been sold but not bought yet
# select qty,allocated,base_qty,sellprice from invoice where trans_id = 9;
# qty | allocated | base_qty | sellprice
# -----+-----------+----------+------------
# 2 | 0 | 2 | 1000.00000
$sth = prepare_execute_query($form, $dbh, $query, conv_i($form->{"id_$i"}));
my $totalqty = $baseqty;
......
my $qty = min $totalqty, ($ref->{base_qty} + $ref->{allocated});
$linetotal = $form->round_amount(($form->{"sellprice_$i"} * $qty) / $basefactor, 2);
if ($ref->{allocated} < 0) {
# we have an entry for it already, adjust amount
$form->update_balance($dbh, "acc_trans", "amount",
qq| (trans_id = $ref->{trans_id})
AND (chart_id = $ref->{inventory_accno_id})
AND (transdate = '$ref->{transdate}')|,
$linetotal);
$form->update_balance($dbh, "acc_trans", "amount",
qq| (trans_id = $ref->{trans_id})
AND (chart_id = $ref->{expense_accno_id})
AND (transdate = '$ref->{transdate}')|,
$linetotal * -1);
} elsif ($linetotal != 0) {
# add entry for inventory, this one is for the sold item
$query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, taxkey) VALUES (?, ?, ?, ?, (SELECT taxkey_id FROM chart WHERE id = ?))|;
@values = ($ref->{trans_id}, $ref->{inventory_accno_id}, $linetotal, $ref->{transdate}, $ref->{inventory_accno_id});
do_query($form, $dbh, $query, @values);
# add expense
$query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, taxkey) VALUES (?, ?, ?, ?, (SELECT taxkey from tax WHERE chart_id = ?))|;
@values = ($ref->{trans_id}, $ref->{expense_accno_id}, ($linetotal * -1), $ref->{transdate}, $ref->{expense_accno_id});
do_query($form, $dbh, $query, @values);
}
if ( $::instance_conf->get_inventory_system eq 'perpetual' ) {
# Warenbestandsbuchungen nur bei Bestandsmethode
if ($ref->{allocated} < 0) {
# we have an entry for it already, adjust amount
$form->update_balance($dbh, "acc_trans", "amount",
qq| (trans_id = $ref->{trans_id})
AND (chart_id = $ref->{inventory_accno_id})
AND (transdate = '$ref->{transdate}')|,
$linetotal);
$form->update_balance($dbh, "acc_trans", "amount",
qq| (trans_id = $ref->{trans_id})
AND (chart_id = $ref->{expense_accno_id})
AND (transdate = '$ref->{transdate}')|,
$linetotal * -1);
} elsif ($linetotal != 0) {
# allocated >= 0
# add entry for inventory, this one is for the sold item
$query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, taxkey) VALUES (?, ?, ?, ?, (SELECT taxkey_id FROM chart WHERE id = ?))|;
@values = ($ref->{trans_id}, $ref->{inventory_accno_id}, $linetotal, $ref->{transdate}, $ref->{inventory_accno_id});
do_query($form, $dbh, $query, @values);
# add expense
$query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, taxkey) VALUES (?, ?, ?, ?, (SELECT taxkey from tax WHERE chart_id = ?))|;
@values = ($ref->{trans_id}, $ref->{expense_accno_id}, ($linetotal * -1), $ref->{transdate}, $ref->{expense_accno_id});
do_query($form, $dbh, $query, @values);
}
};
# update allocated for sold item
$form->update_balance($dbh, "invoice", "allocated", qq|id = $ref->{id}|, $qty * -1);
......
$sth->finish();
} else { # if ($form->{"inventory_accno_id_$i"})
# part doesn't have an inventory_accno_id
# lastcost of the part is updated at the end
$linetotal = $form->round_amount($form->{"sellprice_$i"} * $form->{"qty_$i"} / $price_factor, 2);
SL/IS.pm
my $allocated = 0;
my $qty;
# all invoice entries of an example part:
# id | trans_id | base_qty | allocated | sellprice | inventory_accno | income_accno | expense_accno
# ---+----------+----------+-----------+-----------+-----------------+--------------+---------------
# 4 | 4 | -5 | 5 | 20.00000 | 1140 | 4400 | 5400 bought 5 for 20
# 5 | 5 | 4 | -4 | 50.00000 | 1140 | 4400 | 5400 sold 4 for 50
# 6 | 6 | 1 | -1 | 50.00000 | 1140 | 4400 | 5400 sold 1 for 50
# 7 | 7 | -5 | 1 | 20.00000 | 1140 | 4400 | 5400 bought 5 for 20
# 8 | 8 | 1 | -1 | 50.00000 | 1140 | 4400 | 5400 sold 1 for 50
# AND ((i.base_qty + i.allocated) < 0) filters out all but line with id=7, elsewhere i.base_qty + i.allocated has already reached 0
# and all parts have been allocated
# so transaction 8 only sees transaction 7 with unallocated parts and adjusts allocated for that transaction, before allocated was 0
# 7 | 7 | -5 | 1 | 20.00000 | 1140 | 4400 | 5400 bought 5 for 20
# in this example there are still 4 unsold articles
# search all invoice entries for the part in question, adjusting "allocated"
# until the total number of sold parts has been reached
# ORDER BY trans_id ensures FIFO
while (my $ref = $sth->fetchrow_hashref('NAME_lc')) {
if (($qty = (($ref->{base_qty} * -1) - $ref->{allocated})) > $totalqty) {
$qty = $totalqty;
}
# update allocated in invoice
$form->update_balance($dbh, "invoice", "allocated", qq|id = $ref->{id}|, $qty);
# total expenses and inventory
# sellprice is the cost of the item
my $linetotal = $form->round_amount(($ref->{sellprice} * $qty) / ( ($ref->{price_factor} || 1) * ( $basefactor || 1 )), 2);
if (!$::lx_office_conf{system}->{eur}) {
if ( $::instance_conf->get_inventory_system eq 'perpetual' ) {
# Bestandsmethode: when selling parts, deduct their purchase value from the inventory account
$ref->{expense_accno} = ($form->{"expense_accno_$row"}) ? $form->{"expense_accno_$row"} : $ref->{expense_accno};
# add to expense
$form->{amount_cogs}{ $form->{id} }{ $ref->{expense_accno} } += -$linetotal;
SL/InstanceConfiguration.pm
return $self->{currencies} ? @{ $self->{currencies} } : ();
}
sub get_accounting_method {
my ($self) = @_;
return $self->{data}->{accounting_method};
}
sub get_inventory_system {
my ($self) = @_;
return $self->{data}->{inventory_system};
}
sub get_profit_determination {
my ($self) = @_;
return $self->{data}->{profit_determination};
}
1;
__END__
......
Returns the default currency or undef if no currency has been
configured.
=item C<get_accounting_method>
Returns the default accounting method, accrual or cash
=item C<get_inventory_system>
Returns the default inventory system, perpetual or periodic
=item C<get_profit_determination>
Returns the default profit determination method, balance or income
=back
=head1 BUGS
SL/User.pm
$query = "UPDATE defaults SET coa = ?";
do_query($form, $dbh, $query, $form->{chart});
$query = "UPDATE defaults SET accounting_method = ?";
do_query($form, $dbh, $query, $form->{accounting_method});
$query = "UPDATE defaults SET profit_determination = ?";
do_query($form, $dbh, $query, $form->{profit_determination});
$query = "UPDATE defaults SET inventory_system = ?";
do_query($form, $dbh, $query, $form->{inventory_system});
$dbh->disconnect;
bin/mozilla/admin.pl
}
closedir SQLDIR;
$form->{ACCOUNTING_METHODS} = [];
foreach my $item ( qw(accrual cash) ) {
push @{ $form->{ACCOUNTING_METHODS} }, { "name" => $item,
"selected" => $item eq "cash" };
};
$form->{INVENTORY_SYSTEMS} = [];
foreach my $item ( qw(perpetual periodic) ) {
push @{ $form->{INVENTORY_SYSTEMS} }, { "name" => $item,
"selected" => $item eq "periodic" };
};
$form->{PROFIT_DETERMINATIONS} = [];
foreach my $item ( qw(balance income) ) {
push @{ $form->{PROFIT_DETERMINATIONS} }, { "name" => $item,
"selected" => $item eq "income" };
};
my $default_charset = $::lx_office_conf{system}->{dbcharset};
$default_charset ||= Common::DEFAULT_CHARSET;
bin/mozilla/am.pl
use CGI::Ajax;
use CGI;
use Data::Dumper;
require "bin/mozilla/common.pl";
use strict;
......
}
my $linkaccounts;
if (!$::lx_office_conf{system}->{eur}) {
if ( $::instance_conf->get_inventory_system eq 'perpetual' ) { # was !$::lx_office_conf{system}->{eur}) {
$linkaccounts = qq|
<tr>
<th align=right>| . $locale->text('Inventory') . qq|</th>
<td><select name=inventory_accno_id>$form->{selectIC}</select></td>
<input name=selectIC type=hidden value="$form->{selectIC}">
</tr>|;
} else {
} elsif ( $::instance_conf->get_inventory_system eq 'periodic' ) {
# don't allow choice of inventory accno and don't show that line
$linkaccounts = qq|
<input type=hidden name=inventory_accno_id value=$form->{inventory_accno_id}>|;
}
};
$linkaccounts .= qq|
......
map { $form->{"defaults_${_}"} = $form->{defaults}->{$_} } keys %{ $form->{defaults} };
# EÜR = cash, Bilanzierung = accrual
foreach my $key (keys %{ $form->{IC} }) {
foreach my $accno (sort keys %{ $form->{IC}->{$key} }) {
my $array = "ACCNOS_" . uc($key);
bin/mozilla/ca.pl
$form->{title} = $locale->text('Chart of Accounts');
if ($::lx_office_conf{system}->{eur}) {
if ( $::instance_conf->get_accounting_method eq 'cash' ) {
# $form->{method} can probably be made redundant now that we have get_accounting_method
$form->{method} = "cash";
}
......
<td colspan=3><select name=department>$form->{selectdepartment}</select></td>
</tr>
| if $form->{selectdepartment};
my $accrual = $::lx_office_conf{system}->{eur} ? "" : "checked";
my $cash = $::lx_office_conf{system}->{eur} ? "checked" : "";
my $accrual = $::instance_conf->get_accounting_method eq 'cash' ? "" : "checked";
my $cash = $::instance_conf->get_accounting_method eq 'cash' ? "checked" : "";
my $name_1 = "fromdate";
my $id_1 = "fromdate";
......
$form->{description} =~ s/\"/&quot;/g;
my $eur = $::lx_office_conf{system}->{eur};
my $eur = $::instance_conf->get_accounting_method eq 'cash' ? 1 : 0;
print qq|
<body onLoad="$onload">
bin/mozilla/ic.pl
$auth->assert('part_service_assembly_edit');
$form->{eur} = $::lx_office_conf{system}->{eur}; # config dumps into namespace - yuck
# what does eur set here? why is it in namespace?
# call of get_accounting_method preserves format of $form->{eur}, which expects 1 or 0
$form->{eur} = $::instance_conf->get_accounting_method eq 'cash' ? 1 : 0; # config dumps into namespace - yuck
$form->{pg_keys} = sub { "$_[0]->{partsgroup}--$_[0]->{id}" };
$form->{description_area} = ($form->{rows} = $form->numtextrows($form->{description}, 40)) > 1;
$form->{notes_rows} = max 4, $form->numtextrows($form->{notes}, 40), $form->numtextrows($form->{formel}, 40);
bin/mozilla/rp.pl
$form->{title} = $locale->text($title{ $form->{report} });
my $accrual = $::lx_office_conf{system}->{eur} ? "" : "checked";
my $cash = $::lx_office_conf{system}->{eur} ? "checked" : "";
my $accrual = $::instance_conf->get_accounting_method eq 'cash' ? "" : "checked";
my $cash = $::instance_conf->get_accounting_method eq 'cash' ? "checked" : "";
my $year = (localtime)[5] + 1900;
doc/changelog
# Veränderungen von Lx-Office ERP #
###################################
- Umstellung der Variablen eur in lx_office.conf zu drei neuen Variablen in
Tabelle defaults, zur Einstellung von Gewinnermittlungsart, Versteuerungsart
und Warenbuchungsmethode. Siehe Datei doc/umstellung_eur.txt
2011-06-15 - Release 2.6.3
Größere neue Features:
doc/umstellung_eur.txt
Anstelle des Parameters eur in lx_office.conf werden drei neue Parameter
eingeführt, die in defaults bereitgehalten werden, und damit mandantenabhängig
konfiguriert werden können.
Die drei Parameter regeln Gewinnermittlungsart, Versteuerungsart und
Warenbuchungsmethode:
profit_determination (Gewinnermittlung)
* balance (Betriebsvermögensvergleich/Bilanzierung)
* income (Einnahmen-Überschuß-Rechnung)
accounting_method (Versteuerungsart)
* accrual (Sollversteuerung)
* cash (Istversteuerung)
inventory_system (Warenbuchungsmethode)
* perpetual (Bestandsmethode)
* periodic (Aufwandsmethode)
Beim Anlegen eines neuen Mandanten können diese Optionen nun unabhängig
voneinander eingestellt werden.
Beim Upgrade bestehender Mandanten wird eur ausgelesen und die Variablen werden
so gesetzt, daß sich an der Funktionalität nichts ändert.
Bisher galt:
eur = 1: cash + periodic + income
eur = 0: accrual + perpetual + balance
Die aktuelle Konfiguration wird unter Nummernkreise und Standardkonten unter
dem neuen Punkt "Einstellungen" angezeigt (read-only).
Für die Umstellung eines bestehenden Mandanten gibt es an der Oberfläche
derzeit keine Möglichkeit (gab es aber vorher auch nicht).
Die Konfiguration "eur" unter [system] in lx_office.conf wird nun nicht mehr
benötigt und kann aus der Konfigurationsdatei gelöscht werden (dies muß manuell
geschehen).
TODO:
* bei bestimmten Berichten kann man derzeit noch inviduell einstellen, ob man
nach Ist- oder Sollversteuerung auswertet, und es werden im Code Variablen
wie $accrual oder $cash gesetzt. Diese Codestellen wurden noch nicht
angefasst, sondern nur die wo bisher $::lx_office_conf{system}->{eur}
ausgewertet wurde.
* Hilfetext beim Neuanlegen eines Mandanten, was die Optionen bedeuten, z.B.
mit zwei Standardfällen
locale/de/all
'Account saved!' => 'Konto gespeichert!',
'Accounting Group deleted!' => 'Buchungsgruppe gel&ouml;scht!',
'Accounting Group saved!' => 'Buchungsgruppe gespeichert!',
'Accounting method' => 'Versteuerungsart',
'Accrual' => 'Bilanzierung',
'Active' => 'Aktiv',
'Active?' => 'Aktiviert?',
......
'Company' => 'Firma',
'Company Name' => 'Firmenname',
'Compare to' => 'Gegenüberstellen zu',
'Configuration' => 'Einstellungen',
'Configuration of individual TODO items' => 'Konfiguration f&uuml;r die einzelnen Aufgabenlistenpunkte',
'Configure' => 'Konfigurieren',
'Confirm' => 'Best&auml;tigen',
......
'EAN-Code' => 'EAN-Code',
'EB-Wert' => 'EB-Wert',
'EK' => 'EK',
'EK-Preis' => '',
'ELSE' => 'Zusatz',
'ELSTER Export (Taxbird)' => 'ELSTER-Export nach Taxbird',
'ELSTER Export (Winston)' => 'ELSTER Export nach Winston',
......
'Include in Report' => 'In Bericht aufnehmen',
'Include in drop-down menus' => 'In Aufklappmenü aufnehmen',
'Includeable in reports' => 'In Berichten anzeigbar',
'income' => 'Einnahmen-/Überschussrechnung',
'Income Statement' => 'GuV',
'Income accno' => 'Erl&ouml;skonto',
'Incoming Payments' => 'Zahlungseingänge',
......
'Inventory Account' => 'Warenbestand',
'Inventory quantity must be zero before you can set this assembly obsolete!' => 'Bevor dieses Erzeugnis als ungültig markiert werden kann, muß das Inventar auf Null sein!',
'Inventory quantity must be zero before you can set this part obsolete!' => 'Bevor diese Ware als ungültig markiert werden kann, muß das Inventar Null sein!',
'Inventory system' => 'Warenbuchungsmethode',
'Invno.' => 'Rg. Nr.',
'Invnumber' => 'Rechnungsnummer',
'Invnumber missing!' => 'Rechnungsnummer fehlt!',
......
'POSTED' => 'Gebucht',
'POSTED AS NEW' => 'Als neu gebucht',
'PRINTED' => 'Gedruckt',
'Packing List' => '',
'Packing List Date missing!' => '',
'Packing List Number missing!' => '',
'Packing Lists' => 'Lieferschein',
'Page #1/#2' => 'Seite #1/#2',
'Paid' => 'bezahlt',
......
'Per. Inv.' => 'Wied. Rech.',
'Period' => 'Zeitraum',
'Period:' => 'Zeitraum:',
'periodic' => 'Aufwandsmethode',
'Periodic Invoices' => 'Wiederkehrende Rechnungen',
'Periodic invoices active' => 'Wiederkehrende Rechnungen aktiv',
'Periodic invoices inactive' => 'Wiederkehrende Rechnungen inaktiv',
'Periodicity' => 'Periodizität',
'perpetual' => 'Bestandsmethode',
'Personal settings' => 'Pers&ouml;nliche Einstellungen',
'Pg Database Administration' => 'Datenbankadministration',
'Phone' => 'Telefon',
......
'Produce Assembly' => 'Erzeugnis fertigen',
'Productivity' => 'Produktivität',
'Profit Center' => 'Erfolgsbereich',
'Profit determination' => 'Gewinnermittlung',
'Proforma Invoice' => 'Proformarechnung',
'Program' => 'Programm',
'Project' => 'Projekt',
......
'Storno' => 'Storno',
'Storno (one letter abbreviation)' => 'S',
'Storno Invoice' => 'Stornorechnung',
'Storno Packing List' => '',
'Street' => 'Straße',
'Stylesheet' => 'Stilvorlage',
'Subject' => 'Betreff',
......
'[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',
......
'as at' => 'zum Stand',
'assembly_list' => 'erzeugnisliste',
'back' => 'zurück',
'balance' => 'Betriebsvermögensvergleich',
'bank_collection_payment_list_#1' => 'bankeinzugszahlungsliste_#1',
'bank_transfer_payment_list_#1' => 'ueberweisungszahlungsliste_#1',
'bankaccounts' => 'Bankkonten',
......
'bin_list' => 'Lagerliste',
'bis' => 'bis',
'button' => '?',
'cash' => 'E/Ü-Rechnung (Ist-Versteuerung)',
'cash' => 'Ist-Versteuerung',
'chargenumber #1' => 'Chargennummer #1',
'chart_of_accounts' => 'kontenuebersicht',
'choice' => 'auswählen',
locale/en/all
'Account saved!' => '',
'Accounting Group deleted!' => '',
'Accounting Group saved!' => '',
'Accounting method' => '',
'Accrual' => '',
'Active' => '',
'Active?' => '',
......
'Company' => '',
'Company Name' => '',
'Compare to' => '',
'Configuration' => '',
'Configuration of individual TODO items' => '',
'Configure' => '',
'Confirm' => '',
......
'Include in Report' => '',
'Include in drop-down menus' => '',
'Includeable in reports' => '',
'income' => 'Income statement',
'Income Statement' => '',
'Income accno' => '',
'Incoming Payments' => '',
......
'Inventory Account' => '',
'Inventory quantity must be zero before you can set this assembly obsolete!' => '',
'Inventory quantity must be zero before you can set this part obsolete!' => '',
'Inventory system' => '',
'Invno.' => '',
'Invnumber' => '',
'Invnumber missing!' => '',
......
'Per. Inv.' => '',
'Period' => '',
'Period:' => '',
'periodic' => '',
'Periodic Invoices' => '',
'Periodic invoices active' => '',
'Periodic invoices inactive' => '',
'Periodicity' => '',
'perpetual:' => '',
'Personal settings' => '',
'Pg Database Administration' => '',
'Phone' => '',
......
'Produce Assembly' => '',
'Productivity' => '',
'Profit Center' => '',
'Profit determination' => '',
'Proforma Invoice' => '',
'Program' => '',
'Project' => '',
......
'bankaccounts' => '',
'banktransfers' => '',
'bestbefore #1' => '',
'balance' => '',
'bin_list' => '',
'bis' => '',
'button' => '',
sql/Pg-upgrade2/umstellung_eur.pl
# @tag: umstellung_eur
# @description: Variable eur umstellen: bitte doc/umstellung_eur.txt lesen
# @depends: units_id
# @charset: utf-8
# this script relies on $eur still being set in lx_office.conf, and the
# variable available in $::lx_office_conf{system}->{eur}
# better @depends would be release_2_6_3
use utf8;
#use strict;
use Data::Dumper;
die("This script cannot be run from the command line.") unless ($main::form);
sub mydberror {
my ($msg) = @_;
die($dbup_locale->text("Database update error:") .
"<br>$msg<br>" . $DBI::errstr);
}
sub do_query {
my ($query, $may_fail) = @_;
if (!$dbh->do($query)) {
mydberror($query) unless ($may_fail);
$dbh->rollback();
$dbh->begin_work();
}
}
sub do_update {
# check if accounting_method has already been set (new database), if so return
# only set variables according to eur for update of existing database
foreach my $column (qw(accounting_method inventory_system profit_determination)) {
# this query will fail if columns already exist (new database)
do_query(qq|ALTER TABLE defaults ADD COLUMN ${column} TEXT|, 1);
}
my $accounting_method;
my $inventory_system;
my $profit_determination;
# check current configuration and set default variables accordingly, so that
# Lx-Office behaviour isn't changed by this update
if ($::lx_office_conf{system}->{eur} == 0 ) {
$accounting_method = 'accrual';
$inventory_system = 'perpetual';
$profit_determination = 'balance';
} elsif ( $::lx_office_conf{system}->{eur} == 1 ) {
$accounting_method = 'cash';
$inventory_system = 'periodic';
$profit_determination = 'income';
} else {
die "illegal configuration of eur, must be 0 or 1, not " . $::lx_office_conf{system}->{eur} . "\n";
# or maybe just return 1, dont do anything, because we assume everything is
# already set, or has maybe already been deleted
};
# only set parameters if they haven't already been set (this in only the case
# when upgrading)
my $update_eur = "UPDATE defaults set accounting_method = '$accounting_method' where accounting_method is null;" .
"UPDATE defaults set inventory_system = '$inventory_system' where inventory_system is null; " .
"UPDATE defaults set profit_determination = '$profit_determination' where profit_determination is null;";
do_query($update_eur);
return 1;
}
return do_update();
sql/lx-office.sql
itime timestamp without time zone DEFAULT now(),
mtime timestamp without time zone,
rmanumber text,
cnnumber text
cnnumber text,
accounting_method text,
inventory_system text,
profit_determination text
);
templates/webpages/admin/create_dataset.html
</td>
</tr>
<tr>
<th valign="top" align="right" nowrap>[% 'Accounting method' | $T8 %]</th>
<td>
<select name="accounting_method">
[% FOREACH row = ACCOUNTING_METHODS %]<option value=[% HTML.escape(row.name) %] [% IF row.selected %]selected[% END %]>[% HTML.escape(row.name) | $T8 %]</option>[% END %]
</select>
</td>
</tr>
<tr>
<th valign="top" align="right" nowrap>[% 'Inventory system' | $T8 %]</th>
<td>
<select name="inventory_system">
[% FOREACH row = INVENTORY_SYSTEMS %]<option value=[% HTML.escape(row.name) %] [% IF row.selected %]selected[% END %]>[% HTML.escape(row.name) | $T8 %]</option>[% END %]
</select>
</td>
</tr>
<tr>
<th valign="top" align="right" nowrap>[% 'Profit determination' | $T8 %]</th>
<td>
<select name="profit_determination">
[% FOREACH row = PROFIT_DETERMINATIONS %]<option value=[% HTML.escape(row.name) %] [% IF row.selected %]selected[% END %]>[% HTML.escape(row.name) | $T8 %]</option>[% END %]
</select>
</td>
</tr>
</table>
<input type="hidden" name="dbdriver" value="[% HTML.escape(dbdriver) %]">
templates/webpages/am/edit_defaults.html
</td>
</tr>
<tr class="listheading">
<th colspan="4">[% 'Configuration' | $T8 %]</th>
</tr>
<tr>
<th align="right">[% 'Accounting method' | $T8 %] </th>
<td colspan="3"><input name="accounting_method" size="20" readonly="readonly" value="[% HTML.escape(defaults_accounting_method) | $T8 %]"></td>
</tr>
<tr>
<th align="right">[% 'Inventory system' | $T8 %] </th>
<td colspan="3"><input name="inventory_system" size="20" readonly="readonly" value="[% HTML.escape(defaults_inventory_system) | $T8 %]"></td>
</tr>
<tr>
<th align="right">[% 'Profit determination' | $T8 %] </th>
<td colspan="3"><input name="profit_determination" size="20" readonly="readonly" value="[% HTML.escape(defaults_profit_determination) | $T8 %]"></td>
</tr>
<tr>
<th align="right">[% 'Chart of accounts' | $T8 %] </th>
<td colspan="3"><input name="coa" size="20" readonly="readonly" value="[% HTML.escape(defaults_coa) | $T8 %]"></td>
</tr>
</table>
</p>

Auch abrufbar als: Unified diff