RecordLinks: credit_notes verlinken, und Typ von Rechnungen anzeigen
authorSven Schöling <s.schoeling@linet-services.de>
Fri, 5 Dec 2014 10:43:59 +0000 (11:43 +0100)
committerSven Schöling <s.schoeling@linet-services.de>
Fri, 5 Dec 2014 10:43:59 +0000 (11:43 +0100)
SL/DB/Invoice.pm
SL/IS.pm
SL/Presenter/Record.pm
bin/mozilla/is.pl

index d734003..b6f1bec 100644 (file)
@@ -318,6 +318,16 @@ sub displayable_state {
   return $self->closed ? $::locale->text('closed') : $::locale->text('open');
 }
 
+sub displayable_type {
+  my ($self) = @_;
+
+  return t8('AR Transaction')                         if $self->invoice_type eq 'ar_transaction';
+  return t8('Credit Note')                            if $self->invoice_type eq 'credit_note';
+  return t8('Invoice') . "(" . t8('Storno') . ")"     if $self->invoice_type eq 'invoice_storno';
+  return t8('Credit Note') . "(" . t8('Storno') . ")" if $self->invoice_type eq 'credit_note_storno';
+  return t8('Invoice');
+}
+
 sub abbreviation {
   my $self = shift;
 
index 1398ed8..29886a5 100644 (file)
--- a/SL/IS.pm
+++ b/SL/IS.pm
@@ -1174,6 +1174,17 @@ sub post_invoice {
 
   Common::webdav_folder($form);
 
+  if ($form->{convert_from_ar_ids}) {
+    RecordLinks->create_links('dbh'        => $dbh,
+                              'mode'       => 'ids',
+                              'from_table' => 'ar',
+                              'from_ids'   => $form->{convert_from_ar_ids},
+                              'to_table'   => 'ar',
+                              'to_id'      => $form->{id},
+    );
+    delete $form->{convert_from_ar_ids};
+  }
+
   # Link this record to the records it was created from.
   RecordLinks->create_links('dbh'        => $dbh,
                             'mode'       => 'ids',
index 61bd5cc..23c5d46 100644 (file)
@@ -340,6 +340,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' ],
@@ -382,6 +383,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'               ],
index 35b08b9..d2408ff 100644 (file)
@@ -390,7 +390,7 @@ sub form_header {
     max_dunning_level dunning_amount
     shiptoname shiptostreet shiptozipcode shiptocity shiptocountry  shiptocontact shiptophone shiptofax
     shiptoemail shiptodepartment_1 shiptodepartment_2  shiptocp_gender message email subject cc bcc taxaccounts cursor_fokus
-    convert_from_do_ids convert_from_oe_ids
+    convert_from_do_ids convert_from_oe_ids convert_from_ar_ids
     show_details
   ), @custom_hiddens,
   map { $_.'_rate', $_.'_description', $_.'_taxnumber' } split / /, $form->{taxaccounts}];
@@ -959,6 +959,7 @@ sub credit_note {
   $form->{duedate} =
     $form->current_date(\%myconfig, $form->{invdate}, $form->{terms} * 1);
 
+  $form->{convert_from_ar_ids} = $form->{id};
   $form->{id}     = '';
   $form->{rowcount}--;