Skip to content

Bug : Subtotal lines are not kept when creating deposit invoice from an order #379

@thomas-Ngr

Description

@thomas-Ngr

When creating a deposit invoice and chosing 'all lines identical', the computation of subtotals is lost.

This is the original order:

image

Then we create a deposit invoice with all lines identical (here rate is 30%) :
image

This is the resulting invoice : subtotal lines are lost
image

This is due to problems in quantities : quantities of subtotal lines are set to 30% of the original quantity (here 0.3 and 29.7 instead of 1 and 99). These are the lines for the faulty invoice:

MariaDB [dolitest]> select rowid, fk_facture, fk_parent_line, product_type, price, qty, subprice, info_bits, special_code, label FROM llx_facturedet WHERE fk_facture = 19782; 
+-------+------------+----------------+--------------+-------+------+-------------+-----------+--------------+------------+
| rowid | fk_facture | fk_parent_line | product_type | price | qty  | subprice    | info_bits | special_code | label      |
+-------+------------+----------------+--------------+-------+------+-------------+-----------+--------------+------------+
| 36082 |      19782 |           NULL |            9 |  NULL |  0.3 |  0.00000000 |         0 |       104777 | TITRE      |
| 36083 |      19782 |           NULL |            0 |  NULL |  0.3 | 42.00000000 |         0 |            0 | NULL       |
| 36084 |      19782 |           NULL |            9 |  NULL | 29.7 |  0.00000000 |         0 |       104777 | Sous-total |
+-------+------------+----------------+--------------+-------+------+-------------+-----------+--------------+------------+

When correcting the quantities and setting to (1; 99) instead of (0,3 ; 29,7), the lines of the invoice are correct.

Suggested fix:

On trigger INVOICE_CREATE

IF

  • invoice is a deposit
  • AND origin and origin_id are set and are an order
  • AND we use original lines with a rate

THEN

  • set quantities of all lines where product_type = 9 to original quantities

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions