Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 5104f579

Von Jan Büren vor etwa 2 Jahren hinzugefügt

  • ID 5104f579da0e98053f632cbb03eb8263fe7297bc
  • Vorgänger dd40d937
  • Nachfolger b93886a3

Payment-Helper: offensichtlich toten Code (Methoden) entfernt

Ferner einen Bug in einer Methode gefixt, die aber auch nie
richtig verwendet worden ist.

Unterschiede anzeigen:

SL/DB/Helper/Payment.pm
4 4

  
5 5
use parent qw(Exporter);
6 6
our @EXPORT = qw(pay_invoice);
7
our @EXPORT_OK = qw(skonto_date amount_less_skonto within_skonto_period percent_skonto reference_account reference_amount open_amount open_percent remaining_skonto_days skonto_amount check_skonto_configuration valid_skonto_amount get_payment_suggestions validate_payment_type open_sepa_transfer_amount get_payment_select_options_for_bank_transaction exchangerate forex _skonto_charts_and_tax_correction);
7
our @EXPORT_OK = qw(skonto_date amount_less_skonto within_skonto_period percent_skonto reference_account open_amount skonto_amount check_skonto_configuration valid_skonto_amount get_payment_suggestions validate_payment_type open_sepa_transfer_amount get_payment_select_options_for_bank_transaction exchangerate forex _skonto_charts_and_tax_correction);
8 8
our %EXPORT_TAGS = (
9 9
  "ALL" => [@EXPORT, @EXPORT_OK],
10 10
);
......
414 414
  return $reference_account;
415 415
};
416 416

  
417
sub reference_amount {
418
  my $self = shift;
419

  
420
  my $is_sales = ref($self) eq 'SL::DB::Invoice';
421

  
422
  require SL::DB::Manager::AccTransaction;
423

  
424
  my $link_filter = $is_sales ? 'AR' : 'AP';
425

  
426
  my $acc_trans = SL::DB::Manager::AccTransaction->find_by(
427
     trans_id   => $self->id,
428
     SL::DB::Manager::AccTransaction->chart_link_filter("$link_filter")
429
  );
430

  
431
  return undef unless ref $acc_trans;
432

  
433
  # this should be the same as $self->amount
434
  return $acc_trans->amount;
435
};
436

  
437

  
438 417
sub open_amount {
439 418
  my $self = shift;
440 419

  
......
446 425
  return ($self->amount // 0) - ($self->paid // 0);
447 426
};
448 427

  
449
sub open_percent {
450
  my $self = shift;
451

  
452
  return 0 if $self->amount == 0;
453
  my $open_percent;
454
  if ( $self->open_amount < 0 ) {
455
    # overpaid, currently treated identically
456
    $open_percent = $self->open_amount * 100 / $self->amount;
457
  } else {
458
    $open_percent = $self->open_amount * 100 / $self->amount;
459
  };
460

  
461
  return _round($open_percent) || 0;
462
};
463

  
464 428
sub skonto_amount {
465 429
  my $self = shift;
466 430

  
467 431
  return $self->amount - $self->amount_less_skonto;
468 432
};
469 433

  
470
sub remaining_skonto_days {
471
  my $self = shift;
472

  
473
  return undef unless ref $self->skonto_date;
474

  
475
  my $dur = DateTime::Duration->new($self->skonto_date - DateTime->today);
476
  return $dur->delta_days();
477

  
478
};
479

  
480 434
sub percent_skonto {
481 435
  my $self = shift;
482 436

  
......
534 488

  
535 489
sub open_sepa_transfer_amount {
536 490
  my $self = shift;
537

  
491
#  die "was buggy for ar and not really in use at all";
538 492
  my ($vc, $key, $type);
539 493
  if ( ref($self) eq 'SL::DB::Invoice' ) {
540 494
    $vc   = 'customer';
541
    $key  = 'ap_id';
495
    $key  = 'ar_id';  # BUGGY ar_id
542 496
    $type = 'ar';
543 497
  } else {
544 498
    $vc   = 'vendor';
......
1038 992
Unrounded total open amount of invoice (amount - paid).
1039 993
Doesn't take into account pending SEPA transfers.
1040 994

  
1041
=item C<open_percent>
1042

  
1043
Percentage of the invoice that is still unpaid, e.g. 100,00 if no payments have
1044
been made yet, 0,00 if fully paid.
1045

  
1046
=item C<remaining_skonto_days>
1047

  
1048
How many days skonto can still be taken, calculated from current day. Returns 0
1049
if current day is the max skonto date, and negative number if skonto date has
1050
already passed.
1051

  
1052
Returns undef if skonto is not configured for that invoice.
1053

  
1054 995
=item C<get_payment_suggestions %params>
1055 996

  
1056 997
Creates data intended for an L.select_tag dropdown that can be used in a

Auch abrufbar als: Unified diff