Can I assign some aspects of the invoice to a different account code but the total to the first account code?

Yes, you can! Head to Account Code Settings, add and assign the other account codes to those particular line items under the "Line Item Options" header.