Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision c23849b8

Von Kivitendo Admin vor etwa 8 Jahren hinzugefügt

  • ID c23849b8264fd8bf1e830a0b3752e0ede9bc0fc3
  • Vorgänger b5523546
  • Nachfolger 54fd3801

inventory_accno_id aufräumen

Unterschiede anzeigen:

SL/IC.pm
44 44
use SL::TransNumber;
45 45
use SL::Util qw(trim);
46 46
use SL::DB;
47
use Carp;
47 48

  
48 49
use strict;
49 50

  
......
1562 1563
  my %accno_by_part = map { $_->{id} => $_ }
1563 1564
    selectall_hashref_query($form, $dbh, <<SQL, @part_ids);
1564 1565
    SELECT
1565
      p.id, p.inventory_accno_id AS is_part,
1566
      p.id, p.part_type,
1566 1567
      bg.inventory_accno_id,
1567 1568
      tc.income_accno_id AS income_accno_id,
1568 1569
      tc.expense_accno_id AS expense_accno_id,
......
1595 1596
  while (my ($index => $part_id) = each %args) {
1596 1597
    my $ref = $accno_by_part{$part_id} or next;
1597 1598

  
1598
    $ref->{"inventory_accno_id"} = undef unless $ref->{"is_part"};
1599
    $ref->{"inventory_accno_id"} = undef unless $ref->{"part_type"} eq 'part';
1599 1600

  
1600 1601
    my %accounts;
1601 1602
    for my $type (qw(inventory income expense)) {
SL/IR.pm
837 837

  
838 838
  # reverse inventory items
839 839
  my $query =
840
    qq|SELECT i.parts_id, p.inventory_accno_id, p.expense_accno_id, i.qty, i.allocated, i.sellprice
840
    qq|SELECT i.parts_id, p.part_type, i.qty, i.allocated, i.sellprice
841 841
       FROM invoice i, parts p
842 842
       WHERE (i.parts_id = p.id)
843 843
         AND (i.trans_id = ?)|;
......
848 848
  while (my $ref = $sth->fetchrow_hashref("NAME_lc")) {
849 849
    $netamount += $form->round_amount($ref->{sellprice} * $ref->{qty} * -1, 2);
850 850

  
851
    next unless $ref->{inventory_accno_id};
851
    next unless $ref->{part_type} eq 'part';
852 852

  
853 853
    # if $ref->{allocated} > 0 than we sold that many items
854 854
    next if ($ref->{allocated} <= 0);
......
1019 1019
        i.id AS invoice_id,
1020 1020
        i.description, i.longdescription, i.qty, i.fxsellprice AS sellprice, i.parts_id AS id, i.unit, i.deliverydate, i.project_id, i.serialnumber,
1021 1021
        i.price_factor_id, i.price_factor, i.marge_price_factor, i.discount, i.active_price_source, i.active_discount_source,
1022
        p.partnumber, p.inventory_accno_id AS part_inventory_accno_id,  pr.projectnumber, pg.partsgroup
1022
        p.partnumber, p.part_type, pr.projectnumber, pg.partsgroup
1023 1023

  
1024 1024
        FROM invoice i
1025 1025
        JOIN parts p ON (i.parts_id = p.id)
......
1043 1043
                                          );
1044 1044
    map { $ref->{"ic_cvar_$_->{name}"} = $_->{value} } @{ $cvars };
1045 1045

  
1046
    map({ delete($ref->{$_}); } qw(inventory_accno inventory_new_chart inventory_valid)) if !$ref->{"part_inventory_accno_id"};
1047
    delete($ref->{"part_inventory_accno_id"});
1046
    map({ delete($ref->{$_}); } qw(inventory_accno inventory_new_chart inventory_valid)) if !$ref->{"part_type"} eq 'part';
1048 1047

  
1049 1048
    foreach my $type (qw(inventory income expense)) {
1050 1049
      while ($ref->{"${type}_new_chart"} && ($ref->{"${type}_valid"} >=0)) {
SL/IS.pm
1656 1656
  my ($dbh, $myconfig, $form, $position, $id, $totalqty) = @_;
1657 1657

  
1658 1658
  my $query =
1659
    qq|SELECT a.parts_id, a.qty, p.part_type, p.partnumber, p.description, p.unit,
1660
         p.inventory_accno_id, p.income_accno_id, p.expense_accno_id
1659
    qq|SELECT a.parts_id, a.qty, p.part_type, p.partnumber, p.description, p.unit
1661 1660
       FROM assembly a
1662 1661
       JOIN parts p ON (a.parts_id = p.id)
1663 1662
       WHERE (a.id = ?)|;
......
1797 1796

  
1798 1797
  # reverse inventory items
1799 1798
  my $query =
1800
    qq|SELECT i.id, i.parts_id, i.qty, i.assemblyitem, p.part_type, p.inventory_accno_id
1799
    qq|SELECT i.id, i.parts_id, i.qty, i.assemblyitem, p.part_type
1801 1800
       FROM invoice i
1802 1801
       JOIN parts p ON (i.parts_id = p.id)
1803 1802
       WHERE i.trans_id = ?|;
......
2003 2002
           i.description, i.longdescription, i.qty, i.fxsellprice AS sellprice, i.discount, i.parts_id AS id, i.unit, i.deliverydate AS reqdate,
2004 2003
           i.project_id, i.serialnumber, i.pricegroup_id, i.ordnumber, i.donumber, i.transdate, i.cusordnumber, i.subtotal, i.lastcost,
2005 2004
           i.price_factor_id, i.price_factor, i.marge_price_factor, i.active_price_source, i.active_discount_source,
2006
           p.partnumber, p.part_type, p.notes AS partnotes, p.inventory_accno_id AS part_inventory_accno_id, p.formel, p.listprice,
2005
           p.partnumber, p.part_type, p.notes AS partnotes, p.formel, p.listprice,
2007 2006
           pr.projectnumber, pg.partsgroup, prg.pricegroup
2008 2007

  
2009 2008
         FROM invoice i
SL/OE.pm
1094 1094
           c3.accno AS expense_accno,   c3.new_chart_id AS expense_new_chart,   date($transdate) - c3.valid_from as expense_valid,
1095 1095
           oe.ordnumber AS ordnumber_oe, oe.transdate AS transdate_oe, oe.cusordnumber AS cusordnumber_oe,
1096 1096
           p.partnumber, p.part_type, p.listprice, o.description, o.qty,
1097
           o.sellprice, o.parts_id AS id, o.unit, o.discount, p.notes AS partnotes, p.inventory_accno_id AS part_inventory_accno_id,
1097
           o.sellprice, o.parts_id AS id, o.unit, o.discount, p.notes AS partnotes, p.part_type,
1098 1098
           o.reqdate, o.project_id, o.serialnumber, o.ship, o.lastcost,
1099 1099
           o.ordnumber, o.transdate, o.cusordnumber, o.subtotal, o.longdescription,
1100 1100
           o.price_factor_id, o.price_factor, o.marge_price_factor, o.active_price_source, o.active_discount_source,
......
1126 1126
      map { $ref->{"ic_cvar_$_->{name}"} = $_->{value} } @{ $cvars };
1127 1127

  
1128 1128
      # Handle accounts.
1129
      if (!$ref->{"part_inventory_accno_id"}) {
1129
      if (!$ref->{"part_type"} eq 'part') {
1130 1130
        map({ delete($ref->{$_}); } qw(inventory_accno inventory_new_chart inventory_valid));
1131 1131
      }
1132
      delete($ref->{"part_inventory_accno_id"});
1132
      # delete($ref->{"part_inventory_accno_id"});
1133 1133

  
1134 1134
      # in collective order, copy global ordnumber, transdate, cusordnumber into item scope
1135 1135
      #   unless already present there

Auch abrufbar als: Unified diff