xtcommission-1.10.x : Duplicate Sales Rep assignment exists for Invoice lines

The following error was encountered while trying to import duplicateCheck.sql into the database: ERROR: Duplicate Sales Rep assignment exists for Invoice lines. Please correct this before installing or updating this package.

Should work with xtcommission-1.10.x series.  Reverse engineer the check to fix the records.

BEGIN;

DELETE FROM xtcommission.invcitemcom
WHERE invcitemcom_id IN (SELECT invcitemcom_id
FROM (SELECT invcitemcom_id,
ROW_NUMBER() OVER (PARTITION BY invcitemcom_invcitem_id, invcitemcom_salesrep_id ORDER BY invcitemcom_id) AS rnum
FROM xtcommission.invcitemcom) t
WHERE t.rnum > 1);

COMMIT;