Yes, HMRC are a pain in the backside when it comes to coding notices for people with multiple sources of income which you have.
They never get it right (and never will) because it is very tricky trying to guess what someone's income will be for the whole year when they're issuing the codes in the first place.
What should happen is that no matter what codes have been issued during the year, a year end calculation will determine what your total earnings were (gross), what tax and NI you should have paid, then compare it to what was actually paid.
The resulting difference is what is either owed to them or to you and how they want to collect any underpayment is based on how much it is, but if it's under £3,000 of tax then it should be adjusted by your tax code (which they'll then probably get wrong again).
The first starting point is to check all their calculations. Compare what they're showing as earnings and tax already paid agrees to your P60s. The accountant (or your friend) could help you with this.
This website is good - taxaid.org.uk/guides/taxpayers/tax-debt/paye
It says: "Error or delay
There may have been a mistake or delay for which you should not be held responsible. The official guidance (www.hmrc.gov.uk/manuals/pommanual/paye95011.htm) says that HMRC must collect the unpaid tax from your employer or pension provider if they have failed to operate PAYE correctly. This could be where they used the wrong tax code, or failed to process a form P45 or use the New Starter Checklist correctly when you joined them. Phone or write to HMRC for confirmation that they have checked for any such employer error.
If you think tax was underpaid because of a mistake or delay by HMRC, you can ask them to consider writing off some or all of the tax. It must have been reasonable for you to have thought that your tax code was correct, and HMRC must have delayed using information for at least 12 months from the end of the tax year in which it was received."
And
"Hardship
If a tax debt between £50 – £2,999.99 is to be collected through PAYE, and this will cause hardship if it is all done in a single tax year, you can ask HMRC to spread the collection over two years, or in exceptional cases, three years instead.
If the debt is £3,000 or more, there are two alternative ways to get more time to pay, and avoid getting tax returns, but you must contact HMRC without delay:
if you can pay some of the tax immediately – to reduce the debt below £3,000 – then the rest should be collected through your PAYE code. For example, Harry owes £3,500 and is able to make a payment of £501 straight away, reducing the debt to £2,999. The remaining debt should then be collected through his PAYE code over one year, or two years and can be extended up to three years in case of significant hardship. This avoids the need to complete tax returns and allows more time to clear the debt
OR
if you contact HMRC on 0300 200 3300 immediately – and explain that you cannot pay the full amount right away – they should allow you to make payments over a period of time. Such arrangements may extend over several months, or longer, depending on your personal circumstances"
Good luck OP - it is a bit of a minefield. The only thing you can do to try and avoid it in future is call them every time you change jobs/circumstances. Tell them exactly how much you'll be earning in each post and they should use that information to generate new (hopefully more accurate) codes. Without being told in advance, they're effectively just hazarding a "best guess".