AI Reports

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

ColumnWhat it means
entity_idInternal invoice ID.
order_idThe order, linking to sales_order.entity_id.
increment_idThe invoice number shown in the admin and in emails.
state1 = open (pending), 2 = paid, 3 = canceled.
grand_total / base_grand_totalInvoice total in the order currency / your base currency.
subtotal / tax_amount / shipping_amountThe parts of the total.
created_atWhen the invoice was created, in UTC.

Good to know

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:

Foreign keys

All 47 columns (Magento Open Source)

Show all columns
ColumnTypeCan be emptyMagento's description
entity_idint(10) unsignedEntity ID
store_idsmallint(5) unsignedyesStore ID
base_grand_totaldecimal(20,4)yesBase Grand Total
shipping_tax_amountdecimal(20,4)yesShipping Tax Amount
tax_amountdecimal(20,4)yesTax Amount
base_tax_amountdecimal(20,4)yesBase Tax Amount
store_to_order_ratedecimal(20,4)yesStore To Order Rate
base_shipping_tax_amountdecimal(20,4)yesBase Shipping Tax Amount
base_discount_amountdecimal(20,4)yesBase Discount Amount
base_to_order_ratedecimal(20,4)yesBase To Order Rate
grand_totaldecimal(20,4)yesGrand Total
shipping_amountdecimal(20,4)yesShipping Amount
subtotal_incl_taxdecimal(20,4)yesSubtotal Incl Tax
base_subtotal_incl_taxdecimal(20,4)yesBase Subtotal Incl Tax
store_to_base_ratedecimal(20,4)yesStore To Base Rate
base_shipping_amountdecimal(20,4)yesBase Shipping Amount
total_qtydecimal(12,4)yesTotal Qty
base_to_global_ratedecimal(20,4)yesBase To Global Rate
subtotaldecimal(20,4)yesSubtotal
base_subtotaldecimal(20,4)yesBase Subtotal
discount_amountdecimal(20,4)yesDiscount Amount
billing_address_idint(11)yesBilling Address ID
is_used_for_refundsmallint(5) unsignedyesIs Used For Refund
order_idint(10) unsignedOrder ID
email_sentsmallint(5) unsignedyesEmail Sent
send_emailsmallint(5) unsignedyesSend Email
can_void_flagsmallint(5) unsignedyesCan Void Flag
stateint(11)yesState
shipping_address_idint(11)yesShipping Address ID
store_currency_codevarchar(3)yesStore Currency Code
transaction_idvarchar(255)yesTransaction ID
order_currency_codevarchar(3)yesOrder Currency Code
base_currency_codevarchar(3)yesBase Currency Code
global_currency_codevarchar(3)yesGlobal Currency Code
increment_idvarchar(50)yesIncrement ID
created_attimestampCreated At
updated_attimestampUpdated At
discount_tax_compensation_amountdecimal(20,4)yesDiscount Tax Compensation Amount
base_discount_tax_compensation_amountdecimal(20,4)yesBase Discount Tax Compensation Amount
shipping_discount_tax_compensation_amountdecimal(20,4)yesShipping Discount Tax Compensation Amount
base_shipping_discount_tax_compensation_amntdecimal(20,4)yesBase Shipping Discount Tax Compensation Amount
shipping_incl_taxdecimal(20,4)yesShipping Incl Tax
base_shipping_incl_taxdecimal(20,4)yesBase Shipping Incl Tax
base_total_refundeddecimal(20,4)yesBase Total Refunded
discount_descriptionvarchar(255)yesDiscount Description
customer_notetextyesCustomer Note
customer_note_notifysmallint(5) unsignedyesCustomer Note Notify

Related tables

Gaurav Harsh

Gaurav Harsh is a Magento developer who works on large Adobe Commerce stores and builds AI Reports, a Magento extension for asking your store's data questions in plain English. LinkedIn