Skip to main content

Columns

ColumnDescriptionAPI Field Name
invoice_item_idPrimary key. Unique identifier for the invoice item.items.id
is_deletedIndicates whether the invoice item record is deleted.
invoice_idForeign key to the parent invoice and invoices_enriched record.items.invoice_id
supply_idForeign key to the supply record linking item to supplier.items.supply_id
supplier_idIdentifier of the supplier associated with the invoice item.items.supplier_id
item_idForeign key to the product item.items.item_id
invoice_display_numberHuman-readable display number of the parent invoice.items.invoice_display_number
skuSupplier SKU for the invoice item.items.sku
manufacturer_nameName of the item manufacturer.items.manufacturer_name
nameDisplay name of the invoice item.items.name
dateInvoice item date.items.date
expiration_dateExpiration date recorded for the invoice item, when present.items.expiration_date
unit_priceUnit price recorded on the invoice item, in dollars. Snowflake displays dollars, API returns cents.items.unit_price
total_priceTotal line price recorded on the invoice item, in dollars. Snowflake displays dollars, API returns cents.items.total_price
quantityQuantity recorded on the invoice item.items.quantity
quantity_receivedQuantity marked as received for the invoice item.items.quantity_received
quantity_shippedQuantity shipped for the invoice item.items.quantity_shipped
counts_toward_budgetWhether this item counts toward budget tracking.items.counts_toward_budget
is_receivableIndicates whether the parent invoice is associated with a supplier order that can be linked to receiving data.items.is_receivable
last_updatedThe timestamp when the invoice item record was last updated. This is the most recent timestamp from all related tables.
vetcove_corporate_idThe unique identifier of the corporate group associated with this record.

Relationships

SQL Definition

/*
    This model provides a business-ready, denormalized view of supplier invoice data
    at the invoice line-item level.
*/

"
    )
}}

with invoice_items as (
    select * from {{ ref('invoice_items') }}
)

, invoice as (
    select * from {{ ref('invoices') }}
)

, items as (
    select * from {{ ref('products_item') }}
)

select
    invoice_items.id as invoice_item_id
    , invoice_items.is_deleted
    , invoice_items.invoice_id
    , invoice_items.supply_id
    , invoice.supplier_id
    , items.id as item_id
    , invoice.display_number as invoice_display_number
    , invoice_items.sku
    , items.manufacturer_name
    , invoice_items.name
    , invoice_items.date
    , invoice_items.expiration_date
    , invoice_items.unit_price
    , invoice_items.total_price
    , invoice_items.quantity
    , invoice_items.quantity_received
    , invoice_items.quantity_shipped
    , invoice_items.counts_toward_budget
    , coalesce((invoice_items.quantity > 0), false) as is_receivable
    , greatest(
        coalesce(invoice_items.last_updated, '1900-01-01')
        , coalesce(invoice.last_updated, '1900-01-01')
        , coalesce(items.last_updated, '1900-01-01')
    ) as last_updated
    , invoice_items.vetcove_corporate_id
from invoice_items
inner join invoice
    on invoice_items.invoice_id = invoice.id
left join items
    on invoice_items.item_id = items.id