Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision fc3b49d6

Von Tamino Steinert vor mehr als 1 Jahr hinzugefügt

  • ID fc3b49d655fe696caa1fc338c116b9a5a429991e
  • Vorgänger c6df901c
  • Nachfolger da784064

InvoiceItem: Hinzufügen der Felder für Konten und Steuer

Es werden die Wert von relink_accounts als Default genommen und der
Nutzer kann dies ändern. Es werden alle nötigen Steuerdaten in die Form
geschrieben.

Unterschiede anzeigen:

bin/mozilla/ir.pl
44 44
use SL::DB::PurchaseInvoice;
45 45
use SL::DB::ValidityToken;
46 46
use SL::DB::Vendor;
47
use SL::DB::Tax;
48
use SL::DB::Chart;
47 49
use List::MoreUtils qw(uniq);
48 50
use List::Util qw(max sum);
49 51
use List::UtilsBy qw(sort_by);
......
520 522
  $TMPL_VAR->{payment_terms_obj} = get_payment_terms_for_invoice();
521 523
  $form->{duedate}             = $TMPL_VAR->{payment_terms_obj}->calc_date(reference_date => $form->{invdate}, due_date => $form->{duedate})->to_kivitendo if $TMPL_VAR->{payment_terms_obj};
522 524

  
523
  $::request->{layout}->use_javascript(map { "${_}.js" } qw(kivi.Draft kivi.File kivi.SalesPurchase kivi.Part kivi.CustomerVendor kivi.Validator ckeditor/ckeditor ckeditor/adapters/jquery kivi.io autocomplete_project client_js));
525
  $::request->{layout}->use_javascript(map { "${_}.js" } qw(kivi.Draft kivi.File kivi.SalesPurchase kivi.Part kivi.CustomerVendor kivi.Validator ckeditor/ckeditor ckeditor/adapters/jquery kivi.io autocomplete_project client_js autocomplete_chart));
524 526

  
525 527
  setup_ir_action_bar($TMPL_VAR);
526 528

  
......
820 822
  invoice_links();
821 823
  prepare_invoice();
822 824
  relink_accounts();
825
  set_taxaccounts_and_accnos();
823 826

  
824 827
  # Payments must not be recorded for the new storno invoice.
825 828
  $form->{paidaccounts} = 0;
......
1021 1024
  $form->{storno}  ||= 0;
1022 1025

  
1023 1026
  relink_accounts();
1027
  set_taxaccounts_and_accnos();
1024 1028
  if (IR->post_invoice(\%myconfig, \%$form)){
1025 1029
    # saving the history
1026 1030
    if(!exists $form->{addition} && $form->{id} ne "") {
......
1094 1098
  _assert_access();
1095 1099

  
1096 1100
  relink_accounts();
1101
  set_taxaccounts_and_accnos();
1097 1102

  
1098 1103
  my $new_rowcount = $::form->{"rowcount"} * 1 + 1;
1099 1104
  $::form->{"project_id_${new_rowcount}"} = $::form->{"globalproject_id"};
......
1145 1150
  print $::form->ajax_response_header, $result;
1146 1151
  $::lxdebug->leave_sub;
1147 1152
}
1153

  
1154
# set values form relink_accounts as default
1155
# otherwiese override with user selected values
1156
# recalc taxaccounts string
1157
sub set_taxaccounts_and_accnos {
1158
  $main::lxdebug->enter_sub;
1159

  
1160
  for my $i (1 .. $::form->{rowcount}) {
1161

  
1162
    # fill with default, ids can be 0
1163
    if ('' eq $::form->{"expense_chart_id_$i"}) {
1164
      $::form->{"expense_chart_id_$i"} = $::form->{"expense_accno_id_$i"};
1165
    }
1166
    if ('' eq $::form->{"tax_id_$i"}) {
1167
      $::form->{"tax_id_$i"} = $::form->{"expense_accno_tax_id_$i"};
1168
    }
1169
    if ('' eq $::form->{"inventory_chart_id_$i"}) {
1170
      $::form->{"inventory_chart_id_$i"} = $::form->{"inventory_accno_id_$i"};
1171
    }
1172

  
1173
    # if changed override with user values
1174
    if ($::form->{"expense_chart_id_$i"} ne $::form->{"expense_accno_id_$i"}) {
1175
      $::form->{"expense_accno_id_$i"} = $::form->{"expense_chart_id_$i"};
1176
      my $chart = SL::DB::Chart->new(id => $::form->{"expense_chart_id_$i"})->load;
1177
      $::form->{"expense_accno_$i"}    = $chart->accno;
1178
    }
1179
    if ($::form->{"tax_id_$i"} ne $::form->{"expense_accno_tax_id_$i"}) {
1180
      $::form->{"expense_accno_tax_id_$i"} = $::form->{"tax_id_$i"};
1181
      my $tax = SL::DB::Tax->new(id => $::form->{"tax_id_$i"})->load;
1182
      my $tax_accno;
1183
      if (defined $tax->chart_id) {
1184
        my $chart  = SL::DB::Chart->new(id => $tax->chart_id)->load;
1185
        $tax_accno = $chart->accno;
1186
      } else {
1187
        $tax_accno = "NO_ACCNO_" . $tax->id;
1188
      }
1189
      $::form->{"taxaccounts_$i"} = $tax_accno;
1190
      if (!($::form->{taxaccounts} =~ /\Q$tax_accno\E/)) {
1191
        # add tax info if missing
1192
        $::form->{"${tax_accno}_rate"}        = $tax->rate;
1193
        $::form->{"${tax_accno}_description"} = $tax->taxdescription;
1194
        $::form->{"${tax_accno}_tax_id"}      = $tax->id;
1195
        $::form->{"${tax_accno}_taxnumber"}   = $::form->{"expense_accno_$i"};
1196
      }
1197
    }
1198
    if ($::form->{"inventory_chart_id_$i"} ne $::form->{"inventory_accno_id_$i"}) {
1199
      $::form->{"inventory_accno_id_$i"} = $::form->{"inventory_chart_id_$i"};
1200
      my $chart = SL::DB::Chart->new(id => $::form->{"inventory_chart_id_$i"})->load;
1201
      $::form->{"inventory_accno_$i"}    = $chart->accno;
1202
    }
1203

  
1204
  }
1205

  
1206
  # recalc taxaccounts string
1207
  $::form->{taxaccounts} = "";
1208
  for my $i (1 .. $::form->{rowcount}) {
1209
    my $taxaccounts_i = $::form->{"taxaccounts_$i"};
1210
    if (!($::form->{taxaccounts} =~ /\Q$taxaccounts_i\E/)) {
1211
      $::form->{taxaccounts} .= "$taxaccounts_i ";
1212
    }
1213
  }
1214

  
1215
  $::lxdebug->leave_sub;
1216
}

Auch abrufbar als: Unified diff