epic-ts
authorMichael Wagner <michael@wagnertech.de>
Mon, 6 Dec 2021 14:20:41 +0000 (15:20 +0100)
committerMichael Wagner <michael@wagnertech.de>
Mon, 6 Dec 2021 14:20:41 +0000 (15:20 +0100)
SL/Controller/Mebil.pm
locale/de/all
sql/mebil.sql
templates/webpages/mebil/.dummy [new file with mode: 0644]

index ba50427..fd77ce5 100644 (file)
@@ -8,6 +8,8 @@ use parent qw(SL::Controller::Base);
 use SL::ReportGenerator;
 use SL::DBUtils;
 
+use SL::Locale::String;  # t8
+
 #use Data::Dumper;
 #use SL::ClientJS;
 
@@ -48,8 +50,10 @@ sub action_map {
 sub action_showmap {
        $::lxdebug->enter_sub;
        my ($self) = @_;
+       
+       $::form->{title} = $::locale->text('Mebil Map');
 
-       my $sql = "SELECT  fromacc,typ,toacc from mebil_mapping order by ordering";
+       my $sql = "SELECT fromacc,typ,toacc from mebil_mapping order by ordering";
        $self->{data} = SL::DBUtils::selectall_hashref_query($::form, $::form->get_standard_dbh, $sql);
 
        $self->prepare_report;
@@ -61,19 +65,24 @@ sub action_showmap {
 sub action_calcmap {
        $::lxdebug->enter_sub;
        my ($self) = @_;
-
+       
+       $self->year($::form->{year} || DateTime->today->year - 1);
+       
+       $::form->{title} = $::locale->text('Mebil Map');
+       
        my $sql = "SELECT  fromacc,typ,toacc from mebil_mapping order by ordering";
        $self->{data} = SL::DBUtils::selectall_hashref_query($::form, $::form->get_standard_dbh, $sql);
 
        my %fromacc = ();
        my %toacc   = ();
+       my $year = $self->year;
        foreach my $mapping (@{ $self->{data} }) {
                if ($mapping->{typ} eq 'H') {
                        # process Haben
                        $sql = "SELECT SUM(ac.amount) AS saldo
                                                FROM acc_trans ac 
                                                JOIN chart c ON (c.id = ac.chart_id) 
-                                               WHERE (ac.transdate <= '30.12.2020') 
+                                               WHERE (ac.transdate <= '31.12.$year') 
                                                AND (c.accno = '$mapping->{fromacc}') ";
                        my $result = SL::DBUtils::selectall_hashref_query($::form, $::form->get_standard_dbh, $sql);            
                        $fromacc{$mapping->{fromacc}} = $result->[0]->{saldo};
@@ -84,22 +93,22 @@ sub action_calcmap {
                        $sql = "SELECT SUM(ac.amount)* -1 AS saldo
                                                FROM acc_trans ac 
                                                JOIN chart c ON (c.id = ac.chart_id) 
-                                               WHERE (ac.transdate <= '30.12.2020') 
+                                               WHERE (ac.transdate <= '31.12.$year') 
                                                AND (c.accno = '$mapping->{fromacc}') ";
                        my @result = SL::DBUtils::selectfirst_array_query($::form, $::form->get_standard_dbh, $sql);            
                        $fromacc{$mapping->{fromacc}} = $result[0];
                        $toacc{$mapping->{toacc}} += $result[0];
                }
-               elsif ($mapping->{typ} eq 'V') {
-                       # process Vorjahr
-                       $fromacc{$mapping->{fromacc}} = 300.;
-                       $toacc{$mapping->{toacc}} = 300.;
-               }
-               elsif ($mapping->{typ} eq 'A') {
-                       # process Aktjahr
-                       $fromacc{$mapping->{fromacc}} = 400.;
-                       $toacc{$mapping->{toacc}} = 400.;
-               }
+#              elsif ($mapping->{typ} eq 'V') {
+#                      # process Vorjahr
+#                      $fromacc{$mapping->{fromacc}} = 300.;
+#                      $toacc{$mapping->{toacc}} = 300.;
+#              }
+#              elsif ($mapping->{typ} eq 'A') {
+#                      # process Aktjahr
+#                      $fromacc{$mapping->{fromacc}} = 400.;
+#                      $toacc{$mapping->{toacc}} = 400.;
+#              }
                elsif ($mapping->{typ} eq 'X') {
                        # add to other account
                        $toacc{$mapping->{toacc}} += $toacc{$mapping->{fromacc}};
@@ -108,6 +117,10 @@ sub action_calcmap {
                        # substract from other account
                        $toacc{$mapping->{toacc}} -= $toacc{$mapping->{fromacc}};
                }
+               elsif ($mapping->{typ} eq 'C') {
+                       # constant value
+                       ; # do nothing here
+               }
                else {
                        die "Error: Invalid mapping type: $mapping->{typ}\n";
                }
@@ -122,14 +135,12 @@ sub action_calcmap {
        amount                      => { text => 'Betrag'   , align => 'right'   },
        );
 
-  #$column_defs{$_}->{align} = 'right' for @columns;
-
   $self->report->set_options(
     std_column_visibility => 1,
     controller_class      => 'Mebil',
     output_format         => 'HTML',
#   raw_top_info_text     => $self->render('financial_overview/report_top', { output => 0 }, YEARS_TO_LIST => [ reverse(($self->current_year - 10)..($self->current_year + 5)) ]),
-    title                 => 'mebil - Mapping: Werte für 2020',
      raw_top_info_text     => $self->render('mebil/report_top', { output => 0 }, YEARS_TO_LIST => [ reverse(($self->year - 10)..($self->year + 5)) ]),
+    title                 => t8('mebil - Mapping: values for #1', $self->year),
 #    allow_pdf_export      => 1,
 #    allow_csv_export      => 1,
   );
index c87fdc4..0121e1c 100755 (executable)
@@ -3390,6 +3390,7 @@ $self->{texts} = {
   'list_of_transactions'        => 'buchungsliste',
   'male'                        => 'männlich',
   'mark as paid'                => 'als bezahlt markieren',
+  'mebil - Mapping: values for #1' => 'mebil - Mapping: Werte für #1',
   'missing'                     => 'Fehlbestand',
   'month'                       => 'Monatliche Abgabe',
   'monthly'                     => 'monatlich',
index cb9229d..218a4ff 100644 (file)
@@ -72,6 +72,8 @@ VALUES
        (20,'X',       'is.netIncome.regular.operatingTC.grossTradingProfit.materialServices.material.purchased.generalRateVAT','is.netIncome.regular.operatingTC.grossTradingProfit.materialServices.material.purchased'),
        (21,'X',       'is.netIncome.regular.operatingTC.grossTradingProfit.materialServices.material.purchased','is.netIncome.regular.operatingTC.grossTradingProfit.materialServices.material'),
        (22,'X',       'is.netIncome.regular.operatingTC.grossTradingProfit.materialServices.material','ismi.netIncome.materialServices'),
-       (50,'Y',       'ismi.netIncome.materialServices','ismi.netIncome')
+       (50,'Y',       'ismi.netIncome.materialServices','ismi.netIncome'),
        
+       (0,'C','de-gaap-ci.bsAss','hbst.transfer.bsAss.name')
        ;
+
diff --git a/templates/webpages/mebil/.dummy b/templates/webpages/mebil/.dummy
new file mode 100644 (file)
index 0000000..e69de29