Skip to content
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

[Bug] Issue with Multiple Account Payable #97

Closed
2 of 4 tasks
bernhardF1984 opened this issue Jul 16, 2023 · 4 comments · Fixed by #98
Closed
2 of 4 tasks

[Bug] Issue with Multiple Account Payable #97

bernhardF1984 opened this issue Jul 16, 2023 · 4 comments · Fixed by #98
Assignees
Labels
error:forced priority:p2 Affects most users; fix needed status:in_review Currently in review type:bug Something is broken or incorrect update_type:models Primary focus requires model updates

Comments

@bernhardF1984
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Describe the issue

In case a quickbook account has multiple accounts payable it will cause an issue in the general ledger, multiplying the data.
I am talking about the model: "int_quickbooks__bill_payment_double_entry.sql"
In this model, you check for the active Account Payable, but sometimes there are multiple such accounts:

`ap_accounts as (

select
    account_id
from accounts

where account_type = 'Accounts Payable'
    and is_active
    and not is_sub_account

),`

Afterwards, there is a cross-join, which in the case of multiple accounts, causes duplicate data in the general ledger:

bill_payment_join as (
select
bill_payments.bill_payment_id as transaction_id,
bill_payments.source_relation,
row_number() over(partition by bill_payments.bill_payment_id order by bill_payments.transaction_date) - 1 as index,
bill_payments.transaction_date,
bill_payments.total_amount as amount,
coalesce(bill_payments.credit_card_account_id,bill_payments.check_bank_account_id) as payment_account_id,
ap_accounts.account_id,
bill_payments.vendor_id,
bill_payments.department_id
from bill_payments

**cross join ap_accounts**

),

Relevant error log or model output

No response

Expected behavior

I think it would be good to give the option to define which one is the real account payable in the project yaml, maybe,, and have a note about this issue.
maybe raise an alert if there are multiple accounts!

dbt Project configurations

quickbooks dbt project.yml:

config-version: 2
name: 'quickbooks'

version: '0.9.1'

require-dbt-version: [">=1.3.0", "<2.0.0"]

models:
quickbooks:
+materialized: table
+schema: quickbooks
double_entry_transactions:
+schema: quickbooks_intermediate
+materialized: table
transaction_lines:
+materialized: ephemeral
intermediate:
+materialized: ephemeral
vars:
quickbooks:
account: "{{ ref('stg_quickbooks__account') }}"
address: "{{ ref('stg_quickbooks__address') }}"
bill_line: "{{ ref('stg_quickbooks__bill_line') }}"
bill_linked_txn: "{{ ref('stg_quickbooks__bill_linked_txn') }}"
bill_payment_line: "{{ ref('stg_quickbooks__bill_payment_line') }}"
bill_payment: "{{ ref('stg_quickbooks__bill_payment') }}"
bill: "{{ ref('stg_quickbooks__bill') }}"
bundle_item: "{{ ref('stg_quickbooks__bundle_item') }}"
bundle: "{{ ref('stg_quickbooks__bundle') }}"
credit_memo_line: "{{ ref('stg_quickbooks__credit_memo_line') }}"
credit_memo: "{{ ref('stg_quickbooks__credit_memo') }}"
credit_card_payment_txn: "{{ ref('stg_quickbooks__credit_card_payment_txn') }}"
customer: "{{ ref('stg_quickbooks__customer') }}"
department: "{{ ref('stg_quickbooks__department') }}"
deposit_line: "{{ ref('stg_quickbooks__deposit_line') }}"
deposit: "{{ ref('stg_quickbooks__deposit') }}"
estimate: "{{ ref('stg_quickbooks__estimate') }}"
estimate_line: "{{ ref('stg_quickbooks__estimate_line') }}"
invoice_line: "{{ ref('stg_quickbooks__invoice_line') }}"
invoice_line_bundle: "{{ ref('stg_quickbooks__invoice_line_bundle') }}"
invoice_linked_txn: "{{ ref('stg_quickbooks__invoice_linked_txn') }}"
invoice: "{{ ref('stg_quickbooks__invoice') }}"
item: "{{ ref('stg_quickbooks__item') }}"
journal_entry_line: "{{ ref('stg_quickbooks__journal_entry_line') }}"
journal_entry: "{{ ref('stg_quickbooks__journal_entry') }}"
payment_line: "{{ ref('stg_quickbooks__payment_line') }}"
payment: "{{ ref('stg_quickbooks__payment') }}"
purchase_line: "{{ ref('stg_quickbooks__purchase_line') }}"
purchase: "{{ ref('stg_quickbooks__purchase') }}"
refund_receipt_line: "{{ ref('stg_quickbooks__refund_receipt_line') }}"
refund_receipt: "{{ ref('stg_quickbooks__refund_receipt') }}"
sales_receipt_line: "{{ ref('stg_quickbooks__sales_receipt_line') }}"
sales_receipt: "{{ ref('stg_quickbooks__sales_receipt') }}"
transfer: "{{ ref('stg_quickbooks__transfer') }}"
vendor_credit_line: "{{ ref('stg_quickbooks__vendor_credit_line') }}"
vendor_credit: "{{ ref('stg_quickbooks__vendor_credit') }}"
vendor: "{{ ref('stg_quickbooks__vendor') }}"

financial_statement_ordinal: []
cash_flow_statement_type_ordinal: []

using_address: true
using_bill: true
using_credit_memo: true
using_department: true
using_deposit: true
using_estimate: true
using_invoice: true
using_invoice_bundle: true
using_journal_entry: true
using_payment: true
using_refund_receipt: true
using_transfer: true
using_vendor_credit: true
using_sales_receipt: true
using_credit_card_payment_txn: false

analysis-paths: ["analysis"]
clean-targets:

  • target
  • dbt_modules
  • dbt_packages

Package versions

packages:

  • package: fivetran/quickbooks
    version: [">=0.9.0", "<0.10.0"] # we recommend using ranges to capture non-breaking changes automatically

What database are you using dbt with?

bigquery

dbt Version

1.5.1

Additional Context

No response

Are you willing to open a PR to help address this issue?

  • Yes.
  • Yes, but I will need assistance and will schedule time during our office hours for guidance
  • No.
@bernhardF1984 bernhardF1984 added the type:bug Something is broken or incorrect label Jul 16, 2023
@fivetran-jamie
Copy link
Contributor

hi there @bernhardF1984 👋 thanks for taking the time to open this issue, we really appreciate it and agree with your proposed approach! i also really like the idea of raising a warning if there are multiple Accounts Payable (perhaps it could be automatically disabled if you provide the "real" accounts payable n the dbt_project.yml).

Couple of follow up questions for ya:

  1. On your end, how do you determine which is the appropriate Accounts Payable to use? is it something you just know internally, or could the package somehow programmatically figure it out? I imagine it's probably the former, but wanted to check first

  2. We have similar logic in the following models, where we assume there is only one account of the respective type and perform a cartesian join. I assume we would also introduce variables to configure the "real" accounts of these types as well -- are you seeing duplicates from these models?

We'll get started on this next sprint, which begins mid next week 🤠

@fivetran-jamie fivetran-jamie added status:accepted Scoped and accepted into queue priority:p2 Affects most users; fix needed update_type:models Primary focus requires model updates labels Jul 18, 2023
@bernhardF1984
Copy link
Author

bernhardF1984 commented Jul 19, 2023 via email

@fivetran-avinash fivetran-avinash self-assigned this Jul 27, 2023
@fivetran-avinash fivetran-avinash added status:in_progress Currently being worked on and removed status:accepted Scoped and accepted into queue labels Jul 27, 2023
@fivetran-avinash fivetran-avinash linked a pull request Aug 1, 2023 that will close this issue
15 tasks
@fivetran-avinash fivetran-avinash added status:in_review Currently in review and removed status:in_progress Currently being worked on labels Aug 1, 2023
@fivetran-avinash
Copy link
Contributor

Hi @bernhardF1984 ! We're in the process of deploying a fix. If you want to test this before we deploy it live, try pointing to this branch in your packages.yml rather than the default dbt package, and try configuring your account type values in your dbt_project.yml by following the instructions in the new README?

packages
  - git: https://github.com/fivetran/dbt_quickbooks.git 
     revision: bugfix/set-account-type-variables
     warn-unpinned: false

If not, we should be deploying this live by next week!

@bernhardF1984
Copy link
Author

bernhardF1984 commented Aug 2, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
error:forced priority:p2 Affects most users; fix needed status:in_review Currently in review type:bug Something is broken or incorrect update_type:models Primary focus requires model updates
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants