data query to get the these columns Account Name, ACCOUNT TYPE, Account Territory,…
- User
data query to get the these columns Account Name, ACCOUNT TYPE, Account Territory, Currency, DOCUMENT #, RATE PLAN CHARGE TYPE, REASON CODE, DOCUMENT AMOUNT, DOCUMENT Balance , Debit Memo Balance , Credit Balance, Unapplied Payment , On-Account Credit Memo , Account Balance , Current , 1 to 30 days past due, 31 to 60 days past due , 61 to 90 days past due , 91 to 120 days past due , more than 120 days past due in zuora
- Assistant
To retrieve the mentioned columns from Zuora, you can use the following SQL query:
SELECT Account.Name AS "Account Name", Account.AccountType AS "ACCOUNT TYPE", Account.Territory AS "Account Territory", Account.Currency AS "Currency", DocumentNumber AS "DOCUMENT #", RatePlanChargeType AS "RATE PLAN CHARGE TYPE", ReasonCode AS "REASON CODE", DocumentAmount AS "DOCUMENT AMOUNT", DocumentBalance AS "DOCUMENT Balance", DebitMemoBalance AS "Debit Memo Balance", CreditBalance AS "Credit Balance", UnappliedPayment AS "Unapplied Payment", OnAccountCreditMemo AS "On-Account Credit Memo", AccountBalance AS "Account Balance", Current, Days30 AS "1 to 30 days past due", Days60 AS "31 to 60 days past due", Days90 AS "61 to 90 days past due", Days120 AS "91 to 120 days past due", GreaterThan120 AS "more than 120 days past due" FROM AccountMake sure to replace "Account" with the appropriate table name in your Zuora database.
- User
JOIN is not needed?
- Assistant
Apologies for the oversight. If the columns you mentioned are all available in the
Accounttable in Zuora, you won't need to perform a join. You can simply select the desired columns directly from theAccounttable. Updated query without the join:SELECT Name AS "Account Name", AccountType AS "ACCOUNT TYPE", Territory AS "Account Territory", Currency, DocumentNumber AS "DOCUMENT #", RatePlanChargeType AS "RATE PLAN CHARGE TYPE", ReasonCode AS "REASON CODE", DocumentAmount AS "DOCUMENT AMOUNT", DocumentBalance AS "DOCUMENT Balance", DebitMemoBalance AS "Debit Memo Balance", CreditBalance AS "Credit Balance", UnappliedPayment AS "Unapplied Payment", OnAccountCreditMemo AS "On-Account Credit Memo", AccountBalance AS "Account Balance", Current, Days30 AS "1 to 30 days past due", Days60 AS "31 to 60 days past due", Days90 AS "61 to 90 days past due", Days120 AS "91 to 120 days past due", GreaterThan120 AS "more than 120 days past due" FROM AccountAgain, please ensure that the column names and table name are accurate based on your Zuora database schema.
- User
data query to get the these columns Account Name, ACCOUNT TYPE, Account Territory, Currency, DOCUMENT #, RATE PLAN CHARGE TYPE, REASON CODE, DOCUMENT AMOUNT, DOCUMENT Balance , Debit Memo Balance , Credit Balance, Unapplied Payment , On-Account Credit Memo , Account Balance , Current , 1 to 30 days past due, 31 to 60 days past due , 61 to 90 days past due , 91 to 120 days past due , more than 120 days past due and base object is InvoiceItem in zuora query should have joins between invoice, account and credit memo and how to achieve those last past due columns
- Assistant
To retrieve the mentioned columns from Zuora while joining the InvoiceItem, Invoice, Account, and CreditMemo tables and calculating the last past due columns, you can use the following query:
SELECT Acc.Name AS "Account Name", Acc.AccountType AS "ACCOUNT TYPE", Acc.Territory AS "Account Territory", Acc.Currency, II.DocumentNumber AS "DOCUMENT #", II.RatePlanChargeType AS "RATE PLAN CHARGE TYPE", II.ReasonCode AS "REASON CODE", II.DocumentAmount AS "DOCUMENT AMOUNT", II.DocumentBalance AS "DOCUMENT Balance", II.DebitMemoBalance AS "Debit Memo Balance", II.CreditBalance AS "Credit Balance", II.UnappliedPayment AS "Unapplied Payment", II.OnAccountCreditMemo AS "On-Account Credit Memo", II.AccountBalance AS "Account Balance", II.Current, (CASE WHEN II.Day0 > II.Day1 THEN II.Day0 ELSE II.Day1 END) AS "1 to 30 days past due", (CASE WHEN II.Day30 > II.Day60 THEN II.Day30 ELSE II.Day60 END) AS "31 to 60 days past due", (CASE WHEN II.Day60 > II.Day90 THEN II.Day60 ELSE II.Day90 END) AS "61 to 90 days past due", (CASE WHEN II.Day90 > II.Day120 THEN II.Day90 ELSE II.Day120 END) AS "91 to 120 days past due", (CASE WHEN II.Day120 > II.Day120 THEN II.Day120 ELSE II.GreaterThan120 END) AS "more than 120 days past due" FROM InvoiceItem II INNER JOIN Invoice I ON II.InvoiceId = I.Id INNER JOIN Account Acc ON I.AccountId = Acc.Id LEFT JOIN CreditMemo CM ON II.CreditMemoId = CM.Id - User
Invoice aging report using dataquery
- Assistant
To create an invoice aging report using Data Query in Zuora, you can use the following query:
SELECT Acc.Name AS "Account Name", Acc.AccountType AS "Account Type", Acc.Territory AS "Account Territory", Acc.Currency, I.InvoiceNumber AS "Invoice Number", I.InvoiceDate AS "Invoice Date", I.DueDate AS "Due Date", I.Amount AS "Invoice Amount", I.Status AS "Invoice Status", I.Amount - I.Balance AS "Paid Amount", I.Balance AS "Outstanding Balance", CASE WHEN I.DueDate < TO_DATE(CONVERT_TZ(CURRENT_TIME(),'UTC','America/Los_Angeles')) THEN I.Balance ELSE 0 END AS "Past Due Amount" FROM InvoiceSummary I INNER JOIN Account Acc ON I.AccountId = Acc.Id WHERE I.Status != 'Canceled' ORDER BY I.DueDateThis query retrieves information such as Account Name, Account Type, Account Territory, Currency, Invoice Number, Invoice Date, Due Date, Invoice Amount, Invoice Status, Paid Amount, Outstanding Balance, and Past Due Amount. It also includes a condition to exclude canceled invoices and sorts the results by Due Date.
Please note that the timezone used in the query is America/Los_Angeles. You may need to adjust the timezone according to your environment.