Revision 9f07753b
Von Moritz Bunkus vor mehr als 11 Jahren hinzugefügt
SL/IC.pm | ||
---|---|---|
156 | 156 |
} |
157 | 157 |
$trq->finish; |
158 | 158 |
|
159 |
# now get accno for taxes |
|
160 |
$query = |
|
161 |
qq|SELECT c.accno |
|
162 |
FROM chart c, partstax pt |
|
163 |
WHERE (pt.chart_id = c.id) AND (pt.parts_id = ?)|; |
|
164 |
$sth = prepare_execute_query($form, $dbh, $query, conv_i($form->{id})); |
|
165 |
while (my ($key) = $sth->fetchrow_array) { |
|
166 |
$form->{amount}{$key} = $key; |
|
167 |
} |
|
168 |
|
|
169 |
$sth->finish; |
|
170 |
|
|
171 | 159 |
# is it an orphan |
172 | 160 |
my @referencing_tables = qw(invoice orderitems inventory rmaitems); |
173 | 161 |
my %column_map = ( ); |
... | ... | |
295 | 283 |
do_query($form, $dbh, qq|DELETE FROM assembly WHERE id = ?|, conv_i($form->{id})); |
296 | 284 |
} |
297 | 285 |
|
298 |
# delete tax records |
|
299 |
do_query($form, $dbh, qq|DELETE FROM partstax WHERE parts_id = ?|, conv_i($form->{id})); |
|
300 |
|
|
301 | 286 |
# delete translations |
302 | 287 |
do_query($form, $dbh, qq|DELETE FROM translation WHERE parts_id = ?|, conv_i($form->{id})); |
303 | 288 |
|
... | ... | |
470 | 455 |
} |
471 | 456 |
} |
472 | 457 |
|
473 |
# insert taxes |
|
474 |
foreach my $item (split(/ /, $form->{taxaccounts})) { |
|
475 |
if ($form->{"IC_tax_$item"}) { |
|
476 |
$query = |
|
477 |
qq|INSERT INTO partstax (parts_id, chart_id) |
|
478 |
VALUES (?, (SELECT id FROM chart WHERE accno = ?))|; |
|
479 |
@values = (conv_i($form->{id}), $item); |
|
480 |
do_query($form, $dbh, $query, @values); |
|
481 |
} |
|
482 |
} |
|
483 |
|
|
484 | 458 |
# add assembly records |
485 | 459 |
if ($form->{item} eq 'assembly') { |
486 | 460 |
|
... | ... | |
617 | 591 |
|
618 | 592 |
my %columns = ( "assembly" => "id", "parts" => "id" ); |
619 | 593 |
|
620 |
for my $table (qw(prices partstax makemodel inventory assembly translation parts)) {
|
|
594 |
for my $table (qw(prices makemodel inventory assembly translation parts)) { |
|
621 | 595 |
my $column = defined($columns{$table}) ? $columns{$table} : "parts_id"; |
622 | 596 |
do_query($form, $dbh, qq|DELETE FROM $table WHERE $column = ?|, @values); |
623 | 597 |
} |
Auch abrufbar als: Unified diff
Überflüssige Tabellen customertax, vendortax, partstax entfernt
Fixt #2186.