Guides › Database reference › Orders and sales
Magento 2 sales_invoice table
One row per invoice. An order can have several invoices if it was invoiced in parts.
Key columns
| Column | What it means |
|---|---|
entity_id | Internal invoice ID. |
order_id | The order, linking to sales_order.entity_id. |
increment_id | The invoice number shown in the admin and in emails. |
state | 1 = open (pending), 2 = paid, 3 = canceled. |
grand_total / base_grand_total | Invoice total in the order currency / your base currency. |
subtotal / tax_amount / shipping_amount | The parts of the total. |
created_at | When the invoice was created, in UTC. |
Good to know
- Invoice lines are in
sales_invoice_item; credit memos (refunds) are insales_creditmemo. - Revenue by invoice date and revenue by order date are different numbers. Decide which one your report needs.
Example: Invoiced revenue per month this year
Works on Magento Open Source and Adobe Commerce.
SELECT DATE_FORMAT(created_at, '%Y-%m') AS month, COUNT(*) AS invoices, ROUND(SUM(base_grand_total), 2) AS invoiced
FROM sales_invoice
WHERE created_at >= MAKEDATE(YEAR(NOW()), 1)
AND state = 2 -- paid
GROUP BY month
ORDER BY month;
Tested on Magento Open Source and Adobe Commerce 2.4.8. Read-only. If your tables have a prefix, add it to each table name.
Extra columns on Adobe Commerce
Adobe Commerce has 66 columns here instead of 47. The extra ones come from these Commerce features:
- Customer Balance:
base_customer_balance_amount,customer_balance_amount - Gift Card Account:
base_gift_cards_amount,gift_cards_amount - Gift Wrapping:
gw_base_price,gw_price,gw_items_base_price,gw_items_price,gw_card_base_price,gw_card_price,gw_base_tax_amount,gw_tax_amount,gw_items_base_tax_amount,gw_items_tax_amount,gw_card_base_tax_amount,gw_card_tax_amount - Reward:
base_reward_currency_amount,reward_currency_amount,reward_points_balance
Foreign keys
order_id→ sales_order.entity_idstore_id→store.store_id
All 47 columns (Magento Open Source)
Show all columns
| Column | Type | Can be empty | Magento's description |
|---|---|---|---|
entity_id | int(10) unsigned | Entity ID | |
store_id | smallint(5) unsigned | yes | Store ID |
base_grand_total | decimal(20,4) | yes | Base Grand Total |
shipping_tax_amount | decimal(20,4) | yes | Shipping Tax Amount |
tax_amount | decimal(20,4) | yes | Tax Amount |
base_tax_amount | decimal(20,4) | yes | Base Tax Amount |
store_to_order_rate | decimal(20,4) | yes | Store To Order Rate |
base_shipping_tax_amount | decimal(20,4) | yes | Base Shipping Tax Amount |
base_discount_amount | decimal(20,4) | yes | Base Discount Amount |
base_to_order_rate | decimal(20,4) | yes | Base To Order Rate |
grand_total | decimal(20,4) | yes | Grand Total |
shipping_amount | decimal(20,4) | yes | Shipping Amount |
subtotal_incl_tax | decimal(20,4) | yes | Subtotal Incl Tax |
base_subtotal_incl_tax | decimal(20,4) | yes | Base Subtotal Incl Tax |
store_to_base_rate | decimal(20,4) | yes | Store To Base Rate |
base_shipping_amount | decimal(20,4) | yes | Base Shipping Amount |
total_qty | decimal(12,4) | yes | Total Qty |
base_to_global_rate | decimal(20,4) | yes | Base To Global Rate |
subtotal | decimal(20,4) | yes | Subtotal |
base_subtotal | decimal(20,4) | yes | Base Subtotal |
discount_amount | decimal(20,4) | yes | Discount Amount |
billing_address_id | int(11) | yes | Billing Address ID |
is_used_for_refund | smallint(5) unsigned | yes | Is Used For Refund |
order_id | int(10) unsigned | Order ID | |
email_sent | smallint(5) unsigned | yes | Email Sent |
send_email | smallint(5) unsigned | yes | Send Email |
can_void_flag | smallint(5) unsigned | yes | Can Void Flag |
state | int(11) | yes | State |
shipping_address_id | int(11) | yes | Shipping Address ID |
store_currency_code | varchar(3) | yes | Store Currency Code |
transaction_id | varchar(255) | yes | Transaction ID |
order_currency_code | varchar(3) | yes | Order Currency Code |
base_currency_code | varchar(3) | yes | Base Currency Code |
global_currency_code | varchar(3) | yes | Global Currency Code |
increment_id | varchar(50) | yes | Increment ID |
created_at | timestamp | Created At | |
updated_at | timestamp | Updated At | |
discount_tax_compensation_amount | decimal(20,4) | yes | Discount Tax Compensation Amount |
base_discount_tax_compensation_amount | decimal(20,4) | yes | Base Discount Tax Compensation Amount |
shipping_discount_tax_compensation_amount | decimal(20,4) | yes | Shipping Discount Tax Compensation Amount |
base_shipping_discount_tax_compensation_amnt | decimal(20,4) | yes | Base Shipping Discount Tax Compensation Amount |
shipping_incl_tax | decimal(20,4) | yes | Shipping Incl Tax |
base_shipping_incl_tax | decimal(20,4) | yes | Base Shipping Incl Tax |
base_total_refunded | decimal(20,4) | yes | Base Total Refunded |
discount_description | varchar(255) | yes | Discount Description |
customer_note | text | yes | Customer Note |
customer_note_notify | smallint(5) unsigned | yes | Customer Note Notify |