Expense against sales invoice

Hi, How we can book expense against sales invoice after the invoice submission? For eg: we have contract with a transport company. They are delivering the goods to our customers. In the end of the month, transport company will send us an invoice and that we should book against each sales invoice. We can select the expense head in the purchase invoice, but we need to point each item to one sales invoice. Our invoice wise gross profit calculation should take this expense also into consideration. Any solution for the same? Also in some cases, we have to book sales commission against invoice after sales invoice submission. How we can book the same against sales invoice in journal entry?

Maybe this thread can help: https://discuss.frappe.io/t/how-to-know-the-cost-of-a-sales-order/1751