Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 93dc3778

Von Bernd Bleßmann vor fast 10 Jahren hinzugefügt

  • ID 93dc3778a97299cd8b9dc4a35a9a927b5ba95306
  • Vorgänger 8b17f06f
  • Nachfolger cc8e9951

Item-Positionen für Rechnungen in DB: Rechnungsmasken honorieren und speichern diese.

Unterschiede anzeigen:

SL/IR.pm
106 106
  for my $i (1 .. $form->{rowcount}) {
107 107
    next unless $form->{"id_$i"};
108 108

  
109
    my $position = $i;
110

  
109 111
    $form->{"qty_$i"}  = $form->parse_amount($myconfig, $form->{"qty_$i"});
110 112
    $form->{"qty_$i"} *= -1 if $form->{storno};
111 113

  
......
373 375
      my $h_invoice_id = prepare_query($form, $dbh, $q_invoice_id);
374 376
      do_statement($form, $h_invoice_id, $q_invoice_id);
375 377
      $form->{"invoice_id_$i"}  = $h_invoice_id->fetchrow_array();
376
      my $q_create_invoice_id = qq|INSERT INTO invoice (id, trans_id, parts_id) values (?, ?, ?)|;
377
      do_query($form, $dbh, $q_create_invoice_id, conv_i($form->{"invoice_id_$i"}), conv_i($form->{id}), conv_i($form->{"id_$i"}));
378
      my $q_create_invoice_id = qq|INSERT INTO invoice (id, trans_id, position, parts_id) values (?, ?, ?, ?)|;
379
      do_query($form, $dbh, $q_create_invoice_id, conv_i($form->{"invoice_id_$i"}),
380
               conv_i($form->{id}), conv_i($position), conv_i($form->{"id_$i"}));
378 381
      $h_invoice_id->finish();
379 382
    }
380 383

  
381 384
      # save detail record in invoice table
382 385
      $query = <<SQL;
383
        UPDATE invoice SET trans_id = ?, parts_id = ?, description = ?, longdescription = ?, qty = ?, base_qty = ?,
386
        UPDATE invoice SET trans_id = ?, position = ?, parts_id = ?, description = ?, longdescription = ?, qty = ?, base_qty = ?,
384 387
                           sellprice = ?, fxsellprice = ?, discount = ?, allocated = ?, unit = ?, deliverydate = ?,
385 388
                           project_id = ?, serialnumber = ?, price_factor_id = ?,
386 389
                           price_factor = (SELECT factor FROM price_factors WHERE id = ?), marge_price_factor = ?,
......
388 391
        WHERE id = ?
389 392
SQL
390 393

  
391
    @values = (conv_i($form->{id}), conv_i($form->{"id_$i"}),
394
    @values = (conv_i($form->{id}), conv_i($position), conv_i($form->{"id_$i"}),
392 395
               $form->{"description_$i"}, $restricter->process($form->{"longdescription_$i"}), $form->{"qty_$i"} * -1,
393 396
               $baseqty * -1, $form->{"sellprice_$i"}, $fxsellprice, $form->{"discount_$i"}, $allocated,
394 397
               $form->{"unit_$i"}, conv_date($form->{deliverydate}),
......
1018 1021

  
1019 1022
        WHERE i.trans_id = ?
1020 1023

  
1021
        ORDER BY i.id|;
1024
        ORDER BY i.position|;
1022 1025
  $sth = prepare_execute_query($form, $dbh, $query, conv_i($form->{id}));
1023 1026

  
1024 1027
  while (my $ref = $sth->fetchrow_hashref("NAME_lc")) {
SL/IS.pm
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

  

Auch abrufbar als: Unified diff