[Bug] Wrong invoices if negative lines (discounts)

This issue is related to the issue #32788.

Invoices generated from orders with negative records (as for discounts or previous deposit already billed) starting from version 7.0.0 automatically undergo the conversion of negative lines in “discount” (?!). This conversion happens without any warning and strongly condition the invoice issue and payment process, since a global discount is created for the involved third party and the invoice and payment status are consequently altered.
A similar behavior happens when a payment of a deposit invoice is entered. Also in this case, the payment generates a “discount” and the invoice status changes in “converted to discount” instead of “payed”. The same happens for Credit Notes issued to cancel previous invoices (i.e. for cancelled orders).

This behavior results in a very confusing and hazardous process.
The idea of automatizing these kind of invoices/payment processes would be good, but the current implementation looks confused and buggy.

Then there is a serious bug in the printed output of these kind of invoices (by crabe model) with auto-generated discounts from negative lines. The negative lines (after discount auto-generation) are not correctly computed as “Net in currency” and so not considered in the Total (net of tax) amount. These final invoices with negative lines show wrong “net of tax” total and correct “inc. tax” total.