Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision e2e5606d

Von Tamino Steinert vor etwa 1 Jahr hinzugefügt

  • ID e2e5606dc7af7c3768939d02ae4b0abb4e1bef7b
  • Vorgänger 36d7ceb2
  • Nachfolger 6bec941d

SL::Presenter::Record: Schlichte Darstellung für verknüpfte Belege.

Unterschiede anzeigen:

SL/Presenter/Record.pm
4 4

  
5 5
use SL::Presenter;
6 6
use SL::Presenter::EscapedText qw(escape is_escaped);
7
use SL::Presenter::Tag qw(html_tag);
7 8

  
8 9
use Exporter qw(import);
9 10
our @EXPORT_OK = qw(grouped_record_list empty_record_list record_list record);
......
13 14
use Carp;
14 15
use List::Util qw(first);
15 16

  
17
my @ORDERED_TYPES = qw(
18
  requirement_spec
19
  shop_order
20
  sales_quotation
21
  sales_order_intake
22
  sales_order
23
  sales_delivery_order
24
  rma_delivery_order
25
  sales_reclamation
26
  sales_invoice
27
  ar_transaction
28
  request_quotation
29
  purchase_quotation_intake
30
  purchase_order
31
  purchase_delivery_order
32
  supplier_delivery_order
33
  purchase_reclamation
34
  purchase_invoice
35
  ap_transaction
36
  gl_transaction
37
  bank_transaction
38
  sepa_collection
39
  sepa_transfer
40
  letter
41
  email_journal
42
  dunning
43
  );
44

  
45
my %TYPE_TO_PARAMS = (
46
  # sub gets other params as arguments to override if needed
47
  # has to encoupsulated in a sub for evaluation of locale translations
48
  requirement_spec => sub {
49
    my (%params) = @_;
50
    {
51
      title   => $::locale->text('Requirement specs'),
52
      type    => 'requirement_spec',
53
      columns => [
54
        [ $::locale->text('Requirement spec number'), sub { $_[0]->presenter->requirement_spec(display => 'table-cell') } ],
55
        [ $::locale->text('Customer'),                'customer'                                                      ],
56
        [ $::locale->text('Title'),                   'title'                                                         ],
57
        [ $::locale->text('Project'),                 'project',                                                      ],
58
        [ $::locale->text('Status'),                  sub { $_[0]->status->description }                              ],
59
      ],
60
      %params,
61
    }
62
  },
63
  shop_order => sub {
64
    my (%params) = @_;
65
    {
66
      title   => $::locale->text('Shop Orders'),
67
      type    => 'shop_order',
68
      columns => [
69
        [ $::locale->text('Shop Order Date'),         sub { $_[0]->order_date->to_kivitendo }                         ],
70
        [ $::locale->text('Shop Order Number'),       sub { $_[0]->presenter->shop_order(display => 'table-cell') }   ],
71
        [ $::locale->text('Transfer Date'),           'transfer_date'                                                 ],
72
        [ $::locale->text('Amount'),                  'amount'                                                        ],
73
      ],
74
      %params,
75
    }
76
  },
77
  sales_quotation => sub {
78
    my (%params) = @_;
79
    {
80
      title   => $::locale->text('Sales Quotations'),
81
      type    => 'sales_quotation',
82
      columns => [
83
        [ $::locale->text('Quotation Date'),          'transdate'                                                                ],
84
        [ $::locale->text('Quotation Number'),        sub { $_[0]->presenter->sales_quotation(display => 'table-cell') }         ],
85
        [ $::locale->text('Customer'),                'customer'                                                                 ],
86
        [ $::locale->text('Net amount'),              'netamount'                                                                ],
87
        [ $::locale->text('Transaction description'), 'transaction_description'                                                  ],
88
        [ $::locale->text('Project'),                 'globalproject', ],
89
        [ $::locale->text('Closed'),                  'closed'                                                                   ],
90
      ],
91
      %params,
92
    }
93
  },
94
  request_quotation => sub {
95
    my (%params) = @_;
96
    {
97
      title   => $::locale->text('Request Quotations'),
98
      type    => 'request_quotation',
99
      columns => [
100
        [ $::locale->text('Quotation Date'),          'transdate'                                                                ],
101
        [ $::locale->text('Quotation Number'),        sub { $_[0]->presenter->request_quotation(display => 'table-cell') }       ],
102
        [ $::locale->text('Vendor'),                  'vendor'                                                                   ],
103
        [ $::locale->text('Net amount'),              'netamount'                                                                ],
104
        [ $::locale->text('Transaction description'), 'transaction_description'                                                  ],
105
        [ $::locale->text('Project'),                 'globalproject', ],
106
        [ $::locale->text('Closed'),                  'closed'                                                                   ],
107
      ],
108
      %params,
109
    }
110
  },
111
  purchase_quotation_intake => sub {
112
    my (%params) = @_;
113
    {
114
      title   => $::locale->text('Purchase Quotation Intakes'),
115
      type    => 'purchase_quotation_intake',
116
      columns => [
117
        [ $::locale->text('Quotation Date'),          'transdate'                                                                ],
118
        [ $::locale->text('Quotation Number'),        sub { $_[0]->presenter->purchase_quotation_intake(display => 'table-cell') } ],
119
        [ $::locale->text('Vendor'),                  'vendor'                                                                   ],
120
        [ $::locale->text('Net amount'),              'netamount'                                                                ],
121
        [ $::locale->text('Transaction description'), 'transaction_description'                                                  ],
122
        [ $::locale->text('Project'),                 'globalproject', ],
123
        [ $::locale->text('Closed'),                  'closed'                                                                   ],
124
      ],
125
      %params,
126
    }
127
  },
128
  sales_order_intake => sub {
129
    my (%params) = @_;
130
    {
131
      title   => $::locale->text('Sales Order Intakes'),
132
      type    => 'sales_order_intake',
133
      columns => [
134
        [ $::locale->text('Order Date'),              'transdate'                                                                ],
135
        [ $::locale->text('Order Number'),            sub { $_[0]->presenter->sales_order_intake(display => 'table-cell') }      ],
136
        [ $::locale->text('Quotation'),               'quonumber' ],
137
        [ $::locale->text('Customer'),                'customer'                                                                 ],
138
        [ $::locale->text('Net amount'),              'netamount'                                                                ],
139
        [ $::locale->text('Transaction description'), 'transaction_description'                                                  ],
140
        [ $::locale->text('Project'),                 'globalproject', ],
141
        [ $::locale->text('Closed'),                  'closed'                                                                   ],
142
      ],
143
      %params,
144
    }
145
  },
146
  sales_order => sub {
147
    my (%params) = @_;
148
    {
149
      title   => $::locale->text('Sales Orders'),
150
      type    => 'sales_order',
151
      columns => [
152
        [ $::locale->text('Order Date'),              'transdate'                                                                ],
153
        [ $::locale->text('Order Number'),            sub { $_[0]->presenter->sales_order(display => 'table-cell') }             ],
154
        [ $::locale->text('Quotation'),               'quonumber' ],
155
        [ $::locale->text('Customer'),                'customer'                                                                 ],
156
        [ $::locale->text('Net amount'),              'netamount'                                                                ],
157
        [ $::locale->text('Transaction description'), 'transaction_description'                                                  ],
158
        [ $::locale->text('Project'),                 'globalproject', ],
159
        [ $::locale->text('Closed'),                  'closed'                                                                   ],
160
      ],
161
      %params,
162
    }
163
  },
164
  purchase_order => sub {
165
    my (%params) = @_;
166
    {
167
      title   => $::locale->text('Purchase Orders'),
168
      type    => 'purchase_order',
169
      columns => [
170
        [ $::locale->text('Order Date'),              'transdate'                                                                ],
171
        [ $::locale->text('Order Number'),            sub { $_[0]->presenter->purchase_order(display => 'table-cell') }          ],
172
        [ $::locale->text('Request for Quotation'),   'quonumber' ],
173
        [ $::locale->text('Vendor'),                  'vendor'                                                                 ],
174
        [ $::locale->text('Net amount'),              'netamount'                                                                ],
175
        [ $::locale->text('Transaction description'), 'transaction_description'                                                  ],
176
        [ $::locale->text('Project'),                 'globalproject', ],
177
        [ $::locale->text('Closed'),                  'closed'                                                                   ],
178
      ],
179
      %params,
180
    }
181
  },
182
  sales_delivery_order => sub {
183
    my (%params) = @_;
184
    {
185
      title   => $::locale->text('Sales Delivery Orders'),
186
      type    => 'sales_delivery_order',
187
      columns => [
188
        [ $::locale->text('Delivery Order Date'),     'transdate'                                                                ],
189
        [ $::locale->text('Delivery Order Number'),   sub { $_[0]->presenter->sales_delivery_order(display => 'table-cell') }    ],
190
        [ $::locale->text('Order Number'),            'ordnumber' ],
191
        [ $::locale->text('Customer'),                'customer'                                                                 ],
192
        [ $::locale->text('Transaction description'), 'transaction_description'                                                  ],
193
        [ $::locale->text('Project'),                 'globalproject', ],
194
        [ $::locale->text('Delivered'),               'delivered'                                                                ],
195
        [ $::locale->text('Closed'),                  'closed'                                                                   ],
196
      ],
197
      %params,
198
    }
199
  },
200
  rma_delivery_order => sub {
201
    my (%params) = @_;
202
    {
203
      title   => $::locale->text('RMA Delivery Orders'),
204
      type    => 'rma_delivery_order',
205
      columns => [
206
        [ $::locale->text('Delivery Order Date'),     'transdate'                                                                ],
207
        [ $::locale->text('Delivery Order Number'),   sub { $_[0]->presenter->rma_delivery_order(display => 'table-cell') }    ],
208
        [ $::locale->text('Order Number'),            'ordnumber' ],
209
        [ $::locale->text('Customer'),                'customer'                                                                 ],
210
        [ $::locale->text('Transaction description'), 'transaction_description'                                                  ],
211
        [ $::locale->text('Project'),                 'globalproject', ],
212
        [ $::locale->text('Delivered'),               'delivered'                                                                ],
213
        [ $::locale->text('Closed'),                  'closed'                                                                   ],
214
      ],
215
      %params,
216
    }
217
  },
218
  purchase_delivery_order => sub {
219
    my (%params) = @_;
220
    {
221
      title   => $::locale->text('Purchase Delivery Orders'),
222
      type    => 'purchase_delivery_order',
223
      columns => [
224
        [ $::locale->text('Delivery Order Date'),     'transdate'                                                                ],
225
        [ $::locale->text('Delivery Order Number'),   sub { $_[0]->presenter->purchase_delivery_order(display => 'table-cell') } ],
226
        [ $::locale->text('Order Number'),            'ordnumber' ],
227
        [ $::locale->text('Vendor'),                  'vendor'                                                                 ],
228
        [ $::locale->text('Transaction description'), 'transaction_description'                                                  ],
229
        [ $::locale->text('Project'),                 'globalproject', ],
230
        [ $::locale->text('Delivered'),               'delivered'                                                                ],
231
        [ $::locale->text('Closed'),                  'closed'                                                                   ],
232
      ],
233
      %params,
234
    }
235
  },
236
  supplier_delivery_order => sub {
237
    my (%params) = @_;
238
    {
239
      title   => $::locale->text('Supplier Delivery Orders'),
240
      type    => 'supplier_delivery_order',
241
      columns => [
242
        [ $::locale->text('Delivery Order Date'),     'transdate'                                                                ],
243
        [ $::locale->text('Delivery Order Number'),   sub { $_[0]->presenter->supplier_delivery_order(display => 'table-cell') } ],
244
        [ $::locale->text('Order Number'),            'ordnumber' ],
245
        [ $::locale->text('Vendor'),                  'vendor'                                                                 ],
246
        [ $::locale->text('Transaction description'), 'transaction_description'                                                  ],
247
        [ $::locale->text('Project'),                 'globalproject', ],
248
        [ $::locale->text('Delivered'),               'delivered'                                                                ],
249
        [ $::locale->text('Closed'),                  'closed'                                                                   ],
250
      ],
251
      %params,
252
    }
253
  },
254
  sales_reclamation => sub {
255
    my (%params) = @_;
256
    {
257
      title   => $::locale->text('Sales Reclamations'),
258
      type    => 'sales_reclamation',
259
      columns => [
260
        [ $::locale->text('Reclamation Date'),        'transdate'                                                          ],
261
        [ $::locale->text('Reclamation Number'),      sub { $_[0]->presenter->sales_reclamation(display => 'table-cell') } ],
262
        [ $::locale->text('Customer'),                'customer'                                                           ],
263
        [ $::locale->text('Transaction description'), 'transaction_description'                                            ],
264
        [ $::locale->text('Project'),                 'globalproject',                                                     ],
265
        [ $::locale->text('Delivered'),               'delivered'                                                          ],
266
        [ $::locale->text('Closed'),                  'closed'                                                             ],
267
      ],
268
      %params,
269
    }
270
  },
271
  purchase_reclamation => sub {
272
    my (%params) = @_;
273
    {
274
      title   => $::locale->text('Purchase Reclamations'),
275
      type    => 'purchase_reclamation',
276
      columns => [
277
        [ $::locale->text('Reclamation Date'),        'transdate'                                                          ],
278
        [ $::locale->text('Reclamation Number'),      sub { $_[0]->presenter->purchase_reclamation(display => 'table-cell') } ],
279
        [ $::locale->text('Vendor'),                'vendor'                                                           ],
280
        [ $::locale->text('Transaction description'), 'transaction_description'                                            ],
281
        [ $::locale->text('Project'),                 'globalproject',                                                     ],
282
        [ $::locale->text('Delivered'),               'delivered'                                                          ],
283
        [ $::locale->text('Closed'),                  'closed'                                                             ],
284
      ],
285
      %params,
286
    }
287
  },
288
  sales_invoice => sub {
289
    my (%params) = @_;
290
    {
291
      title   => $::locale->text('Sales Invoices'),
292
      type    => 'sales_invoice',
293
      columns => [
294
        [ $::locale->text('Invoice Date'),            'transdate'               ],
295
        [ $::locale->text('Type'),                    sub { $_[0]->displayable_type } ],
296
        [ $::locale->text('Invoice Number'),          sub { $_[0]->presenter->sales_invoice(display => 'table-cell') } ],
297
        [ $::locale->text('Quotation Number'),        'quonumber' ],
298
        [ $::locale->text('Order Number'),            'ordnumber' ],
299
        [ $::locale->text('Customer'),                'customer'                ],
300
        [ $::locale->text('Net amount'),              'netamount'               ],
301
        [ $::locale->text('Paid'),                    'paid'                    ],
302
        [ $::locale->text('Transaction description'), 'transaction_description' ],
303
      ],
304
      %params,
305
    }
306
  },
307
  purchase_invoice => sub {
308
    my (%params) = @_;
309
    {
310
      title   => $::locale->text('Purchase Invoices'),
311
      type    => 'purchase_invoice',
312
      columns => [
313
        [ $::locale->text('Invoice Date'),                 'transdate'               ],
314
        [ $::locale->text('Invoice Number'),               sub { $_[0]->presenter->purchase_invoice(display => 'table-cell') } ],
315
        [ $::locale->text('Request for Quotation Number'), 'quonumber' ],
316
        [ $::locale->text('Order Number'),                 'ordnumber' ],
317
        [ $::locale->text('Vendor'),                       'vendor'                 ],
318
        [ $::locale->text('Net amount'),                   'netamount'               ],
319
        [ $::locale->text('Paid'),                         'paid'                    ],
320
        [ $::locale->text('Transaction description'),      'transaction_description' ],
321
      ],
322
      %params,
323
    }
324
  },
325
  ar_transaction => sub {
326
    my (%params) = @_;
327
    {
328
      title   => $::locale->text('AR Transactions'),
329
      type    => 'ar_transaction',
330
      columns => [
331
        [ $::locale->text('Invoice Date'),            'transdate'               ],
332
        [ $::locale->text('Type'),                    sub { $_[0]->displayable_type } ],
333
        [ $::locale->text('Invoice Number'),          sub { $_[0]->presenter->ar_transaction(display => 'table-cell') } ],
334
        [ $::locale->text('Customer'),                'customer'                ],
335
        [ $::locale->text('Net amount'),              'netamount'               ],
336
        [ $::locale->text('Paid'),                    'paid'                    ],
337
        [ $::locale->text('Transaction description'), 'transaction_description' ],
338
      ],
339
      %params,
340
    }
341
  },
342
  ap_transaction => sub {
343
    my (%params) = @_;
344
    {
345
      title   => $::locale->text('AP Transactions'),
346
      type    => 'ap_transaction',
347
      columns => [
348
        [ $::locale->text('Invoice Date'),            'transdate'                      ],
349
        [ $::locale->text('Invoice Number'),          sub { $_[0]->presenter->ap_transaction(display => 'table-cell') } ],
350
        [ $::locale->text('Vendor'),                  'vendor'                         ],
351
        [ $::locale->text('Net amount'),              'netamount'                      ],
352
        [ $::locale->text('Paid'),                    'paid'                           ],
353
        [ $::locale->text('Transaction description'), 'transaction_description'        ],
354
      ],
355
      %params,
356
    }
357
  },
358
  gl_transaction => sub {
359
    my (%params) = @_;
360
    {
361
      title   => $::locale->text('GL Transactions'),
362
      type    => 'gl_transaction',
363
      columns => [
364
        [ $::locale->text('Transdate'),        'transdate'                                                    ],
365
        [ $::locale->text('Reference'),   'reference'                                                    ],
366
        [ $::locale->text('Description'), sub { $_[0]->presenter->gl_transaction(display => 'table-cell') } ],
367
      ],
368
      %params,
369
    }
370
  },
371
  bank_transaction => sub {
372
    my (%params) = @_;
373
    {
374
      title   => $::locale->text('Bank transactions'),
375
      type    => 'bank_transactions',
376
      columns => [
377
        [ $::locale->text('Transdate'),            'transdate'                      ],
378
        [ $::locale->text('Local Bank Code'),      sub { $_[0]->local_bank_account->presenter->bank_code }  ],
379
        [ $::locale->text('Local account number'), sub { $_[0]->local_bank_account->presenter->account_number }  ],
380
        [ $::locale->text('Remote Bank Code'),     'remote_bank_code' ],
381
        [ $::locale->text('Remote account number'),'remote_account_number' ],
382
        [ $::locale->text('Valutadate'),           'valutadate' ],
383
        [ $::locale->text('Amount'),               'amount' ],
384
        [ $::locale->text('Currency'),             sub { $_[0]->currency->name } ],
385
        [ $::locale->text('Remote name'),          'remote_name' ],
386
        [ $::locale->text('Purpose'),              'purpose' ],
387
      ],
388
      %params,
389
    }
390
  },
391
  # sepa_export gets called from sepa_transfer and sepa_collection
392
  sepa_export => sub {
393
    my (%params) = @_;
394

  
395
    my ($source, $destination) = $params{type} eq 'sepa_transfer' ? qw(our vc)                                 : qw(vc our);
396
    $params{title}             = $params{type} eq 'sepa_transfer' ? $::locale->text('Bank transfers via SEPA') : $::locale->text('Bank collections via SEPA');
397
    $params{with_columns}      = [ grep { $_ ne 'record_link_direction' } @{ $params{with_columns} || [] } ];
398

  
399
    delete $params{edit_record_links};
400

  
401
    {
402
      columns => [
403
        [ $::locale->text('Export Number'),    'sepa_export',                                  ],
404
        [ $::locale->text('Execution date'),   'execution_date'                                ],
405
        [ $::locale->text('Export date'),      sub { $_[0]->sepa_export->itime->to_kivitendo } ],
406
        [ $::locale->text('Source BIC'),       "${source}_bic"                                 ],
407
        [ $::locale->text('Source IBAN'),      "${source}_iban"                                ],
408
        [ $::locale->text('Destination BIC'),  "${destination}_bic"                            ],
409
        [ $::locale->text('Destination IBAN'), "${destination}_iban"                           ],
410
        [ $::locale->text('Amount'),           'amount'                                        ],
411
      ],
412
      %params,
413
    }
414
  },
415
  sepa_transfer => sub {
416
    my (%params) = @_;
417
    _get_type_params('sepa_export', %params, type => 'sepa_transfer');
418
  },
419
  sepa_collection => sub {
420
    my (%params) = @_;
421
    _get_type_params('sepa_export', %params, type => 'sepa_collection');
422
  },
423
  letter => sub {
424
    my (%params) = @_;
425
    {
426
      title   => $::locale->text('Letters'),
427
      type    => 'letter',
428
      columns => [
429
        [ $::locale->text('Date'),         'date'                                                ],
430
        [ $::locale->text('Letternumber'), sub { $_[0]->presenter->letter(display => 'table-cell') } ],
431
        [ $::locale->text('Customer'),     'customer'                                            ],
432
        [ $::locale->text('Reference'),    'reference'                                           ],
433
        [ $::locale->text('Subject'),      'subject'                                             ],
434
      ],
435
      %params,
436
    }
437
  },
438
  email_journal => sub {
439
    my (%params) = @_;
440
    {
441
      title   => $::locale->text('Email'),
442
      type    => 'email_journal',
443
      columns => [
444
        [ $::locale->text('Sent on'), sub { $_[0]->sent_on->to_kivitendo(precision => 'seconds') } ],
445
        [ $::locale->text('Subject'), sub { $_[0]->presenter->email_journal(display => 'table-cell') } ],
446
        [ $::locale->text('Status'),  'status'                                                     ],
447
        [ $::locale->text('From'),    'from'                                                       ],
448
        [ $::locale->text('To'),      'recipients'                                                 ],
449
      ],
450
      %params,
451
    }
452
  },
453
  dunning => sub {
454
    my (%params) = @_;
455
    {
456
      title   => $::locale->text('Dunnings'),
457
      type    => 'dunning',
458
      columns => [
459
        [ $::locale->text('Dunning Level'),   sub { $_[0]->presenter->dunning(display => 'table-cell') } ],
460
        [ $::locale->text('Dunning Date'),    'transdate'                                                ],
461
        [ $::locale->text('Dunning Duedate'), 'duedate'                                                  ],
462
        [ $::locale->text('Total Fees'),      'fee'                                                      ],
463
        [ $::locale->text('Interest'),        'interest'                                                 ],
464
      ],
465
      %params,
466
    }
467
  },
468
);
469

  
470
sub _get_type_params {
471
  my ($type, %params) = @_;
472

  
473
  my $type_params = $TYPE_TO_PARAMS{$type};
474
  croak "Unknown type '$type'" unless $type_params;
475

  
476
  return %{$type_params->(%params)};
477
}
478

  
16 479
sub _arrayify {
17 480
  my ($array) = @_;
18 481
  return []     if !defined $array;
......
26 489
  my %grouped = _group_records( [ $record ] ); # pass $record as arrayref
27 490
  my $type    = (keys %grouped)[0];
28 491

  
29
  $record->presenter->sales_invoice(   $record, %params) if $type eq 'sales_invoices';
30
  $record->presenter->purchase_invoice($record, %params) if $type eq 'purchase_invoices';
31
  $record->presenter->ar_transaction(  $record, %params) if $type eq 'ar_transactions';
32
  $record->presenter->ap_transaction(  $record, %params) if $type eq 'ap_transactions';
33
  $record->presenter->gl_transaction(  $record, %params) if $type eq 'gl_transactions';
492
  $record->presenter->sales_invoice(   $record, %params) if $type eq 'sales_invoice';
493
  $record->presenter->purchase_invoice($record, %params) if $type eq 'purchase_invoice';
494
  $record->presenter->ar_transaction(  $record, %params) if $type eq 'ar_transaction';
495
  $record->presenter->ap_transaction(  $record, %params) if $type eq 'ap_transaction';
496
  $record->presenter->gl_transaction(  $record, %params) if $type eq 'gl_transaction';
34 497

  
35 498
  return '';
36 499
}
......
43 506
  my %groups = _sort_grouped_lists(_group_records($list));
44 507
  my $output = '';
45 508

  
46
  $output .= _requirement_spec_list(          $groups{requirement_specs},          %params) if $groups{requirement_specs};
47
  $output .= _shop_order_list(                $groups{shop_orders},                %params) if $groups{shop_orders};
48
  $output .= _sales_quotation_list(           $groups{sales_quotations},           %params) if $groups{sales_quotations};
49
  $output .= _sales_order_intake_list(        $groups{sales_order_intakes},        %params) if $groups{sales_order_intakes};
50
  $output .= _sales_order_list(               $groups{sales_orders},               %params) if $groups{sales_orders};
51
  $output .= _sales_delivery_order_list(      $groups{sales_delivery_orders},      %params) if $groups{sales_delivery_orders};
52
  $output .= _rma_delivery_order_list(        $groups{rma_delivery_orders},        %params) if $groups{rma_delivery_orders};
53
  $output .= _sales_reclamation_list(         $groups{sales_reclamation},          %params) if $groups{sales_reclamation};
54
  $output .= _sales_invoice_list(             $groups{sales_invoices},             %params) if $groups{sales_invoices};
55
  $output .= _ar_transaction_list(            $groups{ar_transactions},            %params) if $groups{ar_transactions};
56

  
57
  $output .= _request_quotation_list(         $groups{purchase_quotations},        %params) if $groups{purchase_quotations};
58
  $output .= _purchase_quotation_intake_list( $groups{purchase_quotation_intakes}, %params) if $groups{purchase_quotation_intakes};
59
  $output .= _purchase_order_list(            $groups{purchase_orders},            %params) if $groups{purchase_orders};
60
  $output .= _purchase_delivery_order_list(   $groups{purchase_delivery_orders},   %params) if $groups{purchase_delivery_orders};
61
  $output .= _supplier_delivery_order_list(   $groups{supplier_delivery_orders},   %params) if $groups{supplier_delivery_orders};
62
  $output .= _purchase_reclamation_list(      $groups{purchase_reclamation},       %params) if $groups{purchase_reclamation};
63
  $output .= _purchase_invoice_list(          $groups{purchase_invoices},          %params) if $groups{purchase_invoices};
64
  $output .= _ap_transaction_list(            $groups{ap_transactions},            %params) if $groups{ap_transactions};
509
  foreach my $type (@ORDERED_TYPES) {
510
    $output .= record_list($groups{$type}, _get_type_params($type, %params)) if $groups{$type};
511
  }
65 512

  
66
  $output .= _gl_transaction_list(            $groups{gl_transactions},            %params) if $groups{gl_transactions};
513
  $output  = SL::Presenter->get->render('presenter/record/grouped_record_list',    %params, output => $output);
67 514

  
68
  $output .= _bank_transactions(              $groups{bank_transactions},          %params) if $groups{bank_transactions};
515
  return $output;
516
}
69 517

  
70
  $output .= _sepa_collection_list(           $groups{sepa_collections},           %params) if $groups{sepa_collections};
71
  $output .= _sepa_transfer_list(             $groups{sepa_transfers},             %params) if $groups{sepa_transfers};
518
sub grouped_list { goto &grouped_record_list }
72 519

  
73
  $output .= _letter_list(                    $groups{letters},                    %params) if $groups{letters};
74
  $output .= _email_journal_list(             $groups{email_journals},             %params) if $groups{email_journals};
520
sub simple_grouped_record_list {
521
  my ($list, %params) = @_;
75 522

  
76
  $output .= _dunning_list(                   $groups{dunnings},                   %params) if $groups{dunnings};
523
  my %groups = _sort_grouped_lists(_group_records($list));
524
  my $output = '';
77 525

  
78
  $output  = SL::Presenter->get->render('presenter/record/grouped_record_list',    %params, output => $output);
526
  foreach my $type (@ORDERED_TYPES) {
527
    my $ordered_records = $groups{$type};
528
    next unless $ordered_records;
529
    my %type_params = _get_type_params($type, %params);
530
    my $type_output = html_tag('b', $type_params{title} . ": ");
531
    $type_output .= join (', ',
532
      map { $_->presenter->show(%params) }
533
      @{ $ordered_records }
534
    );
535
    $output .= html_tag('div', $type_output);
536
  }
79 537

  
80 538
  return $output;
81 539
}
82 540

  
83
sub grouped_list { goto &grouped_record_list }
84

  
85 541
sub empty_record_list {
86 542
  my (%params) = @_;
87 543
  return grouped_record_list([], %params);
......
187 643
sub _group_records {
188 644
  my ($list) = @_;
189 645
  my %matchers = (
190
    requirement_specs          => sub { (ref($_[0]) eq 'SL::DB::RequirementSpec')                                         },
191
    shop_orders                => sub { (ref($_[0]) eq 'SL::DB::ShopOrder')       &&  $_[0]->id                           },
192
    sales_quotations           => sub { (ref($_[0]) eq 'SL::DB::Order')           &&  $_[0]->is_type('sales_quotation')   },
193
    sales_order_intakes        => sub { (ref($_[0]) eq 'SL::DB::Order')           &&  $_[0]->is_type('sales_order_intake') },
194
    sales_orders               => sub { (ref($_[0]) eq 'SL::DB::Order')           &&  $_[0]->is_type('sales_order')       },
195
    sales_delivery_orders      => sub { (ref($_[0]) eq 'SL::DB::DeliveryOrder')   &&  $_[0]->is_type('sales_delivery_order') },
196
    rma_delivery_orders        => sub { (ref($_[0]) eq 'SL::DB::DeliveryOrder')   &&  $_[0]->is_type('rma_delivery_order')   },
197
    sales_reclamation          => sub { (ref($_[0]) eq 'SL::DB::Reclamation')     &&  $_[0]->is_type('sales_reclamation') },
198
    sales_invoices             => sub { (ref($_[0]) eq 'SL::DB::Invoice')         &&  $_[0]->invoice                      },
199
    ar_transactions            => sub { (ref($_[0]) eq 'SL::DB::Invoice')         && !$_[0]->invoice                      },
200
    purchase_quotations        => sub { (ref($_[0]) eq 'SL::DB::Order')           &&  $_[0]->is_type('request_quotation') },
201
    purchase_quotation_intakes => sub { (ref($_[0]) eq 'SL::DB::Order')           &&  $_[0]->is_type('purchase_quotation_intake') },
202
    purchase_orders            => sub { (ref($_[0]) eq 'SL::DB::Order')           &&  $_[0]->is_type('purchase_order')    },
203
    purchase_delivery_orders   => sub { (ref($_[0]) eq 'SL::DB::DeliveryOrder')   &&  $_[0]->is_type('purchase_delivery_order') },
204
    supplier_delivery_orders   => sub { (ref($_[0]) eq 'SL::DB::DeliveryOrder')   &&  $_[0]->is_type('supplier_delivery_order') },
205
    purchase_reclamation       => sub { (ref($_[0]) eq 'SL::DB::Reclamation')     &&  $_[0]->is_type('purchase_reclamation')},
206
    purchase_invoices          => sub { (ref($_[0]) eq 'SL::DB::PurchaseInvoice') &&  $_[0]->invoice                      },
207
    ap_transactions            => sub { (ref($_[0]) eq 'SL::DB::PurchaseInvoice') && !$_[0]->invoice                      },
208
    sepa_collections           => sub { (ref($_[0]) eq 'SL::DB::SepaExportItem')  &&  $_[0]->ar_id                        },
209
    sepa_transfers             => sub { (ref($_[0]) eq 'SL::DB::SepaExportItem')  &&  $_[0]->ap_id                        },
210
    gl_transactions            => sub { (ref($_[0]) eq 'SL::DB::GLTransaction')                                           },
211
    bank_transactions          => sub { (ref($_[0]) eq 'SL::DB::BankTransaction') &&  $_[0]->id                           },
212
    letters                    => sub { (ref($_[0]) eq 'SL::DB::Letter')          &&  $_[0]->id                           },
213
    email_journals             => sub { (ref($_[0]) eq 'SL::DB::EmailJournal')    &&  $_[0]->id                           },
214
    dunnings                   => sub { (ref($_[0]) eq 'SL::DB::Dunning')                                                 },
646
    requirement_spec          => sub { (ref($_[0]) eq 'SL::DB::RequirementSpec')                                         },
647
    shop_order                => sub { (ref($_[0]) eq 'SL::DB::ShopOrder')       &&  $_[0]->id                           },
648
    sales_quotation           => sub { (ref($_[0]) eq 'SL::DB::Order')           &&  $_[0]->is_type('sales_quotation')   },
649
    sales_order_intake        => sub { (ref($_[0]) eq 'SL::DB::Order')           &&  $_[0]->is_type('sales_order_intake') },
650
    sales_order               => sub { (ref($_[0]) eq 'SL::DB::Order')           &&  $_[0]->is_type('sales_order')       },
651
    sales_delivery_order      => sub { (ref($_[0]) eq 'SL::DB::DeliveryOrder')   &&  $_[0]->is_type('sales_delivery_order') },
652
    rma_delivery_order        => sub { (ref($_[0]) eq 'SL::DB::DeliveryOrder')   &&  $_[0]->is_type('rma_delivery_order')   },
653
    sales_reclamation         => sub { (ref($_[0]) eq 'SL::DB::Reclamation')     &&  $_[0]->is_type('sales_reclamation') },
654
    sales_invoice             => sub { (ref($_[0]) eq 'SL::DB::Invoice')         &&  $_[0]->invoice                      },
655
    ar_transaction            => sub { (ref($_[0]) eq 'SL::DB::Invoice')         && !$_[0]->invoice                      },
656
    request_quotation         => sub { (ref($_[0]) eq 'SL::DB::Order')           &&  $_[0]->is_type('request_quotation') },
657
    purchase_quotation_intake => sub { (ref($_[0]) eq 'SL::DB::Order')           &&  $_[0]->is_type('purchase_quotation_intake') },
658
    purchase_order            => sub { (ref($_[0]) eq 'SL::DB::Order')           &&  $_[0]->is_type('purchase_order')    },
659
    purchase_delivery_order   => sub { (ref($_[0]) eq 'SL::DB::DeliveryOrder')   &&  $_[0]->is_type('purchase_delivery_order') },
660
    supplier_delivery_order   => sub { (ref($_[0]) eq 'SL::DB::DeliveryOrder')   &&  $_[0]->is_type('supplier_delivery_order') },
661
    purchase_reclamation      => sub { (ref($_[0]) eq 'SL::DB::Reclamation')     &&  $_[0]->is_type('purchase_reclamation')},
662
    purchase_invoice          => sub { (ref($_[0]) eq 'SL::DB::PurchaseInvoice') &&  $_[0]->invoice                      },
663
    ap_transaction            => sub { (ref($_[0]) eq 'SL::DB::PurchaseInvoice') && !$_[0]->invoice                      },
664
    sepa_collection           => sub { (ref($_[0]) eq 'SL::DB::SepaExportItem')  &&  $_[0]->ar_id                        },
665
    sepa_transfer             => sub { (ref($_[0]) eq 'SL::DB::SepaExportItem')  &&  $_[0]->ap_id                        },
666
    gl_transaction            => sub { (ref($_[0]) eq 'SL::DB::GLTransaction')                                           },
667
    bank_transaction          => sub { (ref($_[0]) eq 'SL::DB::BankTransaction') &&  $_[0]->id                           },
668
    letter                    => sub { (ref($_[0]) eq 'SL::DB::Letter')          &&  $_[0]->id                           },
669
    email_journal             => sub { (ref($_[0]) eq 'SL::DB::EmailJournal')    &&  $_[0]->id                           },
670
    dunning                   => sub { (ref($_[0]) eq 'SL::DB::Dunning')                                                 },
215 671
  );
216 672

  
217 673
  my %groups;
......
240 696
  return %groups;
241 697
}
242 698

  
243
sub _requirement_spec_list {
244
  my ($list, %params) = @_;
245

  
246
  return record_list(
247
    $list,
248
    title   => $::locale->text('Requirement specs'),
249
    type    => 'requirement_spec',
250
    columns => [
251
      [ $::locale->text('Requirement spec number'), sub { $_[0]->presenter->requirement_spec(display => 'table-cell') } ],
252
      [ $::locale->text('Customer'),                'customer'                                                      ],
253
      [ $::locale->text('Title'),                   'title'                                                         ],
254
      [ $::locale->text('Project'),                 'project',                                                      ],
255
      [ $::locale->text('Status'),                  sub { $_[0]->status->description }                              ],
256
    ],
257
    %params,
258
  );
259
}
260

  
261
sub _shop_order_list {
262
  my ($list, %params) = @_;
263

  
264
  return record_list(
265
    $list,
266
    title   => $::locale->text('Shop Orders'),
267
    type    => 'shop_order',
268
    columns => [
269
      [ $::locale->text('Shop Order Date'),         sub { $_[0]->order_date->to_kivitendo }                         ],
270
      [ $::locale->text('Shop Order Number'),       sub { $_[0]->presenter->shop_order(display => 'table-cell') }   ],
271
      [ $::locale->text('Transfer Date'),           'transfer_date'                                                 ],
272
      [ $::locale->text('Amount'),                  'amount'                                                        ],
273
    ],
274
    %params,
275
  );
276
}
277

  
278
sub _sales_quotation_list {
279
  my ($list, %params) = @_;
280

  
281
  return record_list(
282
    $list,
283
    title   => $::locale->text('Sales Quotations'),
284
    type    => 'sales_quotation',
285
    columns => [
286
      [ $::locale->text('Quotation Date'),          'transdate'                                                                ],
287
      [ $::locale->text('Quotation Number'),        sub { $_[0]->presenter->sales_quotation(display => 'table-cell') }         ],
288
      [ $::locale->text('Customer'),                'customer'                                                                 ],
289
      [ $::locale->text('Net amount'),              'netamount'                                                                ],
290
      [ $::locale->text('Transaction description'), 'transaction_description'                                                  ],
291
      [ $::locale->text('Project'),                 'globalproject', ],
292
      [ $::locale->text('Closed'),                  'closed'                                                                   ],
293
    ],
294
    %params,
295
  );
296
}
297

  
298
sub _request_quotation_list {
299
  my ($list, %params) = @_;
300

  
301
  return record_list(
302
    $list,
303
    title   => $::locale->text('Request Quotations'),
304
    type    => 'request_quotation',
305
    columns => [
306
      [ $::locale->text('Quotation Date'),          'transdate'                                                                ],
307
      [ $::locale->text('Quotation Number'),        sub { $_[0]->presenter->request_quotation(display => 'table-cell') }       ],
308
      [ $::locale->text('Vendor'),                  'vendor'                                                                   ],
309
      [ $::locale->text('Net amount'),              'netamount'                                                                ],
310
      [ $::locale->text('Transaction description'), 'transaction_description'                                                  ],
311
      [ $::locale->text('Project'),                 'globalproject', ],
312
      [ $::locale->text('Closed'),                  'closed'                                                                   ],
313
    ],
314
    %params,
315
  );
316
}
317

  
318
sub _purchase_quotation_intake_list {
319
  my ($list, %params) = @_;
320

  
321
  return record_list(
322
    $list,
323
    title   => $::locale->text('Purchase Quotation Intakes'),
324
    type    => 'purchase_quotation_intake',
325
    columns => [
326
      [ $::locale->text('Quotation Date'),          'transdate'                                                                ],
327
      [ $::locale->text('Quotation Number'),        sub { $_[0]->presenter->purchase_quotation_intake(display => 'table-cell') } ],
328
      [ $::locale->text('Vendor'),                  'vendor'                                                                   ],
329
      [ $::locale->text('Net amount'),              'netamount'                                                                ],
330
      [ $::locale->text('Transaction description'), 'transaction_description'                                                  ],
331
      [ $::locale->text('Project'),                 'globalproject', ],
332
      [ $::locale->text('Closed'),                  'closed'                                                                   ],
333
    ],
334
    %params,
335
  );
336
}
337

  
338
sub _sales_order_intake_list {
339
  my ($list, %params) = @_;
340

  
341
  return record_list(
342
    $list,
343
    title   => $::locale->text('Sales Order Intakes'),
344
    type    => 'sales_order_intake',
345
    columns => [
346
      [ $::locale->text('Order Date'),              'transdate'                                                                ],
347
      [ $::locale->text('Order Number'),            sub { $_[0]->presenter->sales_order_intake(display => 'table-cell') }      ],
348
      [ $::locale->text('Quotation'),               'quonumber' ],
349
      [ $::locale->text('Customer'),                'customer'                                                                 ],
350
      [ $::locale->text('Net amount'),              'netamount'                                                                ],
351
      [ $::locale->text('Transaction description'), 'transaction_description'                                                  ],
352
      [ $::locale->text('Project'),                 'globalproject', ],
353
      [ $::locale->text('Closed'),                  'closed'                                                                   ],
354
    ],
355
    %params,
356
  );
357
}
358

  
359
sub _sales_order_list {
360
  my ($list, %params) = @_;
361

  
362
  return record_list(
363
    $list,
364
    title   => $::locale->text('Sales Orders'),
365
    type    => 'sales_order',
366
    columns => [
367
      [ $::locale->text('Order Date'),              'transdate'                                                                ],
368
      [ $::locale->text('Order Number'),            sub { $_[0]->presenter->sales_order(display => 'table-cell') }             ],
369
      [ $::locale->text('Quotation'),               'quonumber' ],
370
      [ $::locale->text('Customer'),                'customer'                                                                 ],
371
      [ $::locale->text('Net amount'),              'netamount'                                                                ],
372
      [ $::locale->text('Transaction description'), 'transaction_description'                                                  ],
373
      [ $::locale->text('Project'),                 'globalproject', ],
374
      [ $::locale->text('Closed'),                  'closed'                                                                   ],
375
    ],
376
    %params,
377
  );
378
}
379

  
380
sub _purchase_order_list {
381
  my ($list, %params) = @_;
382

  
383
  return record_list(
384
    $list,
385
    title   => $::locale->text('Purchase Orders'),
386
    type    => 'purchase_order',
387
    columns => [
388
      [ $::locale->text('Order Date'),              'transdate'                                                                ],
389
      [ $::locale->text('Order Number'),            sub { $_[0]->presenter->purchase_order(display => 'table-cell') }          ],
390
      [ $::locale->text('Request for Quotation'),   'quonumber' ],
391
      [ $::locale->text('Vendor'),                  'vendor'                                                                 ],
392
      [ $::locale->text('Net amount'),              'netamount'                                                                ],
393
      [ $::locale->text('Transaction description'), 'transaction_description'                                                  ],
394
      [ $::locale->text('Project'),                 'globalproject', ],
395
      [ $::locale->text('Closed'),                  'closed'                                                                   ],
396
    ],
397
    %params,
398
  );
399
}
400

  
401
sub _sales_delivery_order_list {
402
  my ($list, %params) = @_;
403

  
404
  return record_list(
405
    $list,
406
    title   => $::locale->text('Sales Delivery Orders'),
407
    type    => 'sales_delivery_order',
408
    columns => [
409
      [ $::locale->text('Delivery Order Date'),     'transdate'                                                                ],
410
      [ $::locale->text('Delivery Order Number'),   sub { $_[0]->presenter->sales_delivery_order(display => 'table-cell') }    ],
411
      [ $::locale->text('Order Number'),            'ordnumber' ],
412
      [ $::locale->text('Customer'),                'customer'                                                                 ],
413
      [ $::locale->text('Transaction description'), 'transaction_description'                                                  ],
414
      [ $::locale->text('Project'),                 'globalproject', ],
415
      [ $::locale->text('Delivered'),               'delivered'                                                                ],
416
      [ $::locale->text('Closed'),                  'closed'                                                                   ],
417
    ],
418
    %params,
419
  );
420
}
421

  
422
sub _rma_delivery_order_list {
423
  my ($list, %params) = @_;
424

  
425
  return record_list(
426
    $list,
427
    title   => $::locale->text('RMA Delivery Orders'),
428
    type    => 'rma_delivery_order',
429
    columns => [
430
      [ $::locale->text('Delivery Order Date'),     'transdate'                                                                ],
431
      [ $::locale->text('Delivery Order Number'),   sub { $_[0]->presenter->rma_delivery_order(display => 'table-cell') }    ],
432
      [ $::locale->text('Order Number'),            'ordnumber' ],
433
      [ $::locale->text('Customer'),                'customer'                                                                 ],
434
      [ $::locale->text('Transaction description'), 'transaction_description'                                                  ],
435
      [ $::locale->text('Project'),                 'globalproject', ],
436
      [ $::locale->text('Delivered'),               'delivered'                                                                ],
437
      [ $::locale->text('Closed'),                  'closed'                                                                   ],
438
    ],
439
    %params,
440
  );
441
}
442

  
443
sub _purchase_delivery_order_list {
444
  my ($list, %params) = @_;
445

  
446
  return record_list(
447
    $list,
448
    title   => $::locale->text('Purchase Delivery Orders'),
449
    type    => 'purchase_delivery_order',
450
    columns => [
451
      [ $::locale->text('Delivery Order Date'),     'transdate'                                                                ],
452
      [ $::locale->text('Delivery Order Number'),   sub { $_[0]->presenter->purchase_delivery_order(display => 'table-cell') } ],
453
      [ $::locale->text('Order Number'),            'ordnumber' ],
454
      [ $::locale->text('Vendor'),                  'vendor'                                                                 ],
455
      [ $::locale->text('Transaction description'), 'transaction_description'                                                  ],
456
      [ $::locale->text('Project'),                 'globalproject', ],
457
      [ $::locale->text('Delivered'),               'delivered'                                                                ],
458
      [ $::locale->text('Closed'),                  'closed'                                                                   ],
459
    ],
460
    %params,
461
  );
462
}
463

  
464
sub _supplier_delivery_order_list {
465
  my ($list, %params) = @_;
466

  
467
  return record_list(
468
    $list,
469
    title   => $::locale->text('Supplier Delivery Orders'),
470
    type    => 'supplier_delivery_order',
471
    columns => [
472
      [ $::locale->text('Delivery Order Date'),     'transdate'                                                                ],
473
      [ $::locale->text('Delivery Order Number'),   sub { $_[0]->presenter->supplier_delivery_order(display => 'table-cell') } ],
474
      [ $::locale->text('Order Number'),            'ordnumber' ],
475
      [ $::locale->text('Vendor'),                  'vendor'                                                                 ],
476
      [ $::locale->text('Transaction description'), 'transaction_description'                                                  ],
477
      [ $::locale->text('Project'),                 'globalproject', ],
478
      [ $::locale->text('Delivered'),               'delivered'                                                                ],
479
      [ $::locale->text('Closed'),                  'closed'                                                                   ],
480
    ],
481
    %params,
482
  );
483
}
484

  
485
sub _sales_reclamation_list {
486
  my ($list, %params) = @_;
487

  
488
  return record_list(
489
    $list,
490
    title   => $::locale->text('Sales Reclamation'),
491
    type    => 'sales_reclamation',
492
    columns => [
493
      [ $::locale->text('Reclamation Date'),        'transdate'                                                          ],
494
      [ $::locale->text('Reclamation Number'),      sub { $_[0]->presenter->sales_reclamation(display => 'table-cell') } ],
495
      [ $::locale->text('Customer'),                'customer'                                                           ],
496
      [ $::locale->text('Transaction description'), 'transaction_description'                                            ],
497
      [ $::locale->text('Project'),                 'globalproject',                                                     ],
498
      [ $::locale->text('Delivered'),               'delivered'                                                          ],
499
      [ $::locale->text('Closed'),                  'closed'                                                             ],
500
    ],
501
    %params,
502
  );
503
}
504

  
505
sub _purchase_reclamation_list {
506
  my ($list, %params) = @_;
507

  
508
  return record_list(
509
    $list,
510
    title   => $::locale->text('Purchase Reclamation'),
511
    type    => 'purchase_reclamation',
512
    columns => [
513
      [ $::locale->text('Reclamation Date'),        'transdate'                                                          ],
514
      [ $::locale->text('Reclamation Number'),      sub { $_[0]->presenter->purchase_reclamation(display => 'table-cell') } ],
515
      [ $::locale->text('Vendor'),                'vendor'                                                           ],
516
      [ $::locale->text('Transaction description'), 'transaction_description'                                            ],
517
      [ $::locale->text('Project'),                 'globalproject',                                                     ],
518
      [ $::locale->text('Delivered'),               'delivered'                                                          ],
519
      [ $::locale->text('Closed'),                  'closed'                                                             ],
520
    ],
521
    %params,
522
  );
523
}
524

  
525
sub _sales_invoice_list {
526
  my ($list, %params) = @_;
527

  
528
  return record_list(
529
    $list,
530
    title   => $::locale->text('Sales Invoices'),
531
    type    => 'sales_invoice',
532
    columns => [
533
      [ $::locale->text('Invoice Date'),            'transdate'               ],
534
      [ $::locale->text('Type'),                    sub { $_[0]->displayable_type } ],
535
      [ $::locale->text('Invoice Number'),          sub { $_[0]->presenter->sales_invoice(display => 'table-cell') } ],
536
      [ $::locale->text('Quotation Number'),        'quonumber' ],
537
      [ $::locale->text('Order Number'),            'ordnumber' ],
538
      [ $::locale->text('Customer'),                'customer'                ],
539
      [ $::locale->text('Net amount'),              'netamount'               ],
540
      [ $::locale->text('Paid'),                    'paid'                    ],
541
      [ $::locale->text('Transaction description'), 'transaction_description' ],
542
    ],
543
    %params,
544
  );
545
}
546

  
547
sub _purchase_invoice_list {
548
  my ($list, %params) = @_;
549

  
550
  return record_list(
551
    $list,
552
    title   => $::locale->text('Purchase Invoices'),
553
    type    => 'purchase_invoice',
554
    columns => [
555
      [ $::locale->text('Invoice Date'),                 'transdate'               ],
556
      [ $::locale->text('Invoice Number'),               sub { $_[0]->presenter->purchase_invoice(display => 'table-cell') } ],
557
      [ $::locale->text('Request for Quotation Number'), 'quonumber' ],
558
      [ $::locale->text('Order Number'),                 'ordnumber' ],
559
      [ $::locale->text('Vendor'),                       'vendor'                 ],
560
      [ $::locale->text('Net amount'),                   'netamount'               ],
561
      [ $::locale->text('Paid'),                         'paid'                    ],
562
      [ $::locale->text('Transaction description'),      'transaction_description' ],
563
    ],
564
    %params,
565
  );
566
}
567

  
568
sub _ar_transaction_list {
569
  my ($list, %params) = @_;
570

  
571
  return record_list(
572
    $list,
573
    title   => $::locale->text('AR Transactions'),
574
    type    => 'ar_transaction',
575
    columns => [
576
      [ $::locale->text('Invoice Date'),            'transdate'               ],
577
      [ $::locale->text('Type'),                    sub { $_[0]->displayable_type } ],
578
      [ $::locale->text('Invoice Number'),          sub { $_[0]->presenter->ar_transaction(display => 'table-cell') } ],
579
      [ $::locale->text('Customer'),                'customer'                ],
580
      [ $::locale->text('Net amount'),              'netamount'               ],
581
      [ $::locale->text('Paid'),                    'paid'                    ],
582
      [ $::locale->text('Transaction description'), 'transaction_description' ],
583
    ],
584
    %params,
585
  );
586
}
587

  
588
sub _ap_transaction_list {
589
  my ($list, %params) = @_;
590

  
591
  return record_list(
592
    $list,
593
    title   => $::locale->text('AP Transactions'),
594
    type    => 'ap_transaction',
595
    columns => [
596
      [ $::locale->text('Invoice Date'),            'transdate'                      ],
597
      [ $::locale->text('Invoice Number'),          sub { $_[0]->presenter->ap_transaction(display => 'table-cell') } ],
598
      [ $::locale->text('Vendor'),                  'vendor'                         ],
599
      [ $::locale->text('Net amount'),              'netamount'                      ],
600
      [ $::locale->text('Paid'),                    'paid'                           ],
601
      [ $::locale->text('Transaction description'), 'transaction_description'        ],
602
    ],
603
    %params,
604
  );
605
}
606

  
607
sub _gl_transaction_list {
608
  my ($list, %params) = @_;
609

  
610
  return record_list(
611
    $list,
612
    title   => $::locale->text('GL Transactions'),
613
    type    => 'gl_transaction',
614
    columns => [
615
      [ $::locale->text('Transdate'),        'transdate'                                                    ],
616
      [ $::locale->text('Reference'),   'reference'                                                    ],
617
      [ $::locale->text('Description'), sub { $_[0]->presenter->gl_transaction(display => 'table-cell') } ],
618
    ],
619
    %params,
620
  );
621
}
622

  
623
sub _bank_transactions {
624
  my ($list, %params) = @_;
625

  
626
  return record_list(
627
    $list,
628
    title   => $::locale->text('Bank transactions'),
629
    type    => 'bank_transactions',
630
    columns => [
631
      [ $::locale->text('Transdate'),            'transdate'                      ],
632
      [ $::locale->text('Local Bank Code'),      sub { $_[0]->local_bank_account->presenter->bank_code }  ],
633
      [ $::locale->text('Local account number'), sub { $_[0]->local_bank_account->presenter->account_number }  ],
634
      [ $::locale->text('Remote Bank Code'),     'remote_bank_code' ],
635
      [ $::locale->text('Remote account number'),'remote_account_number' ],
636
      [ $::locale->text('Valutadate'),           'valutadate' ],
637
      [ $::locale->text('Amount'),               'amount' ],
638
      [ $::locale->text('Currency'),             sub { $_[0]->currency->name } ],
639
      [ $::locale->text('Remote name'),          'remote_name' ],
640
      [ $::locale->text('Purpose'),              'purpose' ],
641
    ],
642
    %params,
643
  );
644
}
645

  
646
sub _sepa_export_list {
647
  my ($list, %params) = @_;
648

  
649
  my ($source, $destination) = $params{type} eq 'sepa_transfer' ? qw(our vc)                                 : qw(vc our);
650
  $params{title}             = $params{type} eq 'sepa_transfer' ? $::locale->text('Bank transfers via SEPA') : $::locale->text('Bank collections via SEPA');
651
  $params{with_columns}      = [ grep { $_ ne 'record_link_direction' } @{ $params{with_columns} || [] } ];
652

  
653
  delete $params{edit_record_links};
654

  
655
  return record_list(
656
    $list,
657
    columns => [
658
      [ $::locale->text('Export Number'),    'sepa_export',                                  ],
659
      [ $::locale->text('Execution date'),   'execution_date'                                ],
660
      [ $::locale->text('Export date'),      sub { $_[0]->sepa_export->itime->to_kivitendo } ],
661
      [ $::locale->text('Source BIC'),       "${source}_bic"                                 ],
662
      [ $::locale->text('Source IBAN'),      "${source}_iban"                                ],
663
      [ $::locale->text('Destination BIC'),  "${destination}_bic"                            ],
664
      [ $::locale->text('Destination IBAN'), "${destination}_iban"                           ],
665
      [ $::locale->text('Amount'),           'amount'                                        ],
666
    ],
667
    %params,
668
  );
669
}
670

  
671
sub _sepa_transfer_list {
672
  my ($list, %params) = @_;
673
  _sepa_export_list($list, %params, type => 'sepa_transfer');
674
}
675

  
676
sub _sepa_collection_list {
677
  my ($list, %params) = @_;
678
  _sepa_export_list($list, %params, type => 'sepa_collection');
679
}
680

  
681
sub _letter_list {
682
  my ($list, %params) = @_;
683

  
684
  return record_list(
685
    $list,
686
    title   => $::locale->text('Letters'),
687
    type    => 'letter',
688
    columns => [
689
      [ $::locale->text('Date'),         'date'                                                ],
690
      [ $::locale->text('Letternumber'), sub { $_[0]->presenter->letter(display => 'table-cell') } ],
691
      [ $::locale->text('Customer'),     'customer'                                            ],
692
      [ $::locale->text('Reference'),    'reference'                                           ],
693
      [ $::locale->text('Subject'),      'subject'                                             ],
694
    ],
695
    %params,
696
  );
697
}
698

  
699
sub _email_journal_list {
700
  my ($list, %params) = @_;
701

  
702
  return record_list(
703
    $list,
704
    title   => $::locale->text('Email'),
705
    type    => 'email_journal',
706
    columns => [
707
      [ $::locale->text('Sent on'), sub { $_[0]->sent_on->to_kivitendo(precision => 'seconds') } ],
708
      [ $::locale->text('Subject'), sub { $_[0]->presenter->email_journal(display => 'table-cell') } ],
709
      [ $::locale->text('Status'),  'status'                                                     ],
710
      [ $::locale->text('From'),    'from'                                                       ],
711
      [ $::locale->text('To'),      'recipients'                                                 ],
712
    ],
713
    %params,
714
  );
715
}
716
sub _dunning_list {
717
  my ($list, %params) = @_;
718

  
719
  return record_list(
720
    $list,
721
    title   => $::locale->text('Dunnings'),
722
    type    => 'dunning',
723
    columns => [
724
      [ $::locale->text('Dunning Level'),   sub { $_[0]->presenter->dunning(display => 'table-cell') } ],
725
      [ $::locale->text('Dunning Date'),    'transdate'                                                ],
726
      [ $::locale->text('Dunning Duedate'), 'duedate'                                                  ],
727
      [ $::locale->text('Total Fees'),      'fee'                                                      ],
728
      [ $::locale->text('Interest'),        'interest'                                                 ],
729
    ],
730
    %params,
731
  );
732
}
733

  
734 699
1;
735 700

  
736 701
__END__
......
752 717

  
753 718
  # Give HTML representation:
754 719
  my $html = SL::Presenter->get->grouped_record_list($records);
720
  # simple html version:
721
  my $html = SL::Presenter->get->simple_grouped_record_list($records);
755 722

  
756 723
=head1 OVERVIEW
757 724

  
......
771 738
  my $record = SL::DB::Manager::AccTransaction->get_first()->record;
772 739
  my $html   = SL::Presenter->get->record($record, display => 'inline');
773 740

  
774
=item C<grouped_record_list $list, %params>
775

  
776 741
=item C<empty_record_list>
777 742

  
778 743
Returns a rendered version (actually an instance of
779 744
L<SL::Presenter::EscapedText>) of an empty list of records. Is usually
780 745
only called by L<grouped_record_list> if its list is empty.
781 746

  
747
=item C<simple_grouped_record_list $list, %params>
748

  
749
Generates a simple list of records. The order of the records is the
750
same as in L<grouped_record_list>.
751

  
782 752
=item C<grouped_record_list $list, %params>
783 753

  
784 754
Given a number of Rose::DB objects in the array reference C<$list>

Auch abrufbar als: Unified diff