Revision 3af1d16a
Von Sven Schöling vor etwa 14 Jahren hinzugefügt
SL/DB/Part.pm | ||
---|---|---|
63 | 63 |
return $result{ $self->id }; |
64 | 64 |
} |
65 | 65 |
|
66 |
sub get_uncommissioned_qty { |
|
67 |
my $self = shift; |
|
68 |
my %params = @_; |
|
69 |
|
|
70 |
confess "Missing part id" unless $self->id; |
|
71 |
|
|
72 |
my $query = <<SQL; |
|
73 |
SELECT |
|
74 |
COALESCE((SELECT SUM(oi.qty) |
|
75 |
FROM orderitems oi |
|
76 |
LEFT JOIN oe ON (oi.trans_id = oe.id) |
|
77 |
WHERE (oi.parts_id = ?) |
|
78 |
AND (NOT COALESCE(oe.quotation, FALSE)) |
|
79 |
AND (NOT COALESCE(oe.closed, FALSE)) |
|
80 |
AND (NOT COALESCE(oe.delivered, FALSE)) |
|
81 |
AND (COALESCE(oe.customer_id, 0) <> 0)), |
|
82 |
0) |
|
83 |
- |
|
84 |
COALESCE((SELECT SUM(i.qty) AS qty |
|
85 |
FROM inventory i |
|
86 |
LEFT JOIN warehouse wh ON (i.warehouse_id = wh.id) |
|
87 |
WHERE (i.parts_id = ?) |
|
88 |
AND COALESCE(wh.commission)), |
|
89 |
0) |
|
90 |
AS qty |
|
91 |
SQL |
|
92 |
|
|
93 |
my $result = selectfirst_hashref_query($::form, $self->dbh, $query, $self->id, $self->id); |
|
94 |
return $result ? $result->{qty} : 0; |
|
95 |
} |
|
96 |
|
|
97 | 66 |
sub available_units { |
98 | 67 |
shift->unit_obj->convertible_units; |
99 | 68 |
} |
Auch abrufbar als: Unified diff
Kommissionenrest in SL::DB::Part entfernt.