Credit Notes Generation
Date | Version | Name | Applied changes |
---|---|---|---|
17.10.2024 | 1.0 | Milen | First Publish |
The purpose of this document is to explain how the ‘credit notes’ generation is supposed to work in Hemi.
Credit notes are invoice-like html layouts created in order to be able to create .pdf documents based on the information/fields located in the tables connected with a refund (‘Orders’, ‘Order Payment’, ‘Order Refund Row’, ‘Order Refund Row Lines’, ‘Order Item’).
We can use the same automation that we have for the invoices, work for credit notes as well. We will need a field in the invoice template named ‘Invoice Type’ with options ‘Invoice’ and ‘Credit Note’. If ‘Credit Note’ is selected, we are to be able to use info from the tables above , while using the same layout structure (HTML Template, Table Template, Header, Footer).
The triggers for the credit notes creation are:
Orders
> Refunded
= ‘Yes’
Order Payment
> Type
= ‘Refund’
Order Payment
> Status
= ‘Completed’
When a credit note .pdf is created, it is to be stored in a slave table of ‘Orders’, named ‘Credit Notes’ with the following fields:
Field Name | Comment |
---|---|
Generated file | The path where the file is stored |
Template ID | ID of the Invoice/Credit note layout used |
Order Payment ID | ID of the Order Payment row with type refund, the credit note is created for. |
Number | calculate Invoice Template > Start num of the invoices + Credit Note > id |
It will be possible to have more than 1 credit note per order as 1 credit note will present 1 refund (Order Payment with type ‘Refund’) row, which means we could have a field in the new table to store the id of the order payment row that we have created a credit note for, so we can check if we have already created it in the next cron runs and not create it again.
We will also need some specific tags to show:
- Order Refund Row > Amount - Order Refund Row > Refund VAT for Order Refund Row > Type = Item as {{ITEM_REFUND_NO_VAT}}
- Sum of the Order Refund Row > Amount of rows with Order Refund Row > Type = Shipping as {{TOTAL_SHIPPING_REFUND}}
- Sum of the Order Refund Row > Amount - sum of Order Refund Row > Refund VAT for Order Refund Row > Type = Shipping as {{TOTAL_SHIPPING_REFUND_NO_VAT}}
- Sum of Refund Row > Amount - sum of Order Refund Row > Refund VAT as {{TOTAL_REFUND_NO_VAT}}
- sum of Order Refund Row > Refund VAT as {{TOTAL_REFUND_VAT}}
- Returned quantity per product - count of the refunded lines as {{REFUNDED_QUANTITY}}