From 8f6e92c187fe51696ea3d662299d992653fb7c3a Mon Sep 17 00:00:00 2001 From: Pablo Martin Date: Thu, 16 May 2024 18:21:32 +0200 Subject: [PATCH] credit notes intermediate model --- .../xero/int_xero__credit_notes.sql | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 models/intermediate/xero/int_xero__credit_notes.sql diff --git a/models/intermediate/xero/int_xero__credit_notes.sql b/models/intermediate/xero/int_xero__credit_notes.sql new file mode 100644 index 0000000..e4be166 --- /dev/null +++ b/models/intermediate/xero/int_xero__credit_notes.sql @@ -0,0 +1,41 @@ +with stg_xero__credit_notes as (select * from {{ ref("stg_xero__credit_notes") }}), + +select + id_credit_note, + full_contact_details ->> 'ContactID' as id_contact, + reference, + credit_note_number, + credit_note_issued_at_utc, + credit_note_issued_date_utc, + credit_note_type, + invoice_currency_iso_4217, + exchange_rate_to_gbp, + total_amount_local_curr, + (total_amount_local_curr * exchange_rate_to_gbp)::numeric( + 18, 4 + ) as total_amount_in_gbp, + subtotal_local_curr, + (subtotal_local_curr * exchange_rate_to_gbp)::numeric(18, 4) as subtotal_in_gbp, + total_tax_local_curr, + (total_tax_local_curr * exchange_rate_to_gbp)::numeric(18, 4) as total_tax_in_gbp, + remaining_credit_local_curr, + (remaining_credit_local_curr * exchange_rate_to_gbp)::numeric( + 18, 4 + ) as remaining_credit_in_gbp, + applied_amount, + credit_note_status, + full_contact_details, + credit_note_due_date, + line_items, + date_string, + due_date_string, + allocations, + has_been_sent_to_contact, + has_attachments, + updated_at_utc, + id_branding_theme, + was_fully_paid_on_date_utc, + line_amount_tax_inclusiveness, + updated_date_utc, + dwh_extracted_at_utc +from stg_xero__credit_notes