Skip to content

Commit

Permalink
Merge pull request #7 from fivetran/sales_receipt_var
Browse files Browse the repository at this point in the history
Sales receipt var
  • Loading branch information
fivetran-joemarkiewicz authored Feb 12, 2021
2 parents 5b34d27 + 59b5bd6 commit 3d1725d
Show file tree
Hide file tree
Showing 53 changed files with 633 additions and 200 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ vars:
### Disabling models
This package takes into consideration that not every QuickBooks account utilizes the same transactional tables, and allows you to disable the corresponding functionality. By default, all variables' values are assumed to be `true`. Add variables for only the tables you want to disable:
This package takes into consideration that not every QuickBooks account utilizes the same transactional tables, and allows you to disable the corresponding functionality. By default, most variables' values are assumed to be `true` (with exception of purchase orders). Add variables for only the tables you want to disable or enable respectively:

```yml
# dbt_project.yml
Expand All @@ -57,12 +57,14 @@ vars:
using_refund_receipt: false #disable if you don't have refund receipts in QuickBooks
using_transfer: false #disable if you don't have transfers in QuickBooks
using_vendor_credit: false #disable if you don't have vendor credits in QuickBooks
using_sales_receipt: false #disable if you don't have sales receipts in QuickBooks
using_purchase_order: true #enable if you want to include purchase orders in your staging models
```

## Contributions

Additional contributions to this package are very welcome! Please create issues
or open PRs against `master`. Check out [this post](https://discourse.getdbt.com/t/contributing-to-a-dbt-package/657)
or open PRs against `master`. Check out [this post](https://discourse.getdbt.com/t/contributing-to-a-dbt-package/657)
on the best workflow for contributing to a package.

## Resources:
Expand Down
85 changes: 45 additions & 40 deletions dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,54 +1,57 @@
config-version: 2

name: 'quickbooks_source'
version: '0.1.1'
version: '0.1.2'

require-dbt-version: [">=0.18.0", "<0.20.0"]

models:
models:
quickbooks_source:
materialized: table
tmp:
materialized: view

vars:
quickbooks_source:
account: "{{ source('quickbooks','account') }}"
address: "{{ source('quickbooks','address') }}"
bill_line: "{{ source('quickbooks','bill_line') }}"
bill_linked_txn: "{{ source('quickbooks','bill_linked_txn') }}"
bill_payment_line: "{{ source('quickbooks','bill_payment_line') }}"
bill_payment: "{{ source('quickbooks','bill_payment') }}"
bill: "{{ source('quickbooks','bill') }}"
bundle_item: "{{ source('quickbooks','bundle_item') }}"
bundle: "{{ source('quickbooks','bundle') }}"
credit_memo_line: "{{ source('quickbooks','credit_memo_line') }}"
credit_memo: "{{ source('quickbooks','credit_memo') }}"
customer: "{{ source('quickbooks','customer') }}"
department: "{{ source('quickbooks','department') }}"
deposit_line: "{{ source('quickbooks','deposit_line') }}"
deposit: "{{ source('quickbooks','deposit') }}"
estimate: "{{ source('quickbooks','estimate') }}"
estimate_line: "{{ source('quickbooks','estimate_line') }}"
invoice_line: "{{ source('quickbooks','invoice_line') }}"
invoice_line_bundle: "{{ source('quickbooks','invoice_line_bundle') }}"
invoice_linked_txn: "{{ source('quickbooks','invoice_linked_txn') }}"
invoice: "{{ source('quickbooks','invoice') }}"
item: "{{ source('quickbooks','item') }}"
journal_entry_line: "{{ source('quickbooks','journal_entry_line') }}"
journal_entry: "{{ source('quickbooks','journal_entry') }}"
payment_line: "{{ source('quickbooks','payment_line') }}"
payment: "{{ source('quickbooks','payment') }}"
purchase_line: "{{ source('quickbooks','purchase_line') }}"
purchase: "{{ source('quickbooks','purchase') }}"
refund_receipt_line: "{{ source('quickbooks','refund_receipt_line') }}"
refund_receipt: "{{ source('quickbooks','refund_receipt') }}"
sales_receipt_line: "{{ source('quickbooks','sales_receipt_line') }}"
sales_receipt: "{{ source('quickbooks','sales_receipt') }}"
transfer: "{{ source('quickbooks','transfer') }}"
vendor_credit_line: "{{ source('quickbooks','vendor_credit_line') }}"
vendor_credit: "{{ source('quickbooks','vendor_credit') }}"
vendor: "{{ source('quickbooks','vendor') }}"
account: "{{ source('quickbooks','account') }}"
address: "{{ source('quickbooks','address') }}"
bill_line: "{{ source('quickbooks','bill_line') }}"
bill_linked_txn: "{{ source('quickbooks','bill_linked_txn') }}"
bill_payment_line: "{{ source('quickbooks','bill_payment_line') }}"
bill_payment: "{{ source('quickbooks','bill_payment') }}"
bill: "{{ source('quickbooks','bill') }}"
bundle_item: "{{ source('quickbooks','bundle_item') }}"
bundle: "{{ source('quickbooks','bundle') }}"
credit_memo_line: "{{ source('quickbooks','credit_memo_line') }}"
credit_memo: "{{ source('quickbooks','credit_memo') }}"
customer: "{{ source('quickbooks','customer') }}"
department: "{{ source('quickbooks','department') }}"
deposit_line: "{{ source('quickbooks','deposit_line') }}"
deposit: "{{ source('quickbooks','deposit') }}"
estimate: "{{ source('quickbooks','estimate') }}"
estimate_line: "{{ source('quickbooks','estimate_line') }}"
invoice_line: "{{ source('quickbooks','invoice_line') }}"
invoice_line_bundle: "{{ source('quickbooks','invoice_line_bundle') }}"
invoice_linked_txn: "{{ source('quickbooks','invoice_linked_txn') }}"
invoice: "{{ source('quickbooks','invoice') }}"
item: "{{ source('quickbooks','item') }}"
journal_entry_line: "{{ source('quickbooks','journal_entry_line') }}"
journal_entry: "{{ source('quickbooks','journal_entry') }}"
payment_line: "{{ source('quickbooks','payment_line') }}"
payment: "{{ source('quickbooks','payment') }}"
purchase_line: "{{ source('quickbooks','purchase_line') }}"
purchase: "{{ source('quickbooks','purchase') }}"
purchase_order_line: "{{ source('quickbooks','purchase_order_line') }}"
purchase_order: "{{ source('quickbooks','purchase_order') }}"
purchase_order_linked_txn: "{{ source('quickbooks','purchase_order_linked_txn') }}"
refund_receipt_line: "{{ source('quickbooks','refund_receipt_line') }}"
refund_receipt: "{{ source('quickbooks','refund_receipt') }}"
sales_receipt_line: "{{ source('quickbooks','sales_receipt_line') }}"
sales_receipt: "{{ source('quickbooks','sales_receipt') }}"
transfer: "{{ source('quickbooks','transfer') }}"
vendor_credit_line: "{{ source('quickbooks','vendor_credit_line') }}"
vendor_credit: "{{ source('quickbooks','vendor_credit') }}"
vendor: "{{ source('quickbooks','vendor') }}"

#Variables if your company utilizes the below parent and child transactional tables.
using_bill: True
Expand All @@ -63,8 +66,10 @@ vars:
using_refund_receipt: True
using_transfer: True
using_vendor_credit: True

using_sales_receipt: True
using_purchase_order: False

clean-targets:
- target
- dbt_modules
- dbt_modules

10 changes: 10 additions & 0 deletions integration_tests/data/purchase_order_linked_txn_data.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
index,purchase_order_id,_fivetran_synced,bill_id,purchase_id,vendor_credit_id
0,22302,2020-01-28 22:40:07,22433,,
0,14423,2020-01-15 0:03:46,,16091,
0,14432,2020-01-15 0:03:46,,16091,
0,14435,2020-01-15 0:03:46,,16091,
0,14431,2020-01-15 0:03:46,,16091,
0,14433,2020-01-15 0:03:46,,16091,
0,14448,2020-01-15 0:03:46,,16091,
0,14452,2020-01-15 0:03:46,,16091,
0,14421,2020-01-15 0:03:46,,16091,
80 changes: 43 additions & 37 deletions integration_tests/dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: 'quickbooks_source_integration_tests'
version: '0.1.0'
version: '0.1.2'
profile: 'integration_tests'
config-version: 2

Expand All @@ -11,42 +11,45 @@ models:

vars:
quickbooks_source:
account: "{{ ref('account_data') }}"
address: "{{ ref('address_data') }}"
bill_line: "{{ ref('bill_line_data') }}"
bill_linked_txn: "{{ ref('bill_linked_txn_data') }}"
bill_payment_line: "{{ ref('bill_payment_line_data') }}"
bill_payment: "{{ ref('bill_payment_data') }}"
bill: "{{ ref('bill_data') }}"
bundle_item: "{{ ref('bundle_item_data') }}"
bundle: "{{ ref('bundle_data') }}"
credit_memo: "{{ ref('credit_memo_data') }}"
credit_memo_line: "{{ ref('credit_memo_line_data') }}"
customer: "{{ ref('customer_data') }}"
department: "{{ ref('department_data') }}"
deposit_line: "{{ ref('deposit_line_data') }}"
deposit: "{{ ref('deposit_data') }}"
estimate: "{{ ref('estimate_data') }}"
estimate_line: "{{ ref('estimate_line_data') }}"
invoice: "{{ ref('invoice_data') }}"
invoice_line: "{{ ref('invoice_line_data') }}"
invoice_line_bundle: "{{ ref('invoice_line_bundle_data') }}"
invoice_linked_txn: "{{ ref('invoice_linked_txn_data') }}"
item: "{{ ref('item_data') }}"
journal_entry_line: "{{ ref('journal_entry_line_data') }}"
journal_entry: "{{ ref('journal_entry_data') }}"
payment: "{{ ref('payment_data') }}"
payment_line: "{{ ref('payment_line_data') }}"
purchase_line: "{{ ref('purchase_line_data') }}"
purchase: "{{ ref('purchase_data') }}"
refund_receipt_line: "{{ ref('refund_receipt_line_data') }}"
refund_receipt: "{{ ref('refund_receipt_data') }}"
sales_receipt_line: "{{ ref('sales_receipt_line_data') }}"
sales_receipt: "{{ ref('sales_receipt_data') }}"
transfer: "{{ ref('transfer_data') }}"
vendor_credit_line: "{{ ref('vendor_credit_line_data') }}"
vendor_credit: "{{ ref('vendor_credit_data') }}"
vendor: "{{ ref('vendor_data') }}"
account: "{{ ref('account_data') }}"
address: "{{ ref('address_data') }}"
bill_line: "{{ ref('bill_line_data') }}"
bill_linked_txn: "{{ ref('bill_linked_txn_data') }}"
bill_payment_line: "{{ ref('bill_payment_line_data') }}"
bill_payment: "{{ ref('bill_payment_data') }}"
bill: "{{ ref('bill_data') }}"
bundle_item: "{{ ref('bundle_item_data') }}"
bundle: "{{ ref('bundle_data') }}"
credit_memo: "{{ ref('credit_memo_data') }}"
credit_memo_line: "{{ ref('credit_memo_line_data') }}"
customer: "{{ ref('customer_data') }}"
department: "{{ ref('department_data') }}"
deposit_line: "{{ ref('deposit_line_data') }}"
deposit: "{{ ref('deposit_data') }}"
estimate: "{{ ref('estimate_data') }}"
estimate_line: "{{ ref('estimate_line_data') }}"
invoice: "{{ ref('invoice_data') }}"
invoice_line: "{{ ref('invoice_line_data') }}"
invoice_line_bundle: "{{ ref('invoice_line_bundle_data') }}"
invoice_linked_txn: "{{ ref('invoice_linked_txn_data') }}"
item: "{{ ref('item_data') }}"
journal_entry_line: "{{ ref('journal_entry_line_data') }}"
journal_entry: "{{ ref('journal_entry_data') }}"
payment: "{{ ref('payment_data') }}"
payment_line: "{{ ref('payment_line_data') }}"
purchase_line: "{{ ref('purchase_line_data') }}"
purchase_order: "{{ ref('purchase_order_data') }}"
purchase_order_line: "{{ ref('purchase_order_line_data') }}"
purchase_order_linked_txn: "{{ ref('purchase_order_linked_txn_data') }}"
purchase: "{{ ref('purchase_data') }}"
refund_receipt_line: "{{ ref('refund_receipt_line_data') }}"
refund_receipt: "{{ ref('refund_receipt_data') }}"
sales_receipt_line: "{{ ref('sales_receipt_line_data') }}"
sales_receipt: "{{ ref('sales_receipt_data') }}"
transfer: "{{ ref('transfer_data') }}"
vendor_credit_line: "{{ ref('vendor_credit_line_data') }}"
vendor_credit: "{{ ref('vendor_credit_data') }}"
vendor: "{{ ref('vendor_data') }}"

seeds:
+quote_columns: "{{ true if target.type == 'redshift' else false }}"
Expand Down Expand Up @@ -80,6 +83,9 @@ seeds:
payment_line_data:
purchase_line_data:
purchase_data:
purchase_order_data:
purchase_order_line_data:
purchase_order_linked_txn_data:
refund_receipt_line_data:
refund_receipt_data:
sales_receipt_line_data:
Expand Down
34 changes: 34 additions & 0 deletions macros/get_purchase_order_columns.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{% macro get_purchase_order_columns() %}

{% set columns = [
{"name": "_fivetran_deleted", "datatype": "boolean"},
{"name": "_fivetran_synced", "datatype": dbt_utils.type_timestamp()},
{"name": "class_id", "datatype": dbt_utils.type_int()},
{"name": "created_at", "datatype": dbt_utils.type_timestamp()},
{"name": "currency_id", "datatype": dbt_utils.type_int()},
{"name": "custom_customer_type", "datatype": dbt_utils.type_string()},
{"name": "custom_po_number", "datatype": dbt_utils.type_string()},
{"name": "doc_number", "datatype": dbt_utils.type_string()},
{"name": "due_date", "datatype": dbt_utils.type_timestamp()},
{"name": "exchange_rate", "datatype": dbt_utils.type_float()},
{"name": "global_tax_calculation", "datatype": dbt_utils.type_string()},
{"name": "id", "datatype": dbt_utils.type_int()},
{"name": "memo", "datatype": dbt_utils.type_string()},
{"name": "payable_account_id", "datatype": dbt_utils.type_int()},
{"name": "private_note", "datatype": dbt_utils.type_string()},
{"name": "sales_term_id", "datatype": dbt_utils.type_int()},
{"name": "shipping_address_id", "datatype": dbt_utils.type_int()},
{"name": "status", "datatype": dbt_utils.type_string()},
{"name": "sync_token", "datatype": dbt_utils.type_string()},
{"name": "tax_code_id", "datatype": dbt_utils.type_int()},
{"name": "total_amount", "datatype": dbt_utils.type_float()},
{"name": "total_tax", "datatype": dbt_utils.type_float()},
{"name": "transaction_date", "datatype": dbt_utils.type_timestamp()},
{"name": "updated_at", "datatype": dbt_utils.type_timestamp()},
{"name": "vendor_address_id", "datatype": dbt_utils.type_int()},
{"name": "vendor_id", "datatype": dbt_utils.type_int()}
] %}

{{ return(columns) }}

{% endmacro %}
26 changes: 26 additions & 0 deletions macros/get_purchase_order_line_columns.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{% macro get_purchase_order_line_columns() %}

{% set columns = [
{"name": "_fivetran_synced", "datatype": dbt_utils.type_timestamp()},
{"name": "account_expense_account_id", "datatype": dbt_utils.type_int()},
{"name": "account_expense_billable_status", "datatype": dbt_utils.type_string()},
{"name": "account_expense_class_id", "datatype": dbt_utils.type_int()},
{"name": "account_expense_customer_id", "datatype": dbt_utils.type_int()},
{"name": "account_expense_tax_amount", "datatype": dbt_utils.type_float()},
{"name": "account_expense_tax_code_id", "datatype": dbt_utils.type_int()},
{"name": "amount", "datatype": dbt_utils.type_float()},
{"name": "description", "datatype": dbt_utils.type_string()},
{"name": "index", "datatype": dbt_utils.type_int()},
{"name": "item_expense_billable_status", "datatype": dbt_utils.type_string()},
{"name": "item_expense_class_id", "datatype": dbt_utils.type_int()},
{"name": "item_expense_customer_id", "datatype": dbt_utils.type_int()},
{"name": "item_expense_item_id", "datatype": dbt_utils.type_int()},
{"name": "item_expense_quantity", "datatype": dbt_utils.type_float()},
{"name": "item_expense_tax_code_id", "datatype": dbt_utils.type_int()},
{"name": "item_expense_unit_price", "datatype": dbt_utils.type_float()},
{"name": "purchase_order_id", "datatype": dbt_utils.type_int()}
] %}

{{ return(columns) }}

{% endmacro %}
14 changes: 14 additions & 0 deletions macros/get_purchase_order_linked_txn_columns.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{% macro get_purchase_order_linked_txn_columns() %}

{% set columns = [
{"name": "_fivetran_synced", "datatype": dbt_utils.type_timestamp()},
{"name": "bill_id", "datatype": dbt_utils.type_int()},
{"name": "index", "datatype": dbt_utils.type_int()},
{"name": "purchase_id", "datatype": dbt_utils.type_int()},
{"name": "purchase_order_id", "datatype": dbt_utils.type_int()},
{"name": "vendor_credit_id", "datatype": dbt_utils.type_int()}
] %}

{{ return(columns) }}

{% endmacro %}
Loading

0 comments on commit 3d1725d

Please sign in to comment.