diff --git a/models/intermediate/xero/int_xero__host_resolutions_payments.sql b/models/intermediate/xero/int_xero__host_resolutions_payments.sql index c424253..72dac1c 100644 --- a/models/intermediate/xero/int_xero__host_resolutions_payments.sql +++ b/models/intermediate/xero/int_xero__host_resolutions_payments.sql @@ -25,6 +25,7 @@ select blt.account_name, blt.line_description, bt.transaction_date_utc, + bt.id_contact, xc.id_deal, blt.quantity, blt.unit_amount, @@ -51,6 +52,7 @@ select sdm.account_name, sdm.line_description, sdm.document_issued_date_utc, + sdm.id_contact, sdm.id_deal, sdm.quantity, sdm.unit_amount, diff --git a/models/intermediate/xero/schema.yml b/models/intermediate/xero/schema.yml index 2508a40..00ec773 100644 --- a/models/intermediate/xero/schema.yml +++ b/models/intermediate/xero/schema.yml @@ -510,10 +510,15 @@ models: data_type: date description: "The date of the transaction in UTC." + - name: id_contact + data_type: text + description: "Unique identifier of the contact associated with the transaction." + - name: id_deal data_type: text description: | - "Unique identifier of an account associated with the transaction." + "Unique identifier of an account associated with the transaction. + Can be null." - name: quantity data_type: numeric diff --git a/models/reporting/xero/schema.yml b/models/reporting/xero/schema.yml index 2287731..5ac17c5 100644 --- a/models/reporting/xero/schema.yml +++ b/models/reporting/xero/schema.yml @@ -26,7 +26,7 @@ models: - name: reference data_type: character varying description: | - The Superhog-set reference for the invoices. Only relevant for + The Truvi-set reference for the invoices. Only relevant for records of invoice type (ACCREC). - name: invoice_number @@ -61,8 +61,8 @@ models: - name: invoice_type data_type: character varying description: | - This field indicates whether the invoice is from Superhog towards a customer - (value is "ACCREC") or from a supplier towards Superhog (value is "ACCPAY"). + This field indicates whether the invoice is from Truvi towards a customer + (value is "ACCREC") or from a supplier towards Truvi (value is "ACCPAY"). - name: invoice_currency_iso_4217 data_type: character varying @@ -299,7 +299,7 @@ models: - name: account_number data_type: character varying - description: A Superhog set identifier. For customers, this is Hubspot's Deal Id. + description: A Truvi set identifier. For customers, this is Hubspot's Deal Id. - name: id_deal data_type: text @@ -316,11 +316,11 @@ models: - name: is_customer data_type: boolean - description: Flag that shows if the contact is a Superhog customer. + description: Flag that shows if the contact is a Truvi customer. - name: is_supplier data_type: boolean - description: Flag that shows if the contact is a Superhog supplier. + description: Flag that shows if the contact is a Truvi supplier. - name: tax_number data_type: character varying @@ -496,7 +496,7 @@ models: - name: reference data_type: character varying description: | - The Superhog-set reference for the credit note. + The Truvi-set reference for the credit note. - name: credit_note_number data_type: character varying @@ -1580,3 +1580,144 @@ models: description: | "Year-to-date (YTD) total of sales amount without taxes (GBP) from the start of the previous fiscal year up to the same month." + + - name: xero__host_resolutions_payments + description: | + This model provides a view of transactions related to resolutions, including details + such as transaction date, associated account, and transaction amount. + + Previously, all resolution-related transaction data was stored in the `int_xero__bank_transactions` + model. However, some resolution transactions have been, and will continue to be, credited through + the standard invoicing process — these are stored in the `int_xero__sales_denom_mart` model. + + This model is built by joining the `int_xero__bank_transactions` and `int_xero__sales_denom_mart` + models to provide a unified view of resolution transactions. + + + columns: + - name: id_line_item + data_type: text + description: "Unique identifier of the line item associated with the transaction." + data_tests: + - not_null + - unique + + - name: id_account + data_type: text + description: "Unique identifier of the account associated with the transaction." + data_tests: + - not_null + + - name: account_code + data_type: text + description: "The code of the account associated with the transaction." + data_tests: + - not_null + + - name: account_name + data_type: text + description: "The name of the account associated with the transaction." + data_tests: + - not_null + + - name: line_description + data_type: text + description: "Description of the transaction line item." + + - name: document_class + data_type: text + description: "Indicates whether the record belongs in an a credit note or a bank transaction." + data_tests: + - not_null + - accepted_values: + values: + - "credit note" + - "bank transaction" + + - name: transaction_date_utc + data_type: date + description: "The date of the transaction in UTC." + + - name: quantity + data_type: numeric + description: "The quantity of transactions." + + - name: unit_amount + data_type: numeric + description: "The unit amount of the transaction." + + - name: line_amount_local_curr + data_type: numeric + description: "The transaction amount in the local currency." + + - name: line_amount_in_gbp + data_type: numeric + description: "The transaction amount in GBP." + + - name: line_amount_wo_taxes_local_curr + data_type: numeric + description: "The transaction amount without taxes in the local currency." + + - name: line_amount_wo_taxes_in_gbp + data_type: numeric + description: "The transaction amount without taxes in GBP." + + - name: tax_amount_local_curr + data_type: numeric + description: "The tax amount in the local currency." + + - name: tax_amount_in_gbp + data_type: numeric + description: "The tax amount in GBP." + + - name: transaction_currency_iso_4217 + data_type: character varying + description: "The currency of the transaction, represented in ISO 4217 format." + + - name: id_contact + data_type: text + description: "Unique identifier of the contact associated with the transaction." + date_tests: + - not_null + + - name: id_deal + data_type: text + description: | + "Unique identifier of an account associated with the transaction. + Can be null" + + - name: account_number + data_type: character varying + description: A Truvi set identifier. For customers, this is Hubspot's Deal Id. + + - name: contact_name + data_type: character varying + description: The name for the customer. + + - name: is_customer + data_type: boolean + description: Flag that shows if the contact is a Truvi customer. + + - name: is_supplier + data_type: boolean + description: Flag that shows if the contact is a Truvi supplier. + + - name: contact_first_name + data_type: character varying + description: "" + + - name: contact_last_name + data_type: character varying + description: "" + + - name: email_addresses + data_type: character varying + description: "" + + - name: contact_number + data_type: character varying + description: "" + + - name: contact_status + data_type: character varying + description: "" \ No newline at end of file diff --git a/models/reporting/xero/xero__host_resolutions_payments.sql b/models/reporting/xero/xero__host_resolutions_payments.sql new file mode 100644 index 0000000..ec776f5 --- /dev/null +++ b/models/reporting/xero/xero__host_resolutions_payments.sql @@ -0,0 +1,35 @@ +with + int_xero__host_resolutions_payments as ( + select * from {{ ref("int_xero__host_resolutions_payments") }} + ), + xero__contacts as (select * from {{ ref("xero__contacts") }}) +select + hrp.id_line_item, + hrp.document_class, + hrp.id_account, + hrp.account_code, + hrp.account_name, + hrp.line_description, + hrp.transaction_date_utc, + hrp.quantity, + hrp.unit_amount, + hrp.line_amount_local_curr, + hrp.line_amount_in_gbp, + hrp.line_amount_wo_taxes_local_curr, + hrp.line_amount_wo_taxes_in_gbp, + hrp.tax_amount_local_curr, + hrp.tax_amount_in_gbp, + hrp.transaction_currency_iso_4217, + hrp.id_contact, + hrp.id_deal, + c.account_number, + c.contact_name, + c.is_customer, + c.is_supplier, + c.contact_first_name, + c.contact_last_name, + c.email_addresses, + c.contact_number, + c.contact_status +from int_xero__host_resolutions_payments hrp +left join xero__contacts c on c.id_contact = hrp.id_contact