Indeed the payment may pay a line from a different account. If no clearing is used, it may be helpful to set by default the account from the line of the payment. So this is linked to account_payment only not account_payment_clearing (even if issue9164 will be needed to have proper behavior).
But I think before implementing this behavior, issue6854 should be fixed (see msg51856) because the complexity increases when dealing with many fields to fill the account.
> Indeed if there is no clearing set and no account filled, on_change_payment
> could use the account of the line if there is one.
I must admit not to well understand the existing code.
I would have thought that if clearing was set, it be mandatory.
But the implementation is only if there is no account already set, which seems odd.
Therefore, in the attached I always set the account used in the payment prior to the questionable clearing account code, as we frequently see improper accounts set by default entering the statement origin line form.
finally, I am also surprised that when validating the statement after correcting the account, the payment line is not even reconciled with the statement move line! If it was an invoice selected, and not a payment, the line *is* reconciled.
still difficulties with grouping payments and statements.
- supplier issues bill of exchange for 1 or more invoices in period
- group the payment lines (from French account 401100)
- correct the primary move dates and set grouped amount line to account 403000; then post
- pay the line and approve
- in the statement origin, select the supplier and appropriate payment line
instead of setting account to 403000 it is set to 401100
It should be set to the account in the payment line