X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/ed3be96543e7f224f5a406a73b61f4dc7e8a31e2..8b7b7b3f6252786b38bb6c9357fc00a08750b8db:/SL/DB/Invoice.pm diff --git a/SL/DB/Invoice.pm b/SL/DB/Invoice.pm index c55a22fc9..b3adee734 100644 --- a/SL/DB/Invoice.pm +++ b/SL/DB/Invoice.pm @@ -10,8 +10,10 @@ use List::Util qw(first); use SL::DB::MetaSetup::Invoice; use SL::DB::Manager::Invoice; +use SL::DB::Helper::FlattenToForm; use SL::DB::Helper::LinkedRecords; use SL::DB::Helper::PriceTaxCalculator; +use SL::DB::Helper::PriceUpdater; use SL::DB::Helper::TransNumberGenerator; use SL::DB::AccTransaction; use SL::DB::Chart; @@ -23,21 +25,17 @@ __PACKAGE__->meta->add_relationship( class => 'SL::DB::InvoiceItem', column_map => { id => 'trans_id' }, manager_args => { - with_objects => [ 'part' ] + with_objects => [ 'parts' ] } }, - payment_term => { - type => 'one to one', - class => 'SL::DB::PaymentTerm', - column_map => { payment_id => 'id' }, - }, ); __PACKAGE__->meta->initialize; # methods -sub items { goto &invoiceitems; } +sub items { goto &invoiceitems; } +sub payment_term { goto &payment; } # it is assumed, that ordnumbers are unique here. sub first_order_by_ordnumber { @@ -66,7 +64,7 @@ sub taxamount { my $self = shift; die 'not a setter method' if @_; - return $self->amount - $self->netamount; + return ($self->amount || 0) - ($self->netamount || 0); } __PACKAGE__->meta->make_attr_helpers(taxamount => 'numeric(15,5)'); @@ -151,7 +149,7 @@ sub post { if ($self->db->in_transaction) { $worker->(); } elsif (!$self->db->do_transaction($worker)) { - $::lxdebug->message(0, "convert_to_invoice failed: " . join("\n", (split(/\n/, $self->db->error))[0..2])); + $::lxdebug->message(LXDebug->WARN(), "convert_to_invoice failed: " . join("\n", (split(/\n/, $self->db->error))[0..2])); return undef; } @@ -209,6 +207,22 @@ sub _post_update_allocated { } } +sub invoice_type { + my ($self) = @_; + + return 'ar_transaction' if !$self->invoice; + return 'credit_note' if $self->type eq 'credit_note' && $self->amount < 0 && !$self->storno; + return 'invoice_storno' if $self->type ne 'credit_note' && $self->amount < 0 && $self->storno; + return 'credit_note_storno' if $self->type eq 'credit_note' && $self->amount > 0 && $self->storno; + return 'invoice'; +} + +sub displayable_state { + my $self = shift; + + return $self->closed ? $::locale->text('closed') : $::locale->text('open'); +} + 1; __END__ @@ -274,8 +288,7 @@ and recorded in C. =item 6. Items in C are updated according to their allocation status (regarding for costs of goold sold). Will only be done if -Lx-Office is not configured to use Einnahmenüberschussrechnungen -(C<$::eur>). +kivitendo is not configured to use Einnahmenüberschussrechnungen. =item 7. The invoice and its items are saved.