Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision b3aa9c06

Von Bernd Bleßmann vor etwa 2 Jahren hinzugefügt

  • ID b3aa9c0656dbfe114faef7b6446eedec378e8b08
  • Vorgänger 7d9842f8
  • Nachfolger d973b89f

Umstatzstatistik: actions zu einer zusammengefasst.

Der Code war da fast gleich.

Unterschiede anzeigen:

SL/Controller/CustomerVendorTurnover.pm
112 112
   $self->render('customer_vendor_turnover/count_open_items_by_year', { layout => 0 });
113 113
}
114 114

  
115
sub action_turnover_by_month {
115
sub action_turnover {
116 116

  
117 117
  my ($self) = @_;
118 118

  
......
128 128
    $db      = "ap";
129 129
    $cv_type = "vendor_id";
130 130
  }
131
  my $query = <<SQL;
132
  SELECT CONCAT(EXTRACT (MONTH FROM transdate),'/',EXTRACT (YEAR FROM transdate)) as date_part,
133
         count(id)                                                                as count,
134
         sum(amount)                                                              as amount,
135
         sum(netamount)                                                           as netamount,
136
         sum(paid)                                                                as paid
137
    FROM $db WHERE $cv_type = ?
138
GROUP BY EXTRACT (YEAR FROM transdate), EXTRACT (MONTH FROM transdate)
139
ORDER BY EXTRACT (YEAR FROM transdate) DESC, EXTRACT (MONTH FROM transdate) DESC
140
SQL
141
   $self->{turnover_statistic} = selectall_hashref_query($::form, $dbh, $query, $cv);
142
   $self->render('customer_vendor_turnover/count_turnover', { layout => 0 });
143
}
144 131

  
145
sub action_turnover_by_year {
146
  my ($self) = @_;
147

  
148
  return $self->render('generic/error', { layout => 0 }, label_error => "list_transactions needs a trans_id") unless $::form->{id};
149

  
150
  my $dbh = SL::DB->client->dbh;
151
  my $cv = $::form->{id};
152
  my ($db, $cv_type);
153
  if ($::form->{db} eq 'customer') {
154
    $db      = "ar";
155
    $cv_type = "customer_id";
132
  my ($date_part_select, $group_by, $order_by);
133
  if ('month' eq $::form->{mode}) {
134
    $date_part_select = "CONCAT(EXTRACT (MONTH FROM transdate),'/',EXTRACT (YEAR FROM transdate))";
135
    $group_by         = "EXTRACT (YEAR FROM transdate), EXTRACT (MONTH FROM transdate)";
136
    $order_by         = "EXTRACT (YEAR FROM transdate) DESC, EXTRACT (MONTH FROM transdate) DESC";
156 137
  } else {
157
    $db      = "ap";
158
    $cv_type = "vendor_id";
138
    $date_part_select = "EXTRACT (YEAR FROM transdate)";
139
    $group_by         = "EXTRACT (YEAR FROM transdate)";
140
    $order_by         = "EXTRACT (YEAR FROM transdate) DESC";
159 141
  }
142

  
160 143
  my $query = <<SQL;
161
  SELECT EXTRACT (YEAR FROM transdate) as date_part,
162
         count(id)                     as count,
163
         sum(amount)                   as amount,
164
         sum(netamount)                as netamount,
165
         sum(paid)                     as paid
144
  SELECT $date_part_select as date_part,
145
         count(id)         as count,
146
         sum(amount)       as amount,
147
         sum(netamount)    as netamount,
148
         sum(paid)         as paid
166 149
    FROM $db WHERE $cv_type = ?
167
GROUP BY date_part
168
ORDER BY date_part DESC
150
GROUP BY $group_by
151
ORDER BY $order_by
169 152
SQL
170 153
   $self->{turnover_statistic} = selectall_hashref_query($::form, $dbh, $query, $cv);
171 154
   $self->render('customer_vendor_turnover/count_turnover', { layout => 0 });
......
477 460

  
478 461
gets and shows a dunning statistic of the customer by year
479 462

  
480
=item C<action_turnover_by_month>
463
=item C<action_turnover>
481 464

  
482 465
gets and shows an invoice statistic of customer/vendor by month
483

  
484
=item C<action_turnover_by_year>
485

  
486
gets and shows an invoice statistic of customer/vendor by year
466
or year depending on $::form->{mode}. If $::form->{mode} eq 'month'
467
get statistics by month, otherwise by year.
487 468

  
488 469
=item C<action_get_invoices>
489 470

  
js/kivi.CustomerVendorTurnover.js
36 36
  };
37 37

  
38 38
  ns.show_turnover_stat = function(period) {
39
    if (period === 'y') {
40
      var url = 'controller.pl?action=CustomerVendorTurnover/turnover_by_year&id=' + $('#cv_id').val() + '&db=' + $('#db').val();
41
      $('#turnovers').load(url);
42
    } else {
43
      var url = 'controller.pl?action=CustomerVendorTurnover/turnover_by_month&id=' + $('#cv_id').val() + '&db=' + $('#db').val();
44
      $('#turnovers').load(url);
45
    }
39
    let mode = 'year';
40
    if (period === 'm') mode = 'month';
41
    const url = 'controller.pl?action=CustomerVendorTurnover/turnover&id=' + $('#cv_id').val() + '&db=' + $('#db').val() + '&mode=' + mode;
42
    $('#turnovers').load(url);
46 43
  };
47 44

  
48 45
});

Auch abrufbar als: Unified diff