Revision 653af2fb
Von Jan Büren vor etwa 4 Jahren hinzugefügt
SL/DB/GLTransaction.pm | ||
---|---|---|
129 | 129 |
croak t8('You cannot use a negative amount with debit/credit!') if $amount < 0; |
130 | 130 |
|
131 | 131 |
require SL::DB::Tax; |
132 |
my $tax = SL::DB::Manager::Tax->find_by(id => $params{tax_id}) |
|
133 |
// croak "Can't find tax with id " . $params{tax_id}; |
|
132 |
|
|
133 |
my $ct = $chart->get_active_taxkey($self->deliverydate // $self->transdate); |
|
134 |
my $chart_tax = ref $ct eq 'SL::DB::TaxKey' ? $ct->tax : undef; |
|
135 |
|
|
136 |
my $tax = defined($params{tax_id}) ? SL::DB::Manager::Tax->find_by(id => $params{tax_id}) # 1. user param |
|
137 |
: ref $chart_tax eq 'SL::DB::Tax' ? $chart_tax # automatic tax |
|
138 |
: SL::DB::Manager::Tax->find_by(taxkey => 0, rate => 0.00); # no tax |
|
139 |
|
|
140 |
die "No valid tax found. User input:" . $params{tax_id} unless ref $tax eq 'SL::DB::Tax'; |
|
134 | 141 |
|
135 | 142 |
if ( $tax and $tax->rate != 0 ) { |
136 | 143 |
($netamount, $taxamount) = Form->calculate_tax($amount, $tax->rate, $self->taxincluded, $dec); |
... | ... | |
283 | 290 |
Adds an acc_trans entry to an existing GL transaction, depending on the tax it |
284 | 291 |
will also automatically create the tax entry. The GL transaction already needs |
285 | 292 |
to have certain values, e.g. transdate, taxincluded, ... |
293 |
Tax can be either set via the param tax_id or it will be set automatically |
|
294 |
depending on the chart configuration. If not set and no configuration is found |
|
295 |
no tax entry will be created (taxkey 0). |
|
286 | 296 |
|
287 | 297 |
Mandatory params are |
288 | 298 |
|
... | ... | |
290 | 300 |
|
291 | 301 |
=item * chart as an RDBO object |
292 | 302 |
|
293 |
=item * tax_id |
|
294 |
|
|
295 | 303 |
=item * either debit OR credit (positive values) |
296 | 304 |
|
297 | 305 |
=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).