Which value do you want to change ?
I think it would be bad practice to change the posted amount.
However I have recently worked with something similar.
I have made a customization where you can set up (financial) default dimensions on charges/markuptrans that are related to purchase order lines.
When posting Invoices, the default dimensions set up on the charges are merged with the default dimensions that the standard system finds and the merged dimensions are pushed to the accounting distribution, that the accounting framework will then use for posting.
If system finds a default dimension set up on the charge when invoice posting runs it will use the accounting distribution (that is the merged dimensions) as default dimension for posting - EVEN if the Global Ledger parameter (Ledger / Setup / Ledger Parameters / (TOC) Ledger / (Field group) Accounting rules / (Field) Values used for summary account is set to Source document (and not Accounting Distributions).
Long story short, you have to dive into to the source document framework and the accounting framework, and do not expect this to be a task that is done in a short period time.
The source document frame work will create accounting distributions for each source document line - and sublines (and for the charges part check out the class ChargeSourceDocumentLineItem and the class hierarchy above it).
Also have a look at the SourceDocumentProcessorFacade class.
When all lines on a source document have reached the state "Completed" then the system will create an accounting event.
The accounting framework then uses the accounting event and the accounting distributions to decide how to post into GL.
The accounting framework uses accounting policies and accounting rules to create sub ledger entries (actually the source document frame works also uses these to create accounting distributions - at least that's my understanding).
When all entries have been made in the sub ledger, a process call transfer to general ledger does the actually final posting into GL.
Accounting policies are classes that extends AccountingPolicy.
Accounting policies determines if GL posting are made for a business event at all (parmAccountingRequired method).
Accounting rules are classes that extends AccountingRule.
Accounting rules gives posting types, side (debit/credit) and an AccountingDimensionsProvider to provide which accounts to post on.
I my scenario I was able to change class ChargeSourceDocLineItem to capture if default dimension were setup on charges and merge them by overriding calculateDefaultDimension, hasDimensionDerivationInputChanged and parmDefaultDimension, and the accJourRulePurchaseOfProductCharge - method parmDimensionValuesUsedForSummaryAccount to achieve what I wanted.