Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 4e1e8352

Von Kivitendo Admin vor fast 10 Jahren hinzugefügt

  • ID 4e1e8352aed6d02c28116ea5afe82bf93d62bcba
  • Vorgänger 976b1ddf
  • Nachfolger 327e46b6

Buchungen in ar/ap/is/ir in eigenem Tabreiter anzeigen

Neuer Reiter "Buchungen", wo zu einer Rechnung/Buchung die Buchungen
laut acc_trans angezeigt werden.

In einer Tabelle "Buchungen" werden alle Buchungen laut acc_trans
angezeigt.

In einer Tabelle "Salden" werden die aktuellen Salden der bebuchten
Konten angezeigt, ausgeglichene Konten werden herausgefiltert.

Nicht für Dialogbuchungen umgesetzt.

Es wird auf das FiBu-Recht (general_ledger) geprüft, ansonsten wird der
Reiter nicht angezeigt

Unterschiede anzeigen:

SL/Controller/AccTrans.pm
1
package SL::Controller::AccTrans;
2
use strict;
3
use parent qw(SL::Controller::Base);
4
use SL::DB::AccTransaction;
5

  
6
__PACKAGE__->run_before('check_auth');
7

  
8
sub action_list_transactions {                                                                                
9
  my ($self) = @_;                                                                                      
10

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

  
13
  my $transactions = SL::DB::Manager::AccTransaction->get_all(query => [ trans_id => $::form->{trans_id} ], sort_by => 'acc_trans_id ASC'); 
14

  
15
  return $self->render(\'', { type => 'json' }) unless scalar @{$transactions};
16

  
17
  my $acc_trans_table = $self->_mini_ledger($transactions);
18
  my $balances_table  = $self->_mini_trial_balance($transactions);
19
  
20
  return $self->render('acc_trans/acc_trans', { header => 0 }, acc_trans_table => $acc_trans_table, balances_table => $balances_table);
21
}
22

  
23
sub _mini_ledger {
24
  my ($self, $transactions) = @_;
25

  
26
  $::auth->assert('general_ledger');
27

  
28
  my $debit_sum  = 0;
29
  my $credit_sum = 0;
30

  
31
  foreach my $t ( @{ $transactions } ) {
32
    $debit_sum  += $t->amount if $t->amount < 0;
33
    $credit_sum += $t->amount if $t->amount > 0;
34
  };
35

  
36
  return $self->render('acc_trans/_mini_ledger', { output => 0 }, TRANSACTIONS => $transactions, debit_sum => $debit_sum, credit_sum => $credit_sum, title => $::locale->text('Transactions') );
37
}
38

  
39
sub _mini_trial_balance {
40
  my ($self, $transactions) = @_;
41

  
42
  $::auth->assert('general_ledger');
43

  
44
  my $rec = {};
45
  foreach my $t ( @{ $transactions } ) {
46
    $rec->{$t->chart->accno}->{description} = $t->chart->description;
47
    $rec->{$t->chart->accno}->{accno}       = $t->chart->accno;
48
    $rec->{$t->chart->accno}->{balance}    += $t->amount;
49
  };
50

  
51
  my @balances;
52
  foreach ( sort keys %{ $rec } ) {
53
    push @balances, $rec->{$_} if $rec->{$_}->{balance} != 0;
54
  };
55

  
56
  return $self->render('acc_trans/_mini_trial_balance', { output => 0 }, BALANCES => \@balances, title => $::locale->text('Balances') );
57
}
58

  
59
sub check_auth {
60
  $::auth->assert('general_ledger');
61
}
62

  
63
1;
64

  
65
__END__
66

  
67
=pod
68

  
69
=encoding utf8
70

  
71
=head1 NAME
72

  
73
SL::Controller::AccTrans - module to list all transactions and balances of an invoice
74

  
75
=head1 SYNOPSIS
76

  
77
  list_transactions takes an id of an invoice and displays all the transactions in two HTML tables:
78

  
79
  * mini_ledger: list of all transactions of the invoice,  showing date, chart info and the amount as debit or credit, like a small general ledger just for this invoice.
80

  
81
  * mini_trial_balance: list of all charts from the transactions with their current sum, shown as debit or credit.
82

  
83
  The two tables are returned as an HTML div blob.
84

  
85
  # sample code for console:
86
  use SL::Controller::AccTrans;
87
  # get an invoice (ar/ap/is/ir)
88
  my $invoice = SL::DB::Manager::Invoice->find_by( invnumber => 1 );
89
  # the function is called from an opened invoice and needs the trans_id as a parameter
90
  $::form->{trans_id} = $invoice->id;
91
  SL::Controller::AccTrans->action_list_transactions();
92

  
93
  The HTML blob can also be opened directly as a url:
94
  controller.pl?action=AccTrans/print_table&trans_id=7
95

  
96
=head1 TODO
97

  
98
=head1 BUGS
99

  
100
Nothing here yet.
101

  
102
=head1 AUTHOR
103

  
104
G. Richardson E<lt>grichardson@kivitendo-premium.deE<gt>
105

  
106
=cut
locale/de/all
305 305
  'Balance Sheet'               => 'Bilanz',
306 306
  'Balance sheet date'          => 'Bilanzstichtag',
307 307
  'Balance startdate method'    => 'Methode zur Ermittlung des Startdatums für Bilanz',
308
  'Balances'                    => 'Salden',
308 309
  'Balancing'                   => 'Bilanzierung',
309 310
  'Bank'                        => 'Bank',
310 311
  'Bank Code'                   => 'BLZ',
......
2714 2715
  'Transaction has already been cancelled!' => 'Diese Buchung wurde bereits storniert.',
2715 2716
  'Transaction has been split on both the credit and the debit side' => 'Sowohl auf der Soll- als auch auf der Haben-Seite gesplittete Buchung',
2716 2717
  'Transaction posted!'         => 'Buchung verbucht!',
2718
  'Transactions'                => 'Buchungen',
2717 2719
  'Transactions without account:' => 'Buchungen ohne Konto:',
2718 2720
  'Transactions without reference:' => 'Buchungen ohne Referenz:',
2719 2721
  'Transactions, AR transactions, AP transactions' => 'Dialogbuchen, Debitorenrechnungen, Kreditorenrechnungen',
templates/webpages/acc_trans/acc_trans.html
1
[% acc_trans_table %]
2
<p></p>
3
[% balances_table %]
4

  
templates/webpages/ap/form_header.html
83 83
  <li><a href="#ui-tabs-basic-data">[% 'Basic Data' | $T8 %]</a></li>
84 84
[%- IF id %]
85 85
  <li><a href="controller.pl?action=RecordLinks/ajax_list&object_model=PurchaseInvoice&object_id=[% HTML.url(id) %]">[% 'Linked Records' | $T8 %]</a></li>
86
  <li><a href="[% 'controller.pl?action=AccTrans/list_transactions&trans_id=' _ HTML.url(id) | html %]">[% 'Transactions' | $T8 %]</a></li>
86 87
[%- END %]
87 88
 </ul>
88 89

  
templates/webpages/ar/form_header.html
24 24
  <li><a href="#ui-tabs-basic-data">[% 'Basic Data' | $T8 %]</a></li>
25 25
[%- IF id %]
26 26
  <li><a href="controller.pl?action=RecordLinks/ajax_list&object_model=Invoice&object_id=[% HTML.url(id) %]">[% 'Linked Records' | $T8 %]</a></li>
27
  <li><a href="[% 'controller.pl?action=AccTrans/list_transactions&trans_id=' _ HTML.url(id) | html %]">[% 'Transactions' | $T8 %]</a></li>
27 28
[%- END %]
28 29
 </ul>
29 30

  
templates/webpages/ir/form_header.html
34 34
[%- END %]
35 35
[%- IF id %]
36 36
  <li><a href="controller.pl?action=RecordLinks/ajax_list&object_model=PurchaseInvoice&object_id=[% HTML.url(id) %]">[% 'Linked Records' | $T8 %]</a></li>
37
  <li><a href="[% 'controller.pl?action=AccTrans/list_transactions&trans_id=' _ HTML.url(id) | html %]">[% 'Transactions' | $T8 %]</a></li>
37 38
[%- END %]
38 39
 </ul>
39 40

  
templates/webpages/is/form_header.html
35 35
[%- END %]
36 36
[%- IF id %]
37 37
  <li><a href="controller.pl?action=RecordLinks/ajax_list&object_model=Invoice&object_id=[% HTML.url(id) %]">[% 'Linked Records' | $T8 %]</a></li>
38
  <li><a href="[% 'controller.pl?action=AccTrans/list_transactions&trans_id=' _ HTML.url(id) | html %]">[% 'Transactions' | $T8 %]</a></li>
38 39
[%- END %]
39 40
 </ul>
40 41

  

Auch abrufbar als: Unified diff