Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision cea6445c

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

  • ID cea6445cc3bf1852f6c4146f704ccd7cb7cbe990
  • Vorgänger 8a638ac5
  • Nachfolger 101e13ee

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
385 385
}
386 386

  
387 387
sub skonto_date {
388

  
389 388
  my $self = shift;
390 389

  
391
  return undef unless ref $self->payment_terms;
390
  return undef unless ref $self->payment_terms eq 'SL::DB::PaymentTerm';
392 391
  return undef unless $self->payment_terms->terms_skonto > 0;
392

  
393 393
  return DateTime->from_object(object => $self->transdate)->add(days => $self->payment_terms->terms_skonto);
394 394
}
395 395

  
......
610 610
}
611 611

  
612 612
sub get_payment_select_options_for_bank_transaction {
613
  my ($self, $bt_id, %params) = @_;
613
  my ($self, $bt_id) = @_;
614 614

  
615

  
616
  # CAVEAT template code expects with_skonto_pt at position 1 for visual help
617
  # due to skonto_charts, we cannot offer skonto for credit notes and neg ap
618
  my $skontoable = $self->amount > 0 ? 1 : 0;
619 615
  my @options;
616

  
617
  # 1. no skonto available -> done
620 618
  if(!$self->skonto_date) {
621 619
    push(@options, { payment_type => 'without_skonto', display => t8('without skonto'), selected => 1 });
622
    # wrong call to presenter or not implemented? disabled option is ignored
623
    # push(@options, { payment_type => 'with_skonto_pt', display => t8('with skonto acc. to pt'), disabled => 1 });
624
    push(@options, { payment_type => 'free_skonto', display => t8('free skonto') }) if $skontoable;
620
    push(@options, { payment_type => 'free_skonto', display => t8('free skonto') });
625 621
    return @options;
626 622
  }
627
  # valid skonto date, check if skonto is preferred
623

  
624
  # 2. valid skonto date, check if date is within skonto period
625
  # CAVEAT template code expects with_skonto_pt at position 1 for visual help
626
  # [% is_skonto_pt   = SELECT_OPTIONS.1.selected %]
627

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

  
631
  if ($self->within_skonto_period(transdate => $bt->transdate)) {
630 632
    push(@options, { payment_type => 'without_skonto', display => t8('without skonto') });
631
    push(@options, { payment_type => 'with_skonto_pt', display => t8('with skonto acc. to pt'), selected => 1 }) if $skontoable;
633
    push(@options, { payment_type => 'with_skonto_pt', display => t8('with skonto acc. to pt'), selected => 1 });
632 634
  } else {
633 635
    push(@options, { payment_type => 'without_skonto', display => t8('without skonto') , selected => 1 });
634
    push(@options, { payment_type => 'with_skonto_pt', display => t8('with skonto acc. to pt')}) if $skontoable;
636
    push(@options, { payment_type => 'with_skonto_pt', display => t8('with skonto acc. to pt')});
635 637
  }
636
  push(@options, { payment_type => 'free_skonto', display => t8('free skonto') }) if $skontoable;
638
  push(@options, { payment_type => 'free_skonto', display => t8('free skonto') });
637 639
  return @options;
638 640
}
639 641

  

Auch abrufbar als: Unified diff