fivetran / dbt_netsuite

Data models for Fivetran's Netsuite connector, built using dbt.
https://fivetran.github.io/dbt_netsuite/
Apache License 2.0
36 stars 34 forks source link

[Bug] Reversed transaction not showing up as same date that Netsuite Income Statement records it #52

Closed wwilliamsnuwest closed 1 year ago

wwilliamsnuwest commented 1 year ago

Is there an existing issue for this?

Describe the issue

We have a transaction reversal that is causing a weird issue. When I look in Snowflake's dbt Netsuite2 netsuite2__transaction_details, there's -$8.2 M Income charge from two transactions both on 1/1/2022 with Dec 2021 totals of $47 M and Jan 2022 of $58 M.

` SELECT CASE account_type_name WHEN 'Income' THEN '1 - Income' WHEN 'Cost of Goods Sold' THEN '2 - COGS' WHEN 'Expense' THEN '3 - Expense' ELSE account_type_name END AS account_type_name_sorted,

:datebucket(DATE(transaction_date)) AS transaction_date_bucket, -- Grouping by Month in Snowflake filter not shown

SUM(transaction_amount) AS transaction_amount

FROM dbt_db.dbt_prod_netsuite.netsuite2__transaction_details WHERE account_type_name IN ( 'Income')

AND DATE(transaction_date) BETWEEN '2021-12-01' AND '2022-01-31'

GROUP BY 1,2 ORDER BY 1,2 ` Query above to get these monthly totals in Snowflake: image

Query to isolate the $4.1 M charges: `SELECT CASE account_type_name WHEN 'Income' THEN '1 - Income' WHEN 'Cost of Goods Sold' THEN '2 - COGS' WHEN 'Expense' THEN '3 - Expense' ELSE account_type_name END AS account_type_name_sorted, account_number, parent_account_name, transaction_date, transaction_amount, transaction_line_id

FROM dbt_db.dbt_prod_netsuite.netsuite2__transaction_details WHERE account_type_name IN ('Expense', 'Income', 'Other Expense', 'Other Income', 'Cost of Goods Sold')

AND DATE(transaction_date) = '2022-01-01' AND account_number = 45100 `

image You can see above that there's actually TWO $4.1 M charges, but both are on 1/1/2022. I think instead what should have happened was to have one applied to 12/31/2022 (the date of thing being reversed, if I understand what Netsuite.com is showing) and one apply to 1/1/2022. At least that would make the two months in Snowflake = the two months' totals in Netsuite.com when summing in Snowflake by transaction_date.

image

However, in Netsuite.com on the Income Statement page, that transaction appears to be split between 12/31/2022 and 1/1/2022, resulting in monthly Dec 2021 totals of $47 M and Jan 2022 of $58 M: image

Here's the transaction records from Netsuite showing a +$4.1 M on 12/31/2022 and a -$4.1 M on 1/1/2022: image

Relevant error log or model output

No response

Expected behavior

I'd expect the monthly totals to match in Netsuite.com vs Snowflake, but instead they don't.

dbt Project configurations

Nothing important to add here.

Package versions

packages:

What database are you using dbt with?

snowflake

dbt Version

Not sure if this is relevant since I'm using dbt cloud.

Additional Context

No response

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

fivetran-joemarkiewicz commented 1 year ago

Thanks for opening this issue @wwilliamsnuwest and for your detailed investigation into the issue.

An interesting piece of this puzzle is that the transaction_date (which seems to incorrectly represent the transaction and its reversal) is not modified within our dbt package. You can see it is selected from the staging table (which is a direct query from the source transactions table synced by Fivetran). https://github.com/fivetran/dbt_netsuite/blob/c1fe30ec1b1164679e74bfbf03ec605e00ebc400/models/netsuite2/netsuite2__transaction_details.sql#L87

I would be curious to understand why the data being synced is not accurately reflecting the date of the reversal. If I am understanding your bug report correctly, if we address the one of the two records to take place on 12/31 then it should resolve the issue (please correct me if I am wrong).

If the above is the case, I think this may be a Fivetran Support related inquiry and should be investigated at the connector level. Happy to chat more if you feel the transformation is causing this instead.

wwilliamsnuwest commented 1 year ago

Gotcha. Yeah, it does seem like it's the issue you're describing where perhaps the reversal needs to have a transaction date of the date of the ORIGINAL transaction being 'reversed' (12/31/2021) vs the date of the reversal (1/1/2022).

If this is a Fivetran connector issue, do I need to open up a separate ticket with them, or are you able to do that on my behalf?

Thanks! Ward


From: Joe Markiewicz @.> Sent: Thursday, October 6, 2022 9:37 PM To: fivetran/dbt_netsuite @.> Cc: Ward Williams @.>; Mention @.> Subject: Re: [fivetran/dbt_netsuite] [Bug] Reversed transaction not showing up as same date that Netsuite Income Statement records it (Issue #52)

You don't often get email from @.*** Learn why this is importanthttps://aka.ms/LearnAboutSenderIdentification

Thanks for opening this issue @wwilliamsnuwesthttps://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fwwilliamsnuwest&data=05%7C01%7Cwwilliams%40nuwestgroup.com%7C8c00b02361964b8f865108daa81d93a6%7C5f334365592d48068c5dc237622d6bfe%7C0%7C0%7C638007142255710488%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=tv1W0CIvyHPaIcrSbQShp3s6dqFeByRXyVDyi0Gh3uM%3D&reserved=0 and for your detailed investigation into the issue.

An interesting piece of this puzzle is that the transaction_date (which seems to incorrectly represent the transaction and its reversal) is not modified within our dbt package. You can see it is selected from the staging table (which is a direct query from the source transactions table synced by Fivetran). https://github.com/fivetran/dbt_netsuite/blob/c1fe30ec1b1164679e74bfbf03ec605e00ebc400/models/netsuite2/netsuite2__transaction_details.sql#L87https://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Ffivetran%2Fdbt_netsuite%2Fblob%2Fc1fe30ec1b1164679e74bfbf03ec605e00ebc400%2Fmodels%2Fnetsuite2%2Fnetsuite2__transaction_details.sql%23L87&data=05%7C01%7Cwwilliams%40nuwestgroup.com%7C8c00b02361964b8f865108daa81d93a6%7C5f334365592d48068c5dc237622d6bfe%7C0%7C0%7C638007142255710488%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=PZFqUqT59o3oWGyTBZOAgi%2FqoNzy%2FqbZZiwBLg4sDM8%3D&reserved=0

I would be curious to understand why the data being synced is not accurately reflecting the date of the reversal. If I am understanding your bug report correctly, if we address the one of the two records to take place on 12/31 then it should resolve the issue (please correct me if I am wrong).

If the above is the case, I think this may be a Fivetran Supporthttps://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fsupport.fivetran.com%2Fhc%2Fen-us&data=05%7C01%7Cwwilliams%40nuwestgroup.com%7C8c00b02361964b8f865108daa81d93a6%7C5f334365592d48068c5dc237622d6bfe%7C0%7C0%7C638007142255710488%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=Tg9yA2D%2BeW7XJXWiFc11UVu%2BHoc7Cp5DsJ2OsP%2FyAOs%3D&reserved=0 related inquiry and should be investigated at the connector level. Happy to chat more if you feel the transformation is causing this instead.

ā€” Reply to this email directly, view it on GitHubhttps://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Ffivetran%2Fdbt_netsuite%2Fissues%2F52%23issuecomment-1271099978&data=05%7C01%7Cwwilliams%40nuwestgroup.com%7C8c00b02361964b8f865108daa81d93a6%7C5f334365592d48068c5dc237622d6bfe%7C0%7C0%7C638007142255710488%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=8EWjWJzb0yxPoZDDLbn6IbYIqtGVN%2Bmu3K5X9oyJqXU%3D&reserved=0, or unsubscribehttps://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAYA77U7OAHIKGU4QN4IXWY3WB6SGZANCNFSM6AAAAAAQ7CJVYE&data=05%7C01%7Cwwilliams%40nuwestgroup.com%7C8c00b02361964b8f865108daa81d93a6%7C5f334365592d48068c5dc237622d6bfe%7C0%7C0%7C638007142255710488%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=31AKG6acWCYUJJ58wjvjU7RfkLHtSTYSWGFgwKntjlY%3D&reserved=0. You are receiving this because you were mentioned.Message ID: @.***>

fivetran-reneeli commented 1 year ago

Hey @wwilliamsnuwest ! If the problem seems to be within the connector itself, we encourage customers to open a ticket to support on their end! However feel free to link this issue. I reckon engineering will tag us in the ticket.

fivetran-joemarkiewicz commented 1 year ago

Hi @wwilliamsnuwest I will close this issue as it should be addressed within the connector itself. If you were unable to create the support ticket, you can create one here.

If you feel this GitHub issue should remain open, feel free to comment here and we can reopen if needed. šŸ˜„