Field "Amount to pay" in account_payment

We have created a view of account moves where you can view payable and receivable account moves in the same tab.

Attached image:

In the account_payment module we find the following definition in the code:

def get_payment_kind(self, name):
    if (self.account.type.receivable
            and (self.debit > 0 or self.credit < 0)):
        return 'receivable'
    elif (self.account.type.payable
            and (self.credit > 0 or self.debit < 0)):
        return 'payable'

By having this code, as you can see in the image there is an account move that does not show a value in the “Amount to pay” field.

Shouldn’t we do it so that the amount is always shown?

In this case, perhaps I would modify:

def get_payment_kind(self, name):
    if (self.account.type.receivable
            or (self.debit > 0 or self.credit < 0)):
        return 'receivable'
    elif (self.account.type.payable
            or (self.credit > 0 or self.debit < 0)):
        return 'payable'

This way, the value will always be shown.

Maybe I’m missing something but what you propose as modification is exactly the same as what you say in correct code. Probably you need to edit your post to fix it.

Also it will be great to explain the rational of your change, and why you need to adapt the function.

What has in special the first payment that the amount to pay is not shown but it is shown in other lines?

Hi Sergi,

The modified code is not exactly the same. If you look, change the condition and to an or.

My proposal to modify the code is that we have created a personalized view of account moves to be able to easily view account moves that can be compensated, since they are from the same party but with normal or rectification invoices.

This means that in the same tab we have the account moves that can be compensated, but having the code that currently exists does not allow us to see the value of the amount to pay, since it only shows the value if it is receivable or payable, having:

def get_payment_kind(self, name):
    if (self.account.type.receivable
            and (self.debit > 0 or self.credit < 0)):
        return 'receivable'
    elif (self.account.type.payable
            and (self.credit > 0 or self.debit < 0)):
        return 'payable'

That’s why I propose to change to:

def get_payment_kind(self, name):
if (self.account.type.receivable
or (self.debit > 0 or self.credit < 0)):
return ‘receivable’
elif (self.account.type.payable
or (self.credit > 0 or self.debit < 0)):
return ‘payable’

So if there is a customer rectification invoice it will be shown as a receivable, and as a consequence we’ll be shown the value of amount to pay.

If the line is not on a receivable nor payable account, there is no amount to pay to compute or display.

By the way if you want to compensate two lines to make a single payment, you must use the “Payable/Receivable Lines” relate from the party to group the lines.
Showing all the lines to pay will not help user to spot lines from the same party that can be grouped.

Having this into account, how should I manage a customer rectification invoice where I want to make a transfer by SEPA?

Just use the normall workflow. If there is something to compensate when paying the line a warning will be shown to let you know that it is possible to group the lines.

If you want to group the lines, then just refresh the lines to pay view and a new line will be shown with the right amounts.

The problem is not just about compensating account moves.

In the lines to pay view, receivable tab: if you have a rectification customer invoice, the amount to pay is not shown.