Annotation: core.count_item_in_stock

CREATE OR REPLACE FUNCTION core.count_item_in_stock(_item_id integer, _unit_id integer, _store_id integer)
RETURNS numeric

Information: core.count_item_in_stock

Schema core
Function Name count_item_in_stock
Arguments _item_id integer, _unit_id integer, _store_id integer
Owner postgres
Result Type numeric
Description

Implementation: core.count_item_in_stock

CREATE OR REPLACE FUNCTION core.count_item_in_stock(_item_id integer, _unit_id integer, _store_id integer)
 RETURNS numeric
 LANGUAGE plpgsql
 STABLE
AS $function$
    DECLARE _debit decimal;
    DECLARE _credit decimal;
    DECLARE _balance decimal;
BEGIN

    _debit := core.count_purchases($1, $2, $3);
    _credit := core.count_sales($1, $2, $3);

    _balance:= _debit - _credit;    
    return _balance;  
END
$function$