X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FPresenter%2FInvoice.pm;h=ebde34f1d0d933c614e49de334b3daa6c35fbe48;hb=821cc7062fddb5cbcc7b8077c34e252f00e09003;hp=c078450160c755440ac7185f362f977c396fa23c;hpb=0c28bb82b805b07543debaf08061b58d0b437c07;p=kivitendo-erp.git diff --git a/SL/Presenter/Invoice.pm b/SL/Presenter/Invoice.pm index c07845016..ebde34f1d 100644 --- a/SL/Presenter/Invoice.pm +++ b/SL/Presenter/Invoice.pm @@ -5,10 +5,28 @@ use strict; use parent qw(Exporter); use Exporter qw(import); -our @EXPORT = qw(sales_invoice ar_transaction purchase_invoice ap_transaction); +our @EXPORT = qw(invoice sales_invoice ar_transaction purchase_invoice ap_transaction); use Carp; +sub invoice { + my ($self, $invoice, %params) = @_; + + if ( $invoice->is_sales ) { + if ( $invoice->invoice ) { + return _is_ir_record($self, $invoice, 'is', %params); + } else { + return _is_ir_record($self, $invoice, 'ar', %params); + } + } else { + if ( $invoice->invoice ) { + return _is_ir_record($self, $invoice, 'ir', %params); + } else { + return _is_ir_record($self, $invoice, 'ap', %params); + } + }; +}; + sub sales_invoice { my ($self, $invoice, %params) = @_; @@ -79,10 +97,36 @@ transaction, purchase invoice and AP transaction Rose::DB objects my $object = SL::DB::Manager::PurchaseInvoice->get_first(where => [ or => [ invoice => undef, invoice => 0 ]]); my $html = SL::Presenter->get->ar_transaction($object, display => 'inline'); + # use with any of the above ar/ap/is/ir types: + my $html = SL::Presenter->get->invoice($object, display => 'inline'); + =head1 FUNCTIONS =over 4 +=item C + +Returns a rendered version (actually an instance of +L) of an ar/ap/is/ir object C<$object> . Determines +which type (sales or purchase, invoice or not) the object is. + +C<%params> can include: + +=over 2 + +=item * display + +Either C (the default) or C. At the moment both +representations are identical and produce the invoice number linked +to the corresponding 'edit' action. + +=item * no_link + +If falsish (the default) then the invoice number will be linked to the +"edit invoice" dialog from the sales menu. + +=back + =item C Returns a rendered version (actually an instance of