Revision d2291970
Von Johannes Grassler vor etwa 1 Jahr hinzugefügt
bin/mozilla/ap.pl | ||
---|---|---|
150 | 150 |
%metadata = %{$parser->metadata}; |
151 | 151 |
@items = @{$parser->items}; |
152 | 152 |
|
153 |
$default_ap_amount_chart = SL::DB::Manager::Chart->find_by(charttype => 'A'); |
|
153 |
$default_ap_amount_chart = SL::DB::Manager::Chart->find_by(id => $::instance_conf->get_expense_accno_id); |
|
154 |
|
|
155 |
# Fallback if there's no default AP amount chart configured |
|
156 |
unless ( $default_ap_amount_chart ) { |
|
157 |
$default_ap_amount_chart = SL::DB::Manager::Chart->find_by(charttype => 'A'); |
|
158 |
} |
|
154 | 159 |
|
155 | 160 |
my $row = 0; |
156 | 161 |
foreach my $i (@items) { |
... | ... | |
162 | 167 |
my $desc = $item{'description'}; |
163 | 168 |
my $tax_rate = $item{'tax_rate'} / 100; # XML data is usually in percent |
164 | 169 |
|
165 |
my $taxes = SL::DB::Manager::Tax->get_all( |
|
166 |
where => [ |
|
167 |
chart_categories => { like => '%' . $default_ap_amount_chart->category . '%' }, |
|
168 |
rate => $tax_rate, |
|
169 |
], |
|
170 |
my $active_taxkey = $default_ap_amount_chart->taxkey_id; |
|
171 |
my $taxes = SL::DB::Manager::Tax->get_all( |
|
172 |
where => [ chart_categories => { like => '%' . $default_ap_amount_chart->category . '%' }], |
|
173 |
sort_by => 'taxkey, rate', |
|
170 | 174 |
); |
171 | 175 |
|
176 |
my $tax = first { $tax_rate == $_->rate } @{ $taxes }; |
|
177 |
$tax //= first { $active_taxkey->tax_id == $_->id } @{ $taxes }; |
|
178 |
$tax //= $taxes->[0]; |
|
179 |
|
|
172 | 180 |
# If we really can't find any tax definition (a simple rounding error may |
173 | 181 |
# be sufficient for that to happen), grab the first tax fitting the default |
174 | 182 |
# AP amount chart, just like the AP form would do it for manual entry. |
... | ... | |
178 | 186 |
); |
179 | 187 |
} |
180 | 188 |
|
181 |
my $tax = ${$taxes}[0]; |
|
182 |
|
|
183 | 189 |
if (!$tax) { |
184 | 190 |
$row--; |
185 | 191 |
next; |
186 | 192 |
} |
187 | 193 |
|
188 |
$::form->{"AP_amount_chart_id_${row}"} = $default_ap_amount_chart->id; # FIXME: add heuristic for picking a better one
|
|
189 |
$::form->{"previous_AP_amount_chart_id_${row}"} = $default_ap_amount_chart->id; # FIXME: add heuristic for picking a better one
|
|
194 |
$::form->{"AP_amount_chart_id_${row}"} = $default_ap_amount_chart->id; |
|
195 |
$::form->{"previous_AP_amount_chart_id_${row}"} = $default_ap_amount_chart->id; |
|
190 | 196 |
$::form->{"amount_${row}"} = $net_total; |
191 | 197 |
$::form->{"taxchart_${row}"} = $tax->id . '--' . $tax->rate; |
192 | 198 |
} |
Auch abrufbar als: Unified diff
ZUGFeRD-Import: Steuer-Heuristik verbessert
Die Heuristik funktioniert nun folgendermassen:
1) Ausgangsbasis: Standard-Aufwandskonto aus der Mandantenkonfiguration. Erstes
Aufwandskonto in der Datenbank falls keines konfiguriert ist.
2) Verwende den Steuerschluessel des Aufwandskontos um in Frage kommende
Steuern zu finden.
3) Sollte es (z.B. aufgrund von Rundungsfehlern) keinen passenden Steuersatz
geben, waehle den ersten fuer dieses Aufwandskonto passenden Steuersatz aus.