You can use the
project_revenue module which allows to assign purchase line to a project or task. Such line will be included in the cost of the project.
Then to invoice it to the customer, there is not yet any standard module for that. But it should not be difficult to extend the
project_invoice to add a invoice line for flagged purchase lines.
project_revenue gives you information about the profitability of the project by comparing what it generated against what it cost (timesheet cost and purchase lines).
If you are not looking at project base reporting. You can use the analytic modules, they allow to define multiple analytic (one per axis) on the lines of documents. There is also a rule engine in
analytic_account which can set automatically the accounts based on criteria. (For more information, I submitted an patch to improve the analytic documantation.)