Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision ed3be965

Von Moritz Bunkus vor etwa 14 Jahren hinzugefügt

  • ID ed3be96543e7f224f5a406a73b61f4dc7e8a31e2
  • Vorgänger e86ae696
  • Nachfolger 3b70d2a0

Invoice::post selber ar_id setzen lassen, wenn nicht angegeben

Unterschiede anzeigen:

SL/DB/Invoice.pm
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(
......
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;
......
=item * C<ar_id>
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
SL/DB/Order.pm
croak("Conversion to invoices is only supported for sales records") unless $self->customer_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 $invoice;
if (!$self->db->do_transaction(sub {
$invoice = SL::DB::Invoice->new_from($self)->post(%params) || die;
......
linked to the new invoice via L<SL::DB::RecordLink>. C<$self>'s
C<closed> attribute is set to C<true>, and C<$self> is saved.
The arguments in C<%params> are passed to
L<SL::DB::Invoice::post>. One parameter of note is
C<$paras{ar_id}>. If set it must be the ID of the accounts receivables
chart to post to. If it is not set then the first chart configured for
accounts receivables is used.
The arguments in C<%params> are passed to L<SL::DB::Invoice::post>.
Returns the new invoice instance on success and C<undef> on
failure. The whole process is run inside a transaction. On failure

Auch abrufbar als: Unified diff