Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision c05d3f5b

Von Moritz Bunkus vor fast 2 Jahren hinzugefügt

Liquiditätsübersicht: Auftragsliste gefixt

Die Links im Tabellenfuß hatten bisher auf die normale Auftragssuche
verwiesen. Problem war aber, dass dabei schlicht nicht exakt
diejenigen Aufträge angezeigt wurden, die für die Liquiditätsübersicht
relevant waren: teils zu viele, teils zu wenige (z.B. nicht diejenigen
der wiederkehrenden Rechnungen).

Die neue Liste ist eine eigene Funktion des
Liquiditätsübersichts-Controllers, die explizit diejenigen Belege
heraussucht, die für die Berechnung herangezogen werden.

Unterschiede anzeigen:

SL/Controller/LiquidityProjection.pm
11 11
__PACKAGE__->run_before('check_auth');
12 12

  
13 13
use Rose::Object::MakeMethods::Generic (
14
  scalar                  => [ qw(liquidity) ],
15
  'scalar --get_set_init' => [ qw(oe_report_columns_str) ],
14
  scalar => [ qw(liquidity) ],
16 15
);
17 16

  
18 17

  
......
37 36
  $self->render('liquidity_projection/show', title => t8('Liquidity projection'));
38 37
}
39 38

  
39
sub action_list_orders {
40
  my ($self) = @_;
41

  
42
  my @orders = SL::LiquidityProjection->orders_for_time_period(
43
    after  => $::form->{after}  ? DateTime->from_kivitendo($::form->{after})  : undef,
44
    before => $::form->{before} ? DateTime->from_kivitendo($::form->{before}) : undef,
45
  );
46

  
47
  $self->render(
48
    'liquidity_projection/list_orders',
49
    title  => t8('Sales Orders'),
50
    ORDERS => \@orders,
51
  );
52
}
53

  
40 54
#
41 55
# filters
42 56
#
......
54 68

  
55 69
  my $reqdate = $params{reqdate};
56 70
  my $months  = $params{months} * 1;
71
  my $today   = DateTime->today_local->truncate(to => 'month');
72
  my %url_params;
57 73

  
58 74
  my $fields  = '';
59 75

  
60 76
  if ($reqdate eq 'old') {
61
    $fields .= '&reqdate_unset_or_old=Y';
77
    $url_params{before} = $today->to_kivitendo;
62 78

  
63 79
  } elsif ($reqdate eq 'future') {
64
    my @now  = localtime;
65
    $fields .= '&reqdatefrom=' . $self->iso_to_display(SL::LiquidityProjection::_the_date($now[5] + 1900, $now[4] + 1 + $months) . '-01');
80
    $url_params{after} = $today->add(months => $months)->to_kivitendo;
66 81

  
67 82
  } else {
68
    $reqdate =~ m/(\d+)-(\d+)/;
69
    $fields .=  '&reqdatefrom=' . $self->iso_to_display($reqdate . '-01');
70
    $fields .=  '&reqdateto='   . $self->iso_to_display($reqdate . sprintf('-%02d', DateTime->last_day_of_month(year => $1, month => $2)->day));
71

  
83
    $reqdate            =~ m/(\d+)-(\d+)/;
84
    my $date            = DateTime->new_local(year => $1, month => $2, day => 1);
85
    $url_params{after}  = $date->to_kivitendo;
86
    $url_params{before} = $date->add(months => 1)->to_kivitendo;
72 87
  }
73 88

  
74
  return "oe.pl?action=orders&type=sales_order&vc=customer&" . $self->oe_report_columns_str . $fields;
75
}
76

  
77
sub iso_to_display {
78
  my ($self, $date) = @_;
79

  
80
  $::locale->reformat_date({ dateformat => 'yyyy-mm-dd' }, $date, $::myconfig{dateformat});
89
  return $self->url_for(action => 'list_orders', %url_params);
81 90
}
82 91

  
83 92
sub setup_show_action_bar {
SL/LiquidityProjection.pm
318 318
  :                              $date;
319 319
}
320 320

  
321
sub orders_for_time_period {
322
  my ($class, %params) = @_;
323

  
324
  my $dbh = SL::DB::Order->new->db->dbh;
325

  
326
  my @recurring_orders;
327

  
328
  # 1. Alle aktiven Konfigurationen für wiederkehrende Rechnungen auslesen.
329

  
330
  my $configs = SL::DB::Manager::PeriodicInvoicesConfig->get_all(where => [ active => 1 ]);
331

  
332
  my %calc_params;
333
  $calc_params{start_date} = $params{after}->clone                   if $params{after};
334
  $calc_params{end_date}   = $params{before}->clone->add(days => -1) if $params{before};
335
  $calc_params{end_date} //= $calc_params{start_date}->clone->add(years => 1);
336

  
337
  foreach my $config (@{ $configs }) {
338
    my @dates = $config->calculate_invoice_dates(%calc_params);
339
    next unless @dates;
340

  
341
    my $order = SL::DB::Order->new(id => $config->oe_id)->load(with_objects => [ qw(customer employee) ]);
342
    $order->{is_recurring} = 1;
343

  
344
    push @recurring_orders, $order;
345
  }
346

  
347
  my @where = (
348
    '!customer_id' => undef,
349
    or             => [ quotation => undef, quotation => 0, ],
350
    or             => [ closed    => undef, closed    => 0, ],
351
  );
352
  push @where, (reqdate => { ge => $params{after}->clone })  if $params{after};
353
  push @where, (reqdate => { lt => $params{before}->clone }) if $params{before};
354
  push @where, '!id' => [ map { $_->id } @recurring_orders ] if @recurring_orders;
355

  
356
  # 1. Auslesen aller offenen Aufträge, deren Lieferdatum im
357
  # gewünschten Bereich liegt
358
  my $regular_orders = SL::DB::Manager::Order->get_all(
359
    where        => \@where,
360
    with_objects => [ qw(customer employee) ],
361
  );
362

  
363
  return sort {
364
         ($a->transdate          <=> $b->transdate)
365
      || ($a->reqdate            <=> $b->reqdate)
366
      || (lc($a->customer->name) cmp lc($b->customer->name))
367
  } (@recurring_orders, @{ $regular_orders });
368
}
369

  
321 370
1;
locale/de/all
3022 3022
  'Recorded Tax'                => 'Gespeicherte Steuern',
3023 3023
  'Recorded taxkey'             => 'Gespeicherter Steuerschlüssel',
3024 3024
  'Records'                     => 'Belege',
3025
  'Recurring'                   => 'Wiederkehrend',
3025 3026
  'Reduced Master Data'         => 'Abschlag',
3026 3027
  'Reference'                   => 'Referenz',
3027 3028
  'Reference / Invoice Number'  => 'Referenz / Rechnungsnummer',
......
4066 4067
  'There are no entries that match the filter.' => 'Es gibt keine Einträge, auf die der Filter zutrifft.',
4067 4068
  'There are no items in stock.' => 'Dieser Artikel ist nicht eingelagert.',
4068 4069
  'There are no items on your TODO list at the moment.' => 'Ihre Aufgabenliste enthält momentan keine Einträge.',
4070
  'There are no orders for the selected time period.' => 'Es gibt für den ausgewählten Zeitraum keine Aufträge.',
4069 4071
  'There are no record templates yet.' => 'Es gibt noch keine Belegvorlagen.',
4070 4072
  'There are parts with no reclamation reason at position:' => 'Es git Artikel mit keinem Reklamationsgrund an Position:',
4071 4073
  'There are several options you can handle this problem, please select one:' => 'Bitte wählen Sie eine der folgenden Optionen, um mit dem Problem umzugehen:',
templates/design40_webpages/liquidity_projection/list_orders.html
1
[%- USE LxERP -%][%- USE HTML -%][%- USE P -%]
2

  
3
<h1>[% HTML.escape(title) %]</h1>
4

  
5
[% IF !ORDERS.size %]
6
  <p>[% LxERP.t8("There are no orders for the selected time period.") %]</p>
7

  
8
[% ELSE %]
9

  
10
  <table class="tbl-list">
11
    <thead>
12
      <tr class="listheading">
13
        <th class="right">[% LxERP.t8("Date") %]</th>
14
        <th class="right">[% LxERP.t8("Delivery Date") %]</th>
15
        <th class="right">[% LxERP.t8("Order") %]</th>
16
        <th class="right">[% LxERP.t8("Customer Order Number") %]</th>
17
        <th>[% LxERP.t8("Customer") %]</th>
18
        <th class="right">[% LxERP.t8("Total") %]</th>
19
        <th class="right">[% LxERP.t8("Net amount") %]</th>
20
        <th>[% LxERP.t8("Employee") %]</th>
21
        <th>[% LxERP.t8("Transaction description") %]</th>
22
        <th>[% LxERP.t8("Recurring") %]</th>
23
      </tr>
24
    </thead>
25

  
26
    <tbody>
27
      [% FOREACH order = ORDERS %]
28
        <tr>
29
          <td class="date">[% HTML.escape(order.transdate.to_kivitendo) %]</td>
30
          <td class="date">[% HTML.escape(order.reqdate.to_kivitendo) %]</td>
31
          <td class="numeric">[% P.order.sales_order(order) %]</td>
32
          <td class="numeric">[% HTML.escape(order.cusordnumber) %]</td>
33
          <td>[% P.customer_vendor.customer(order.customer) %]</td>
34
          <td class="numeric">[% HTML.escape(LxERP.format_amount(order.amount,    2)) %]</td>
35
          <td class="numeric">[% HTML.escape(LxERP.format_amount(order.netamount, 2)) %]</td>
36
          <td>[% HTML.escape(order.employee.safe_name) %]</td>
37
          <td>[% HTML.escape(order.transaction_description) %]</td>
38
          <td>[% IF order.is_recurring %][% LxERP.t8("yes") %][% ELSE %][% LxERP.t8("no") %][% END %]</td>
39
        </tr>
40
      [% END %]
41
    </tbody>
42
  </table>
43
[% END %]
templates/webpages/liquidity_projection/list_orders.html
1
[%- USE LxERP -%][%- USE HTML -%][%- USE P -%]
2

  
3
<h1>[% HTML.escape(title) %]</h1>
4

  
5
[% IF !ORDERS.size %]
6
  <p>[% LxERP.t8("There are no orders for the selected time period.") %]</p>
7

  
8
[% ELSE %]
9

  
10
  <table style="width: 100%">
11
    <thead>
12
      <tr class="listheading">
13
        <th align="right">[% LxERP.t8("Date") %]</th>
14
        <th align="right">[% LxERP.t8("Delivery Date") %]</th>
15
        <th align="right">[% LxERP.t8("Order") %]</th>
16
        <th align="right">[% LxERP.t8("Customer Order Number") %]</th>
17
        <th>[% LxERP.t8("Customer") %]</th>
18
        <th align="right">[% LxERP.t8("Total") %]</th>
19
        <th align="right">[% LxERP.t8("Net amount") %]</th>
20
        <th>[% LxERP.t8("Employee") %]</th>
21
        <th>[% LxERP.t8("Transaction description") %]</th>
22
        <th>[% LxERP.t8("Recurring") %]</th>
23
      </tr>
24
    </thead>
25

  
26
    <tbody>
27
      [% FOREACH order = ORDERS %]
28
        <tr class="listrow">
29
          <td align="right">[% HTML.escape(order.transdate.to_kivitendo) %]</td>
30
          <td align="right">[% HTML.escape(order.reqdate.to_kivitendo) %]</td>
31
          <td align="right">[% P.order.sales_order(order) %]</td>
32
          <td align="right">[% HTML.escape(order.cusordnumber) %]</td>
33
          <td>[% P.customer_vendor.customer(order.customer) %]</td>
34
          <td align="right">[% HTML.escape(LxERP.format_amount(order.amount,    2)) %]</td>
35
          <td align="right">[% HTML.escape(LxERP.format_amount(order.netamount, 2)) %]</td>
36
          <td>[% HTML.escape(order.employee.safe_name) %]</td>
37
          <td>[% HTML.escape(order.transaction_description) %]</td>
38
          <td>[% IF order.is_recurring %][% LxERP.t8("yes") %][% ELSE %][% LxERP.t8("no") %][% END %]</td>
39
        </tr>
40
      [% END %]
41
    </tbody>
42
  </table>
43
[% END %]

Auch abrufbar als: Unified diff