Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision ad4bebf4

Von Felix Eichler vor fast 4 Jahren hinzugefügt

  • ID ad4bebf4dfcc48d0e313bfc4cb045de485c4d9fb
  • Vorgänger 8f07fac1
  • Nachfolger 83fac3d1

Mahnungen: Mit Rechnung verknüpfen

Erstellte Mahnungen werden mit den gemahnten Rechnungen verknüpft und
unter "Verknüpfte Belege" gelistet.
Außerdem werden Rechnungen über Mahnkosten wiederum zu den zugehörigen
Mahnungen verknüpft.

impl. #7440

Unterschiede anzeigen:

SL/Controller/RecordLinks.pm
52 52
  { title => t8('Email'),                   type => 'email_journal',           model => 'EmailJournal',    number => 'id', description => 'subject', description_title => t8('Subject'), },
53 53
  { title => t8('AR Transaction'),          type => 'ar_transaction',          model => 'Invoice',         number => 'invnumber', },
54 54
  { title => t8('AP Transaction'),          type => 'ap_transaction',          model => 'PurchaseInvoice', number => 'invnumber', },
55
  { title => t8('Dunning'),                 type => 'dunning',                 model => 'Dunning',         number => 'dunning_id', },
55 56
);
56 57

  
57 58
my @link_types = map { +{ %link_type_defaults, %{ $_ } } } @link_type_specifics;
SL/DB/Dunning.pm
6 6
use strict;
7 7

  
8 8
use SL::DB::MetaSetup::Dunning;
9
use SL::DB::Helper::LinkedRecords;
9 10

  
10 11
__PACKAGE__->meta->initialize;
11 12

  
12 13
# Creates get_all, get_all_count, get_all_iterator, delete_all and update_all.
13 14
__PACKAGE__->meta->make_manager_class;
14 15

  
16

  
17
sub date {
18
  goto &transdate;
19
}
20

  
15 21
1;
SL/DB/Helper/LinkedRecords.pm
314 314
                  'SL::DB::Letter'          => sub { $_[0]->letternumber },
315 315
                  'SL::DB::ShopOrder'       => sub { $_[0]->shop_ordernumber },
316 316
                  'SL::DB::EmailJournal'    => sub { $_[0]->id },
317
                  'SL::DB::Dunning'         => sub { $_[0]->dunning_id },
317 318
                  UNKNOWN                   => '9999999999999999',
318 319
                );
319 320
  my $number_xtor = sub {
......
345 346
              'SL::DB::Letter'          => 200,
346 347
              'SL::DB::ShopOrder'       => 250,
347 348
              'SL::DB::EmailJournal'    => 300,
349
              'SL::DB::Dunning'         => 350,
348 350
              UNKNOWN                   => 999,
349 351
            );
350 352
  my $score_xtor = sub {
SL/DN.pm
192 192
             AND (d_interest.dunning_id <> ?)
193 193
             AND NOT (d_interest.fee_interest_ar_id ISNULL)
194 194
         ), 0)
195
         AS max_previous_interest
195
         AS max_previous_interest,
196
         d.id AS link_id
196 197
       FROM dunning d
197 198
       WHERE dunning_id = ?|;
198 199
  @values = ($dunning_id, $dunning_id, $dunning_id);
......
201 202
  my ($fee_remaining, $interest_remaining) = (0, 0);
202 203
  my ($fee_total, $interest_total) = (0, 0);
203 204

  
205
  my @link_ids;
206

  
204 207
  while (my $ref = $sth->fetchrow_hashref()) {
205 208
    $fee_remaining      += $form->round_amount($ref->{fee}, 2);
206 209
    $fee_remaining      -= $form->round_amount($ref->{max_previous_fee}, 2);
......
208 211
    $interest_remaining += $form->round_amount($ref->{interest}, 2);
209 212
    $interest_remaining -= $form->round_amount($ref->{max_previous_interest}, 2);
210 213
    $interest_total     += $form->round_amount($ref->{interest}, 2);
214
    push @link_ids, $ref->{link_id};
211 215
  }
212 216

  
213 217
  $sth->finish();
......
271 275
             $::myconfig{login});   # employee_id
272 276
  do_query($form, $dbh, $query, @values);
273 277

  
278
  RecordLinks->create_links(
279
    'dbh'        => $dbh,
280
    'mode'       => 'ids',
281
    'from_table' => 'dunning',
282
    'from_ids'   => \@link_ids,
283
    'to_table'   => 'ar',
284
    'to_id'      => $ar_id,
285
  );
286

  
274 287
  $query =
275 288
    qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, gldate, taxkey, tax_id, chart_link)
276 289
       VALUES (?, ?, ?, current_date, current_date, 0,
......
326 339
  my $h_update_ar = prepare_query($form, $dbh, $q_update_ar);
327 340

  
328 341
  my $q_insert_dunning =
329
    qq|INSERT INTO dunning (dunning_id, dunning_config_id, dunning_level, trans_id,
330
                            fee,        interest,          transdate,     duedate)
331
       VALUES (?, ?,
342
    qq|INSERT INTO dunning (id,  dunning_id, dunning_config_id, dunning_level, trans_id,
343
                            fee, interest,   transdate,         duedate)
344
       VALUES (?, ?, ?,
332 345
               (SELECT dunning_level FROM dunning_config WHERE id = ?),
333 346
               ?,
334 347
               (SELECT SUM(fee)
......
366 379
    $send_email       |= $row->{email};
367 380
    $print_invoice    |= $row->{print_invoice};
368 381

  
382
    my ($row_id)       = selectrow_query($form, $dbh, qq|SELECT nextval('id')|);
369 383
    my $next_config_id = conv_i($row->{next_dunning_config_id});
370 384
    my $invoice_id     = conv_i($row->{invoice_id});
371 385

  
372
    @values = ($dunning_id,     $next_config_id, $next_config_id,
373
               $invoice_id,     $next_config_id, $invoice_id,
374
               $next_config_id, $next_config_id);
386
    @values = ($row_id,         $dunning_id,     $next_config_id,
387
               $next_config_id, $invoice_id,     $next_config_id,
388
               $invoice_id,     $next_config_id, $next_config_id);
375 389
    do_statement($form, $h_insert_dunning, $q_insert_dunning, @values);
390

  
391
    RecordLinks->create_links(
392
      'dbh'        => $dbh,
393
      'mode'       => 'ids',
394
      'from_table' => 'ar',
395
      'from_ids'   => $invoice_id,
396
      'to_table'   => 'dunning',
397
      'to_id'      => $row_id,
398
    );
376 399
  }
377 400
  # die this transaction, because for this customer only credit notes are
378 401
  # selected ...
SL/Presenter/ALL.pm
5 5
use SL::Presenter::Chart;
6 6
use SL::Presenter::CustomerVendor;
7 7
use SL::Presenter::DeliveryOrder;
8
use SL::Presenter::Dunning;
8 9
use SL::Presenter::EscapedText;
9 10
use SL::Presenter::Invoice;
10 11
use SL::Presenter::GL;
......
26 27
  chart                       => 'SL::Presenter::Chart',
27 28
  customer_vendor             => 'SL::Presenter::CustomerVendor',
28 29
  delivery_order              => 'SL::Presenter::DeliveryOrder',
30
  dunning                     => 'SL::Presenter::Dunning',
29 31
  escaped_text                => 'SL::Presenter::EscapedText',
30 32
  invoice                     => 'SL::Presenter::Invoice',
31 33
  gl                          => 'SL::Presenter::GL',
SL/Presenter/Dunning.pm
1
package SL::Presenter::Dunning;
2

  
3
use strict;
4

  
5
use SL::Presenter::EscapedText qw(escape is_escaped);
6

  
7
use Exporter qw(import);
8
our @EXPORT_OK = qw(dunning);
9

  
10
use Carp;
11

  
12
sub dunning {
13
  my ($dunning, $type, %params) = @_;
14

  
15
  $params{display} ||= 'inline';
16

  
17
  croak "Unknown display type '$params{display}'" unless $params{display} =~ m/^(?:inline|table-cell)$/;
18

  
19
  my $invoice = SL::DB::Manager::Invoice->find_by( id => $dunning->trans_id );
20

  
21
  my $text = join '', (
22
    $params{no_link} ? '' : '<a href="dn.pl?action=print_dunning&amp;format=pdf&amp;media=screen&amp;dunning_id=' . $dunning->dunning_id . '&amp;language_id=' . $invoice->language_id . '">',
23
    escape($dunning->dunning_config->dunning_description),
24
    $params{no_link} ? '' : '</a>',
25
  );
26

  
27
  is_escaped($text);
28
}
29

  
30
1;
SL/Presenter/Record.pm
67 67
  $output .= _letter_list(                 $groups{letters},                  %params) if $groups{letters};
68 68
  $output .= _email_journal_list(          $groups{email_journals},           %params) if $groups{email_journals};
69 69

  
70
  $output .= _dunning_list(                $groups{dunnings},                 %params) if $groups{dunnings};
71

  
70 72
  $output  = SL::Presenter->get->render('presenter/record/grouped_record_list', %params, output => $output);
71 73

  
72 74
  return $output;
......
195 197
    bank_transactions        => sub { (ref($_[0]) eq 'SL::DB::BankTransaction') &&  $_[0]->id                           },
196 198
    letters                  => sub { (ref($_[0]) eq 'SL::DB::Letter')          &&  $_[0]->id                           },
197 199
    email_journals           => sub { (ref($_[0]) eq 'SL::DB::EmailJournal')    &&  $_[0]->id                           },
200
    dunnings                 => sub { (ref($_[0]) eq 'SL::DB::Dunning')                                                 },
198 201
  );
199 202

  
200 203
  my %groups;
......
573 576
    %params,
574 577
  );
575 578
}
579
sub _dunning_list {
580
  my ($list, %params) = @_;
576 581

  
582
  return record_list(
583
    $list,
584
    title   => $::locale->text('Dunnings'),
585
    type    => 'dunning',
586
    columns => [
587
      [ $::locale->text('Dunning Level'),   sub { $_[0]->presenter->dunning(display => 'table-cell') } ],
588
      [ $::locale->text('Dunning Date'),    'transdate'                                                ],
589
      [ $::locale->text('Dunning Duedate'), 'duedate'                                                  ],
590
      [ $::locale->text('Total Fees'),      'fee'                                                      ],
591
      [ $::locale->text('Interest'),        'interest'                                                 ],
592
    ],
593
    %params,
594
  );
595
}
577 596

  
578 597
1;
579 598

  

Auch abrufbar als: Unified diff