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

Add invoice discount to invoice_double_entry [resolve #59] #60

Merged
merged 2 commits into from
Apr 11, 2023

Conversation

SellJamHere
Copy link
Contributor

Are you a current Fivetran customer?
Yes. James Heller from Apartment 304.

What change(s) does this PR introduce?
This change adds invoice discounts to the int_quickbooks__invoice_double_entry table, and calculates the expected Accounts Receivable amount (sum of sales/service line items less discount), instead of creating an A/R record for each sales/service line item in the invoice.

Did you update the CHANGELOG?

  • Yes

Not yet. I would like to review the changes with the team.

Does this PR introduce a breaking change?

  • Yes (please provide breaking change details below.)
  • No (please provide an explanation as to how the change is non-breaking below.)

This change will generate correct invoice amounts for users using invoice discounts.

Did you update the dbt_project.yml files with the version upgrade (please leverage standard semantic versioning)? (In both your main project and integration_tests)

  • Yes

Not yet. I would like to review the changes with the team.

Is this PR in response to a previously created Bug or Feature Request

How did you test the PR changes?

  • CircleCi
  • Local (please provide additional testing details below)
  • Fivetran

I tested the feature using a Fivetran Transformation on a Databricks destination. I'm happy to take on further testing and validation if the team thinks the query changes can be merged in.

Select which warehouse(s) were used to test the PR

  • BigQuery
  • Redshift
  • Snowflake
  • Postgres
  • Databricks
  • Other (provide details below)

Provide an emoji that best describes your current mood

😃

Feedback

We are so excited you decided to contribute to the Fivetran community dbt package! We continue to work to improve the packages and would greatly appreciate your feedback on our existing dbt packages or what you'd like to see next.

@fivetran-joemarkiewicz
Copy link
Contributor

@SellJamHere thanks again for opening this PR. I am currently taking a look and had a quick question.

I see you do a lot of work to separate out the invoice discounts from the normal invoice lines. However, would it work instead to still keep the invoice and invoice discounts together, but have a case when statement for amount to appropriately convey the discount as a subtraction from the total invoice amount? Essentially I am thinking we could possible use the following in the double entry model for invoices:

invoice_join as (

    select
        invoices.invoice_id as transaction_id,
        invoices.source_relation,
        invoice_lines.index, 
        invoices.transaction_date as transaction_date,
        case when invoices.total_amount != 0 then invoice_lines.amount
            when coalesce(invoices.total_amount,0) == 0 then invoices.total_amount
            when invoice_lines.discount_account_id is not null then amount * -1
        end as amount,

What are your thoughts?

@fivetran-joemarkiewicz fivetran-joemarkiewicz changed the base branch from main to bugfix/invoice-discount-consideration April 11, 2023 15:56
@fivetran-joemarkiewicz fivetran-joemarkiewicz changed the base branch from bugfix/invoice-discount-consideration to main April 11, 2023 15:56
@fivetran-joemarkiewicz fivetran-joemarkiewicz changed the base branch from main to release/v0.5.3 April 11, 2023 16:00
Copy link
Contributor

@fivetran-joemarkiewicz fivetran-joemarkiewicz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SellJamHere thanks again for opening this PR! This gives us a great start into considering discounts properly in the invoice double entry and downstream models!

There are likely a few changes I will make to your updates once I merge this into a staging branch. I highly recommend following the corresponding PRs to give the updates a try on your end to confirm your initial issue is addressed.

Thanks again!

@fivetran-joemarkiewicz fivetran-joemarkiewicz merged commit c0fdd1f into fivetran:release/v0.5.3 Apr 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants