X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FPresenter%2FRecord.pm;h=b395e822a8c52ccf0e8ba8f492e9a2bac150eeb1;hb=0b8b24545c98eb4cf22bda155d0e7efbf2bdcdb7;hp=23c5d46eac6d1539142c38feef600462bda28889;hpb=001155e424a519b543499cdb1f1841f48cfae352;p=kivitendo-erp.git diff --git a/SL/Presenter/Record.pm b/SL/Presenter/Record.pm index 23c5d46ea..b395e822a 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,6 +55,8 @@ 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 .= _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}; @@ -161,6 +178,8 @@ 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 }, ); my %groups; @@ -413,6 +432,29 @@ sub _ap_transaction_list { ); } +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) = @_; @@ -478,6 +520,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