Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 558c234e

Von Moritz Bunkus vor fast 8 Jahren hinzugefügt

  • ID 558c234e56b3a5387b164655e05f562929d9f736
  • Vorgänger cbdc5c37
  • Nachfolger 1ca98d42

Belegvorlagen: Speichern bei Debitorenbuchungen

Unterschiede anzeigen:

bin/mozilla/ar.pl
37 37
use List::UtilsBy qw(sort_by);
38 38

  
39 39
use SL::AR;
40
use SL::Controller::Base;
40 41
use SL::FU;
41 42
use SL::GL;
42 43
use SL::IS;
......
152 153
  update();
153 154
}
154 155

  
156
sub save_record_template {
157
  $::auth->assert('ar_transactions');
158

  
159
  my $template = $::form->{record_template_id} ? SL::DB::RecordTemplate->new(id => $::form->{record_template_id})->load : SL::DB::RecordTemplate->new;
160
  my $js       = SL::ClientJS->new(controller => SL::Controller::Base->new);
161
  my $new_name = $template->template_name_to_use($::form->{record_template_new_template_name});
162

  
163
  $js->dialog->close('#record_template_dialog');
164

  
165
  my @items = grep {
166
    $_->{chart_id} && (($_->{tax_id} // '') ne '') && ($_->{amount1} != 0)
167
  } map {
168
    +{ chart_id   => $::form->{"AR_amount_chart_id_${_}"},
169
       amount1    => $::form->parse_amount(\%::myconfig, $::form->{"amount_${_}"}),
170
       tax_id     => (split m{--}, $::form->{"taxchart_${_}"})[0],
171
       project_id => $::form->{"project_id_${_}"} || undef,
172
     }
173
  } (1..($::form->{rowcount} || 1));
174

  
175
  $template->assign_attributes(
176
    template_type  => 'ar_transaction',
177
    template_name  => $new_name,
178

  
179
    currency_id    => SL::DB::Manager::Currency->find_by(name => $::form->{currency})->id,
180
    ar_ap_chart_id => $::form->{AR_chart_id}      || undef,
181
    customer_id    => $::form->{customer_id}      || undef,
182
    department_id  => $::form->{department_id}    || undef,
183
    project_id     => $::form->{globalproject_id} || undef,
184
    employee_id    => $::form->{employee_id}      || undef,
185
    taxincluded    => $::form->{taxincluded}  ? 1 : 0,
186
    direct_debit   => $::form->{direct_debit} ? 1 : 0,
187
    ordnumber      => $::form->{ordnumber},
188
    notes          => $::form->{notes},
189

  
190
    items          => \@items,
191
  );
192

  
193
  eval {
194
    $template->save;
195
    1;
196
  } or do {
197
    return $js
198
      ->flash('error', $::locale->text("Saving the record template '#1' failed.", $new_name))
199
      ->render;
200
  };
201

  
202
  return $js
203
    ->flash('info', $::locale->text("The record template '#1' has been saved.", $new_name))
204
    ->render;
205
}
206

  
155 207
sub add {
156 208
  $main::lxdebug->enter_sub();
157 209

  
......
334 386
  my $follow_up_vc         = $form->{customer_id} ? SL::DB::Customer->load_cached($form->{customer_id})->name : '';
335 387
  my $follow_up_trans_info =  "$form->{invnumber} ($follow_up_vc)";
336 388

  
337
  $::request->layout->add_javascripts("autocomplete_chart.js", "autocomplete_customer.js", "show_vc_details.js", "show_history.js", "follow_up.js", "kivi.Draft.js", "kivi.GL.js");
389
  $::request->layout->add_javascripts("autocomplete_chart.js", "autocomplete_customer.js", "show_vc_details.js", "show_history.js", "follow_up.js", "kivi.Draft.js", "kivi.GL.js", "kivi.RecordTemplate.js");
338 390

  
339 391
  my $transdate = $::form->{transdate} ? DateTime->from_kivitendo($::form->{transdate}) : DateTime->today_local;
340 392
  my $first_taxchart;

Auch abrufbar als: Unified diff