Oracle default the legal entity (legal_entity_id) based on the balancing segment value of the liability account in AP invoice. The balance segment value assigned to legal entity and optionally operating unit in legal entity configuration pages.
Oracle allow user to enter other legal entity value in “customer taxpayer ID” in AP invioce header to change legal entity party and determine tax.
The legal entity (legal_entity_id) is used to determine tax. In E-Business Tax, the legal entity first party is get from the source product like AP, AR, etc.