openfoodfoundation / openfoodnetwork

Connect suppliers, distributors and consumers to trade local produce.
https://www.openfoodnetwork.org
GNU Affero General Public License v3.0
1.12k stars 723 forks source link

[Invoices] When an order is cancelled, generate a credit invoice #11357

Open RachL opened 1 year ago

RachL commented 1 year ago

Description

- As a: enterprise user - On page: /admin/orders/RXXXXX/edit - I want to be able to do:

When a paid order gets cancelled AND there was a first invoice was issued before canceling then we need to generate a credit invoice. If the order was unpaid and the order gets cancelled (through the cancel button or deleting all line items), the credit invoice should show the amount of 0 euros due left.

Same goes if the order is edited to the point

Design of the credit invoice needs 2 things: amounts in negative form + previous invoice number the credit invoice applies on:

credit invoice.pdf

Acceptance Criteria & Tests

  1. Activate invoice toggle
  2. Go to a paid order and generate an invoice
  3. Cancel the order
  4. See the generate / update button is activated again in invoice tab
  5. Clicking it generates the credit invoice

Check this scenario on a unpaid order: the credit invoice should be generated with an amount of 0 euro.

abdellani commented 11 months ago

@RachL

what if the order is partially paid?

RachL commented 11 months ago

@abdellani thanks! I guess that if the order is partially paid and there was an invoice and the user decide to cancel it in the end, if they re-generate a invoice we need to do a credit invoice with the amount paid in negative form.

So if the previous invoice was unpaid => credit invoice of 0 Previous invoice partially paid, let's say 5 euros => credit invoice of -5 euros Previous invoice fully paid 10 euros => credit invoice of -10 euros

Does this make sense?