Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 5a485635

Von Jan Büren vor mehr als 1 Jahr hinzugefügt

  • ID 5a485635a4aa7ed03b95f4b956f03f1a5a5bdaaf
  • Vorgänger fe9ae8aa
  • Nachfolger cbb1f3f2

S/D/H/Payment zwei Methoden leicht überarbeitet

get_payment_select_options_for_bank_transaction
> unnötige %params und test auf skontoable entfernt
> direkt auf Typ anstatt auf definiert prüfen

skonto_date
-> direkt auf Typ anstatt nur auf definiert prüfen

Unterschiede anzeigen:

SL/DB/Helper/Payment.pm
393 393
}
394 394

  
395 395
sub skonto_date {
396

  
397 396
  my $self = shift;
398 397

  
399
  return undef unless ref $self->payment_terms;
398
  return undef unless ref $self->payment_terms eq 'SL::DB::PaymentTerm';
400 399
  return undef unless $self->payment_terms->terms_skonto > 0;
400

  
401 401
  return DateTime->from_object(object => $self->transdate)->add(days => $self->payment_terms->terms_skonto);
402 402
}
403 403

  
......
618 618
}
619 619

  
620 620
sub get_payment_select_options_for_bank_transaction {
621
  my ($self, $bt_id, %params) = @_;
621
  my ($self, $bt_id) = @_;
622 622

  
623

  
624
  # CAVEAT template code expects with_skonto_pt at position 1 for visual help
625
  # due to skonto_charts, we cannot offer skonto for credit notes and neg ap
626
  my $skontoable = $self->amount > 0 ? 1 : 0;
627 623
  my @options;
624

  
625
  # 1. no skonto available -> done
628 626
  if(!$self->skonto_date) {
629 627
    push(@options, { payment_type => 'without_skonto', display => t8('without skonto'), selected => 1 });
630
    # wrong call to presenter or not implemented? disabled option is ignored
631
    # push(@options, { payment_type => 'with_skonto_pt', display => t8('with skonto acc. to pt'), disabled => 1 });
632
    push(@options, { payment_type => 'free_skonto', display => t8('free skonto') }) if $skontoable;
628
    push(@options, { payment_type => 'free_skonto', display => t8('free skonto') });
633 629
    return @options;
634 630
  }
635
  # valid skonto date, check if skonto is preferred
631

  
632
  # 2. valid skonto date, check if date is within skonto period
633
  # CAVEAT template code expects with_skonto_pt at position 1 for visual help
634
  # [% is_skonto_pt   = SELECT_OPTIONS.1.selected %]
635

  
636 636
  my $bt = SL::DB::BankTransaction->new(id => $bt_id)->load;
637
  if ($self->skonto_date && $self->within_skonto_period(transdate => $bt->transdate)) {
637
  croak "No Bank Transaction with ID $bt_id found" unless ref $bt eq 'SL::DB::BankTransaction';
638

  
639
  if ($self->within_skonto_period(transdate => $bt->transdate)) {
638 640
    push(@options, { payment_type => 'without_skonto', display => t8('without skonto') });
639
    push(@options, { payment_type => 'with_skonto_pt', display => t8('with skonto acc. to pt'), selected => 1 }) if $skontoable;
641
    push(@options, { payment_type => 'with_skonto_pt', display => t8('with skonto acc. to pt'), selected => 1 });
640 642
  } else {
641 643
    push(@options, { payment_type => 'without_skonto', display => t8('without skonto') , selected => 1 });
642
    push(@options, { payment_type => 'with_skonto_pt', display => t8('with skonto acc. to pt')}) if $skontoable;
644
    push(@options, { payment_type => 'with_skonto_pt', display => t8('with skonto acc. to pt')});
643 645
  }
644
  push(@options, { payment_type => 'free_skonto', display => t8('free skonto') }) if $skontoable;
646
  push(@options, { payment_type => 'free_skonto', display => t8('free skonto') });
645 647
  return @options;
646 648
}
647 649

  

Auch abrufbar als: Unified diff