TaxzoneChart displayable_name und refactoring
authorG. Richardson <information@kivitendo-premium.de>
Thu, 30 Jul 2015 05:39:47 +0000 (07:39 +0200)
committerG. Richardson <information@kivitendo-premium.de>
Thu, 30 Jul 2015 10:43:55 +0000 (12:43 +0200)
displayable_name für die Kontenbeschreibung benutzen.

Statt eigener Methoden in TaxzoneChart die Foreign Key Verknüpfungen von
Rose nutzen.

SL/DB/TaxzoneChart.pm

index 6a98845..f24a771 100644 (file)
@@ -24,16 +24,16 @@ sub get_all_accounts_by_buchungsgruppen_id {
 
   # inventory_accno and description of the Buchungsgruppe:
   $list{inventory_accno}             = SL::DB::Manager::Buchungsgruppe->find_by(id => $buchungsgruppen_id)->inventory_account->accno;
-  $list{inventory_accno_description} = SL::DB::Manager::Buchungsgruppe->find_by(id => $buchungsgruppen_id)->inventory_account->description;
+  $list{inventory_accno_description} = SL::DB::Manager::Buchungsgruppe->find_by(id => $buchungsgruppen_id)->inventory_account->displayable_name;
 
   foreach my $taxzonechart (@{ $all_taxzonecharts }) {
     $list{ $taxzonechart->taxzone_id }{taxzone_chart_id}          = $taxzonechart->id;
-    $list{ $taxzonechart->taxzone_id }{income_accno}              = $taxzonechart->get_income_accno;
-    $list{ $taxzonechart->taxzone_id }{expense_accno}             = $taxzonechart->get_expense_accno;
-    $list{ $taxzonechart->taxzone_id }{income_accno_id}           = $taxzonechart->income_accno_id;
-    $list{ $taxzonechart->taxzone_id }{expense_accno_id}          = $taxzonechart->expense_accno_id;
-    $list{ $taxzonechart->taxzone_id }{income_accno_description}  = $taxzonechart->get_income_accno_description;
-    $list{ $taxzonechart->taxzone_id }{expense_accno_description} = $taxzonechart->get_expense_accno_description;
+    $list{ $taxzonechart->taxzone_id }{income_accno}              = $taxzonechart->income_accno->accno;
+    $list{ $taxzonechart->taxzone_id }{expense_accno}             = $taxzonechart->expense_accno->accno;
+    $list{ $taxzonechart->taxzone_id }{income_accno_id}           = $taxzonechart->income_accno->id;
+    $list{ $taxzonechart->taxzone_id }{expense_accno_id}          = $taxzonechart->expense_accno->id;
+    $list{ $taxzonechart->taxzone_id }{income_accno_description}  = $taxzonechart->income_accno->displayable_name;
+    $list{ $taxzonechart->taxzone_id }{expense_accno_description} = $taxzonechart->expense_accno->displayable_name;
   }
   return \%list;
 }
@@ -47,39 +47,15 @@ sub get_all_accounts_by_taxzone_id {
 
   foreach my $tzchart (@{ $all_taxzonecharts }) {
     $list{ $tzchart->buchungsgruppen_id }{taxzone_chart_id}          = $tzchart->id;
-    $list{ $tzchart->buchungsgruppen_id }{income_accno}              = $tzchart->get_income_accno;
-    $list{ $tzchart->buchungsgruppen_id }{expense_accno}             = $tzchart->get_expense_accno;
-    $list{ $tzchart->buchungsgruppen_id }{income_accno_id}           = $tzchart->income_accno_id;
-    $list{ $tzchart->buchungsgruppen_id }{expense_accno_id}          = $tzchart->expense_accno_id;
-    $list{ $tzchart->buchungsgruppen_id }{income_accno_description}  = $tzchart->get_income_accno_description;
-    $list{ $tzchart->buchungsgruppen_id }{expense_accno_description} = $tzchart->get_expense_accno_description;
+    $list{ $tzchart->buchungsgruppen_id }{income_accno}              = $tzchart->income_accno->accno;
+    $list{ $tzchart->buchungsgruppen_id }{expense_accno}             = $tzchart->expense_accno->accno;
+    $list{ $tzchart->buchungsgruppen_id }{income_accno_id}           = $tzchart->income_accno->id;
+    $list{ $tzchart->buchungsgruppen_id }{expense_accno_id}          = $tzchart->expense_accno->id;
+    $list{ $tzchart->buchungsgruppen_id }{income_accno_description}  = $tzchart->income_accno->displayable_name;
+    $list{ $tzchart->buchungsgruppen_id }{expense_accno_description} = $tzchart->expense_accno->displayable_name;
   }
 
   return \%list;
 }
 
-sub get_income_accno {
-  my $self = shift;
-  require SL::DB::Manager::Chart;
-  return SL::DB::Manager::Chart->find_by(id => $self->income_accno_id)->accno();
-}
-
-sub get_expense_accno {
-  my $self = shift;
-  require SL::DB::Manager::Chart;
-  return SL::DB::Manager::Chart->find_by(id => $self->expense_accno_id)->accno();
-}
-
-sub get_income_accno_description {
-  my $self = shift;
-  require SL::DB::Manager::Chart;
-  return SL::DB::Manager::Chart->find_by(id => $self->income_accno_id)->description();
-}
-
-sub get_expense_accno_description {
-  my $self = shift;
-  require SL::DB::Manager::Chart;
-  return SL::DB::Manager::Chart->find_by(id => $self->expense_accno_id)->description();
-}
-
 1;