X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/78600d89c89dbdbb0ff0ef31e04feacedb1b5589..f9c7abfae65b79945beb7e9260942bc94876248a:/SL/DB/Invoice.pm diff --git a/SL/DB/Invoice.pm b/SL/DB/Invoice.pm index e9c04ed92..401d08865 100644 --- a/SL/DB/Invoice.pm +++ b/SL/DB/Invoice.pm @@ -10,10 +10,13 @@ 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; use SL::DB::Employee; __PACKAGE__->meta->add_relationship( @@ -123,7 +126,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 +250,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