Revision 8a638ac5
Von Jan Büren vor etwa 2 Jahren hinzugefügt
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 |
); |
... | ... | |
457 | 457 |
|
458 | 458 |
} |
459 | 459 |
|
460 |
# dead method, used to be called in get_payment_select_options_for_bank_transaction |
|
461 |
# error handling is now in _skonto_charts_and_tax_correction that dies with a user info |
|
462 |
# and not silently disables the option for the user |
|
463 |
sub check_skonto_configuration { |
|
464 |
my $self = shift; |
|
465 |
|
|
466 |
my $is_sales = ref($self) eq 'SL::DB::Invoice'; |
|
467 |
|
|
468 |
my $skonto_configured = 1; # default is assume skonto works |
|
469 |
|
|
470 |
# my $transactions = $self->transactions; |
|
471 |
foreach my $transaction (@{ $self->transactions }) { |
|
472 |
# find all transactions with an AR_amount or AP_amount link |
|
473 |
my $tax = SL::DB::Manager::Tax->get_first( where => [taxkey => $transaction->taxkey, id => $transaction->tax_id ]); |
|
474 |
|
|
475 |
# acc_trans entries for the taxes (chart_link == A[RP]_tax) often |
|
476 |
# have combinations of taxkey & tax_id that don't exist in |
|
477 |
# tax. Those must be skipped. |
|
478 |
next if !$tax && ($transaction->chart_link !~ m{A[RP]_amount}); |
|
479 |
|
|
480 |
croak "no tax for taxkey " . $transaction->{taxkey} unless ref $tax; |
|
481 |
|
|
482 |
$transaction->{chartlinks} = { map { $_ => 1 } split(m/:/, $transaction->chart_link) }; |
|
483 |
if ( $is_sales && $transaction->{chartlinks}->{AR_amount} ) { |
|
484 |
$skonto_configured = 0 unless $tax->skonto_sales_chart_id; |
|
485 |
} elsif ( !$is_sales && $transaction->{chartlinks}->{AP_amount}) { |
|
486 |
$skonto_configured = 0 unless $tax->skonto_purchase_chart_id; |
|
487 |
}; |
|
488 |
}; |
|
489 |
|
|
490 |
return $skonto_configured; |
|
491 |
} |
|
492 |
|
|
493 | 460 |
sub _skonto_charts_and_tax_correction { |
494 | 461 |
my ($self, %params) = @_; |
495 | 462 |
my $amount = $params{amount} || $self->skonto_amount; |
Auch abrufbar als: Unified diff
S/D/H/Payment check_skonto_configuration entfernt