Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision ed3be965

Von Moritz Bunkus vor fast 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
14 14
use SL::DB::Helper::PriceTaxCalculator;
15 15
use SL::DB::Helper::TransNumberGenerator;
16 16
use SL::DB::AccTransaction;
17
use SL::DB::Chart;
17 18
use SL::DB::Employee;
18 19

  
19 20
__PACKAGE__->meta->add_relationship(
......
123 124
sub post {
124 125
  my ($self, %params) = @_;
125 126

  
126
  croak("Missing parameter 'ar_id'") unless $params{ar_id};
127
  if (!$params{ar_id}) {
128
    my $chart = SL::DB::Manager::Chart->get_all(query   => [ SL::DB::Manager::Chart->link_filter('AR') ],
129
                                                sort_by => 'id ASC',
130
                                                limit   => 1)->[0];
131
    croak("No AR chart found and no parameter `ar_id' given") unless $chart;
132
    $params{ar_id} = $chart->id;
133
  }
127 134

  
128 135
  my $worker = sub {
129 136
    my %data = $self->calculate_prices_and_taxes;
......
241 248
=item * C<ar_id>
242 249

  
243 250
The ID of the accounds receivable chart the invoices amounts are
244
posted to.
251
posted to. If it is not set then the first chart configured for
252
accounts receivables is used.
245 253

  
246 254
=back
247 255

  
SL/DB/Order.pm
91 91

  
92 92
  croak("Conversion to invoices is only supported for sales records") unless $self->customer_id;
93 93

  
94
  if (!$params{ar_id}) {
95
    my $chart = SL::DB::Manager::Chart->get_all(query   => [ SL::DB::Manager::Chart->link_filter('AR') ],
96
                                                sort_by => 'id ASC',
97
                                                limit   => 1)->[0];
98
    croak("No AR chart found and no parameter `ar_id' given") unless $chart;
99
    $params{ar_id} = $chart->id;
100
  }
101

  
102 94
  my $invoice;
103 95
  if (!$self->db->do_transaction(sub {
104 96
    $invoice = SL::DB::Invoice->new_from($self)->post(%params) || die;
......
149 141
linked to the new invoice via L<SL::DB::RecordLink>. C<$self>'s
150 142
C<closed> attribute is set to C<true>, and C<$self> is saved.
151 143

  
152
The arguments in C<%params> are passed to
153
L<SL::DB::Invoice::post>. One parameter of note is
154
C<$paras{ar_id}>. If set it must be the ID of the accounts receivables
155
chart to post to. If it is not set then the first chart configured for
156
accounts receivables is used.
144
The arguments in C<%params> are passed to L<SL::DB::Invoice::post>.
157 145

  
158 146
Returns the new invoice instance on success and C<undef> on
159 147
failure. The whole process is run inside a transaction. On failure

Auch abrufbar als: Unified diff