Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 07d71c33

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

  • ID 07d71c33315605fcfc450d3b9abf0fd10e92bed5
  • Vorgänger becc49b1
  • Nachfolger ee583bd5

Merge von 599-602,605,614,615 aus unstable: Preisgruppen Teil 1
--Preisgruppenerweiterung auf Basis von Andres Patch - Thanks
-Preisgruppenverwaltung
-Preiseingabe der Preisgruppen in Masken Waren,etc.
-Auswahl der Preisgruppen in den Verkaufsmasken
-Erweiterung Datenbankschema
-Übersetzungen für Preisgruppen
-Bugfix Preisgruppen, in der Warenmaske zeigte er eine Preisgruppe a
"Gruppe 1" als "Gruppe" an
-Anpassung locale
--Fehler bei negativen Umsaetzen behoben
--Fehler beim Speichern von Rechnungen und Angeboten/Auftraegen wenn keine Preisgruppen vorhanden
--Fehler bei Drucken und Buchen und Preisgruppen behoben, Preisgruppen Quelltext ein wenig modifiziert

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
      $pricegroup_id *= 1;
558

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

  
564 572
      if ($form->{lizenzen}) {
......
1105 1113

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  
1567
 
1568
    $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|;
1569

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

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

  
1585

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

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

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

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

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

  
1669
    $pkq->finish;
1670
  }
1671

  
1672
  $dbh->disconnect;
1673

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

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

  

Auch abrufbar als: Unified diff