Calculating tax for down payments

Here is my scenario:

  • Customers pay a certain amount as a down payment, let’s say 500.
  • We then proceed with the different stages of the sales order, including other payment(s) from the customer.
  • We close the sales order, issue invoice, and the tax is calculated.

Now here is the issue
When the month ends, we have to pay Tax for all the money that we received.
That includes the down payments for sales orders that are still in process.
How can I have the system calculate the tax on this down payment, and when the order is finally closed, I don’t want to pay the tax again on this 500.
I want to avoid making a separate sales order and invoice for the down payments.

Is there a way to handle this?
I’m completely new to ERPNext, so forgive my ignorance if the solution is obvious.

Thanks in advance.