X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=inline;f=bin%2Fmozilla%2Fam.pl;h=d0415618717701f7910e3d82d7067b12620eeaa7;hb=853991311bc6804da985219eb28d86114e359cc6;hp=e24e7c2eb1e5a0b937dff9ec91344199e739a2c6;hpb=2f833a265b6b21799b80724c59456a876ec36ed3;p=kivitendo-erp.git diff --git a/bin/mozilla/am.pl b/bin/mozilla/am.pl index e24e7c2eb..d04156187 100644 --- a/bin/mozilla/am.pl +++ b/bin/mozilla/am.pl @@ -24,7 +24,8 @@ # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +# MA 02110-1335, USA. #====================================================================== # # administration @@ -33,16 +34,25 @@ use utf8; +use List::MoreUtils qw(any); + use SL::Auth; use SL::Auth::PasswordPolicy; use SL::AM; use SL::CA; use SL::Form; +use SL::Helper::Flash; +use SL::Helper::UserPreferences; use SL::User; use SL::USTVA; use SL::Iconv; +use SL::Locale::String qw(t8); 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 conv_dateq); use CGI; require "bin/mozilla/common.pl"; @@ -75,7 +85,6 @@ sub add_account { $form->{callback} = "am.pl?action=list_account" unless $form->{callback}; &account_header; - &form_footer; $main::lxdebug->leave_sub(); } @@ -85,10 +94,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})) { @@ -96,7 +112,6 @@ sub edit_account { } &account_header; - &form_footer; $main::lxdebug->leave_sub(); } @@ -144,7 +159,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; @@ -212,38 +227,7 @@ sub account_header { } my $select_eur = q|\n|; - my %eur = ( - 1 => "Umsatzerlöse", - 2 => "sonstige Erlöse", - 3 => "Privatanteile", - 4 => "Zinserträge", - 5 => "Ausserordentliche Erträge", - 6 => "Vereinnahmte Umsatzst.", - 7 => "Umsatzsteuererstattungen", - 8 => "Wareneingänge", - 9 => "Löhne und Gehälter", - 10 => "Gesetzl. sozialer Aufw.", - 11 => "Mieten", - 12 => "Gas, Strom, Wasser", - 13 => "Instandhaltung", - 14 => "Steuern, Versich., Beiträge", - 15 => "Kfz-Steuern", - 16 => "Kfz-Versicherungen", - 17 => "Sonst. Fahrzeugkosten", - 18 => "Werbe- und Reisekosten", - 19 => "Instandhaltung u. Werkzeuge", - 20 => "Fachzeitschriften, Bücher", - 21 => "Miete für Einrichtungen", - 22 => "Rechts- und Beratungskosten", - 23 => "Bürobedarf, Porto, Telefon", - 24 => "Sonstige Aufwendungen", - 25 => "Abschreibungen auf Anlagever.", - 26 => "Abschreibungen auf GWG", - 27 => "Vorsteuer", - 28 => "Umsatzsteuerzahlungen", - 29 => "Zinsaufwand", - 30 => "Ausserordentlicher Aufwand", - 31 => "Betriebliche Steuern"); + my %eur = %{ AM->get_eur_categories(\%myconfig, $form) }; foreach my $item (sort({ $a <=> $b } keys(%eur))) { my $text = H($::locale->{iconv_utf8}->convert($eur{$item})); if ($item == $form->{pos_eur}) { @@ -254,31 +238,23 @@ 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 = ( - 1 => 'Umsatzerlöse', - 2 => 'Best.Verdg.FE/UE', - 3 => 'Aktiv.Eigenleistung', - 4 => 'Mat./Wareneinkauf', - 5 => 'So.betr.Erlöse', - 10 => 'Personalkosten', - 11 => 'Raumkosten', - 12 => 'Betriebl.Steuern', - 13 => 'Vers./Beiträge', - 14 => 'Kfz.Kosten o.St.', - 15 => 'Werbe-Reisek.', - 16 => 'Kosten Warenabgabe', - 17 => 'Abschreibungen', - 18 => 'Rep./instandhlt.', - 19 => 'Ãbrige Steuern', - 20 => 'Sonst.Kosten', - 30 => 'Zinsauwand', - 31 => 'Sonst.neutr.Aufw.', - 32 => 'Zinserträge', - 33 => 'Sonst.neutr.Ertrag', - 34 => 'Verr.kalk.Kosten', - 35 => 'Steuern Eink.u.Ertr.'); + my %bwapos = %{ AM->get_bwa_categories(\%myconfig, $form) }; foreach my $item (sort({ $a <=> $b } keys %bwapos)) { my $text = H($::locale->{iconv_utf8}->convert($bwapos{$item})); if ($item == $form->{pos_bwa}) { @@ -336,7 +312,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; } @@ -345,6 +321,8 @@ sub account_header { my $ChartTypeIsAccount = ($form->{charttype} eq "A") ? "1":""; my $AccountIsPosted = ($form->{orphaned} ) ? "":"1"; + setup_am_edit_account_action_bar(); + $form->header(); my $parameters_ref = { @@ -356,6 +334,7 @@ sub account_header { select_bwa => $select_bwa, select_bilanz => $select_bilanz, select_eur => $select_eur, + select_er => $select_er, }; # Ausgabe des Templates @@ -365,21 +344,6 @@ sub account_header { $main::lxdebug->leave_sub(); } -sub form_footer { - $::lxdebug->enter_sub; - $::auth->assert('config'); - - print $::form->parse_html_template('am/form_footer', { - show_save => !$::form->{id} - || ($::form->{id} && $::form->{orphaned}) - || ($::form->{type} eq "account" && !$::form->{new_chart_valid}), - show_delete => $::form->{id} && $::form->{orphaned}, - show_save_as_new => $::form->{id} && $::form->{type} eq "account", - }); - - $::lxdebug->leave_sub; -} - sub save_account { $main::lxdebug->enter_sub(); @@ -394,6 +358,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 +401,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 +437,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; @@ -530,833 +501,52 @@ sub list_account_details { : ( $link eq 'IC_cogs' ) ? $locale->text('Account Link IC_cogs') : ( $link eq 'IC_taxpart' ) ? $locale->text('Account Link IC_taxpart') : ( $link eq 'IC_income' ) ? $locale->text('Account Link IC_income') - : ( $link eq 'IC_expense' ) ? $locale->text('Account Link IC_expense') - : ( $link eq 'IC_taxservice' ) ? $locale->text('Account Link IC_taxservice') - : $locale->text('Unknown Link') . ': ' . $link; - $ca->{link} .= ($link ne '') ? "[$link] ":''; - } - - $ca->{category} = ($ca->{category} eq 'A') ? $locale->text('Account Category A') - : ($ca->{category} eq 'E') ? $locale->text('Account Category E') - : ($ca->{category} eq 'L') ? $locale->text('Account Category L') - : ($ca->{category} eq 'I') ? $locale->text('Account Category I') - : ($ca->{category} eq 'Q') ? $locale->text('Account Category Q') - : ($ca->{category} eq 'C') ? $locale->text('Account Category C') - : ($ca->{category} eq 'G') ? $locale->text('Account Category G') - : $locale->text('Unknown Category') . ': ' . $ca->{category}; - } - - $form->{title} = $locale->text('Chart of Accounts'); - - print $form->ajax_response_header, $form->parse_html_template('am/list_account_details'); - - $main::lxdebug->leave_sub(); - -} - -sub delete_account { - $main::lxdebug->enter_sub(); - - my $form = $main::form; - my %myconfig = %main::myconfig; - my $locale = $main::locale; - - $main::auth->assert('config'); - - $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) - ) { - if ($form->{id} == $form->{$id}) { - $form->error($locale->text('Cannot delete default account!')); - } - } - - $form->redirect($locale->text('Account deleted!')) - if (AM->delete_account(\%myconfig, \%$form)); - $form->error($locale->text('Cannot delete account!')); - - $main::lxdebug->leave_sub(); -} - -sub add_lead { - $main::lxdebug->enter_sub(); - - my $form = $main::form; - - $main::auth->assert('config'); - - $form->{title} = "Add"; - - $form->{callback} = "am.pl?action=add_lead" unless $form->{callback}; - - &lead_header; - &form_footer; - - $main::lxdebug->leave_sub(); -} - -sub edit_lead { - $main::lxdebug->enter_sub(); - - my $form = $main::form; - my %myconfig = %main::myconfig; - - $main::auth->assert('config'); - - $form->{title} = "Edit"; - - AM->get_lead(\%myconfig, \%$form); - - &lead_header; - - $form->{orphaned} = 1; - &form_footer; - - $main::lxdebug->leave_sub(); -} - -sub list_lead { - $main::lxdebug->enter_sub(); - - my $form = $main::form; - my %myconfig = %main::myconfig; - my $locale = $main::locale; - - $main::auth->assert('config'); - - AM->lead(\%myconfig, \%$form); - - $form->{callback} = "am.pl?action=list_lead"; - - my $callback = $form->escape($form->{callback}); - - $form->{title} = $locale->text('Lead'); - - my @column_index = qw(description cost profit); - my %column_header; - $column_header{description} = - qq|
$form->{title} | -
---|
$ref->{lead} | |; - - map { print "$column_data{$_}\n" } @column_index; - - print qq| -