]> wagnertech.de Git - mfinanz.git/blobdiff - SL/DB/PurchaseInvoice.pm
invoice_type, displayable_type und displayable_name für ap
[mfinanz.git] / SL / DB / PurchaseInvoice.pm
index fbb990329eb3accb8df81ee36e8adc832b52442f..d1eaded8ff9ca39d7b3d49c69a25b63749ba08a3 100644 (file)
@@ -9,6 +9,7 @@ use SL::DB::Manager::PurchaseInvoice;
 use SL::DB::Helper::AttrHTML;
 use SL::DB::Helper::AttrSorted;
 use SL::DB::Helper::LinkedRecords;
+use SL::DB::Helper::Payment qw(:ALL);
 use SL::Locale::String qw(t8);
 
 # The calculator hasn't been adjusted for purchase invoices yet.
@@ -49,6 +50,7 @@ __PACKAGE__->attr_sorted('items');
 
 sub items { goto &invoiceitems; }
 sub add_items { goto &add_invoiceitems; }
+sub record_number { goto &invnumber; };
 
 sub is_sales {
   # For compatibility with Order, DeliveryOrder
@@ -76,6 +78,34 @@ sub abbreviation {
   return t8('Invoice (one letter abbreviation)'). '(' . t8('Storno (one letter abbreviation)') . ')' if $self->storno;
   return t8('Invoice (one letter abbreviation)');
 
+};
+
+sub link {
+  my ($self) = @_;
+
+  my $html;
+  $html   = SL::Presenter->get->purchase_invoice($self, display => 'inline') if $self->invoice;
+  $html   = SL::Presenter->get->ap_transaction($self, display => 'inline') if !$self->invoice;
+
+  return $html;
+}
+
+sub invoice_type {
+  my ($self) = @_;
+
+  return 'ap_transaction' if !$self->invoice;
+  return 'purchase_invoice';
 }
 
+sub displayable_type {
+  my ($self) = @_;
+
+  return t8('AP Transaction')    if $self->invoice_type eq 'ap_transaction';
+  return t8('Purchase Invoice');
+}
+
+sub displayable_name {
+  join ' ', grep $_, map $_[0]->$_, qw(displayable_type record_number);
+};
+
 1;