Cost Center does not belong to Company "B Enterprise"

I have two companies in ERPNext, say those are 'A Company" and " B Enterprise". Issue is happening with “B Enterprise” when trying to submit any Purchase Receipt/Purchase Invoice etc,

Showing below error:
Purchase Receipt MAT-PRE-2021-00023: Cost Center ‘Main - A Company’ does not belong to Company ‘B Enterprise’. Yes, it is true, this cost center does not belong to the selected company. But why this cost center being selected automatically? I selected “B Enterprise” so cost center of this company should be selected automatically, but it is not happening.
So, I can not execute the submission.

Can anyone help?

Check cost Center in Tax Charges Template table.
This issue happens when you change the Company after entering details in Item table. If you change the company first and then add other details, you won’t have this issues.