diff --git a/models/staging/xero/schema.yml b/models/staging/xero/schema.yml index c07e69a..92322bc 100644 --- a/models/staging/xero/schema.yml +++ b/models/staging/xero/schema.yml @@ -416,3 +416,173 @@ models: - name: dwh_extracted_at_utc data_type: timestamp with time zone description: "" + - name: stg_xero__credit_notes + description: | + Credit notes that we have issued within our accounting books. + + This includes both our credit notes towards customers and credit notes provided by our suppliers. + + You can read more here: https://developer.xero.com/documentation/api/accounting/creditnotes + columns: + - name: id_credit_note + data_type: character varying + description: Xero's unique identifier for the credit note. + tests: + - not_null + - unique + + - name: reference + data_type: character varying + description: The reference number for the credit note. + + - name: credit_note_number + data_type: character varying + description: The number assigned to the credit note. + + - name: credit_note_issued_at_utc + data_type: timestamp with time zone + description: The timestamp at which the credit note was issued. + + - name: credit_note_issued_date_utc + data_type: date + description: The date on which the credit note was issued. + + - name: credit_note_type + data_type: character varying + description: The type of the credit note (e.g., ACCRECCREDIT or ACCPAYCREDIT). + tests: + - not_null + - accepted_values: + values: + - "ACCRECCREDIT" + - "ACCPAYCREDIT" + + - name: credit_note_currency_iso_4217 + data_type: character varying + description: The ISO 4217 code for the currency in which the credit note is denominated. + + - name: exchange_rate_to_gbp + data_type: numeric + description: | + The implied exchange rate between the credit note currency and GBP. + + This is the XXX to GBP rate, indicating how many GBP one unit of XXX is worth. + tests: + - not_null + - not_negative + + - name: total_amount_local_curr + data_type: numeric + description: The total amount of the credit note in the local currency. + tests: + - not_null + + - name: subtotal_local_curr + data_type: numeric + description: The subtotal of the credit note in the local currency, before tax. + tests: + - not_null + + - name: total_tax_local_curr + data_type: numeric + description: The total tax amount of the credit note in the local currency. + tests: + - not_null + + - name: remaining_credit_local_curr + data_type: numeric + description: The remaining credit amount in the local currency. + tests: + - not_null + + - name: applied_amount + data_type: numeric + description: The amount applied from the credit note. + + - name: credit_note_status + data_type: character varying + description: | + The status of the credit note. + + Can be one of: PAID, VOIDED, DRAFT, DELETED, AUTHORISED, SUBMITTED. + + You can read more here: https://developer.xero.com/documentation/api/accounting/types#invoices + tests: + - not_null + - accepted_values: + values: + - PAID + - VOIDED + - DRAFT + - DELETED + - AUTHORISED + - SUBMITTED + + - name: full_contact_details + data_type: jsonb + description: The full contact details related to the credit note. + tests: + - not_null + + - name: credit_note_due_date + data_type: timestamp with time zone + description: The due date for the credit note. + + - name: line_items + data_type: jsonb + description: An array of line items associated with the credit note. + tests: + - not_null + + - name: date_string + data_type: character varying + description: The date string representation of the credit note date. + + - name: due_date_string + data_type: character varying + description: The date string representation of the credit note due date. + + - name: allocations + data_type: jsonb + description: An array of allocations related to the credit note. + + - name: has_been_sent_to_contact + data_type: boolean + description: Flag indicating if the credit note has been sent to the contact. + + - name: has_attachments + data_type: boolean + description: Flag indicating if the credit note has attachments. + + - name: updated_at_utc + data_type: timestamp with time zone + description: The timestamp at which the credit note was last updated. + + - name: id_branding_theme + data_type: character varying + description: The identifier for the branding theme associated with the credit note. + + - name: was_fully_paid_on_date_utc + data_type: date + description: The date on which the credit note was fully paid, if applicable. + + - name: line_amount_tax_inclusiveness + data_type: character varying + description: | + Indicates whether the amounts included in line items are tax + inclusive (Inclusive), tax exclusive (Exclusive) or simply, + there are no taxes on the credit note (NoTax). + tests: + - accepted_values: + values: + - Inclusive + - Exclusive + - NoTax + + - name: updated_date_utc + data_type: date + description: The date on which the credit note was last updated. + + - name: dwh_extracted_at_utc + data_type: timestamp with time zone + description: The timestamp at which the data warehouse last extracted the credit note data.