Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 4e8e33e9

Von G. Richardson vor fast 4 Jahren hinzugefügt

  • ID 4e8e33e9c0a98f10551a4ae18597dc724e621a13
  • Vorgänger a05cda74
  • Nachfolger c4cea463

AR/IR/OE - Steuerbeschreibung an Oberfläche / Druck aus tax_id holen

siehe Kommentare in SL/IS.pm

Wenn ein Steuerautomatikkonto mehrmals bei den Steuern auftaucht kann
man die Steuerbeschreibung nicht mehr eindeutig anhand der Kontonummer
(hier als taxnumber verwendet) bestimmen, von daher wird jetzt immer
auch die tax_id mit ausgelesen.

Hier gibt es noch ganz viel Refactoringpotential...

Unterschiede anzeigen:

SL/IS.pm
171 171
  push @arrays, map { "ic_cvar_$_->{name}" } @{ $ic_cvar_configs };
172 172
  push @arrays, map { "project_cvar_$_->{name}" } @{ $project_cvar_configs };
173 173

  
174
  my @tax_arrays = qw(taxbase tax taxdescription taxrate taxnumber);
174
  my @tax_arrays = qw(taxbase tax taxdescription taxrate taxnumber tax_id);
175 175

  
176 176
  my @payment_arrays = qw(payment paymentaccount paymentdate paymentsource paymentmemo);
177 177

  
......
505 505
    push(@{ $form->{TEMPLATE_ARRAYS}->{taxrate} },        $form->format_amount($myconfig, $form->{"${item}_rate"} * 100));
506 506
    push(@{ $form->{TEMPLATE_ARRAYS}->{taxrate_nofmt} },  $form->{"${item}_rate"} * 100);
507 507
    push(@{ $form->{TEMPLATE_ARRAYS}->{taxnumber} },      $form->{"${item}_taxnumber"});
508
    push(@{ $form->{TEMPLATE_ARRAYS}->{tax_id} },         $form->{"${item}_tax_id"});
508 509

  
509
    # taxnumber is used for grouping the amount of the various taxes
510
    # taxnumber (= accno) is used for grouping the amounts of the various taxes and as a prefix in form
510 511

  
511
    # this code assumes that at most one tax entry can point to the same
512
    # This code used to assume that at most one tax entry can point to the same
512 513
    # chart_id, even though chart_id does not have a unique constraint!
513 514

  
514
    # this chart_id is then looked up via its accno, which is the key that is
515
    # This chart_id was then looked up via its accno, which is the key that is
515 516
    # used to group the different taxes by for a record
516 517

  
517
    # not every tax has a taxnumber (e.g. tax-free), but that is ok, because
518
    # then there would be no tax amount to assign it to
518
    # As we now also store the tax_id we can use that to look up the tax
519
    # instead, this is only done here to get the (translated) taxdescription.
519 520

  
520
    my $tax_objs = SL::DB::Manager::Tax->get_objects_from_sql(
521
      sql  => 'SELECT * FROM tax WHERE chart_id = (SELECT id FROM chart WHERE accno = ?)',
522
      args => [ $form->{"${item}_taxnumber"} ]
523
    );
524
    my $tax_obj;
525
    if ( $tax_objs ) {
526
      $tax_obj     = $tax_objs->[0];
521
    if ( $form->{"${item}_tax_id"} ) {
522
      my $tax_obj = SL::DB::Manager::Tax->find_by(id => $form->{"${item}_tax_id"}) or die "Can't find tax with id " . $form->{"${item}_tax_id"};
523
      my $description = $tax_obj ? $tax_obj->translated_attribute('taxdescription',  $form->{language_id}, 0) : '';
524
      push(@{ $form->{TEMPLATE_ARRAYS}->{taxdescription} }, $description . q{ } . 100 * $form->{"${item}_rate"} . q{%});
527 525
    }
528
    my $description = $tax_obj ? $tax_obj->translated_attribute('taxdescription',  $form->{language_id}, 0) : '';
529
    push(@{ $form->{TEMPLATE_ARRAYS}->{taxdescription} }, $description . q{ } . 100 * $form->{"${item}_rate"} . q{%});
526

  
530 527
  }
531 528

  
532 529
  for my $i (1 .. $form->{paidaccounts}) {
......
2087 2084
      # get tax rates and description
2088 2085
      my $accno_id = ($form->{vc} eq "customer") ? $ref->{income_accno} : $ref->{expense_accno};
2089 2086
      $query =
2090
        qq|SELECT c.accno, t.taxdescription, t.rate, c.accno as taxnumber
2087
        qq|SELECT c.accno, t.taxdescription, t.rate, t.id as tax_id, c.accno as taxnumber
2091 2088
           FROM tax t
2092 2089
           LEFT JOIN chart c ON (c.id = t.chart_id)
2093 2090
           WHERE t.id IN
......
2110 2107
        if (!($form->{taxaccounts} =~ /\Q$ptr->{accno}\E/)) {
2111 2108
          $form->{"$ptr->{accno}_rate"}        = $ptr->{rate};
2112 2109
          $form->{"$ptr->{accno}_description"} = $ptr->{taxdescription};
2113
          $form->{"$ptr->{accno}_taxnumber"}   = $ptr->{taxnumber};
2110
          $form->{"$ptr->{accno}_taxnumber"}   = $ptr->{taxnumber}; # don't use this anymore
2111
          $form->{"$ptr->{accno}_tax_id"}      = $ptr->{tax_id};
2114 2112
          $form->{taxaccounts} .= "$ptr->{accno} ";
2115 2113
        }
2116 2114

  
......
2412 2410
    # get tax rates and description
2413 2411
    my $accno_id = ($form->{vc} eq "customer") ? $ref->{income_accno} : $ref->{expense_accno};
2414 2412
    $query =
2415
      qq|SELECT c.accno, t.taxdescription, t.rate, c.accno as taxnumber
2413
      qq|SELECT c.accno, t.taxdescription, t.id as tax_id, t.rate, c.accno as taxnumber
2416 2414
         FROM tax t
2417 2415
         LEFT JOIN chart c ON (c.id = t.chart_id)
2418 2416
         WHERE t.id in
......
2441 2439
        $form->{"$ptr->{accno}_rate"}        = $ptr->{rate};
2442 2440
        $form->{"$ptr->{accno}_description"} = $ptr->{taxdescription};
2443 2441
        $form->{"$ptr->{accno}_taxnumber"}   = $ptr->{taxnumber};
2442
        $form->{"$ptr->{accno}_tax_id"}      = $ptr->{tax_id};
2444 2443
        $form->{taxaccounts} .= "$ptr->{accno} ";
2445 2444
      }
2446 2445

  

Auch abrufbar als: Unified diff