-
Notifications
You must be signed in to change notification settings - Fork 47
Add inventory model #208
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add inventory model #208
Changes from all commits
629bcca
c78bf42
7176dab
b504c7a
72d1261
94f9b4b
6d36413
8bafb08
2576cc2
296174b
64b071f
13f8ff0
e9844fb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| {{ config( | ||
| tags="fivetran_validations", | ||
| enabled=var('fivetran_validation_tests_enabled', false) | ||
| ) }} | ||
|
|
||
| -- this test ensures the inventory item activity end model matches the prior version | ||
| with prod as ( | ||
| select {{ dbt_utils.star(from=ref('quickbooks__inventory_item_activity'), except=var('qb_consistency_exclude_columns', [])) }} | ||
| from {{ target.schema }}_quickbooks_prod.quickbooks__inventory_item_activity | ||
| ), | ||
|
|
||
| dev as ( | ||
| select {{ dbt_utils.star(from=ref('quickbooks__inventory_item_activity'), except=var('qb_consistency_exclude_columns', [])) }} | ||
| from {{ target.schema }}_quickbooks_dev.quickbooks__inventory_item_activity | ||
| ), | ||
|
|
||
| prod_not_in_dev as ( | ||
| -- rows from prod not found in dev | ||
| select * from prod | ||
| except distinct | ||
| select * from dev | ||
| ), | ||
|
|
||
| dev_not_in_prod as ( | ||
| -- rows from dev not found in prod | ||
| select * from dev | ||
| except distinct | ||
| select * from prod | ||
| ), | ||
|
|
||
| final as ( | ||
| select | ||
| *, | ||
| 'from prod' as source | ||
| from prod_not_in_dev | ||
|
|
||
| union all -- union since we only care if rows are produced | ||
|
|
||
| select | ||
| *, | ||
| 'from dev' as source | ||
| from dev_not_in_prod | ||
| ) | ||
|
|
||
| select * | ||
| from final |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -493,4 +493,53 @@ models: | |||||
| - name: converted_amount | ||||||
| description: The total ending period balance, converted with exchange rates applied if available, | ||||||
| - name: account_ordinal | ||||||
| description: "{{ doc('account_ordinal') }}" | ||||||
| description: "{{ doc('account_ordinal') }}" | ||||||
|
|
||||||
| - name: quickbooks__inventory_item_activity | ||||||
| description: > | ||||||
| Line-level view of all item-bearing transactions across purchases, bills, vendor credits, invoices, sales receipts, | ||||||
| credit memos, refund receipts, and purchase orders. Each row includes item enrichment details, inventory quantity, | ||||||
| unit price, and status indicators for inventory movement analysis. | ||||||
| columns: | ||||||
| - name: inventory_item_activity_id | ||||||
| description: Surrogate primary key hashed on transaction_type, transaction_id, transaction_line_id, and source_relation. | ||||||
| tests: | ||||||
| - unique | ||||||
| - not_null | ||||||
| - name: transaction_type | ||||||
| description: The source transaction type (invoice, bill, purchase, sales_receipt, credit_memo, refund_receipt, vendor_credit, purchase_order). | ||||||
| - name: transaction_id | ||||||
| description: Unique identifier of the parent transaction. | ||||||
| - name: transaction_line_id | ||||||
| description: Index of the line within the parent transaction. Combined with transaction_id and source_relation, uniquely identifies the row. | ||||||
| - name: doc_number | ||||||
| description: Reference number for the transaction, as shown in QuickBooks reports. | ||||||
| - name: transaction_date | ||||||
| description: Date the transaction occurred. | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Matches other transaction_date fields in yml |
||||||
| - name: item_id | ||||||
| description: Foreign key to the item record. Null for non-item lines. | ||||||
| - name: name | ||||||
| description: Item name from the item table. | ||||||
| - name: type | ||||||
| description: Item type (Inventory, NonInventory, Service, etc.). Use to filter to physical inventory items. | ||||||
| - name: description | ||||||
| description: Item sale or purchase description from the item record. | ||||||
| - name: stock_keeping_unit | ||||||
| description: Stock keeping unit (SKU) for the item. | ||||||
| - name: quantity | ||||||
| description: Raw line-level quantity from the source. Always a positive value; use inventory_direction to determine movement direction. | ||||||
| - name: inventory_direction | ||||||
| description: > | ||||||
| Indicates the direction of inventory movement: inbound (items received — bills, purchases, | ||||||
| credit memos, refund receipts), outbound (items leaving — invoices, sales receipts, | ||||||
| vendor credits), or pending (items ordered but not yet received — purchase orders). | ||||||
| - name: unit_price | ||||||
| description: Unit price from the transaction line, reflecting the actual price recorded on the transaction. | ||||||
| - name: amount | ||||||
| description: Total line amount. For credit memos, refund receipts, and vendor credits, this value is negative as recorded in the source transaction. | ||||||
| - name: customer_id | ||||||
| description: Customer associated with the transaction. Populated for sales-side transactions; null for purchase-side transactions. | ||||||
| - name: vendor_id | ||||||
| description: Vendor associated with the transaction. Populated for purchase-side transactions; null for sales-side transactions. | ||||||
| - name: source_relation | ||||||
| description: "{{ doc('source_relation') }}" | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Matches other transaction_id fields in yml