Debit Note not posting to correct customer

Trying to find out when a national account is paying multiple invoices under multiple customer numbers under the main national account and a deduction is being taken against a customer # that is not paying any invoice, the Debit Note will post to the account of the first invoice applied. When the debit note is created and the original invoice # is entered, if it is at a zero balance it gives us an error message stating a debit note can not be created for an amount greater than the open balance. How do we direct the debit note to the correct customer number?