Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 677899f8

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

  • ID 677899f84095a390a46d1b815491916699e46832
  • Vorgänger 9a5f5b0e
  • Nachfolger 92bdcd10

S/D/H/Payment check_skonto_configuration entfernt

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 open_amount skonto_amount check_skonto_configuration valid_skonto_amount validate_payment_type 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_ valid_skonto_amount validate_payment_type 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
);
......
465 465

  
466 466
}
467 467

  
468
# dead method,  used to be called in get_payment_select_options_for_bank_transaction
469
# error handling is now in _skonto_charts_and_tax_correction that dies with a user info
470
# and not silently disables the option for the user
471
sub check_skonto_configuration {
472
  my $self = shift;
473

  
474
  my $is_sales = ref($self) eq 'SL::DB::Invoice';
475

  
476
  my $skonto_configured = 1; # default is assume skonto works
477

  
478
  # my $transactions = $self->transactions;
479
  foreach my $transaction (@{ $self->transactions }) {
480
    # find all transactions with an AR_amount or AP_amount link
481
    my $tax = SL::DB::Manager::Tax->get_first( where => [taxkey => $transaction->taxkey, id => $transaction->tax_id ]);
482

  
483
    # acc_trans entries for the taxes (chart_link == A[RP]_tax) often
484
    # have combinations of taxkey & tax_id that don't exist in
485
    # tax. Those must be skipped.
486
    next if !$tax && ($transaction->chart_link !~ m{A[RP]_amount});
487

  
488
    croak "no tax for taxkey " . $transaction->{taxkey} unless ref $tax;
489

  
490
    $transaction->{chartlinks} = { map { $_ => 1 } split(m/:/, $transaction->chart_link) };
491
    if ( $is_sales && $transaction->{chartlinks}->{AR_amount} ) {
492
      $skonto_configured = 0 unless $tax->skonto_sales_chart_id;
493
    } elsif ( !$is_sales && $transaction->{chartlinks}->{AP_amount}) {
494
      $skonto_configured = 0 unless $tax->skonto_purchase_chart_id;
495
    };
496
  };
497

  
498
  return $skonto_configured;
499
}
500

  
501 468
sub _skonto_charts_and_tax_correction {
502 469
  my ($self, %params)   = @_;
503 470
  my $amount = $params{amount} || $self->skonto_amount;

Auch abrufbar als: Unified diff