Projekt

Allgemein

Profil

Umsatzstatistik als Reiter in der Kundendatei » diffStatistiken2.txt

patch - Werner Hahn, 18.06.2015 09:57

 
1
diff --git a/SL/Controller/CustomerVendor.pm b/SL/Controller/CustomerVendor.pm
2
index 403413f..17b0c4b 100644
3
--- a/SL/Controller/CustomerVendor.pm
4
+++ b/SL/Controller/CustomerVendor.pm
5
@@ -8,6 +8,8 @@ use SL::DBUtils;
6
 use SL::Helper::Flash;
7
 use SL::Locale::String;
8
 use SL::Controller::Helper::GetModels;
9
+use SL::Controller::Helper::ReportGenerator;
10
+use SL::Controller::Helper::ParseFilter;
11
 
12
 use SL::DB::Customer;
13
 use SL::DB::Vendor;
14
@@ -23,6 +25,9 @@ use SL::DB::FollowUp;
15
 use SL::DB::FollowUpLink;
16
 use SL::DB::History;
17
 use SL::DB::Currency;
18
+use SL::DB::Invoice;
19
+
20
+use Data::Dumper;
21
 
22
 use Rose::Object::MakeMethods::Generic (
23
   'scalar --get_set_init' => [ qw(customer_models vendor_models) ],
24
@@ -427,7 +432,6 @@ sub action_search_contact {
25
   print $::form->redirect_header($url);
26
 }
27
 
28
-
29
 sub action_get_delivery {
30
   my ($self) = @_;
31
 
32
@@ -913,7 +917,14 @@ sub _pre_render {
33
     ],
34
     with_objects => ['follow_up'],
35
   );
36
-
37
+  
38
+  $self->{open_items} = SL::DB::Manager::Invoice->get_all_count(
39
+    query => [
40
+      customer_id => $self->{cv}->id,
41
+      paid => {lt_sql => 'amount'},      
42
+    ],
43
+  );
44
+  
45
   $self->{template_args} ||= {};
46
 
47
   $::request->{layout}->add_javascripts('autocomplete_customer.js');
48
diff --git a/SL/Controller/CustomerVendorTurnover.pm b/SL/Controller/CustomerVendorTurnover.pm
49
new file mode 100644
50
index 0000000..3101bbf
51
--- /dev/null
52
+++ b/SL/Controller/CustomerVendorTurnover.pm
53
@@ -0,0 +1,143 @@
54
+package SL::Controller::CustomerVendorTurnover;
55
+use strict;
56
+use parent qw(SL::Controller::Base);
57
+use SL::DBUtils;
58
+use SL::DB::AccTransaction;
59
+use SL::DB::Invoice;
60
+
61
+__PACKAGE__->run_before('check_auth');
62
+
63
+sub action_list_turnover {
64
+  my ($self) = @_;
65
+  
66
+  return $self->render('generic/error', { layout => 0 }, label_error => "list_transactions needs a trans_id") unless $::form->{id};
67
+
68
+  my $cv = $::form->{id} || {};
69
+  my $open_invoices;
70
+  $open_invoices = SL::DB::Manager::Invoice->get_all(
71
+    query => [customer_id => $cv,
72
+              paid => {lt_sql => 'amount'},      
73
+    ],
74
+    with_objects => ['dunnings'],
75
+  );
76
+  my $open_items;
77
+  if (@{$open_invoices}) {
78
+    return $self->render(\'', { type => 'json' }) unless scalar @{$open_invoices};
79
+    $open_items = $self->_list_open_items($open_invoices);
80
+  }
81
+  return $self->render('customer_vendor_turnover/turnover', { header => 0 }, open_items => $open_items, id => $cv);
82
+}
83
+
84
+sub _list_open_items {
85
+  my ($self, $open_items) = @_;
86
+
87
+  return $self->render('customer_vendor_turnover/_list_open_items', { output => 0 }, OPEN_ITEMS => $open_items, title => $::locale->text('Open Items') );
88
+}
89
+
90
+sub action_count_open_items_by_year {
91
+  my ($self) = @_;
92
+
93
+  return $self->render('generic/error', { layout => 0 }, label_error => "list_transactions needs a trans_id") unless $::form->{id};
94
+  my $dbh = $::form->get_standard_dbh();
95
+
96
+  my $cv = $::form->{id} || {};
97
+
98
+  my $query = "SELECT EXTRACT (YEAR FROM d.transdate),
99
+    count(d.id),
100
+    max(d.dunning_level)
101
+    FROM dunning d
102
+    LEFT JOIN ar a
103
+    ON a.id = d.trans_id
104
+    LEFT JOIN customer c
105
+    ON a.customer_id = c.id
106
+    WHERE c.id = $cv
107
+    GROUP BY EXTRACT (YEAR FROM d.transdate), c.id
108
+    ORDER BY date_part DESC";
109
+
110
+   $self->{dun_statistic} = selectall_hashref_query($::form, $dbh, $query);
111
+   $self->render('customer_vendor_turnover/count_open_items_by_year', { layout => 0 }); 
112
+}
113
+sub action_count_open_items_by_month {
114
+
115
+  my ($self) = @_;
116
+
117
+  return $self->render('generic/error', { layout => 0 }, label_error => "list_transactions needs a trans_id") unless $::form->{id};
118
+  my $dbh = $::form->get_standard_dbh();
119
+
120
+  my $cv = $::form->{id} || {};
121
+
122
+  my $query = "SELECT CONCAT(EXTRACT (MONTH FROM d.transdate),'/',EXTRACT (YEAR FROM d.transdate)) AS date_part,
123
+    count(d.id),
124
+    max(d.dunning_level)
125
+    FROM dunning d
126
+    LEFT JOIN ar a
127
+    ON a.id = d.trans_id
128
+    LEFT JOIN customer c
129
+    ON a.customer_id = c.id
130
+    WHERE c.id = $cv
131
+    GROUP BY EXTRACT (YEAR FROM d.transdate), EXTRACT (MONTH FROM d.transdate), c.id
132
+    ORDER BY EXTRACT (YEAR FROM d.transdate) DESC";
133
+
134
+   $self->{dun_statistic} = selectall_hashref_query($::form, $dbh, $query);
135
+   $self->render('customer_vendor_turnover/count_open_items_by_year', { layout => 0 }); 
136
+}
137
+sub action_turnover_by_month {
138
+
139
+  my ($self) = @_;
140
+
141
+  return $self->render('generic/error', { layout => 0 }, label_error => "list_transactions needs a trans_id") unless $::form->{id};
142
+
143
+  my $dbh = $::form->get_standard_dbh();
144
+  my $cv = $::form->{id} || {};
145
+  my $query = "SELECT CONCAT(EXTRACT (MONTH FROM transdate),'/',EXTRACT (YEAR FROM transdate)) AS date_part,
146
+    count(id) as count,
147
+    sum(amount) as amount,
148
+    sum(netamount) as netamount,
149
+    sum(paid) as paid
150
+    FROM ar WHERE customer_id = $cv
151
+    GROUP BY EXTRACT (YEAR FROM transdate), EXTRACT (MONTH FROM transdate)
152
+    ORDER BY EXTRACT (YEAR FROM transdate) DESC, EXTRACT (MONTH FROM transdate) DESC";
153
+
154
+   $self->{turnover_statistic} = selectall_hashref_query($::form, $dbh, $query);
155
+   $self->render('customer_vendor_turnover/count_turnover', { layout => 0 }); 
156
+}
157
+sub action_turnover_by_year {
158
+
159
+  my ($self) = @_;
160
+
161
+  return $self->render('generic/error', { layout => 0 }, label_error => "list_transactions needs a trans_id") unless $::form->{id};
162
+
163
+  my $dbh = $::form->get_standard_dbh();
164
+  my $cv = $::form->{id} || {};
165
+  my $query = "SELECT EXTRACT (YEAR FROM transdate) as date_part,
166
+    count(id) as count,
167
+    sum(amount) as amount,
168
+    sum(netamount) as netamount,
169
+    sum(paid) as paid
170
+    FROM ar WHERE customer_id = $cv
171
+    GROUP BY date_part
172
+    ORDER BY date_part DESC";
173
+
174
+   $self->{turnover_statistic} = selectall_hashref_query($::form, $dbh, $query);
175
+   $self->render('customer_vendor_turnover/count_turnover', { layout => 0 }); 
176
+}
177
+sub action_get_invoices {
178
+  my ($self) = @_;
179
+  
180
+  return $self->render('generic/error', { layout => 0 }, label_error => "list_transactions needs a trans_id") unless $::form->{id};
181
+
182
+  my $cv = $::form->{id} || {};
183
+  my $invoices = SL::DB::Manager::Invoice->get_all(
184
+    query => [ customer_id => $cv, ],
185
+    sort_by => 'invnumber DESC',
186
+  );
187
+  $self->render('customer_vendor_turnover/invoices_statistic', { layout => 0 }, invoices => $invoices);
188
+}
189
+sub _list_articles_by_invoice {
190
+}
191
+sub _list_count_articles_by_year {
192
+}
193
+sub check_auth {
194
+  $::auth->assert('general_ledger');
195
+}
196
+1;
197
diff --git a/SL/DB/Invoice.pm b/SL/DB/Invoice.pm
198
index 065d2b3..337d550 100644
199
--- a/SL/DB/Invoice.pm
200
+++ b/SL/DB/Invoice.pm
201
@@ -54,6 +54,12 @@ __PACKAGE__->meta->add_relationship(
202
       sort_by      => 'acc_trans_id ASC',
203
     },
204
   },
205
+  dunnings       => {
206
+    type         => 'one to many',
207
+    class        => 'SL::DB::Dunning',
208
+    column_map   => { id => 'trans_id' },
209
+    manager_args => { with_objects => [ 'dunnings' ] }
210
+  },
211
 );
212
 
213
 __PACKAGE__->meta->initialize;
214
diff --git a/locale/de/all b/locale/de/all
215
index 7ef64ac..47749c7 100755
216
--- a/locale/de/all
217
+++ b/locale/de/all
218
@@ -958,6 +958,7 @@ $self->{texts} = {
219
   'Dunning number'              => 'Mahnungsnummer',
220
   'Dunning overview'            => 'Mahnungsübersicht',
221
   'Dunnings'                    => 'Mahnungen',
222
+  'Dunningstatistic'            => 'Mahnstatistik',
223
   'Duplicate in CSV file'       => 'Duplikat in CSV-Datei',
224
   'Duplicate in database'       => 'Duplikat in Datenbank',
225
   '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.',
226
@@ -1293,6 +1294,7 @@ $self->{texts} = {
227
   'Hide chart details'          => 'Konteninformation verstecken',
228
   'Hide help text'              => 'Hilfetext verbergen',
229
   'Hide settings'               => 'Einstellungen verbergen',
230
+  'Highest Dunninglevel'        => 'Höchste Mahnstufe',
231
   'Hints'                       => 'Hinweise',
232
   'History'                     => 'Historie',
233
   'History Search'              => 'Historien Suche',
234
@@ -1617,6 +1619,7 @@ $self->{texts} = {
235
   'Module name'                 => 'Modulname',
236
   'Monat'                       => 'Monat',
237
   'Month'                       => 'Monat',
238
+  'Month/Year'                  => 'Monat/Jahr',
239
   'Monthly'                     => 'monatlich',
240
   'More than one #1 found matching, please be more specific.' => 'Mehr als ein #1 wurde gefunden, bitte geben Sie den Namen genauer an.',
241
   'More than one control file with the tag \'%s\' exist.' => 'Es gibt mehr als eine Kontrolldatei mit dem Tag \'%s\'.',
242
@@ -1632,6 +1635,7 @@ $self->{texts} = {
243
   'Net Income Statement'        => 'Einnahmenüberschußrechnung',
244
   'Net amount'                  => 'Nettobetrag',
245
   'Net amount (for verification)' => 'Nettobetrag (zur Überprüfung)',
246
+  'Net.Turnover'                => 'Netto Umsatz',
247
   'Netto Terms'                 => 'Zahlungsziel netto',
248
   'New Password'                => 'Neues Passwort',
249
   'New Purchase Price Rule'     => 'Neue Einkaufspreisregel',
250
@@ -1783,6 +1787,7 @@ $self->{texts} = {
251
   '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.',
252
   'Open'                        => 'Offen',
253
   'Open Amount'                 => 'Offener Betrag',
254
+  'Open Items'                  => 'Offene Posten',
255
   'Open a further kivitendo window or tab' => 'Weiteres kivitendo-Fenster/-Tab öffnen',
256
   'Open amount'                 => 'offener Betrag',
257
   'Open in new window'          => 'In neuem Fenster öffnen.',
258
@@ -2983,6 +2988,9 @@ $self->{texts} = {
259
   'Trial Balance'               => 'Summen- und Saldenliste',
260
   'Trial balance between %s and %s' => 'Summen- und Saldenlisten vom %s bis zum %s',
261
   'Trying to call a sub without a name' => 'Es wurde versucht, eine Unterfunktion ohne Namen aufzurufen.',
262
+  'Turnover'                    => 'Umsatz',
263
+  'Turnovers'                   => 'Umsätze',
264
+  'Turnoverstatistic'           => 'Umsatzstatistik',
265
   'Type'                        => 'Typ',
266
   '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.',
267
   'Type of Business'            => 'Kunden-/Lieferantentyp',
268
diff --git a/templates/webpages/customer_vendor/form.html b/templates/webpages/customer_vendor/form.html
269
index 356bb1f..6572464 100644
270
--- a/templates/webpages/customer_vendor/form.html
271
+++ b/templates/webpages/customer_vendor/form.html
272
@@ -1,7 +1,7 @@
273
 [%- USE T8 %]
274
 [%- USE LxERP %]
275
 [%- USE L %]
276
-<h1>[% FORM.title %]</h1>
277
+<h1>[% FORM.title %] -- [% SELF.cv.name %], [% SELF.cv.street %], [% SELF.cv.zipcode %] [% SELF.cv.city %]</h1>
278
 
279
 [% L.hidden_tag('_cti_enabled', !!LXCONFIG.cti.dial_command) %]
280
 
281
@@ -32,6 +32,7 @@
282
       [% IF SELF.cv.id %]
283
         <li><a href="#price_rules">[% 'Price Rules' | $T8 %]</a></li>
284
       [% END %]
285
+      <li><a href="[% 'controller.pl?action=CustomerVendorTurnover/list_turnover&id=' _ SELF.cv.id | html %]">[% LxERP.t8('Turnovers') %] [%- IF SELF.open_items > 0 %] <span style="background-color:red;color:black;">&nbsp; $&nbsp; </span>[% END %]</a></li>
286
     </ul>
287
 
288
     [% PROCESS "customer_vendor/tabs/billing.html" %]
289
diff --git a/templates/webpages/customer_vendor_turnover/_list_open_items.html b/templates/webpages/customer_vendor_turnover/_list_open_items.html
290
new file mode 100644
291
index 0000000..6953adc
292
--- /dev/null
293
+++ b/templates/webpages/customer_vendor_turnover/_list_open_items.html
294
@@ -0,0 +1,39 @@
295
+[%- USE T8 %]
296
+[%- USE LxERP %]
297
+[%- USE L %]
298
+[%- USE HTML %]
299
+<div class="listtop">[%- HTML.escape(title) %]</div>
300
+
301
+<div id="sales_report">
302
+  <table width="100%">
303
+    <tbody>
304
+      <tr>
305
+        <td class="listheading">[% 'Invoice Number' | $T8 %]</td>
306
+        <td class="listheading">[% 'Invoice Date' | $T8 %]</td>
307
+        <td class="listheading">[% 'Amount' | $T8 %]</td>
308
+        <td class="listheading">[% 'Inv. Duedate' | $T8 %]</td>
309
+        <td class="listheading">[% 'Paid' | $T8 %]</td>
310
+        <td class="listheading">[% 'Open Amount' | $T8 %]</td>
311
+        <td class="listheading">[% 'Dunnings' | $T8 %]</td>
312
+      </tr>
313
+
314
+      [%- FOREACH row = OPEN_ITEMS %]
315
+      <tr class="listrow[% loop.count % 2 %]">
316
+        <td>[% row.invnumber | html %]</td>
317
+        <td>[% row.transdate.to_kivitendo | html %]</td>
318
+        <td>[%- LxERP.format_amount(row.amount, 2) %]</td>
319
+        <td>[% row.duedate.to_kivitendo | html %]</td>
320
+        <td>[%- LxERP.format_amount(row.paid, 2) %]</td>
321
+        <td>[%- LxERP.format_amount(row.amount - row.paid, 2) %]
322
+        <td>
323
+        [%- IF row.dunning_config_id != '' %]
324
+          [%- FOREACH dun = row.dunnings %]
325
+            [% dun.dunning_id | html %] -- [% dun.duedate.to_kivitendo | html %] -- [% dun.dunning_level | html %] -- [% LxERP.format_amount(dun.fee, 2) %]<br>
326
+          [% END %]
327
+        [% END %]
328
+        </td>
329
+      </tr>
330
+      [% END %]
331
+    </tbody>
332
+  </table>
333
+</div> 
334
diff --git a/templates/webpages/customer_vendor_turnover/_statistic_tabs.html b/templates/webpages/customer_vendor_turnover/_statistic_tabs.html
335
new file mode 100644
336
index 0000000..ce34e2a
337
--- /dev/null
338
+++ b/templates/webpages/customer_vendor_turnover/_statistic_tabs.html
339
@@ -0,0 +1,23 @@
340
+[%- USE T8 %]
341
+[%- USE LxERP %]
342
+[%- USE L %]
343
+[%- USE HTML %]
344
+<script type="text/javascript">
345
+  $(function() {
346
+      $ ( "#statistic_tabs" ).tabs();
347
+  });
348
+  function get_invoices() {
349
+    var url = 'controller.pl?action=CustomerVendorTurnover/get_invoices&id=' + $('#cv_id').val();
350
+    $('#invoices').load(url);
351
+  }
352
+</script>
353
+  <div class="tabwidget" id="statistic_tabs">
354
+    <ul>
355
+      <li><a href="#turnover_stat">[% 'Turnoverstatistic' | $T8 %]</a></li>
356
+      <li><a href="#dun_stat">[% 'Dunningstatistic' | $T8 %]</a></li>
357
+      <li><a href="#invoices" onclick="get_invoices();">[% 'Invoices' | $T8 %]</a></li>
358
+    </ul>
359
+    <div id="turnover_stat">[% PROCESS "customer_vendor_turnover/turnover_statistic.html" %]</div>
360
+    <div id="dun_stat">[% PROCESS "customer_vendor_turnover/dun_statistic.html" %]</div>
361
+    <div id="invoices"></div>
362
+  </div>
363
diff --git a/templates/webpages/customer_vendor_turnover/count_open_items_by_year.html b/templates/webpages/customer_vendor_turnover/count_open_items_by_year.html
364
new file mode 100644
365
index 0000000..8309b05
366
--- /dev/null
367
+++ b/templates/webpages/customer_vendor_turnover/count_open_items_by_year.html
368
@@ -0,0 +1,23 @@
369
+[%- USE T8 %]
370
+[%- USE LxERP %]
371
+[%- USE L %]
372
+[%- USE HTML %]
373
+<div id="dun_statistic">
374
+  <table width="100%">
375
+    <tbody>
376
+      <tr>
377
+        <td class="listheading">[% 'Month/Year' | $T8 %]</td>
378
+        <td class="listheading">[% 'Dunnings' | $T8 %]</td>
379
+        <td class="listheading">[% 'Highest Dunninglevel' | $T8 %]</td>
380
+      </tr>
381
+
382
+      [%- FOREACH row = SELF.dun_statistic %]
383
+      <tr class="listrow[% loop.count % 2 %]">
384
+        <td>[% row.date_part | html %]</td>
385
+        <td>[% row.count | html %]</td>
386
+        <td>[% row.max | html %]</td>
387
+      </tr>
388
+      [% END %]
389
+    </tbody>
390
+  </table>
391
+</div>
392
diff --git a/templates/webpages/customer_vendor_turnover/count_turnover.html b/templates/webpages/customer_vendor_turnover/count_turnover.html
393
new file mode 100644
394
index 0000000..cf793e2
395
--- /dev/null
396
+++ b/templates/webpages/customer_vendor_turnover/count_turnover.html
397
@@ -0,0 +1,27 @@
398
+[%- USE T8 %]
399
+[%- USE LxERP %]
400
+[%- USE L %]
401
+[%- USE HTML %]
402
+<div id="turnover_statistic">
403
+  <table width="100%">
404
+    <tbody>
405
+      <tr>
406
+        <td class="listheading">[% 'Month/Year' | $T8 %]</td>
407
+        <td class="listheading">[% 'Invoices' | $T8 %]</td>
408
+        <td class="listheading">[% 'Turnover' | $T8 %]</td>
409
+        <td class="listheading">[% 'Net.Turnover' | $T8 %]</td>
410
+        <td class="listheading">[% 'Paid' | $T8 %]</td>
411
+      </tr>
412
+      [%- FOREACH row = SELF.turnover_statistic %]
413
+      <tr class="listrow[% loop.count % 2 %]">
414
+        <td>[% row.date_part | html %]</td>
415
+        <td>[% row.count | html %]</td>
416
+        <td>[%- LxERP.format_amount(row.amount,2) %]</td>
417
+        <td>[%- LxERP.format_amount(row.netamount,2) %]</td>
418
+        <td>[%- LxERP.format_amount(row.paid,2) %]</td>
419
+      </tr>
420
+      [% END %]
421
+
422
+    </tbody>
423
+  </table>
424
+</div>
425
diff --git a/templates/webpages/customer_vendor_turnover/dun_statistic.html b/templates/webpages/customer_vendor_turnover/dun_statistic.html
426
new file mode 100644
427
index 0000000..7d46bf9
428
--- /dev/null
429
+++ b/templates/webpages/customer_vendor_turnover/dun_statistic.html
430
@@ -0,0 +1,22 @@
431
+[%- USE T8 %]
432
+[%- USE LxERP %]
433
+[%- USE L %]
434
+[%- USE HTML %]
435
+
436
+<p> 
437
+[% L.radio_button_tag('period', value='year', label= LxERP.t8('Year'), onclick='show_dun_stat("y");') %]
438
+
439
+[% L.radio_button_tag('period', value='month', label= LxERP.t8('Month'), onclick='show_dun_stat("m");') %]
440
+</p>
441
+<script type="text/javascript">
442
+  function show_dun_stat(period) {
443
+    if (period === 'y') {
444
+      var url = 'controller.pl?action=CustomerVendorTurnover/count_open_items_by_year&id=' + $('#cv_id').val();
445
+      $('#duns').load(url);
446
+    } else {
447
+      var url = 'controller.pl?action=CustomerVendorTurnover/count_open_items_by_month&id=' + $('#cv_id').val();
448
+      $('#duns').load(url);
449
+    }
450
+  }
451
+</script>
452
+<div id="duns"></div>
453
diff --git a/templates/webpages/customer_vendor_turnover/invoices_statistic.html b/templates/webpages/customer_vendor_turnover/invoices_statistic.html
454
new file mode 100644
455
index 0000000..7b8f3d9
456
--- /dev/null
457
+++ b/templates/webpages/customer_vendor_turnover/invoices_statistic.html
458
@@ -0,0 +1,33 @@
459
+[%- USE T8 %]
460
+[%- USE LxERP %]
461
+[%- USE L %]
462
+[%- USE HTML %]
463
+<div id="invoice_statistic">
464
+  <table width="100%">
465
+    <tbody>
466
+      <tr>
467
+        <td class="listheading">[% 'Invoice Number' | $T8 %]</td>
468
+        <td class="listheading">[% 'Invoice Date' | $T8 %]</td>
469
+        <td class="listheading">[% 'Amount' | $T8 %]</td>
470
+        <td class="listheading">[% 'Inv. Duedate' | $T8 %]</td>
471
+        <td class="listheading">[% 'Paid' | $T8 %]</td>
472
+        <td class="listheading">[% 'Open Amount' | $T8 %]</td>
473
+      </tr>
474
+
475
+      [%- FOREACH row = invoices %]
476
+      <tr class="listrow[% loop.count % 2 %]">
477
+        <td>[% row.invnumber | html %]</td>
478
+        <td>[% row.transdate.to_kivitendo | html %]</td>
479
+        <td>[%- LxERP.format_amount(row.amount, 2) %]</td>
480
+        <td>[% row.duedate.to_kivitendo | html %]</td>
481
+        <td>[%- LxERP.format_amount(row.paid, 2) %]</td>
482
+        <td>[%- LxERP.format_amount(row.amount - row.paid, 2) %]
483
+      </tr>
484
+      [% END %]
485
+    </tbody>
486
+  </table>
487
+
488
+      
489
+    </tbody>
490
+  </table>
491
+</div>
492
diff --git a/templates/webpages/customer_vendor_turnover/turnover.html b/templates/webpages/customer_vendor_turnover/turnover.html
493
new file mode 100644
494
index 0000000..310355d
495
--- /dev/null
496
+++ b/templates/webpages/customer_vendor_turnover/turnover.html
497
@@ -0,0 +1,11 @@
498
+[%- USE T8 %]
499
+[%- USE LxERP %]
500
+[%- USE L %]
501
+[%- USE HTML %]
502
+[%- USE JavaScript -%]
503
+
504
+[%- IF open_items %]
505
+[% open_items %]
506
+[% END %]
507
+
508
+[% PROCESS "customer_vendor_turnover/_statistic_tabs.html" %]
509
diff --git a/templates/webpages/customer_vendor_turnover/turnover_statistic.html b/templates/webpages/customer_vendor_turnover/turnover_statistic.html
510
new file mode 100644
511
index 0000000..c2ea10e
512
--- /dev/null
513
+++ b/templates/webpages/customer_vendor_turnover/turnover_statistic.html
514
@@ -0,0 +1,21 @@
515
+[%- USE T8 %]
516
+[%- USE LxERP %]
517
+[%- USE L %]
518
+[%- USE HTML %]
519
+<p> 
520
+[% L.radio_button_tag('period', value='year', label= LxERP.t8('Year'), onclick='show_turnover_stat("y");') %]
521
+
522
+[% L.radio_button_tag('period', value='month', label= LxERP.t8('Month'), onclick='show_turnover_stat("m");') %]
523
+</p>
524
+<script type="text/javascript">
525
+  function show_turnover_stat(period) {
526
+    if (period === 'y') {
527
+      var url = 'controller.pl?action=CustomerVendorTurnover/turnover_by_year&id=' + $('#cv_id').val();
528
+      $('#turnovers').load(url);
529
+    } else {
530
+      var url = 'controller.pl?action=CustomerVendorTurnover/turnover_by_month&id=' + $('#cv_id').val();
531
+      $('#turnovers').load(url);
532
+    }
533
+  }
534
+</script>
535
+<div id="turnovers"></div>
(1-1/2)