Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 32ee774f

Von Moritz Bunkus vor etwa 14 Jahren hinzugefügt

  • ID 32ee774ff3674951d5e2402750c1a3053ad63afa
  • Vorgänger 60f784c0
  • Nachfolger 3ef69a72

Unterscheidung Bankeinzug/Überweisung beim Verbuchen von Zahlungen

Unterschiede anzeigen:

SL/SEPA.pm
336 336

  
337 337
  my $myconfig = \%main::myconfig;
338 338
  my $form     = $main::form;
339
  my $vc       = $params{vc} eq 'customer' ? 'customer' : 'vendor';
340
  my $arap     = $params{vc} eq 'customer' ? 'ar'       : 'ap';
341
  my $mult     = $params{vc} eq 'customer' ? -1         : 1;
342
  my $ARAP     = uc $arap;
339 343

  
340 344
  my $dbh      = $params{dbh} || $form->get_standard_dbh($myconfig);
341 345

  
......
346 350
                             FROM sepa_export_items sei
347 351
                             WHERE sei.id = ?| ],
348 352

  
349
    'get_ap'         => [ qq|SELECT at.chart_id
353
    'get_arap'       => [ qq|SELECT at.chart_id
350 354
                             FROM acc_trans at
351 355
                             LEFT JOIN chart c ON (at.chart_id = c.id)
352 356
                             WHERE (trans_id = ?)
353
                               AND ((c.link LIKE '%:AP') OR (c.link LIKE 'AP:%') OR (c.link = 'AP'))
357
                               AND ((c.link LIKE '%:${ARAP}') OR (c.link LIKE '${ARAP}:%') OR (c.link = '${ARAP}'))
354 358
                             LIMIT 1| ],
355 359

  
356 360
    'add_acc_trans'  => [ qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, gldate,       source, memo)
357 361
                             VALUES                (?,        ?,        ?,      ?,         current_date, ?,      '')| ],
358 362

  
359
    'update_ap'      => [ qq|UPDATE ap
363
    'update_arap'    => [ qq|UPDATE ${arap}
360 364
                             SET paid = paid + ?
361 365
                             WHERE id = ?| ],
362 366

  
......
388 392

  
389 393
    next if (!$orig_item);
390 394

  
391
    # Retrieve the invoice's AP chart ID.
392
    do_statement($form, @{ $handles{get_ap} }, $orig_item->{ap_id});
393
    my ($ap_chart_id) = $handles{get_ap}->[0]->fetchrow_array();
395
    # Retrieve the invoice's AR/AP chart ID.
396
    do_statement($form, @{ $handles{get_arap} }, $orig_item->{"${arap}_id"});
397
    my ($arap_chart_id) = $handles{get_arap}->[0]->fetchrow_array();
394 398

  
395
    # Record the payment in acc_trans offsetting AP.
396
    do_statement($form, @{ $handles{add_acc_trans} }, $orig_item->{ap_id}, $ap_chart_id,           -1 * $orig_item->{amount}, $item->{execution_date}, '');
397
    do_statement($form, @{ $handles{add_acc_trans} }, $orig_item->{ap_id}, $orig_item->{chart_id},      $orig_item->{amount}, $item->{execution_date}, $orig_item->{reference});
399
    # Record the payment in acc_trans offsetting AR/AP.
400
    do_statement($form, @{ $handles{add_acc_trans} }, $orig_item->{"${arap}_id"}, $arap_chart_id,         -1 * $mult * $orig_item->{amount}, $item->{execution_date}, '');
401
    do_statement($form, @{ $handles{add_acc_trans} }, $orig_item->{"${arap}_id"}, $orig_item->{chart_id},      $mult * $orig_item->{amount}, $item->{execution_date}, $orig_item->{reference});
398 402

  
399 403
    # Update the invoice to reflect the new paid amount.
400
    do_statement($form, @{ $handles{update_ap} }, $orig_item->{amount}, $orig_item->{ap_id});
404
    do_statement($form, @{ $handles{update_arap} }, $orig_item->{amount}, $orig_item->{"${arap}_id"});
401 405

  
402 406
    # Update the item to reflect that it has been posted.
403 407
    do_statement($form, @{ $handles{finish_item} }, $item->{execution_date}, $item_id);
bin/mozilla/sepa.pl
330 330

  
331 331
  my $form   = $main::form;
332 332
  my $locale = $main::locale;
333
  my $vc     = $form->{vc} eq 'customer' ? 'customer' : 'vendor';
333 334

  
334 335
  my @items  = grep { $_->{selected} } @{ $form->{items} || [] };
335 336

  
......
337 338
    $form->show_generic_error($locale->text('You have not selected any item.'), 'back_button' => 1);
338 339
  }
339 340
  my @export_ids    = uniq map { $_->{sepa_export_id} } @items;
340
  my %exports       = map { $_ => SL::SEPA->retrieve_export('id' => $_, 'details' => 1) } @export_ids;
341
  my %exports       = map { $_ => SL::SEPA->retrieve_export('id' => $_, 'details' => 1, vc => $vc) } @export_ids;
341 342
  my @items_to_post = ();
342 343

  
343 344
  foreach my $item (@items) {
......
355 356
    $form->show_generic_error($locale->text('You have to specify an execution date for each antry.'), 'back_button' => 1);
356 357
  }
357 358

  
358
  SL::SEPA->post_payment('items' => \@items_to_post);
359
  SL::SEPA->post_payment('items' => \@items_to_post, vc => $vc);
359 360

  
360 361
  $form->show_generic_information($locale->text('The payments have been posted.'));
361 362

  
362 363
  $main::lxdebug->leave_sub();
363 364
}
364 365

  
366
# TODO
365 367
sub bank_transfer_payment_list_as_pdf {
366 368
  $main::lxdebug->enter_sub();
367 369

  

Auch abrufbar als: Unified diff