Revision 688a2aef
Von Bernd Bleßmann vor fast 3 Jahren hinzugefügt
SL/IS.pm | ||
---|---|---|
1082 | 1082 |
} |
1083 | 1083 |
} |
1084 | 1084 |
|
1085 |
my $iap_amounts; |
|
1085 | 1086 |
if ($form->{type} eq 'final_invoice') { |
1086 | 1087 |
my $invoices_for_advance_payment = $self->_get_invoices_for_advance_payment($form->{convert_from_ar_ids} || $form->{id}); |
1087 | 1088 |
if (scalar @$invoices_for_advance_payment > 0) { |
... | ... | |
1110 | 1111 |
} |
1111 | 1112 |
|
1112 | 1113 |
# VAT for invoices for advance payment is booked on payment of these. So do not book this VAT for final invoice. |
1113 |
# Collect VAT of invoices for advance payment. |
|
1114 |
# And book the amount of the invoices for advance payment with taxkey 0 (see below). |
|
1115 |
# Collect amounts and VAT of invoices for advance payment. |
|
1116 |
|
|
1114 | 1117 |
# Set sellprices to fxsellprices for items, because |
1115 | 1118 |
# the PriceTaxCalculator sets fxsellprice from sellprice before calculating. |
1116 | 1119 |
$_->sellprice($_->fxsellprice) for @{$invoice_for_advance_payment->items}; |
1117 | 1120 |
my %pat = $invoice_for_advance_payment->calculate_prices_and_taxes; |
1118 | 1121 |
|
1119 | 1122 |
foreach my $tax_chart_id (keys %{ $pat{taxes_by_chart_id} }) { |
1120 |
my $tax_accno = SL::DB::Chart->new(id => $tax_chart_id)->load->accno; |
|
1121 |
$form->{amount}{ $form->{id} }{$tax_accno} -= $pat{taxes_by_chart_id}->{$tax_chart_id}; |
|
1123 |
my $tax_accno = SL::DB::Chart->load_cached($tax_chart_id)->accno; |
|
1124 |
$form->{amount}{ $form->{id} }{$tax_accno} -= $pat{taxes_by_chart_id}->{$tax_chart_id}; |
|
1125 |
$form->{amount}{ $form->{id} }{$form->{AR}} += $pat{taxes_by_chart_id}->{$tax_chart_id}; |
|
1126 |
} |
|
1127 |
|
|
1128 |
foreach my $amount_chart_id (keys %{ $pat{amounts} }) { |
|
1129 |
my $amount_accno = SL::DB::Chart->load_cached($amount_chart_id)->accno; |
|
1130 |
$iap_amounts->{$amount_accno} += $pat{amounts}->{$amount_chart_id}->{amount}; |
|
1131 |
$form->{amount}{ $form->{id} }{$amount_accno} -= $pat{amounts}->{$amount_chart_id}->{amount}; |
|
1122 | 1132 |
} |
1123 | 1133 |
} |
1124 | 1134 |
} |
... | ... | |
1237 | 1247 |
} |
1238 | 1248 |
} |
1239 | 1249 |
|
1250 |
# Book the amount of the invoices for advance payment with taxkey 0 (see below). |
|
1251 |
if ($form->{type} eq 'final_invoice' && $iap_amounts) { |
|
1252 |
foreach my $accno (keys %$iap_amounts) { |
|
1253 |
$query = |
|
1254 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, tax_id, taxkey, project_id, chart_link) |
|
1255 |
VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, (SELECT id FROM tax WHERE taxkey=0), 0, ?, (SELECT link FROM chart WHERE accno = ?))|; |
|
1256 |
@values = (conv_i($form->{id}), $accno, $iap_amounts->{$accno}, conv_date($form->{invdate}), conv_i($project_id), $accno); |
|
1257 |
do_query($form, $dbh, $query, @values); |
|
1258 |
} |
|
1259 |
} |
|
1260 |
|
|
1240 | 1261 |
# deduct payment differences from diff |
1241 | 1262 |
for my $i (1 .. $form->{paidaccounts}) { |
1242 | 1263 |
if ($form->{"paid_$i"} != 0) { |
Auch abrufbar als: Unified diff
Anzahlungs-Rg.: Steuer der Anzahlungs-Rgs. nicht auf das Forderungskto buchen …
… und Betrag der Anzahlungs-Rgs. mit Steuerschlüssel 0 buchen