Revision 653af2fb
Von Jan Büren vor mehr als 4 Jahren hinzugefügt
SL/DB/GLTransaction.pm | ||
---|---|---|
croak t8('You cannot use a negative amount with debit/credit!') if $amount < 0;
|
||
|
||
require SL::DB::Tax;
|
||
my $tax = SL::DB::Manager::Tax->find_by(id => $params{tax_id})
|
||
// croak "Can't find tax with id " . $params{tax_id};
|
||
|
||
my $ct = $chart->get_active_taxkey($self->deliverydate // $self->transdate);
|
||
my $chart_tax = ref $ct eq 'SL::DB::TaxKey' ? $ct->tax : undef;
|
||
|
||
my $tax = defined($params{tax_id}) ? SL::DB::Manager::Tax->find_by(id => $params{tax_id}) # 1. user param
|
||
: ref $chart_tax eq 'SL::DB::Tax' ? $chart_tax # automatic tax
|
||
: SL::DB::Manager::Tax->find_by(taxkey => 0, rate => 0.00); # no tax
|
||
|
||
die "No valid tax found. User input:" . $params{tax_id} unless ref $tax eq 'SL::DB::Tax';
|
||
|
||
if ( $tax and $tax->rate != 0 ) {
|
||
($netamount, $taxamount) = Form->calculate_tax($amount, $tax->rate, $self->taxincluded, $dec);
|
||
... | ... | |
Adds an acc_trans entry to an existing GL transaction, depending on the tax it
|
||
will also automatically create the tax entry. The GL transaction already needs
|
||
to have certain values, e.g. transdate, taxincluded, ...
|
||
Tax can be either set via the param tax_id or it will be set automatically
|
||
depending on the chart configuration. If not set and no configuration is found
|
||
no tax entry will be created (taxkey 0).
|
||
|
||
Mandatory params are
|
||
|
||
... | ... | |
|
||
=item * chart as an RDBO object
|
||
|
||
=item * tax_id
|
||
|
||
=item * either debit OR credit (positive values)
|
||
|
||
=back
|
Auch abrufbar als: Unified diff
GLTransaction:: add_chart_booking um get_active_taxkey erweitert
Der Aufruf von add_chart_booking muss sich nicht mehr
darum kümmern welcher Steuerschlüssel gesetzt sein muss, wenn
er einfach nur den vorkonfigurierten Steuerschlüssel setzen will.
Dementsprechend ist param{tax_id} kein Pflichtparameter mehr.
POD ergänzt und mit Testfällen abgesichert (19% / 16% Fall).