X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=sidebyside;f=bin%2Fmozilla%2Fam.pl;h=7e760c27e9012d2f9f31dd964a6dfbe20656b288;hb=561d4521aa9148dc3523f297afdfea53b263b48d;hp=10ab28005516b843d6012ece3da6dde65ad3d6e5;hpb=99e420aa730ca1d640804e8ce4074d8abb62e927;p=kivitendo-erp.git
diff --git a/bin/mozilla/am.pl b/bin/mozilla/am.pl
index 10ab28005..7e760c27e 100644
--- a/bin/mozilla/am.pl
+++ b/bin/mozilla/am.pl
@@ -42,7 +42,11 @@ use SL::User;
use SL::USTVA;
use SL::Iconv;
use SL::TODO;
-use SL::Printer;
+use SL::DB::Printer;
+use SL::DB::Tax;
+use SL::DB::Language;
+use SL::DB::Default;
+use SL::DBUtils qw(selectall_array_query);
use CGI;
require "bin/mozilla/common.pl";
@@ -85,10 +89,17 @@ sub edit_account {
my $form = $main::form;
my %myconfig = %main::myconfig;
+ my $defaults = SL::DB::Default->get;
$main::auth->assert('config');
$form->{title} = "Edit";
+ $form->{feature_balance} = $defaults->feature_balance;
+ $form->{feature_datev} = $defaults->feature_datev;
+ $form->{feature_erfolgsrechnung} = $defaults->feature_erfolgsrechnung;
+ $form->{feature_eurechnung} = $defaults->feature_eurechnung;
+ $form->{feature_ustva} = $defaults->feature_ustva;
+
AM->get_account(\%myconfig, \%$form);
foreach my $item (split(/:/, $form->{link})) {
@@ -144,7 +155,7 @@ sub account_header {
rate => '',
taxkey_id => '',
pos_ustva => '',
- startdate => '',
+ startdate => $form->{account_exists} ? '' : DateTime->new(year => 1970, month => 1, day => 1)->to_lxoffice,
};
push @{ $form->{ACCOUNT_TAXKEYS} }, $newtaxkey_ref;
@@ -254,6 +265,20 @@ sub account_header {
}
+ my $select_er = q|\n|;
+ my %er = (
+ 1 => "Ertrag",
+ 6 => "Aufwand");
+ foreach my $item (sort({ $a <=> $b } keys(%er))) {
+ my $text = H($::locale->{iconv_utf8}->convert($er{$item}));
+ if ($item == $form->{pos_er}) {
+ $select_er .= qq|\n|;
+ } else {
+ $select_er .= qq|\n|;
+ }
+
+ }
+
my $select_bwa = q|\n|;
my %bwapos = (
@@ -336,7 +361,7 @@ sub account_header {
# account where AR_tax or AP_tax is set are not orphaned if they are used as
# tax-o-matic account
- if ( $form->{id} && !$form->{orphaned} && ($form->{link} =~ m/(AP_tax|AR_tax)/) ) {
+ if ( $form->{id} && $form->{orphaned} && ($form->{link} =~ m/(AP_tax|AR_tax)/) ) {
if (SL::DB::Manager::Tax->find_by(chart_id => $form->{id})) {
$form->{orphaned} = 0;
}
@@ -356,6 +381,7 @@ sub account_header {
select_bwa => $select_bwa,
select_bilanz => $select_bilanz,
select_eur => $select_eur,
+ select_er => $select_er,
};
# Ausgabe des Templates
@@ -394,6 +420,17 @@ sub save_account {
if ($form->{charttype} eq 'A'){
$form->isblank("category", $locale->text('Account Type missing!'));
+
+ my $found_valid_taxkey = 0;
+ foreach my $i (0 .. 10) { # 10 is maximum count of taxkeys in form
+ if ($form->{"taxkey_startdate_$i"} and !$form->{"taxkey_del_$i"}) {
+ $found_valid_taxkey = 1;
+ last;
+ }
+ }
+ if ($found_valid_taxkey == 0) {
+ $form->error($locale->text('A valid taxkey is missing!'));
+ }
}
$form->redirect($locale->text('Account saved!'))
@@ -426,10 +463,6 @@ sub save_as_new_account {
}
$form->{id} = 0;
- if ($form->{"original_accno"} &&
- ($form->{"accno"} eq $form->{"original_accno"})) {
- $form->error($locale->text('Account Number already used!'));
- }
$form->redirect($locale->text('Account saved!'))
if (AM->save_account(\%myconfig, \%$form));
$form->error($locale->text('Cannot save account!'));
@@ -466,7 +499,7 @@ sub list_account {
$ca->{link_edit_account} = $link_edit_account . '&id=' . E($ca->{id});
}
- $form->use_stylesheet("list_accounts.css");
+ $::request->{layout}->use_stylesheet("list_accounts.css");
$form->{title} = $locale->text('Chart of Accounts');
$form->header;
@@ -566,7 +599,7 @@ sub delete_account {
$form->{title} = $locale->text('Delete Account');
foreach my $id (
- qw(inventory_accno_id income_accno_id expense_accno_id fxgain_accno_id fxloss_accno_id)
+ qw(inventory_accno_id income_accno_id expense_accno_id fxgain_accno_id fxloss_accno_id rndgain_accno_id rndloss_accno_id)
) {
if ($form->{id} == $form->{$id}) {
$form->error($locale->text('Cannot delete default account!'));
@@ -741,8 +774,8 @@ sub language_header {
$::form->header;
print $::form->parse_html_template('am/language_header', {
- numberformats => [ '1,000.00', '1000.00', '1.000,00', '1000,00' ],
- dateformats => [ qw(mm-dd-yy mm/dd/yy dd-mm-yy dd/mm/yy dd.mm.yy yyyy-mm-dd) ],
+ numberformats => [ '1,000.00', '1000.00', '1.000,00', '1000,00', "1'000.00" ],
+ dateformats => [ qw(mm/dd/yy dd/mm/yy dd.mm.yy yyyy-mm-dd) ],
});
$::lxdebug->leave_sub;
@@ -781,481 +814,6 @@ sub delete_language {
$main::lxdebug->leave_sub();
}
-
-sub add_buchungsgruppe {
- $main::lxdebug->enter_sub();
-
- my $form = $main::form;
- my %myconfig = %main::myconfig;
- my $locale = $main::locale;
-
- $main::auth->assert('config');
-
- # $locale->text("Add Buchungsgruppe")
- # $locale->text("Edit Buchungsgruppe")
- $form->{title} = "Add";
-
- $form->{callback} = "am.pl?action=add_buchungsgruppe" unless $form->{callback};
-
- AM->get_buchungsgruppe(\%myconfig, \%$form);
- $form->{"inventory_accno_id"} = $form->{"std_inventory_accno_id"};
- for (my $i = 0; 4 > $i; $i++) {
- map({ $form->{"${_}_accno_id_$i"} = $form->{"std_${_}_accno_id"}; }
- qw(income expense));
- }
-
- &buchungsgruppe_header;
- &form_footer;
-
- $main::lxdebug->leave_sub();
-}
-
-sub edit_buchungsgruppe {
- $main::lxdebug->enter_sub();
-
- my $form = $main::form;
- my %myconfig = %main::myconfig;
-
- $main::auth->assert('config');
-
- $form->{title} = "Edit";
-
- AM->get_buchungsgruppe(\%myconfig, \%$form);
-
- &buchungsgruppe_header;
-
- &form_footer;
-
- $main::lxdebug->leave_sub();
-}
-
-sub list_buchungsgruppe {
- $main::lxdebug->enter_sub();
-
- my $form = $main::form;
- my %myconfig = %main::myconfig;
- my $locale = $main::locale;
-
- $main::auth->assert('config');
-
- AM->buchungsgruppe(\%myconfig, \%$form);
-
- $form->{callback} = "am.pl?action=list_buchungsgruppe";
-
- my $callback = $form->escape($form->{callback});
-
- $form->{title} = $locale->text('Buchungsgruppen');
-
- my @column_index = qw(up down description inventory_accno
- income_accno_0 expense_accno_0
- income_accno_1 expense_accno_1
- income_accno_2 expense_accno_2
- income_accno_3 expense_accno_3 );
- my %column_header;
- $column_header{up} =
- qq|
|
- . qq||
- . qq| | |;
- $column_header{down} =
- qq||
- . qq||
- . qq| | |;
- $column_header{description} =
- qq||
- . $locale->text('Description')
- . qq| | |;
- $column_header{inventory_accno} =
- qq||
- . $locale->text('Bestandskonto')
- . qq| | |;
- $column_header{income_accno_0} =
- qq||
- . $locale->text('National Revenues')
- . qq| | |;
- $column_header{expense_accno_0} =
- qq||
- . $locale->text('National Expenses')
- . qq| | |;
- $column_header{income_accno_1} =
- qq||
- . $locale->text('Revenues EU with UStId')
- . qq| | |;
- $column_header{expense_accno_1} =
- qq||
- . $locale->text('Expenses EU with UStId')
- . qq| | |;
- $column_header{income_accno_2} =
- qq||
- . $locale->text('Revenues EU without UStId')
- . qq| | |;
- $column_header{expense_accno_2} =
- qq||
- . $locale->text('Expenses EU without UStId')
- . qq| | |;
- $column_header{income_accno_3} =
- qq||
- . $locale->text('Foreign Revenues')
- . qq| | |;
- $column_header{expense_accno_3} =
- qq||
- . $locale->text('Foreign Expenses')
- . qq| | |;
- $form->header;
-
- print qq|
-
-
-
-
- $form->{title} |
-
-
-
-
-
-
-|;
-
- map { print "$column_header{$_}\n" } @column_index;
-
- print qq|
-
-|;
-
- my $swap_link = qq|am.pl?action=swap_buchungsgruppen&|;
-
- my $row = 0;
- my ($i, %column_data);
- foreach my $ref (@{ $form->{ALL} }) {
-
- $i++;
- $i %= 2;
-
- print qq|
-
-|;
-
- if ($row) {
- my $pref = $form->{ALL}->[$row - 1];
- $column_data{up} =
- qq|| .
- qq|| .
- qq|| .
- qq| | |;
- } else {
- $column_data{up} = qq| | |;
- }
-
- if ($row == (scalar(@{ $form->{ALL} }) - 1)) {
- $column_data{down} = qq| | |;
- } else {
- my $nref = $form->{ALL}->[$row + 1];
- $column_data{down} =
- qq|| .
- qq|| .
- qq|| .
- qq| | |;
- }
-
- $column_data{description} = qq|$ref->{description} | |;
- $column_data{inventory_accno} = qq|$ref->{inventory_accno} | |;
- $column_data{income_accno_0} =
- qq|$ref->{income_accno_0} | |;
- $column_data{expense_accno_0} = qq|$ref->{expense_accno_0} | |;
- $column_data{income_accno_1} =
- qq|$ref->{income_accno_1} | |;
- $column_data{expense_accno_1} = qq|$ref->{expense_accno_1} | |;
- $column_data{income_accno_2} =
- qq|$ref->{income_accno_2} | |;
- $column_data{expense_accno_2} = qq|$ref->{expense_accno_2} | |;
- $column_data{income_accno_3} =
- qq|$ref->{income_accno_3} | |;
- $column_data{expense_accno_3} = qq|$ref->{expense_accno_3} | |;
-
- map { print "$column_data{$_}\n" } @column_index;
-
- print qq|
-
-|;
-
- $row++;
- }
-
- print qq|
-
- |
-
-
-
|
-
-
-
-
-
-
-
-