data-dwh-dbt-project/models/reporting/xero
Oriol Roqué Paniagua 5928a198b6 Merged PR 4734: Bugfix - Ensures accounts cannot be duplicated in Xero sales monthly trends
# Description

This fixes the duplication error when the same deal has more than one contact. Impact was not massive, it just affected because of the Home to Host account and this has happened during the past week. There were other cases that contained duplicates but these were not invoiced so it didn't affect the total sum.

Changes:
* Contacts now has a boolean field indicating if a deal exists.
* Contacts now has a boolean field indicating if that contact has a deal informed and it's the last updated one. This is opinionated - it could have been done with creation, for instance.
* Sales monthly trends forces the last updated contact to be true.
* Improved robustness by adding tests.

Note that modifying the logic in intermediate on `int_xero__sales_monthly_trends` by changing `id_deal` per `id_contact` would not have worked - we need to do this compute by deal to ensure that any invoicing is reported MoM and YTD.

# Checklist

- [X] The edited models and dependants run properly with production data.
- [X] The edited models are sufficiently documented.
- [X] The edited models contain PK tests, and I've ran and passed them.
- [X] I have checked for DRY opportunities with other models and docs.
- [X] I've picked the right materialization for the affected models.

# Other

- [ ] Check if a full-refresh is required after this PR is merged.

Related work items: #28576
2025-03-19 08:19:20 +00:00
..
schema.yml Merged PR 4734: Bugfix - Ensures accounts cannot be duplicated in Xero sales monthly trends 2025-03-19 08:19:20 +00:00
xero__bank_transaction_denom_mart.sql propagate transaction sign 2024-07-01 11:44:55 +02:00
xero__bank_transaction_line_items.sql reporting model 2024-06-26 11:24:34 +02:00
xero__bank_transactions.sql propagate transaction sign 2024-07-01 11:44:55 +02:00
xero__contacts.sql reporting models 2024-05-13 16:52:55 +02:00
xero__credit_note_line_items.sql Merged PR 4077: Propagate account code and account name for Xero - reporting models 2025-01-16 10:04:41 +00:00
xero__credit_notes.sql Merged PR 4568: Adds flag to identify invoices/credit notes that are posted in Hyperline 2025-03-04 10:12:03 +00:00
xero__invoice_line_items.sql Merged PR 4077: Propagate account code and account name for Xero - reporting models 2025-01-16 10:04:41 +00:00
xero__invoices.sql Merged PR 4568: Adds flag to identify invoices/credit notes that are posted in Hyperline 2025-03-04 10:12:03 +00:00
xero__net_fees.sql add proper value to waiver_items array 2024-05-29 13:23:05 +02:00
xero__net_fees_by_deal.sql Setting xero__net_fees_by_deal as per deal id, not dedicated to guesty 2024-05-30 10:00:39 +02:00
xero__sales_denom_mart.sql Merged PR 4572: Applies logic to modify the invoicing cycle date depending on the issuing source 2025-03-04 11:32:52 +00:00
xero__sales_monthly_trends.sql Merged PR 4734: Bugfix - Ensures accounts cannot be duplicated in Xero sales monthly trends 2025-03-19 08:19:20 +00:00