Create Accounting Distributions through code

Hello All,

We have a requirement where we need to split the accounting distribution values for a purchase order and post the purchase invoice via code. Generally when we generate the invoice , we have an option to split and distribute the amounts from the invoice form but i am unable to get the exact source code for this distribution process.

Does anyone have an easy code to adopt for this kind of scenario ?

Version - D365 F&O