Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 195883fd

Von Stephan Köhler vor etwa 19 Jahren hinzugefügt

  • ID 195883fdfd3b10f329036767f027baa6e7c402b9
  • Vorgänger c103dedd
  • Nachfolger 054ec89e

Preisgruppenerweiterung auf Basis von Andres Patch - Thanks
Preisgruppenverwaltung
-Preiseingabe der Preisgruppen in Masken Waren,etc.
-Auswahl der Preisgruppen in den Verkaufsmasken
...

Erweiterung Datenbankschema

Unterschiede anzeigen:

SL/IS.pm
34 34

  
35 35
package IS;
36 36

  
37
use Data::Dumper;
38

  
37 39
sub invoice_details {
38 40
  $main::lxdebug->enter_sub();
39 41

  
......
365 367

  
366 368
sub post_invoice {
367 369
  $main::lxdebug->enter_sub();
368

  
370
print STDERR "IS.pm-post_invoice\n";
369 371
  my ($self, $myconfig, $form) = @_;
370 372

  
371 373
  # connect to database, turn off autocommit
......
549 551
        ? qq|'$form->{"deliverydate_$i"}'|
550 552
        : "NULL";
551 553

  
554

  
555
      # get pricegroup_id and save ist
556
      ($null, my $pricegroup_id) = split /--/, $form->{"sellprice_drag_$i"};
557

  
552 558
      # save detail record in invoice table
553 559
      $query = qq|INSERT INTO invoice (trans_id, parts_id, description, qty,
554 560
                  sellprice, fxsellprice, discount, allocated, assemblyitem,
555
		  unit, deliverydate, project_id, serialnumber)
561
		  unit, deliverydate, project_id, serialnumber, pricegroup_id)
556 562
		  VALUES ($form->{id}, $form->{"id_$i"},
557 563
		  '$form->{"description_$i"}', $form->{"qty_$i"},
558 564
		  $form->{"sellprice_$i"}, $fxsellprice,
559 565
		  $form->{"discount_$i"}, $allocated, 'f',
560 566
		  '$form->{"unit_$i"}', $deliverydate, (SELECT id from project where projectnumber = '$project_id'),
561
		  '$form->{"serialnumber_$i"}')|;
567
		  '$form->{"serialnumber_$i"}',
568
      '$pricegroup_id')|;
562 569
      $dbh->do($query) || $form->dberror($query);
563 570

  
564 571
      if ($form->{lizenzen}) {
......
1105 1112

  
1106 1113
sub retrieve_invoice {
1107 1114
  $main::lxdebug->enter_sub();
1108

  
1115
print STDERR "IS.pm-retrieve_invoice\n";
1109 1116
  my ($self, $myconfig, $form) = @_;
1110 1117

  
1111 1118
  # connect to database
......
1211 1218
		i.discount, i.parts_id AS id, i.unit, i.deliverydate,
1212 1219
		i.project_id, pr.projectnumber, i.serialnumber,
1213 1220
		p.partnumber, p.assembly, p.bin, p.notes AS partnotes, i.id AS invoice_pos,
1214
		pg.partsgroup
1221
		pg.partsgroup, i.pricegroup_id, (SELECT pricegroup FROM pricegroup WHERE id=i.pricegroup_id) as pricegroup
1215 1222
		FROM invoice i
1216 1223
	        JOIN parts p ON (i.parts_id = p.id)
1217 1224
	        LEFT JOIN project pr ON (i.project_id = pr.id)
......
1306 1313
                 c.email, c.cc, c.bcc, c.language,
1307 1314
		 c.street, c.zipcode, c.city, c.country,
1308 1315
	         $duedate + c.terms AS duedate, c.notes AS intnotes,
1309
		 b.discount AS tradediscount, b.description AS business
1316
		 b.discount AS tradediscount, b.description AS business, c.klass as customer_klass
1310 1317
                 FROM customer c
1311 1318
		 LEFT JOIN business b ON (b.id = c.business_id)
1312 1319
	         WHERE c.id = $form->{customer_id}|;
......
1513 1520
        $stw->finish;
1514 1521
      }
1515 1522
    }
1516

  
1517 1523
  }
1518 1524
  $sth->finish;
1519 1525
  $dbh->disconnect;
......
1521 1527
  $main::lxdebug->leave_sub();
1522 1528
}
1523 1529

  
1530
##########################
1531
# get pricegroups from database
1532
# build up selected pricegroup
1533
# if an exchange rate - change price 
1534
# for each part
1535
#
1536
sub get_pricegroups_for_parts {
1537
print STDERR "IS.pm - get_pricegroups_for_parts\n";
1538
  $main::lxdebug->enter_sub();
1539

  
1540
  my ($self, $myconfig, $form) = @_;
1541

  
1542
  my $dbh = $form->dbconnect($myconfig);
1543

  
1544
  my $i  = 1;
1545
  my $id = 0;
1546

  
1547
  while (($form->{"id_$i"}) or ($form->{"new_id_$i"})) {
1548

  
1549
    $id = $form->{"id_$i"};
1550

  
1551
    if (!($form->{"id_$i"}) and $form->{"new_id_$i"}) {
1552

  
1553
      $id = $form->{"new_id_$i"};
1554
    }
1555

  
1556
    ($price, $selectedpricegroup_id) = split /--/, $form->{"sellprice_drag_$i"};
1557
#  print (STDERR "sellprice_drag_$i", Dumper($form->{"sellprice_drag_$i"}));
1558

  
1559
    $pricegroup_old = $form->{"pricegroup_old_$i"};
1560
#  print (STDERR "pricegroup_old_i-$i", Dumper($pricegroup_old));
1561

  
1562
    $price_new = $form->{"price_new_$i"};
1563

  
1564
    $price_old = $form->{"price_old_$i"};
1565

  
1566
 
1567
    $query = qq|SELECT pricegroup_id, (SELECT p.sellprice from parts p where p.id = $id) as default_sellprice,(SELECT pg.pricegroup FROM pricegroup pg WHERE id=pricegroup_id) AS pricegroup, price, '' AS selected FROM prices WHERE parts_id = $id UNION SELECT 0 as pricegroup_id,(SELECT sellprice FROM parts WHERE id=$id) as default_sellprice,'' as pricegroup, (SELECT DISTINCT sellprice from parts where id=$id) as price, 'selected' AS selected from prices ORDER BY pricegroup|;
1568

  
1569
    $pkq = $dbh->prepare($query);
1570
    $pkq->execute || $form->dberror($query);
1571
    while ($pkr = $pkq->fetchrow_hashref(NAME_lc)) {
1572
#       push @{ $form->{PRICES}{$id} }, $pkr;
1573
        push @{ $form->{PRICES}{$i} }, $pkr;
1574
        $pkr->{id} = $id;
1575
        $pkr->{selected}  = '';
1576

  
1577
    # if there is an exchange rate change price
1578
      if (($form->{exchangerate} * 1) != 0) {
1579
# print STDERR "WECHSELKURS?-$form->{exchangerate}\n";
1580
        $pkr->{price} /= $form->{exchangerate};
1581
      }
1582
      $pkr->{price} = $form->format_amount($myconfig,$pkr->{price},5);
1583

  
1584

  
1585
      if ($selectedpricegroup_id eq undef) {
1586
        if ($pkr->{pricegroup_id} eq $form->{customer_klass}) {
1587
print STDERR "   INIT ROW \n";
1588
#print (STDERR "   PREIS", Dumper($pkr->{price}));
1589
          $pkr->{selected}  = ' selected';
1590
          $last->{selected} = '';
1591
# print (STDERR "   SELLPRICE", Dumper($form->{"sellprice_$i"}));
1592

  
1593
        # no customer pricesgroup set 
1594
          if ($pkr->{price} == $pkr->{default_sellprice}) {
1595
print (STDERR "   PREIS IST DEFAULT-SELLPRICE", Dumper($form->{"sellprice_$i"}));
1596
           $pkr->{price} = $form->{"sellprice_$i"};
1597

  
1598
#  if ($form->{tradediscount}){
1599
#  print (STDERR "TRADE--", Dumper($pkr->{price}));
1600
#               $pkr->{price} =$pkr->{price} * (1 - $form->{tradediscount});
1601
#               $pkr->{price} = $form->format_amount($myconfig,$pkr->{price},5);
1602
#  print (STDERR "TRADE--", Dumper($pkr->{price}));
1603
#  }
1604

  
1605
          } else {
1606
print STDERR "   PREIS IST NICHT NULL\n";
1607
             $form->{"sellprice_$i"} = $pkr->{price};
1608
          }
1609
# print (STDERR "           PRICE", Dumper($pkr->{price}));
1610

  
1611
        } else {
1612
print STDERR "   INIT ROW but what\n";
1613
print (STDERR "   PREIS -", Dumper($pkr->{price}), "Default", Dumper($pkr->{default_sellprice}));
1614
          if ($pkr->{price} == $pkr->{default_sellprice}) {
1615
print (STDERR "   PREIS IST DEFAULT-", Dumper($form->{"sellprice_$i"}));
1616
            $pkr->{price} = $form->{"sellprice_$i"};
1617
            $pkr->{selected}                    = ' selected';
1618
          }
1619
        }
1620
      }
1621
      if ($selectedpricegroup_id or $selectedpricegroup_id == 0){
1622
        if ($selectedpricegroup_id ne $pricegroup_old) {
1623
          if ($pkr->{pricegroup_id} eq $selectedpricegroup_id) {
1624
            if ($price_new != $form->{"sellprice_$i"}) {
1625
print STDERR "   MANUELLEN PREIS W?HLEN\n";
1626
            } else {
1627
print STDERR "   UPDATE CHANGE PRICEGROUP\n";
1628
              $pkr->{selected}                    = ' selected';
1629
              $last->{selected}                   = '';
1630
#$form->{"pricegroup_old_$i"} = $pkr->{$pricegroup_id};
1631
            }
1632
          }
1633
        } else { 
1634
          if (($price_new != $form->{"sellprice_$i"}) and ($price_new ne 0)) {
1635
            if ($pkr->{pricegroup_id} == 0) {
1636
print STDERR "   UPDATE CHANGE PRICEGROUP with price manuelly\n";
1637
print (STDERR "  SELLPRICE??? ---", Dumper($form->{"sellprice_$i"}));
1638
print (STDERR "  NEWPRICE??? ---", Dumper($price_new));
1639
              $pkr->{price} = $form->{"sellprice_$i"};
1640
              $pkr->{selected}                    = ' selected';
1641
              $last->{selected}                   = '';
1642
       #$form->{"sellprice_$i"} = $form->format_amount($myconfig, $price_new, 2);
1643
# print (STDERR "----5555---", Dumper($pkr));
1644
            }
1645
          } else {
1646
            if ($pkr->{pricegroup_id} eq $selectedpricegroup_id) {
1647
print STDERR "   UPDATE NO CHANGE\n";
1648
              $pkr->{selected}                    = ' selected';
1649
              $last->{selected}                   = '';
1650
print STDERR "  DEFAULTPRICE??? ---$pkr->{default_sellprice}\n";
1651
print (STDERR "  SELLPRICE??? ---", Dumper($form->{"sellprice_$i"}));
1652
# print (STDERR "  HIER DER SELLPRICE DEFAULT??? ---", Dumper($form));
1653
print STDERR "  NEWPRICE??? ---$price_new_\n";
1654
              if (($pkr->{pricegroup_id} == 0) and ($pkr->{price} == $form->{"sellprice_$i"})) {
1655
print (STDERR "  UPDATE NO CHANGE BUT PRICE MANUELLY SET", Dumper($pkr->{price}));
1656
                # $pkr->{price}                         = $form->{"sellprice_$i"};
1657
              } else {
1658
                $pkr->{price} = $form->{"sellprice_$i"};
1659
              }
1660
#print (STDERR "   FEHLER", Dumper($form->{"sellprice_$i"}));
1661
            }
1662
          }
1663
        }
1664
      }
1665
    }
1666
    $i++;
1667

  
1668
    $pkq->finish;
1669
  }
1670

  
1671
  $dbh->disconnect;
1672

  
1673
#        print (STDERR "TEST", Dumper($form->{PRICES}));
1674
# print (STDERR "TEST id_$i", Dumper($form->{"id_$i"}));
1675
  $main::lxdebug->leave_sub();
1676
}
1677

  
1524 1678
sub webdav_folder {
1525 1679
  $main::lxdebug->enter_sub();
1526 1680

  

Auch abrufbar als: Unified diff