Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision a6a97a5f

Von Bernd Bleßmann vor mehr als 4 Jahren hinzugefügt

SEPA-Überweisungen: Zahlungsbedingungen f. Skonto aus EK-Rechnungen übernehmen …

… und nicht aus den Lieferanten-Stammdaten.

Hier könnte es im VK und EK noch eine Art fallback auf die Zahlungsbedingungen
aus den Kunden-/Lieferanten-Stammdaten geben - so dass diese zusätzlich als
Auswahl angeboten werden, sofern sie nicht in der Rechnung angegeben sind.
Refs #444 (redmine)

Unterschiede anzeigen:

SL/DB/Helper/Payment.pm
my $self = shift;
my $is_sales = ref($self) eq 'SL::DB::Invoice';
my $skonto_date;
if ( $is_sales ) {
return undef unless ref $self->payment_terms;
return undef unless $self->payment_terms->terms_skonto > 0;
$skonto_date = DateTime->from_object(object => $self->transdate)->add(days => $self->payment_terms->terms_skonto);
} else {
return undef unless ref $self->vendor->payment_terms;
return undef unless $self->vendor->payment_terms->terms_skonto > 0;
$skonto_date = DateTime->from_object(object => $self->transdate)->add(days => $self->vendor->payment_terms->terms_skonto);
};
return $skonto_date;
return undef unless ref $self->payment_terms;
return undef unless $self->payment_terms->terms_skonto > 0;
return DateTime->from_object(object => $self->transdate)->add(days => $self->payment_terms->terms_skonto);
};
sub reference_account {
......
sub percent_skonto {
my $self = shift;
my $is_sales = ref($self) eq 'SL::DB::Invoice';
my $percent_skonto = 0;
if ( $is_sales ) {
return undef unless ref $self->payment_terms;
return undef unless $self->payment_terms->percent_skonto > 0;
$percent_skonto = $self->payment_terms->percent_skonto;
} else {
return undef unless ref $self->vendor->payment_terms;
return undef unless $self->vendor->payment_terms->terms_skonto > 0;
$percent_skonto = $self->vendor->payment_terms->percent_skonto;
};
return undef unless ref $self->payment_terms;
return undef unless $self->payment_terms->percent_skonto > 0;
$percent_skonto = $self->payment_terms->percent_skonto;
return $percent_skonto;
};
......
# TODO: check whether there are negative values in invoice / acc_trans ... credited items
# don't check whether skonto applies, because user may want to override this
# return undef unless $self->percent_skonto; # for is_sales
# return undef unless $self->vendor->payment_terms->percent_skonto; # for purchase
# return undef unless $self->percent_skonto;
my $is_sales = ref($self) eq 'SL::DB::Invoice';
......
=item C<percent_skonto>
Returns the configured skonto percentage of the payment terms of an invoice,
e.g. 0.02 for 2%. Payment terms come from invoice settings for ar, from vendor
settings for ap.
e.g. 0.02 for 2%. Payment terms come from invoice settingssettings for ap.
=item C<amount_less_skonto>
If the invoice has a payment term (via ar for sales, via vendor for purchase),
If the invoice has a payment term,
calculate the amount to be paid in the case of skonto. This doesn't check,
whether skonto applies (i.e. skonto doesn't wasn't exceeded), it just subtracts
the configured percentage (e.g. 2%) from the total amount.
SL/SEPA.pm
my $mandate = $params{vc} eq 'customer' ? " AND COALESCE(vc.mandator_id, '') <> '' AND vc.mandate_date_of_signature IS NOT NULL " : '';
# in query: for customers, use payment terms from invoice, for vendors use
# payment terms from vendor settings
# currently there is no option in vendor invoices for setting payment terms,
# so the vendor settings are always used
my $payment_term_type = $params{vc} eq 'customer' ? "${arap}" : 'vc';
# open_amount is not the current open amount according to bookkeeping, but
# the open amount minus the SEPA transfer amounts that haven't been closed yet
my $query =
......
GROUP BY sei.${arap}_id)
AS open_transfers ON (${arap}.id = open_transfers.${arap}_id)
LEFT JOIN payment_terms pt ON (${payment_term_type}.payment_id = pt.id)
LEFT JOIN payment_terms pt ON (${arap}.payment_id = pt.id)
WHERE ${arap}.amount > (COALESCE(open_transfers.amount, 0) + ${arap}.paid)
......
Otherwise the function just dies with a short notice of the id.
=cut
t/db_helper/payment.t
# $params{amount} = '226'; # pass full amount
$params{payment_type} = 'with_skonto_pt';
$ap_transaction->payment_terms($ap_transaction->vendor->payment);
$ap_transaction->pay_invoice( %params );
my ($number_of_payments, $paid_amount) = number_of_payments($ap_transaction);

Auch abrufbar als: Unified diff