Annotation: unit_tests.check_party_currency_code_mismatch

CREATE OR REPLACE FUNCTION unit_tests.check_party_currency_code_mismatch()
RETURNS test_result

Information: unit_tests.check_party_currency_code_mismatch

Schema unit_tests
Function Name check_party_currency_code_mismatch
Arguments
Owner postgres
Result Type test_result
Description

Implementation: unit_tests.check_party_currency_code_mismatch

CREATE OR REPLACE FUNCTION unit_tests.check_party_currency_code_mismatch()
 RETURNS test_result
 LANGUAGE plpgsql
AS $function$
    DECLARE message test_result;
BEGIN
    IF EXISTS
    (
        SELECT party_code FROM core.parties
        INNER JOIN core.accounts
        ON core.parties.account_id = core.accounts.account_id
        WHERE core.parties.currency_code != core.accounts.currency_code
        LIMIT 1
    ) THEN
        SELECT assert.fail('Some party accounts have different currency setup on their mapped GL heads.') INTO message;
        RETURN message;
    END IF;

    SELECT assert.ok('End of test.') INTO message;  
    RETURN message;
END
$function$