Instead of initially creating the payment in the Quicken invoice account, create it in the Undeposited Funds account. Create a split transaction, with split line 1 equal to the amount you billed the carpet store (the amount of your invoice) as a transfer to the Quicken invoice account, with the expenses then subtracted from split line 1 using however many additional splits lines you need, so the split transaction net amount equals the amount deposited in Undeposited Funds.
Then in the Quicken invoice account you should be able to key the invoice number into the Invoice# field of the PMT transaction created by the above step, and Quicken should apply the payment to the invoice (clearing both transactions).
"Create a split transaction, with split line 1 equal to the amount you billed the carpet store (the amount of your invoice) as a transfer to the Quicken invoice account ....".
Correction: that sentence should read, "Create a split transaction, with split line 1 equal to the amount you billed the carpet store (the amount of your invoice) as a transfer FROM the Quicken invoice account ....".
Sorry about that.