Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 9508e215

Von Werner Hahn vor etwa 6 Jahren hinzugefügt

  • ID 9508e215c78bc172721e14d41d21858abb23672e
  • Vorgänger 6c19cff0
  • Nachfolger 26cfeadb

Kundenstatistik: erster commit ohne Webtemplates

Unterschiede anzeigen:

SL/Controller/CustomerVendor.pm
10 10
use SL::Helper::Flash;
11 11
use SL::Locale::String;
12 12
use SL::Controller::Helper::GetModels;
13
use SL::Controller::Helper::ReportGenerator;
14
use SL::Controller::Helper::ParseFilter;
13 15

  
14 16
use SL::DB::Customer;
15 17
use SL::DB::Vendor;
......
25 27
use SL::DB::FollowUpLink;
26 28
use SL::DB::History;
27 29
use SL::DB::Currency;
30
use SL::DB::Invoice;
31

  
32
use Data::Dumper;
28 33

  
29 34
use Rose::Object::MakeMethods::Generic (
30 35
  'scalar --get_set_init' => [ qw(customer_models vendor_models) ],
......
466 471
  print $::form->redirect_header($url);
467 472
}
468 473

  
469

  
470 474
sub action_get_delivery {
471 475
  my ($self) = @_;
472 476

  
......
941 945
    ],
942 946
    with_objects => ['follow_up'],
943 947
  );
944

  
948
  
949
  $self->{open_items} = SL::DB::Manager::Invoice->get_all_count(
950
    query => [
951
      customer_id => $self->{cv}->id,
952
      paid => {lt_sql => 'amount'},      
953
    ],
954
  );
955
  
945 956
  $self->{template_args} ||= {};
946 957

  
947 958
  $::request->{layout}->add_javascripts('kivi.CustomerVendor.js');
SL/Controller/CustomerVendorTurnover.pm
1
package SL::Controller::CustomerVendorTurnover;
2
use strict;
3
use parent qw(SL::Controller::Base);
4
use SL::DBUtils;
5
use SL::DB::AccTransaction;
6
use SL::DB::Invoice;
7

  
8
__PACKAGE__->run_before('check_auth');
9

  
10
sub action_list_turnover {
11
  my ($self) = @_;
12
  
13
  return $self->render('generic/error', { layout => 0 }, label_error => "list_transactions needs a trans_id") unless $::form->{id};
14

  
15
  my $cv = $::form->{id} || {};
16
  my $open_invoices;
17
  $open_invoices = SL::DB::Manager::Invoice->get_all(
18
    query => [customer_id => $cv,
19
              paid => {lt_sql => 'amount'},      
20
    ],
21
    with_objects => ['dunnings'],
22
  );
23
  my $open_items;
24
  if (@{$open_invoices}) {
25
    return $self->render(\'', { type => 'json' }) unless scalar @{$open_invoices};
26
    $open_items = $self->_list_open_items($open_invoices);
27
  }
28
  return $self->render('customer_vendor_turnover/turnover', { header => 0 }, open_items => $open_items, id => $cv);
29
}
30

  
31
sub _list_open_items {
32
  my ($self, $open_items) = @_;
33

  
34
  return $self->render('customer_vendor_turnover/_list_open_items', { output => 0 }, OPEN_ITEMS => $open_items, title => $::locale->text('Open Items') );
35
}
36

  
37
sub action_count_open_items_by_year {
38
  my ($self) = @_;
39

  
40
  return $self->render('generic/error', { layout => 0 }, label_error => "list_transactions needs a trans_id") unless $::form->{id};
41
  my $dbh = $::form->get_standard_dbh();
42

  
43
  my $cv = $::form->{id} || {};
44

  
45
  my $query = "SELECT EXTRACT (YEAR FROM d.transdate),
46
    count(d.id),
47
    max(d.dunning_level)
48
    FROM dunning d
49
    LEFT JOIN ar a
50
    ON a.id = d.trans_id
51
    LEFT JOIN customer c
52
    ON a.customer_id = c.id
53
    WHERE c.id = $cv
54
    GROUP BY EXTRACT (YEAR FROM d.transdate), c.id
55
    ORDER BY date_part DESC";
56

  
57
   $self->{dun_statistic} = selectall_hashref_query($::form, $dbh, $query);
58
   $self->render('customer_vendor_turnover/count_open_items_by_year', { layout => 0 }); 
59
}
60
sub action_count_open_items_by_month {
61

  
62
  my ($self) = @_;
63

  
64
  return $self->render('generic/error', { layout => 0 }, label_error => "list_transactions needs a trans_id") unless $::form->{id};
65
  my $dbh = $::form->get_standard_dbh();
66

  
67
  my $cv = $::form->{id} || {};
68

  
69
  my $query = "SELECT CONCAT(EXTRACT (MONTH FROM d.transdate),'/',EXTRACT (YEAR FROM d.transdate)) AS date_part,
70
    count(d.id),
71
    max(d.dunning_level)
72
    FROM dunning d
73
    LEFT JOIN ar a
74
    ON a.id = d.trans_id
75
    LEFT JOIN customer c
76
    ON a.customer_id = c.id
77
    WHERE c.id = $cv
78
    GROUP BY EXTRACT (YEAR FROM d.transdate), EXTRACT (MONTH FROM d.transdate), c.id
79
    ORDER BY EXTRACT (YEAR FROM d.transdate) DESC";
80

  
81
   $self->{dun_statistic} = selectall_hashref_query($::form, $dbh, $query);
82
   $self->render('customer_vendor_turnover/count_open_items_by_year', { layout => 0 }); 
83
}
84
sub action_turnover_by_month {
85

  
86
  my ($self) = @_;
87

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

  
90
  my $dbh = $::form->get_standard_dbh();
91
  my $cv = $::form->{id} || {};
92
  my $query = "SELECT CONCAT(EXTRACT (MONTH FROM transdate),'/',EXTRACT (YEAR FROM transdate)) AS date_part,
93
    count(id) as count,
94
    sum(amount) as amount,
95
    sum(netamount) as netamount,
96
    sum(paid) as paid
97
    FROM ar WHERE customer_id = $cv
98
    GROUP BY EXTRACT (YEAR FROM transdate), EXTRACT (MONTH FROM transdate)
99
    ORDER BY EXTRACT (YEAR FROM transdate) DESC, EXTRACT (MONTH FROM transdate) DESC";
100

  
101
   $self->{turnover_statistic} = selectall_hashref_query($::form, $dbh, $query);
102
   $self->render('customer_vendor_turnover/count_turnover', { layout => 0 }); 
103
}
104
sub action_turnover_by_year {
105

  
106
  my ($self) = @_;
107

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

  
110
  my $dbh = $::form->get_standard_dbh();
111
  my $cv = $::form->{id} || {};
112
  my $query = "SELECT EXTRACT (YEAR FROM transdate) as date_part,
113
    count(id) as count,
114
    sum(amount) as amount,
115
    sum(netamount) as netamount,
116
    sum(paid) as paid
117
    FROM ar WHERE customer_id = $cv
118
    GROUP BY date_part
119
    ORDER BY date_part DESC";
120

  
121
   $self->{turnover_statistic} = selectall_hashref_query($::form, $dbh, $query);
122
   $self->render('customer_vendor_turnover/count_turnover', { layout => 0 }); 
123
}
124
sub action_get_invoices {
125
  my ($self) = @_;
126
  
127
  return $self->render('generic/error', { layout => 0 }, label_error => "list_transactions needs a trans_id") unless $::form->{id};
128

  
129
  my $cv = $::form->{id} || {};
130
  my $invoices = SL::DB::Manager::Invoice->get_all(
131
    query => [ customer_id => $cv, ],
132
    sort_by => 'invnumber DESC',
133
  );
134
  $self->render('customer_vendor_turnover/invoices_statistic', { layout => 0 }, invoices => $invoices);
135
}
136
sub _list_articles_by_invoice {
137
}
138
sub _list_count_articles_by_year {
139
}
140
sub check_auth {
141
  $::auth->assert('general_ledger');
142
}
143
1;
SL/DB/Invoice.pm
60 60
      sort_by      => 'acc_trans_id ASC',
61 61
    },
62 62
  },
63
  dunnings       => {
64
    type         => 'one to many',
65
    class        => 'SL::DB::Dunning',
66
    column_map   => { id => 'trans_id' },
67
    manager_args => { with_objects => [ 'dunnings' ] }
68
  },
63 69
);
64 70

  
65 71
__PACKAGE__->meta->initialize;
js/kivi.CustomerVendor.js
208 208
  };
209 209

  
210 210
  this.inline_report = function(target, source, data){
211
//    alert("HALLO S " + source + " --T " + target + " tt D " + data);
211 212
    $.ajax({
212 213
      url:        source,
213 214
      success:    function (rsp) {
locale/de/all
1093 1093
  'Dunning overview'            => 'Mahnungsübersicht',
1094 1094
  'Dunning status'              => 'Mahnstatus',
1095 1095
  'Dunnings'                    => 'Mahnungen',
1096
  'Dunningstatistic'            => 'Mahnstatistic',
1096 1097
  'Duplicate in CSV file'       => 'Duplikat in CSV-Datei',
1097 1098
  'Duplicate in database'       => 'Duplikat in Datenbank',
1098 1099
  'During the next update a taxkey 0 with tax rate of 0 will automatically created.' => 'Beim nächsten Ausführen des Updates wird ein Steuerschlüssel 0 mit einem Steuersatz von 0% automatisch erzeugt.',
......
1519 1520
  'Hide mappings (csv_import)'  => 'Spaltenzuordnungen verbergen',
1520 1521
  'Hide settings'               => 'Einstellungen verbergen',
1521 1522
  'Hint: Not all VC Numbers are personal accounts compliant' => 'Hinweis: Nicht alle Kunden-/Lieferantennummern sind DATEV-Personenkonten kompatibel.',
1523
  'Highest Dunninglevel'        => 'Höchste Mahnstufe',
1522 1524
  'Hints'                       => 'Hinweise',
1523 1525
  'History'                     => 'Historie',
1524 1526
  'History Search'              => 'Historien Suche',
......
1668 1670
  'Invoice Field 2'             => 'Belegfeld 2',
1669 1671
  'Invoice Number'              => 'Rechnungsnummer',
1670 1672
  'Invoice Number missing!'     => 'Rechnungsnummer fehlt!',
1673
  'Invoice Total'               => '',
1671 1674
  'Invoice deleted!'            => 'Rechnung gelöscht!',
1672 1675
  'Invoice filter'              => 'Rechnungsfilter',
1673 1676
  'Invoice for fees'            => 'Rechnung über Gebühren',
......
1891 1894
  'Module name'                 => 'Modulname',
1892 1895
  'Monat'                       => 'Monat',
1893 1896
  'Month'                       => 'Monat',
1897
  'Month/Year'                  => 'Monat/Jahr',
1894 1898
  'Monthly'                     => 'monatlich',
1895 1899
  'More than one control file with the tag \'%s\' exist.' => 'Es gibt mehr als eine Kontrolldatei mit dem Tag \'%s\'.',
1896 1900
  'More than one file selected, please set only one checkbox!' => 'Mehr als ein Element selektiert, bitte nur eine Box anklicken',
......
2101 2105
  'Oops. No valid action found to dispatch. Please report this case to the kivitendo team.' => 'Ups. Es wurde keine gültige Funktion zum Aufrufen gefunden. Bitte berichten Sie diesen Fall den kivitendo-Entwicklern.',
2102 2106
  'Open'                        => 'Offen',
2103 2107
  'Open Amount'                 => 'Offener Betrag',
2108
  'Open Items'                  => 'Offene Posten',
2104 2109
  'Open a further kivitendo window or tab' => 'Weiteres kivitendo-Fenster/-Tab öffnen',
2105 2110
  'Open amount'                 => 'offener Betrag',
2106 2111
  'Open in new window'          => 'In neuem Fenster öffnen.',
......
3594 3599
  'Trial balance between %s and %s' => 'Summen- und Saldenlisten vom %s bis zum %s',
3595 3600
  'Trying to call a sub without a name' => 'Es wurde versucht, eine Unterfunktion ohne Namen aufzurufen.',
3596 3601
  'TypAbbreviation'             => 'Abkürzung des Artikel-Typs',
3602
  'Turnover'                    => 'Umsätze',
3603
  'Turnovers'                   => 'Umsätze',
3604
  'Turnoverstatistic'           => 'Umsatzstatistik',
3597 3605
  'Type'                        => 'Typ',
3598 3606
  'Type abbreviation'           => 'Typen-Abkürzung',
3599 3607
  'Type can be either \'part\', \'service\' or \'assembly\'.' => 'Der Typ kann entweder \'part\' (für Waren), \'service\' (für Dienstleistungen) oder \'assembly\' (für Erzeugnisse) enthalten.',

Auch abrufbar als: Unified diff