data-dwh-dbt-project/models/reporting/xero/xero__credit_notes.sql
Oriol Roqué Paniagua dcf0f205a2 Merged PR 4568: Adds flag to identify invoices/credit notes that are posted in Hyperline
# Description

Adds flag to identify invoices/credit notes that are posted in Hyperline.
For Invoices, these need to be ACCREC and follow a convention of 20XX-Y
For Credit Notes, these need to be ACCRECCREDIT and follow a convention of CN-20XX-Y

# 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: #28146
2025-03-04 10:12:03 +00:00

36 lines
1.6 KiB
SQL

with int_xero__credit_notes as (select * from {{ ref("int_xero__credit_notes") }})
select
id_credit_note as id_credit_note,
id_contact as id_contact,
reference as reference,
credit_note_number as credit_note_number,
is_credit_note_posted_in_hyperline as is_credit_note_posted_in_hyperline,
credit_note_issued_at_utc as credit_note_issued_at_utc,
credit_note_issued_date_utc as credit_note_issued_date_utc,
credit_note_type as credit_note_type,
credit_note_currency_iso_4217 as credit_note_currency_iso_4217,
exchange_rate_to_gbp as exchange_rate_to_gbp,
total_amount_local_curr as total_amount_local_curr,
total_amount_in_gbp as total_amount_in_gbp,
subtotal_local_curr as subtotal_local_curr,
subtotal_in_gbp as subtotal_in_gbp,
total_tax_local_curr as total_tax_local_curr,
total_tax_in_gbp as total_tax_in_gbp,
remaining_credit_local_curr as remaining_credit_local_curr,
remaining_credit_in_gbp as remaining_credit_in_gbp,
applied_amount as applied_amount,
credit_note_status as credit_note_status,
credit_note_due_date as credit_note_due_date,
date_string as date_string,
due_date_string as due_date_string,
allocations as allocations,
has_been_sent_to_contact as has_been_sent_to_contact,
has_attachments as has_attachments,
updated_at_utc as updated_at_utc,
id_branding_theme as id_branding_theme,
was_fully_paid_on_date_utc as was_fully_paid_on_date_utc,
line_amount_tax_inclusiveness as line_amount_tax_inclusiveness,
updated_date_utc as updated_date_utc,
dwh_extracted_at_utc as dwh_extracted_at_utc
from int_xero__credit_notes