Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision d975f05c

Von Kivitendo Admin vor fast 8 Jahren hinzugefügt

  • ID d975f05c964dbc034da664b156744fdb3088c2a0
  • Vorgänger ab725987
  • Nachfolger 280b772d

SL::Dev::Payment create_bank_transaction nutzt param bank_chart_id

Unterschiede anzeigen:

SL/Dev/Payment.pm
49 49
 my $amount = (delete $params{amount} || $record->amount) * $multiplier;
50 50

  
51 51
 my $bank_chart;
52
 if ( $params{chart_id} ) {
53
   $bank_chart = SL::DB::Manager::Chart->find_by(chart_id => $params{chart_id}) or die "Can't find bank chart";
52
 if ( $params{bank_chart_id} ) {
53
   $bank_chart = SL::DB::Manager::Chart->find_by(id => delete $params{bank_chart_id}) or die "Can't find bank chart";
54 54
 } elsif ( $::instance_conf->get_ar_paid_accno_id ) {
55 55
   $bank_chart   = SL::DB::Manager::Chart->find_by(id => $::instance_conf->get_ar_paid_accno_id);
56 56
 } else {
......
99 99

  
100 100
=head2 C<create_bank_transaction %PARAMS>
101 101

  
102
Create a bank transaction that matches an existing invoice record, e.g. to be able to
103
test the point system.
104

  
102 105
Required params: record  (an SL::DB::Invoice or SL::DB::PurchaseInvoice object)
103 106

  
107
Optional params: bank_chart_id : the chart id of a configured bank account
108
                 amount        : the amount of the bank transaction
104 109

  
105
$params{amount} should always be relative to the absolute amount of the invoice, i.e. use positive
106
values for sales and purchases.
110
If no bank_chart_id is given, it tries to find a chart via defaults
111
(ar_paid_accno_id) or by searching for the chart named "Bank". The chart must
112
be connected to an existing BankAccount.
107 113

  
108
Create a bank transaction that matches an existing invoice record, e.g. to be able to
109
test the point system.
114
Param amount should always be relative to the absolute amount of the invoice, i.e. use positive
115
values for sales and purchases.
110 116

  
111 117
Example:
112 118
  my $payment_terms = SL::Dev::Record::create_payment_terms;
t/bank/bank_transactions.t
231 231
                                        payment_id => $payment_terms->id,
232 232
                                       );
233 233

  
234
  my $bt = SL::Dev::Payment::create_bank_transaction(record => $ar_transaction,
235
                                                     amount => $ar_transaction->amount_less_skonto
234
  my $bt = SL::Dev::Payment::create_bank_transaction(record        => $ar_transaction,
235
                                                     bank_chart_id => $bank->id,
236
                                                     amount        => $ar_transaction->amount_less_skonto
236 237
                                                    ) or die "Couldn't create bank_transaction";
237 238

  
238 239
  $::form->{invoice_ids} = {
......
260 261
  my $ar_transaction_1 = test_ar_transaction(invnumber => 'salesinv_1');
261 262
  my $ar_transaction_2 = test_ar_transaction(invnumber => 'salesinv_2');
262 263

  
263
  my $bt = SL::Dev::Payment::create_bank_transaction(record => $ar_transaction_1,
264
                                                     amount => ($ar_transaction_1->amount + $ar_transaction_2->amount),
265
                                                     purpose => "Rechnungen " . $ar_transaction_1->invnumber . " und " . $ar_transaction_2->invnumber,
264
  my $bt = SL::Dev::Payment::create_bank_transaction(record        => $ar_transaction_1,
265
                                                     amount        => ($ar_transaction_1->amount + $ar_transaction_2->amount),
266
                                                     purpose       => "Rechnungen " . $ar_transaction_1->invnumber . " und " . $ar_transaction_2->invnumber,
267
                                                     bank_chart_id => $bank->id,
266 268
                                                    ) or die "Couldn't create bank_transaction";
267 269

  
268 270
  $::form->{invoice_ids} = {
......
291 293
  $ar_transaction = test_ar_transaction(invnumber => 'salesinv overpaid');
292 294

  
293 295
  # amount 135 > 119
294
  my $bt = SL::Dev::Payment::create_bank_transaction(record => $ar_transaction,
295
                                                     amount => 135
296
  my $bt = SL::Dev::Payment::create_bank_transaction(record        => $ar_transaction,
297
                                                     bank_chart_id => $bank->id,
298
                                                     amount        => 135
296 299
                                                    ) or die "Couldn't create bank_transaction";
297 300

  
298 301
  $::form->{invoice_ids} = {
......
321 324

  
322 325
  $ar_transaction = test_ar_transaction(invnumber => 'salesinv overpaid partial');
323 326

  
324
  my $bt_1 = SL::Dev::Payment::create_bank_transaction(record    => $ar_transaction,
325
                                                       amount    =>  10
327
  my $bt_1 = SL::Dev::Payment::create_bank_transaction(record        => $ar_transaction,
328
                                                       bank_chart_id => $bank->id,
329
                                                       amount        =>  10
326 330
                                                      ) or die "Couldn't create bank_transaction";
327
  my $bt_2 = SL::Dev::Payment::create_bank_transaction(record    => $ar_transaction,
328
                                                       amount    => 119,
329
                                                       transdate => DateTime->today->add(days => 5),
331
  my $bt_2 = SL::Dev::Payment::create_bank_transaction(record        => $ar_transaction,
332
                                                       amount        => 119,
333
                                                       transdate     => DateTime->today->add(days => 5),
334
                                                       bank_chart_id => $bank->id,
330 335
                                                      ) or die "Couldn't create bank_transaction";
331 336

  
332 337
  $::form->{invoice_ids} = {
......
358 363
  $ar_transaction = test_ar_transaction(invnumber => 'salesinv partial payment');
359 364

  
360 365
  # amount 100 < 119
361
  my $bt = SL::Dev::Payment::create_bank_transaction(record => $ar_transaction,
362
                                                     amount => 100
366
  my $bt = SL::Dev::Payment::create_bank_transaction(record        => $ar_transaction,
367
                                                     bank_chart_id => $bank->id,
368
                                                     amount        => 100
363 369
                                                    ) or die "Couldn't create bank_transaction";
364 370

  
365 371
  $::form->{invoice_ids} = {

Auch abrufbar als: Unified diff