648 |
648 |
|
649 |
649 |
if ($form->{"id_$i"}) {
|
650 |
650 |
my $item_unit;
|
|
651 |
my $position = $i;
|
651 |
652 |
|
652 |
653 |
if (defined($baseunits{$form->{"id_$i"}})) {
|
653 |
654 |
$item_unit = $baseunits{$form->{"id_$i"}};
|
... | ... | |
733 |
734 |
|
734 |
735 |
if ($form->{"assembly_$i"}) {
|
735 |
736 |
# record assembly item as allocated
|
736 |
|
&process_assembly($dbh, $myconfig, $form, $form->{"id_$i"}, $baseqty);
|
|
737 |
&process_assembly($dbh, $myconfig, $form, $position, $form->{"id_$i"}, $baseqty);
|
737 |
738 |
|
738 |
739 |
} else {
|
739 |
740 |
$allocated = &cogs($dbh, $myconfig, $form, $form->{"id_$i"}, $baseqty, $basefactor, $i);
|
... | ... | |
754 |
755 |
my $h_invoice_id = prepare_query($form, $dbh, $q_invoice_id);
|
755 |
756 |
do_statement($form, $h_invoice_id, $q_invoice_id);
|
756 |
757 |
$form->{"invoice_id_$i"} = $h_invoice_id->fetchrow_array();
|
757 |
|
my $q_create_invoice_id = qq|INSERT INTO invoice (id, trans_id, parts_id) values (?, ?, ?)|;
|
758 |
|
do_query($form, $dbh, $q_create_invoice_id, conv_i($form->{"invoice_id_$i"}), conv_i($form->{id}), conv_i($form->{"id_$i"}));
|
|
758 |
my $q_create_invoice_id = qq|INSERT INTO invoice (id, trans_id, position, parts_id) values (?, ?, ?, ?)|;
|
|
759 |
do_query($form, $dbh, $q_create_invoice_id, conv_i($form->{"invoice_id_$i"}),
|
|
760 |
conv_i($form->{id}), conv_i($position), conv_i($form->{"id_$i"}));
|
759 |
761 |
$h_invoice_id->finish();
|
760 |
762 |
}
|
761 |
763 |
|
762 |
764 |
# save detail record in invoice table
|
763 |
765 |
$query = <<SQL;
|
764 |
|
UPDATE invoice SET trans_id = ?, parts_id = ?, description = ?, longdescription = ?, qty = ?,
|
|
766 |
UPDATE invoice SET trans_id = ?, position = ?, parts_id = ?, description = ?, longdescription = ?, qty = ?,
|
765 |
767 |
sellprice = ?, fxsellprice = ?, discount = ?, allocated = ?, assemblyitem = ?,
|
766 |
768 |
unit = ?, deliverydate = ?, project_id = ?, serialnumber = ?, pricegroup_id = ?,
|
767 |
769 |
ordnumber = ?, donumber = ?, transdate = ?, cusordnumber = ?, base_qty = ?, subtotal = ?,
|
... | ... | |
770 |
772 |
WHERE id = ?
|
771 |
773 |
SQL
|
772 |
774 |
|
773 |
|
@values = (conv_i($form->{id}), conv_i($form->{"id_$i"}),
|
|
775 |
@values = (conv_i($form->{id}), conv_i($position), conv_i($form->{"id_$i"}),
|
774 |
776 |
$form->{"description_$i"}, $restricter->process($form->{"longdescription_$i"}), $form->{"qty_$i"},
|
775 |
777 |
$form->{"sellprice_$i"}, $fxsellprice,
|
776 |
778 |
$form->{"discount_$i"}, $allocated, 'f',
|
... | ... | |
1388 |
1390 |
sub process_assembly {
|
1389 |
1391 |
$main::lxdebug->enter_sub();
|
1390 |
1392 |
|
1391 |
|
my ($dbh, $myconfig, $form, $id, $totalqty) = @_;
|
|
1393 |
my ($dbh, $myconfig, $form, $position, $id, $totalqty) = @_;
|
1392 |
1394 |
|
1393 |
1395 |
my $query =
|
1394 |
1396 |
qq|SELECT a.parts_id, a.qty, p.assembly, p.partnumber, p.description, p.unit,
|
... | ... | |
1409 |
1411 |
$ref->{qty} *= $totalqty;
|
1410 |
1412 |
|
1411 |
1413 |
if ($ref->{assembly}) {
|
1412 |
|
&process_assembly($dbh, $myconfig, $form, $ref->{parts_id}, $ref->{qty});
|
|
1414 |
&process_assembly($dbh, $myconfig, $form, $position, $ref->{parts_id}, $ref->{qty});
|
1413 |
1415 |
next;
|
1414 |
1416 |
} else {
|
1415 |
1417 |
if ($ref->{inventory_accno_id}) {
|
... | ... | |
1419 |
1421 |
|
1420 |
1422 |
# save detail record for individual assembly item in invoice table
|
1421 |
1423 |
$query =
|
1422 |
|
qq|INSERT INTO invoice (trans_id, description, parts_id, qty, sellprice, fxsellprice, allocated, assemblyitem, unit)
|
1423 |
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)|;
|
1424 |
|
my @values = (conv_i($form->{id}), $ref->{description}, conv_i($ref->{parts_id}), $ref->{qty}, 0, 0, $allocated, 't', $ref->{unit});
|
|
1424 |
qq|INSERT INTO invoice (trans_id, position, description, parts_id, qty, sellprice, fxsellprice, allocated, assemblyitem, unit)
|
|
1425 |
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)|;
|
|
1426 |
my @values = (conv_i($form->{id}), conv_i($position), $ref->{description},
|
|
1427 |
conv_i($ref->{parts_id}), $ref->{qty}, 0, 0, $allocated, 't', $ref->{unit});
|
1425 |
1428 |
do_query($form, $dbh, $query, @values);
|
1426 |
1429 |
|
1427 |
1430 |
}
|
... | ... | |
1723 |
1726 |
LEFT JOIN chart c2 ON ((SELECT tc.income_accno_id FROM taxzone_charts tc WHERE tc.taxzone_id = '$taxzone_id' and tc.buchungsgruppen_id = p.buchungsgruppen_id) = c2.id)
|
1724 |
1727 |
LEFT JOIN chart c3 ON ((SELECT tc.expense_accno_id FROM taxzone_charts tc WHERE tc.taxzone_id = '$taxzone_id' and tc.buchungsgruppen_id = p.buchungsgruppen_id) = c3.id)
|
1725 |
1728 |
|
1726 |
|
WHERE (i.trans_id = ?) AND NOT (i.assemblyitem = '1') ORDER BY i.id|;
|
|
1729 |
WHERE (i.trans_id = ?) AND NOT (i.assemblyitem = '1') ORDER BY i.position|;
|
1727 |
1730 |
|
1728 |
1731 |
$sth = prepare_execute_query($form, $dbh, $query, $id);
|
1729 |
1732 |
|
Item-Positionen für Rechnungen in DB: Rechnungsmasken honorieren und speichern diese.