X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FPresenter%2FRecord.pm;h=708e72653fd53113a6f1f90d8d8659a0fec56483;hb=59320b5a20c6fe1286f0460182d0a8566d19c0eb;hp=2bbaaf61132fb6078aa85f49dc0b4587aad5b824;hpb=89ade8da54d47af2cbf100fac07bf88ed9f23c43;p=kivitendo-erp.git diff --git a/SL/Presenter/Record.pm b/SL/Presenter/Record.pm index 2bbaaf611..708e72653 100644 --- a/SL/Presenter/Record.pm +++ b/SL/Presenter/Record.pm @@ -5,7 +5,7 @@ use strict; use parent qw(Exporter); use Exporter qw(import); -our @EXPORT = qw(grouped_record_list empty_record_list record_list); +our @EXPORT = qw(grouped_record_list empty_record_list record_list record); use SL::Util; @@ -19,6 +19,21 @@ sub _arrayify { return [ $array ]; } +sub record { + my ($self, $record, %params) = @_; + + my %grouped = _group_records( [ $record ] ); # pass $record as arrayref + my $type = (keys %grouped)[0]; + + return $self->sales_invoice( $record, %params) if $type eq 'sales_invoices'; + return $self->purchase_invoice($record, %params) if $type eq 'purchase_invoices'; + return $self->ar_transaction( $record, %params) if $type eq 'ar_transactions'; + return $self->ap_transaction( $record, %params) if $type eq 'ap_transactions'; + return $self->gl_transaction( $record, %params) if $type eq 'gl_transactions'; + + return ''; +} + sub grouped_record_list { my ($self, $list, %params) = @_; @@ -40,9 +55,15 @@ sub grouped_record_list { $output .= _purchase_invoice_list( $self, $groups{purchase_invoices}, %params) if $groups{purchase_invoices}; $output .= _ap_transaction_list( $self, $groups{ap_transactions}, %params) if $groups{ap_transactions}; + $output .= _gl_transaction_list( $self, $groups{gl_transactions}, %params) if $groups{gl_transactions}; + + $output .= _bank_transactions( $self, $groups{bank_transactions}, %params) if $groups{bank_transactions}; + $output .= _sepa_collection_list( $self, $groups{sepa_collections}, %params) if $groups{sepa_collections}; $output .= _sepa_transfer_list( $self, $groups{sepa_transfers}, %params) if $groups{sepa_transfers}; + $output .= _letter_list( $self, $groups{letters}, %params) if $groups{letters}; + $output = $self->render('presenter/record/grouped_record_list', %params, output => $output); return $output; @@ -75,7 +96,12 @@ sub record_list { if ($with_columns{record_link_direction}) { push @columns, { title => $::locale->text('Link direction'), - data => sub { $_[0]->{_record_link_direction} eq 'from' ? $::locale->text('Row was source for current record') : $::locale->text('Row was created from current record') }, + data => sub { + $_[0]->{_record_link_depth} > 1 + ? $::locale->text('Row was linked to another record') + : $_[0]->{_record_link_direction} eq 'from' + ? $::locale->text('Row was source for current record') + : $::locale->text('Row was created from current record') }, }; } @@ -156,6 +182,9 @@ sub _group_records { ap_transactions => sub { (ref($_[0]) eq 'SL::DB::PurchaseInvoice') && !$_[0]->invoice }, sepa_collections => sub { (ref($_[0]) eq 'SL::DB::SepaExportItem') && $_[0]->ar_id }, sepa_transfers => sub { (ref($_[0]) eq 'SL::DB::SepaExportItem') && $_[0]->ap_id }, + gl_transactions => sub { (ref($_[0]) eq 'SL::DB::GLTransaction') }, + bank_transactions => sub { (ref($_[0]) eq 'SL::DB::BankTransaction') && $_[0]->id }, + letters => sub { (ref($_[0]) eq 'SL::DB::Letter') && $_[0]->id }, ); my %groups; @@ -335,6 +364,7 @@ sub _sales_invoice_list { type => 'sales_invoice', columns => [ [ $::locale->text('Invoice Date'), 'transdate' ], + [ $::locale->text('Type'), sub { $_[0]->displayable_type } ], [ $::locale->text('Invoice Number'), sub { $self->sales_invoice($_[0], display => 'table-cell') } ], [ $::locale->text('Quotation Number'), 'quonumber' ], [ $::locale->text('Order Number'), 'ordnumber' ], @@ -377,6 +407,7 @@ sub _ar_transaction_list { type => 'ar_transaction', columns => [ [ $::locale->text('Invoice Date'), 'transdate' ], + [ $::locale->text('Type'), sub { $_[0]->displayable_type } ], [ $::locale->text('Invoice Number'), sub { $self->ar_transaction($_[0], display => 'table-cell') } ], [ $::locale->text('Customer'), 'customer' ], [ $::locale->text('Net amount'), 'netamount' ], @@ -406,6 +437,45 @@ sub _ap_transaction_list { ); } +sub _gl_transaction_list { + my ($self, $list, %params) = @_; + + return $self->record_list( + $list, + title => $::locale->text('GL Transactions'), + type => 'gl_transaction', + columns => [ + [ $::locale->text('Transdate'), 'transdate' ], + [ $::locale->text('Reference'), 'reference' ], + [ $::locale->text('Description'), sub { $self->gl_transaction($_[0 ], display => 'table-cell') } ], + ], + %params, + ); +} + +sub _bank_transactions { + my ($self, $list, %params) = @_; + + return $self->record_list( + $list, + title => $::locale->text('Bank transactions'), + type => 'bank_transactions', + columns => [ + [ $::locale->text('Transdate'), 'transdate' ], + [ $::locale->text('Local Bank Code'), sub { $self->bank_code($_[0]->local_bank_account) } ], + [ $::locale->text('Local account number'), sub { $self->account_number($_[0]->local_bank_account) } ], + [ $::locale->text('Remote Bank Code'), 'remote_bank_code' ], + [ $::locale->text('Remote account number'),'remote_account_number' ], + [ $::locale->text('Valutadate'), 'valutadate' ], + [ $::locale->text('Amount'), 'amount' ], + [ $::locale->text('Currency'), sub { $_[0]->currency->name } ], + [ $::locale->text('Remote name'), 'remote_name' ], + [ $::locale->text('Purpose'), 'purpose' ], + ], + %params, + ); +} + sub _sepa_export_list { my ($self, $list, %params) = @_; @@ -441,6 +511,24 @@ sub _sepa_collection_list { _sepa_export_list($self, $list, %params, type => 'sepa_collection'); } +sub _letter_list { + my ($self, $list, %params) = @_; + + return $self->record_list( + $list, + title => $::locale->text('Letters'), + type => 'letter', + columns => [ + [ $::locale->text('Date'), 'date' ], + [ $::locale->text('Letternumber'), sub { $self->letter($_[0], display => 'table-cell') } ], + [ $::locale->text('Customer'), 'customer' ], + [ $::locale->text('Reference'), 'reference' ], + [ $::locale->text('Subject'), 'subject' ], + ], + %params, + ); +} + 1; __END__ @@ -471,6 +559,18 @@ TODO =over 4 +=item C + +Returns a rendered version (actually an instance of +L) of a single ar, ap or gl object. + +Example: + # fetch the record from a random acc_trans object and print its link (could be ar, ap or gl) + my $record = SL::DB::Manager::AccTransaction->get_first()->record; + my $html = SL::Presenter->get->record($record, display => 'inline'); + +=item C + =item C Returns a rendered version (actually an instance of @@ -511,6 +611,8 @@ The order in which the records are grouped is: =item * AP transactions +=item * GL transactions + =item * SEPA collections =item * SEPA transfers @@ -565,13 +667,13 @@ C. =item C Can be set by the caller to indicate additional columns to -list. Currently supported: +be listed. Currently supported: =over 2 =item C -The record link destination. Requires that the records to list have +The record link destination. Requires that the records to be listed have been retrieved via the L helper. =back @@ -579,7 +681,7 @@ been retrieved via the L helper. =item C If trueish additional controls will be rendered that allow the user to -remove and add record links. Requires that the records to list have +remove and add record links. Requires that the records to be listed have been retrieved via the L helper. =back