Credit slip can be generated for an order that has no invoice
Prerequisites
- I understand and accept the project's code of conduct.
- I have already searched in existing issues and found no previous report of this bug.
Describe the bug and add attachments
The back office allows a credit slip (order_slip) to be created for an order that has no invoice (order_invoice). The refund is accepted silently, a credit slip is generated with a consecutive number, and it becomes available as a PDF under Orders > Credit slips.
A credit note is, by definition, a document that rectifies an existing invoice. Creating one for an order that was never invoiced produces a rectifying document that refers to nothing, which is not acceptable for accounting or tax reporting in the EU. The merchant is left with a numbered credit note in the sequence that cannot be justified.
There is also no supported way to undo it: credit slips cannot be deleted from the back office, so the only option is to delete the rows directly in the database (order_slip, order_slip_detail, and the refunded columns in order_detail), which is error-prone and leaves a gap in the credit slip numbering.
Steps to reproduce
Have an order that has no invoice. Any of these works:
- an order imported by a marketplace module, or
- an order whose current state has
invoice = 0in Statuses configuration. Confirm it: the "Documents" tab of the order is empty, andSELECT * FROM ps_order_invoice WHERE id_order = X;returns no rows.
Open the order in the back office (Orders > select the order).
Click "Standard refund", tick the product line, enter the quantity, and optionally tick the shipping amount.
Submit the refund.
The refund is accepted with no warning. A row is inserted in
ps_order_slipand the credit slip appears under Orders > Credit slips, with a consecutive number and a downloadable PDF.
At no point does the back office indicate that the order has no invoice, and once created the credit slip cannot be removed from the interface.
Expected behavior
A credit slip is a document that rectifies an existing invoice, so it should not be possible to issue one for an order that was never invoiced. The resulting document refers to nothing and cannot be justified for accounting or tax purposes, while still consuming a number in the credit slip sequence.
When the order has no invoice, the refund action should either:
- be blocked, with a clear message explaining that an invoice must be issued before a credit slip can be generated, or
- generate the invoice first and then create the credit slip against it.
At minimum, the back office should warn the user before creating a credit document that has no invoice behind it.
Related: credit slips cannot be deleted from the back office, so an accidental one can only be removed with manual SQL on the database, which leaves a gap in the credit slip numbering.
Actual Result
The refund is accepted without any validation. PrestaShop inserts a row in
ps_order_slip, assigns it the next number in the credit slip sequence,
and makes the PDF available under Orders > Credit slips. No warning, no
error, and nothing in the interface indicates that the order has no
invoice.
The difference with the expected behavior: instead of being blocked (or having the invoice generated first), the shop ends up with a numbered credit note that rectifies an invoice which does not exist. From an accounting point of view the document is unjustifiable, and it also takes a number out of the sequence.
It cannot be undone either. The back office offers no way to delete a
credit slip, so the only option is to delete the rows manually in
ps_order_slip and ps_order_slip_detail and reset the refunded columns
in ps_order_detail, on a production database, leaving a gap in the
numbering unless the AUTO_INCREMENT is adjusted as well.
PrestaShop version where the bug happens
8.1
How have you installed PrestaShop
No response
PHP version(s) where the bug happened
No response
Your company or customer's name goes here (if applicable).
No response
Source: PrestaShop/PrestaShop