Move line maturity date as default payment date

In tryton 5.0 when the user selects move lines to be paid the payments generated have today date as the payment’s date instead of move line maturity date.

Despite of:

https://hg.tryton.org/modules/account_payment/file/5.0/payment.py#l270

I think it’s because:

https://hg.tryton.org/modules/account_payment/file/5.0/account.py#l277

That on_change_line is not being executed.

Moreover in default branch of account_payment module has been introduced a field to define the date of the payment noted at february newsletter.

I do not know how it will exactly works so it would be great that if no payment date was introduced at payment wizard, the payments gets the move line maturity date as default date in order to be coherent with payment term setted in invoices that I think is the model used to determine the maturity date of move lines generated for those invoices.

The “Pay Line” wizard is about paying multiple lines in a row. And generally it is done the day the payment are issued which is why the default date is today.
When user fill manually a payment form, it is to plan them. So it is logical to use as default the maturity date (which may be too late depending on the payment method).
Now, the “Pay Line” wizard could propose as default the earliest maturity date of the selected line but it may not make sense for all cases (e.g. only receivable lines). Maybe an option is to use the maturity date if all the lines have the same.

So suppose you get two move lines with maturity date 10th of April generated from two posted invoices due to its payment terms.

In order to get paid through SEPA direct debit message I have to generate the payments to process payments in a group later.

If I pay those move lines today (30th of march) in order to push SEPA message to bank in advance, the payments are generated with 30th of march as a date where I wished 10th of April.

For this use case I have to change manually the dates for this two payments to 10th of April (move line maturity date) at least at 5.0 series so 5.2 allows you to introduce a date through wizard.

Does it seem to you the default right behavior for tryton?

Yes, the wizard asks for the date so you fill the wanted date. But as I said, we could put the maturity date as default instead of today when a single line is selected and it has a maturity date.

This will be an improvement but it will not solve the case to schedule multiple payments in a bunch This is usd for example when requesting advancements of SEPA payments as you normally send to the bank all the payments of the next month and request it’s advacement but can be used also to create all the payments for lines that are due in a period.

For me the best will be to make the PayLines date optional, and use the line maturity date as payment date if the wizard date is empty.

Just filled Issue 9073: Schedule payments to it's line maturity date - Tryton issue tracker which implements it!