Skip to content

Commit

Permalink
Merge pull request #5109 from ehuelsmann/1.8-issue-5107
Browse files Browse the repository at this point in the history
1.8 issue 5107
  • Loading branch information
ehuelsmann committed Sep 22, 2020
2 parents 91ba1b5 + 3c9dd24 commit 1cd18a1
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/LedgerSMB/Report/Inventory/History.pm
Expand Up @@ -48,7 +48,7 @@ This is a serial number of the part, for a prefix search
=cut

has serial_number => (is => 'ro', isa => 'Str', required => 0);
has serialnumber => (is => 'ro', isa => 'Str', required => 0);

=item inc_is bool
Expand Down
4 changes: 2 additions & 2 deletions lib/LedgerSMB/Report/Inventory/Search.pm
Expand Up @@ -58,13 +58,13 @@ Limit search to partsgroup specified

has partsgroup_id => (is => 'ro', isa => 'Int', required => 0);

=item serial_number text
=item serialnumber text
This is a serial number of the part, for a prefix search
=cut

has serial_number => (is => 'ro', isa => 'Str', required => 0);
has serialnumber => (is => 'ro', isa => 'Str', required => 0);

=item make
Expand Down
26 changes: 20 additions & 6 deletions sql/modules/Goods.sql
Expand Up @@ -131,10 +131,17 @@ DROP FUNCTION IF EXISTS goods__search
in_model text, in_drawing text, in_microfiche text,
in_status text, in_date_from date, in_date_to date);

CREATE OR REPLACE FUNCTION goods__search
DROP FUNCTION IF EXISTS goods__search
(in_parttype text, in_partnumber text, in_description text,
in_partsgroup_id int, in_serial_number text, in_make text,
in_model text, in_drawing text, in_microfiche text,
in_status text, in_date_from date, in_date_to date);


CREATE OR REPLACE FUNCTION goods__search
(in_parttype text, in_partnumber text, in_description text,
in_partsgroup_id int, in_serialnumber text, in_make text,
in_model text, in_drawing text, in_microfiche text,
in_status text, in_date_from date, in_date_to date)
RETURNS SETOF goods_search_result
LANGUAGE SQL STABLE AS $$
Expand All @@ -160,10 +167,9 @@ LANGUAGE SQL STABLE AS $$
AND (in_drawing IS NULL OR p.drawing ilike in_drawing || '%')
AND (in_microfiche IS NULL
OR p.microfiche ilike in_microfiche || '%')
AND (in_serial_number IS NULL OR p.id IN
AND (in_serialnumber IS NULL OR p.id IN
(select parts_id from invoice
where in_serial_number is not null
and serialnumber = in_serial_number))
where serialnumber = in_serialnumber))
AND (in_parttype IS NULL
OR (in_parttype = 'assemblies' and p.assembly)
OR (in_parttype = 'services'
Expand Down Expand Up @@ -489,14 +495,21 @@ name text,
sellprice numeric,
qty numeric,
discount numeric,
serial_number text
serialnumber text
);

CREATE OR REPLACE FUNCTION goods__history(
DROP FUNCTION IF EXISTS goods__history(
in_date_from date, in_date_to date,
in_partnumber text, in_description text, in_serial_number text,
in_inc_po bool, in_inc_so bool, in_inc_quo bool, in_inc_rfq bool,
in_inc_is bool, in_inc_ir bool
);

CREATE OR REPLACE FUNCTION goods__history(
in_date_from date, in_date_to date,
in_partnumber text, in_description text, in_serialnumber text,
in_inc_po bool, in_inc_so bool, in_inc_quo bool, in_inc_rfq bool,
in_inc_is bool, in_inc_ir bool
) RETURNS SETOF parts_history_result LANGUAGE SQL AS
$$
SELECT p.id, p.partnumber, o.transdate, p.description, p.bin,
Expand Down Expand Up @@ -530,6 +543,7 @@ $$
OR p.description @@ plainto_tsquery(in_description))
AND (in_date_from is null or in_date_from <= o.transdate)
and (in_date_to is null or in_date_to >= o.transdate)
AND (in_serialnumber is null or i.serialnumber = in_serialnumber)
AND ((in_inc_po IS NULL AND in_inc_so IS NULL
AND in_inc_quo IS NULL AND in_inc_rfq IS NULL
AND in_inc_ir IS NULL AND in_inc_is IS NULL)
Expand Down

0 comments on commit 1cd18a1

Please sign in to comment.