IO-1914 Added inventory page.
This commit is contained in:
37
hasura/migrations/1654023641223_run_sql_migration/down.sql
Normal file
37
hasura/migrations/1654023641223_run_sql_migration/down.sql
Normal file
@@ -0,0 +1,37 @@
|
||||
-- Could not auto-generate a down migration.
|
||||
-- Please write an appropriate down migration for the SQL below:
|
||||
-- CREATE OR REPLACE FUNCTION public.search_inventory (search text)
|
||||
-- RETURNS SETOF inventory
|
||||
-- LANGUAGE plpgsql
|
||||
-- STABLE
|
||||
-- AS $function$
|
||||
-- BEGIN
|
||||
-- IF search = '' THEN
|
||||
-- RETURN query
|
||||
-- SELECT
|
||||
-- *
|
||||
-- FROM
|
||||
-- inventory;
|
||||
-- ELSE
|
||||
-- RETURN query
|
||||
-- SELECT
|
||||
-- inventory.*
|
||||
-- FROM
|
||||
-- inventory inner JOIN billlines ON inventory.billlineid = billlines.id
|
||||
-- inner JOIN bills ON billlines.billid = bills.id
|
||||
-- inner JOIN vendors ON bills.vendorid = vendors.id
|
||||
--
|
||||
-- WHERE
|
||||
-- inventory.line_desc ILIKE '%' || search || '%'
|
||||
-- OR bills.invoice_number ILIKE '%' || search || '%'
|
||||
-- OR vendors.name ILIKE '%' || search || '%'
|
||||
-- ORDER BY
|
||||
-- inventory.line_desc ILIKE '%' || search || '%'
|
||||
-- OR NULL,
|
||||
-- bills.invoice_number ILIKE '%' || search || '%'
|
||||
-- OR NULL,
|
||||
-- vendors.name ILIKE '%' || search || '%'
|
||||
-- OR NULL;
|
||||
-- END IF;
|
||||
-- END
|
||||
-- $function$;
|
||||
35
hasura/migrations/1654023641223_run_sql_migration/up.sql
Normal file
35
hasura/migrations/1654023641223_run_sql_migration/up.sql
Normal file
@@ -0,0 +1,35 @@
|
||||
CREATE OR REPLACE FUNCTION public.search_inventory (search text)
|
||||
RETURNS SETOF inventory
|
||||
LANGUAGE plpgsql
|
||||
STABLE
|
||||
AS $function$
|
||||
BEGIN
|
||||
IF search = '' THEN
|
||||
RETURN query
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
inventory;
|
||||
ELSE
|
||||
RETURN query
|
||||
SELECT
|
||||
inventory.*
|
||||
FROM
|
||||
inventory inner JOIN billlines ON inventory.billlineid = billlines.id
|
||||
inner JOIN bills ON billlines.billid = bills.id
|
||||
inner JOIN vendors ON bills.vendorid = vendors.id
|
||||
|
||||
WHERE
|
||||
inventory.line_desc ILIKE '%' || search || '%'
|
||||
OR bills.invoice_number ILIKE '%' || search || '%'
|
||||
OR vendors.name ILIKE '%' || search || '%'
|
||||
ORDER BY
|
||||
inventory.line_desc ILIKE '%' || search || '%'
|
||||
OR NULL,
|
||||
bills.invoice_number ILIKE '%' || search || '%'
|
||||
OR NULL,
|
||||
vendors.name ILIKE '%' || search || '%'
|
||||
OR NULL;
|
||||
END IF;
|
||||
END
|
||||
$function$;
|
||||
Reference in New Issue
Block a user