Erfolgsrechnung 1st draft
authorRolf Fluehmann <rolf.fluehmann@revamp-it.ch>
Fri, 3 Jul 2015 12:27:48 +0000 (14:27 +0200)
committerRolf Fluehmann <rolf.fluehmann@revamp-it.ch>
Fri, 16 Oct 2015 10:09:37 +0000 (12:09 +0200)
Conflicts:
bin/mozilla/rp.pl

SL/Menu.pm
SL/RP.pm
bin/mozilla/rp.pl
menus/user/00-erp.yaml
templates/webpages/rp/report.html

index f01b341..ac8f728 100644 (file)
@@ -220,6 +220,12 @@ sub parse_instance_conf_string {
   return $::instance_conf->data->{$setting};
 }
 
+sub parse_compare_string {
+  my ($self, $switch) = @_;
+  my ($setting, $mode) = split m/=/, $switch, 2;
+  return $::instance_conf->data->{$setting} eq $mode;
+}
+
 sub clear_access {
   my ($self) = @_;
   for my $node ($self->tree_walk("all")) {
@@ -230,11 +236,14 @@ sub clear_access {
 
 sub set_access {
   my ($self) = @_;
-  # 1. evaluate access for all
-  # 2. if a menu has no visible children, its not visible either
+  # 1. evaluate appearence
+  # 2. evaluate access for all
+  # 3. if a menu has no visible children, its not visible either
 
   for my $node (reverse $self->tree_walk("all")) {
-    $node->{visible} = $node->{access}           ? $self->parse_access_string($node)
+    $node->{visible} = $node->{inclusion}        ? $self->parse_compare_string($node->{inclusion})  : 1
+                   && $node->{exclusion}        ? !$self->parse_compare_string($node->{exclusion}) : 1
+                   && $node->{access}           ? $self->parse_access_string($node)
                      : !$node->{children}        ? 1
                      : $node->{visible_children} ? 1
                      :                             0;
index b2fd5e0..e8e07e0 100644 (file)
--- a/SL/RP.pm
+++ b/SL/RP.pm
@@ -1871,4 +1871,34 @@ sub income_statement {
   }
   $main::lxdebug->leave_sub();
 }
+
+sub income_statement_ch {
+
+  $main::lxdebug->enter_sub();
+
+  my ($self, $myconfig, $form) = @_;
+
+  my $last_period  = 0;
+
+
+  # connect to database
+  my $dbh = $form->dbconnect($myconfig);
+
+  get_accounts_ch($dbh, $last_period, $form->{fromdate}, $form->{todate}, $form);
+
+   $main::lxdebug->leave_sub();
+}
+
+
+ sub get_accounts_ch {
+  $main::lxdebug->enter_sub();
+
+  my $query =
+    qq|SELECT c.accno, c.description
+       FROM chart c
+       ORDER BY c.accno|;
+
+   $main::lxdebug->leave_sub();
+}
+
 1;
index 02023f5..6672be7 100644 (file)
@@ -101,15 +101,16 @@ use strict;
 # $form->parse_html_template('rp/html_report_susa')
 
 my $rp_access_map = {
-  'projects'         => 'report',
-  'ar_aging'         => 'general_ledger',
-  'ap_aging'         => 'general_ledger',
-  'receipts'         => 'cash',
-  'payments'         => 'cash',
-  'trial_balance'    => 'report',
-  'income_statement' => 'report',
-  'bwa'              => 'report',
-  'balance_sheet'    => 'report',
+  'projects'           => 'report',
+  'ar_aging'           => 'general_ledger',
+  'ap_aging'           => 'general_ledger',
+  'receipts'           => 'cash',
+  'payments'           => 'cash',
+  'trial_balance'      => 'report',
+  'income_statement'   => 'report',
+  'income_statement_ch'=> 'report',
+  'bwa'                => 'report',
+  'balance_sheet'      => 'report',
 };
 
 sub check_rp_access {
@@ -129,6 +130,7 @@ sub report {
   my %title = (
     balance_sheet        => $::locale->text('Balance Sheet'),
     income_statement     => $::locale->text('Income Statement'),
+    income_statement_ch     => ('Erfolgsrechnung'),
     trial_balance        => $::locale->text('Trial Balance'),
     ar_aging             => $::locale->text('Search AR Aging'),
     ap_aging             => $::locale->text('Search AP Aging'),
@@ -152,13 +154,14 @@ sub report {
 
   $::form->get_lists("projects" => { "key" => "ALL_PROJECTS", "all" => 1 });
 
-  my $is_projects         = $::form->{report} eq "projects";
-  my $is_income_statement = $::form->{report} eq "income_statement";
-  my $is_bwa              = $::form->{report} eq "bwa";
-  my $is_balance_sheet    = $::form->{report} eq "balance_sheet";
-  my $is_trial_balance    = $::form->{report} eq "trial_balance";
-  my $is_aging            = $::form->{report} =~ /^a[rp]_aging$/;
-  my $is_payments         = $::form->{report} =~ /(receipts|payments)$/;
+  my $is_projects            = $::form->{report} eq "projects";
+  my $is_income_statement    = $::form->{report} eq "income_statement";
+  my $is_income_statement_ch = $::form->{report} eq "income_statement_ch";
+  my $is_bwa                 = $::form->{report} eq "bwa";
+  my $is_balance_sheet       = $::form->{report} eq "balance_sheet";
+  my $is_trial_balance       = $::form->{report} eq "trial_balance";
+  my $is_aging               = $::form->{report} =~ /^a[rp]_aging$/;
+  my $is_payments            = $::form->{report} =~ /(receipts|payments)$/;
 
   my ($label, $nextsub, $vc);
   if ($is_aging) {
@@ -191,22 +194,23 @@ sub report {
 
   $::form->header;
   print $::form->parse_html_template('rp/report', {
-    paymentaccounts     => $paymentaccounts,
-    selection           => $selection,
-    is_aging            => $is_aging,
-    vc                  => $vc,
-    label               => $label,
-    year                => DateTime->today->year,
-    today               => DateTime->today,
-    nextsub             => $nextsub,
-    accrual             => $::instance_conf->get_accounting_method ne 'cash',
-    cash                => $::instance_conf->get_accounting_method eq 'cash',
-    is_payments         => $is_payments,
-    is_trial_balance    => $is_trial_balance,
-    is_balance_sheet    => $is_balance_sheet,
-    is_bwa              => $is_bwa,
-    is_income_statement => $is_income_statement,
-    is_projects         => $is_projects,
+    paymentaccounts        => $paymentaccounts,
+    selection              => $selection,
+    is_aging               => $is_aging,
+    vc                     => $vc,
+    label                  => $label,
+    year                   => DateTime->today->year,
+    today                  => DateTime->today,
+    nextsub                => $nextsub,
+    accrual                => $::instance_conf->get_accounting_method ne 'cash',
+    cash                   => $::instance_conf->get_accounting_method eq 'cash',
+    is_payments            => $is_payments,
+    is_trial_balance       => $is_trial_balance,
+    is_balance_sheet       => $is_balance_sheet,
+    is_bwa                 => $is_bwa,
+    is_income_statement    => $is_income_statement,
+    is_income_statement_ch => $is_income_statement_ch,
+    is_projects            => $is_projects,
   });
 
   $::lxdebug->leave_sub;
@@ -397,6 +401,175 @@ sub generate_income_statement {
   $main::lxdebug->leave_sub();
 }
 
+sub generate_income_statement_ch {
+  $main::lxdebug->enter_sub();
+
+  $main::auth->assert('report');
+
+  my $form     = $main::form;
+  my %myconfig = %main::myconfig;
+  my $locale   = $main::locale;
+
+  my $defaults = SL::DB::Default->get;
+  $form->error($::locale->text('No print templates have been created for this client yet. Please do so in the client configuration.')) if !$defaults->templates;
+  $form->{templates} = $defaults->templates;
+
+  $form->{padding} = "&nbsp;&nbsp;";
+  $form->{bold}    = "<b>";
+  $form->{endbold} = "</b>";
+  $form->{br}      = "<br>";
+
+  if ($form->{reporttype} eq "custom") {
+
+    #forgotten the year --> thisyear
+    if ($form->{year} !~ m/^\d\d\d\d$/) {
+      $locale->date(\%myconfig, $form->current_date(\%myconfig), 0) =~
+        /(\d\d\d\d)/;
+      $form->{year} = $1;
+    }
+
+    #yearly report
+    if ($form->{duetyp} eq "13") {
+      $form->{fromdate} = "1.1.$form->{year}";
+      $form->{todate}   = "31.12.$form->{year}";
+    }
+   #Quater reports
+    if ($form->{duetyp} eq "A") {
+      $form->{fromdate} = "1.1.$form->{year}";
+      $form->{todate}   = "31.3.$form->{year}";
+    }
+    if ($form->{duetyp} eq "B") {
+      $form->{fromdate} = "1.4.$form->{year}";
+      $form->{todate}   = "30.6.$form->{year}";
+    }
+    if ($form->{duetyp} eq "C") {
+      $form->{fromdate} = "1.7.$form->{year}";
+      $form->{todate}   = "30.9.$form->{year}";
+    }
+    if ($form->{duetyp} eq "D") {
+      $form->{fromdate} = "1.10.$form->{year}";
+      $form->{todate}   = "31.12.$form->{year}";
+    }
+  #Monthly reports
+  SWITCH: {
+      $form->{duetyp} eq "1" && do {
+        $form->{fromdate} = "1.1.$form->{year}";
+        $form->{todate}   = "31.1.$form->{year}";
+        last SWITCH;
+      };
+      $form->{duetyp} eq "2" && do {
+        $form->{fromdate} = "1.2.$form->{year}";
+
+        #this works from 1901 to 2099, 1900 and 2100 fail.
+        my $leap = ($form->{year} % 4 == 0) ? "29" : "28";
+        $form->{todate} = "$leap.2.$form->{year}";
+        last SWITCH;
+      };
+      $form->{duetyp} eq "3" && do {
+        $form->{fromdate} = "1.3.$form->{year}";
+        $form->{todate}   = "31.3.$form->{year}";
+        last SWITCH;
+      };
+      $form->{duetyp} eq "4" && do {
+        $form->{fromdate} = "1.4.$form->{year}";
+        $form->{todate}   = "30.4.$form->{year}";
+        last SWITCH;
+      };
+      $form->{duetyp} eq "5" && do {
+        $form->{fromdate} = "1.5.$form->{year}";
+        $form->{todate}   = "31.5.$form->{year}";
+        last SWITCH;
+      };
+      $form->{duetyp} eq "6" && do {
+        $form->{fromdate} = "1.6.$form->{year}";
+        $form->{todate}   = "30.6.$form->{year}";
+        last SWITCH;
+      };
+      $form->{duetyp} eq "7" && do {
+        $form->{fromdate} = "1.7.$form->{year}";
+        $form->{todate}   = "31.7.$form->{year}";
+        last SWITCH;
+      };
+    $form->{duetyp} eq "8" && do {
+        $form->{fromdate} = "1.8.$form->{year}";
+        $form->{todate}   = "31.8.$form->{year}";
+        last SWITCH;
+      };
+      $form->{duetyp} eq "9" && do {
+        $form->{fromdate} = "1.9.$form->{year}";
+        $form->{todate}   = "30.9.$form->{year}";
+        last SWITCH;
+      };
+      $form->{duetyp} eq "10" && do {
+        $form->{fromdate} = "1.10.$form->{year}";
+        $form->{todate}   = "31.10.$form->{year}";
+        last SWITCH;
+      };
+      $form->{duetyp} eq "11" && do {
+        $form->{fromdate} = "1.11.$form->{year}";
+        $form->{todate}   = "30.11.$form->{year}";
+        last SWITCH;
+      };
+      $form->{duetyp} eq "12" && do {
+        $form->{fromdate} = "1.12.$form->{year}";
+        $form->{todate}   = "31.12.$form->{year}";
+        last SWITCH;
+      };
+    }
+    hotfix_reformat_date();
+  } # Ende Bericht für vorgewählten Zeitraum (warum auch immer die Prüfung (custom eq true) ist ...
+
+   RP->income_statement_ch(\%myconfig, \%$form);
+
+  ($form->{department}) = split /--/, $form->{department};
+
+  $form->{period} =
+    $locale->date(\%myconfig, $form->current_date(\%myconfig), 1);
+  $form->{todate} = $form->current_date(\%myconfig) unless $form->{todate};
+
+  # if there are any dates construct a where
+  if ($form->{fromdate} || $form->{todate}) {
+
+    unless ($form->{todate}) {
+      $form->{todate} = $form->current_date(\%myconfig);
+    }
+
+    my $longtodate  = $locale->date(\%myconfig, $form->{todate}, 1);
+    my $shorttodate = $locale->date(\%myconfig, $form->{todate}, 0);
+
+    my $longfromdate  = $locale->date(\%myconfig, $form->{fromdate}, 1);
+    my $shortfromdate = $locale->date(\%myconfig, $form->{fromdate}, 0);
+
+    $form->{this_period} = "$shortfromdate\n$shorttodate";
+    $form->{period}      =
+        $locale->text('for Period')
+      . qq|\n$longfromdate |
+      . $locale->text('Bis')
+      . qq| $longtodate|;
+  }
+
+  if ($form->{comparefromdate} || $form->{comparetodate}) {
+    my $longcomparefromdate = $locale->date(\%myconfig, $form->{comparefromdate}, 1);
+    my $shortcomparefromdate = $locale->date(\%myconfig, $form->{comparefromdate}, 0);
+
+    my $longcomparetodate  = $locale->date(\%myconfig, $form->{comparetodate}, 1);
+    my $shortcomparetodate = $locale->date(\%myconfig, $form->{comparetodate}, 0);
+
+    $form->{last_period} = "$shortcomparefromdate\n$shortcomparetodate";
+    $form->{period} .=
+        "\n$longcomparefromdate "
+      . $locale->text('Bis')
+      . qq| $longcomparetodate|;
+  }
+
+   $form->{IN} = "erfolgsrechnung.html";
+
+  $form->parse_template;
+
+  $main::lxdebug->leave_sub();
+}
+
+
 sub generate_balance_sheet {
   $::lxdebug->enter_sub;
   $::auth->assert('report');
index 53d0586..1dddff2 100644 (file)
   id: general_ledger_datev_export_assistent
   name: DATEV - Export Assistent
   icon: datev
+  exclusion: country_mode=CH
   order: 400
   access: datev_export
   module: datev.pl
   params:
     action: report
     report: trial_balance
+- parent: reports
+  id: reports_erfolgsrechnung
+  name: Erfolgsrechnung
+  icon: income_statement
+  order: 300
+  inclusion: country_mode=CH
+  access: report
+  module: rp.pl
+  params:
+    action: report
+    report: erfolgsrechnung
 - parent: reports
   id: reports_income_statement
   name: Income Statement
   icon: income_statement
   order: 300
+  exclusion: country_mode=CH
   access: report
   module: rp.pl
   params:
   id: reports_bwa
   name: BWA
   order: 400
+  exclusion: country_mode=CH
   access: report
   module: rp.pl
   params:
   name: Balance Sheet
   icon: balance_sheet
   order: 500
+  exclusion: country_mode=CH
   access: report
   module: rp.pl
   params:
   name: UStVa
   icon: ustva
   order: 600
+  exclusion: country_mode=CH
   access: advance_turnover_tax_return
   module: ustva.pl
   params:
   id: system_ustva_einstellungen
   name: UStVa Einstellungen
   order: 200
+  exclusion: country_mode=CH
   module: ustva.pl
   params:
     action: config_step1
index 93ef0a9..7744f31 100644 (file)
   </tr>
 [%- END %]
 
+  [%- IF is_income_statement_ch %]
+[%- PROCESS projectnumber %]
+  <input type=hidden name=nextsub value=generate_income_statement_ch>
+</table>
+<table>
+[%- PROCESS customized_report %]
+[%- PROCESS cash_or_accrual %]
+  <tr>
+    <th align=left nowrap>[% 'Include in Report' | $T8 %]</th>
+    <td><input name=l_cb class=checkbox type=checkbox value=Y>&nbsp;[% 'CB Transactions' | $T8 %]</td>
+  </tr>
+[%- END %]
+
+
 [%- IF is_bwa %]
 [%- PROCESS projectnumber %]
   <input type=hidden name=nextsub value=generate_bwa>