Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 101b9705

Von Moritz Bunkus vor mehr als 7 Jahren hinzugefügt

  • ID 101b9705bda052abb1237c92d3920f6ddbf12d04
  • Vorgänger 9a9025f6
  • Nachfolger 962ae5f9

Belegvorlagen: Zeilen ohne Betrag beibehalten

Unterschiede anzeigen:

bin/mozilla/gl.pl
105 105
  $::form->{title}            = "Add";
106 106
  $::form->{transdate}        = $today->to_kivitendo;
107 107
  $::form->{duedate}          = $today->to_kivitendo;
108
  $::form->{rowcount}         = @{ $template->items } + 1;
108
  $::form->{rowcount}         = @{ $template->items };
109 109
  $::form->{paidaccounts}     = 1;
110 110
  $::form->{$_}               = $template->$_     for qw(department_id taxincluded ob_transaction cb_transaction reference description);
111 111
  $::form->{$_}               = $dummy_form->{$_} for qw(closedto revtrans previous_id previous_gldate);
......
139 139

  
140 140
  flash('info', $::locale->text("The record template '#1' has been loaded.", $template->template_name));
141 141

  
142
  update();
142
  update(
143
    keep_rows_without_amount => 1,
144
    dont_add_new_row         => 1,
145
  );
143 146
}
144 147

  
145 148
sub save_record_template {
......
152 155
  $js->dialog->close('#record_template_dialog');
153 156

  
154 157
  my @items = grep {
155
    $_->{chart_id} && (($_->{tax_id} // '') ne '') && (($_->{amount1} != 0) || ($_->{amount2} != 0))
158
    $_->{chart_id} && (($_->{tax_id} // '') ne '')
156 159
  } map {
157 160
    +{ chart_id   => $::form->{"accno_id_${_}"},
158 161
       amount1    => $::form->parse_amount(\%::myconfig, $::form->{"debit_${_}"}),
......
628 631
}
629 632

  
630 633
sub update {
634
  my %params = @_;
635

  
631 636
  $main::lxdebug->enter_sub();
632 637

  
633 638
  $main::auth->assert('gl_transactions');
......
653 658
    qw(accno debit credit projectnumber fx_transaction source memo tax taxchart);
654 659

  
655 660
  for my $i (1 .. $form->{rowcount}) {
661
    $form->{"${_}_$i"} = $form->parse_amount(\%myconfig, $form->{"${_}_$i"}) for qw(debit credit tax);
656 662

  
657
    unless (($form->{"debit_$i"} eq "") && ($form->{"credit_$i"} eq "")) {
658
      for (qw(debit credit tax)) {
659
        $form->{"${_}_$i"} =
660
          $form->parse_amount(\%myconfig, $form->{"${_}_$i"});
661
      }
663
    next if !$form->{"debit_$i"} && !$form->{"credit_$i"} && !$params{keep_rows_without_amount};
664

  
665
    push @a, {};
666
    $debitcredit = ($form->{"debit_$i"} == 0) ? "0" : "1";
667
    if ($debitcredit) {
668
      $debitcount++;
669
    } else {
670
      $creditcount++;
671
    }
662 672

  
663
      push @a, {};
664
      $debitcredit = ($form->{"debit_$i"} == 0) ? "0" : "1";
673
    if (($debitcount >= 2) && ($creditcount == 2)) {
674
      $form->{"credit_$i"} = 0;
675
      $form->{"tax_$i"}    = 0;
676
      $creditcount--;
677
      $form->{creditlock} = 1;
678
    }
679
    if (($creditcount >= 2) && ($debitcount == 2)) {
680
      $form->{"debit_$i"} = 0;
681
      $form->{"tax_$i"}   = 0;
682
      $debitcount--;
683
      $form->{debitlock} = 1;
684
    }
685
    if (($creditcount == 1) && ($debitcount == 2)) {
686
      $form->{creditlock} = 1;
687
    }
688
    if (($creditcount == 2) && ($debitcount == 1)) {
689
      $form->{debitlock} = 1;
690
    }
691
    if ($debitcredit && $credittax) {
692
      $form->{"taxchart_$i"} = "$notax_id--0.00";
693
    }
694
    if (!$debitcredit && $debittax) {
695
      $form->{"taxchart_$i"} = "$notax_id--0.00";
696
    }
697
    $amount =
698
      ($form->{"debit_$i"} == 0)
699
      ? $form->{"credit_$i"}
700
      : $form->{"debit_$i"};
701
    my $j = $#a;
702
    if (($debitcredit && $credittax) || (!$debitcredit && $debittax)) {
703
      $form->{"taxchart_$i"} = "$notax_id--0.00";
704
      $form->{"tax_$i"}      = 0;
705
    }
706
    my ($taxkey, $rate) = split(/--/, $form->{"taxchart_$i"});
707
    my $iswithouttax = grep { $_->{id} == $taxkey } @{ $zerotaxes };
708
    if (!$iswithouttax) {
665 709
      if ($debitcredit) {
666
        $debitcount++;
710
        $debittax = 1;
667 711
      } else {
668
        $creditcount++;
669
      }
670

  
671
      if (($debitcount >= 2) && ($creditcount == 2)) {
672
        $form->{"credit_$i"} = 0;
673
        $form->{"tax_$i"}    = 0;
674
        $creditcount--;
675
        $form->{creditlock} = 1;
676
      }
677
      if (($creditcount >= 2) && ($debitcount == 2)) {
678
        $form->{"debit_$i"} = 0;
679
        $form->{"tax_$i"}   = 0;
680
        $debitcount--;
681
        $form->{debitlock} = 1;
682
      }
683
      if (($creditcount == 1) && ($debitcount == 2)) {
684
        $form->{creditlock} = 1;
685
      }
686
      if (($creditcount == 2) && ($debitcount == 1)) {
687
        $form->{debitlock} = 1;
688
      }
689
      if ($debitcredit && $credittax) {
690
        $form->{"taxchart_$i"} = "$notax_id--0.00";
691
      }
692
      if (!$debitcredit && $debittax) {
693
        $form->{"taxchart_$i"} = "$notax_id--0.00";
694
      }
695
      $amount =
696
        ($form->{"debit_$i"} == 0)
697
        ? $form->{"credit_$i"}
698
        : $form->{"debit_$i"};
699
      my $j = $#a;
700
      if (($debitcredit && $credittax) || (!$debitcredit && $debittax)) {
701
        $form->{"taxchart_$i"} = "$notax_id--0.00";
702
        $form->{"tax_$i"}      = 0;
712
        $credittax = 1;
703 713
      }
704
      my ($taxkey, $rate) = split(/--/, $form->{"taxchart_$i"});
705
      my $iswithouttax = grep { $_->{id} == $taxkey } @{ $zerotaxes };
706
      if (!$iswithouttax) {
707
        if ($debitcredit) {
708
          $debittax = 1;
709
        } else {
710
          $credittax = 1;
711
        }
712
      };
713
      my ($tmpnetamount,$tmpdiff);
714
      ($tmpnetamount,$form->{"tax_$i"},$tmpdiff) = $form->calculate_tax($amount,$rate,$form->{taxincluded} *= 1,2);
714
    };
715
    my ($tmpnetamount,$tmpdiff);
716
    ($tmpnetamount,$form->{"tax_$i"},$tmpdiff) = $form->calculate_tax($amount,$rate,$form->{taxincluded} *= 1,2);
715 717

  
716
      for (@flds) { $a[$j]->{$_} = $form->{"${_}_$i"} }
717
      $count++;
718
    }
718
    for (@flds) { $a[$j]->{$_} = $form->{"${_}_$i"} }
719
    $count++;
719 720
  }
720 721

  
721 722
  for my $i (1 .. $count) {
......
727 728
    for (@flds) { delete $form->{"${_}_$i"} }
728 729
  }
729 730

  
730
  $form->{rowcount} = $count + 1;
731
  $form->{rowcount} = $count + ($params{dont_add_new_row} ? 0 : 1);
731 732

  
732
  &display_form;
733
  display_form();
733 734
  $main::lxdebug->leave_sub();
734 735

  
735 736
}

Auch abrufbar als: Unified diff