X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/6834acd9f95035050fc9bbe591bcbbd6d1c2a4f4..ed3be96543e7f224f5a406a73b61f4dc7e8a31e2:/SL/DB/Invoice.pm diff --git a/SL/DB/Invoice.pm b/SL/DB/Invoice.pm index 6e0cf60a1..c55a22fc9 100644 --- a/SL/DB/Invoice.pm +++ b/SL/DB/Invoice.pm @@ -14,6 +14,7 @@ use SL::DB::Helper::LinkedRecords; use SL::DB::Helper::PriceTaxCalculator; use SL::DB::Helper::TransNumberGenerator; use SL::DB::AccTransaction; +use SL::DB::Chart; use SL::DB::Employee; __PACKAGE__->meta->add_relationship( @@ -123,7 +124,13 @@ sub new_from { sub post { my ($self, %params) = @_; - croak("Missing parameter 'ar_id'") unless $params{ar_id}; + if (!$params{ar_id}) { + my $chart = SL::DB::Manager::Chart->get_all(query => [ SL::DB::Manager::Chart->link_filter('AR') ], + sort_by => 'id ASC', + limit => 1)->[0]; + croak("No AR chart found and no parameter `ar_id' given") unless $chart; + $params{ar_id} = $chart->id; + } my $worker = sub { my %data = $self->calculate_prices_and_taxes; @@ -241,7 +248,8 @@ Posts the invoice. Required parameters are: =item * C The ID of the accounds receivable chart the invoices amounts are -posted to. +posted to. If it is not set then the first chart configured for +accounts receivables is used. =back @@ -273,7 +281,10 @@ Lx-Office is not configured to use Einnahmenüberschussrechnungen =back -Returns C<$self> on success and C on failure. +Returns C<$self> on success and C on failure. The whole process +is run inside a transaction. If it fails then nothing is saved to or +changed in the database. A new transaction is only started if none is +active. =item C