Table of Contents

Explanation of SQL

To export the APs to Quickbooks requires two queries to be run, saved, and imported.

Risk of Data Corruption if Run Improperly

None. This is a selection query and no data is modified in Cyrious in the running of it.

SQL

Vendors with Open Bills

SELECT Account.CompanyName AS [Vendor], 
       Bill.BillNumber AS [Bill NUMBER],  
       Bill.PONumber AS [Reference NUMBER], 
       Bill.DueDate AS [Due DATE], 
       Bill.OrderCreatedDate AS [Bill DATE], 
       Bill.SaleDate AS [Invoice DATE], 
       Bill.BalanceDue AS [Balance Due],
       Account.AccountNumber AS [Company NUMBER]
FROM TransHeader Bill
LEFT JOIN Account ON Bill.AccountID = Account.ID
WHERE TransactionType=8 AND StatusID = 6

Open Bills

SELECT Account.CompanyName AS [Vendor],
       Account.AccountNumber AS [Company NUMBER],
       Address.FormattedText AS [Address],
       COALESCE(PC.FirstName + ' ' + PC.LastName, '') AS [Contact],
       COALESCE(PC.PrimaryNumber, Account.PrimaryNumber, '') AS [Phone NUMBER],
       COALESCE(PC.SecondaryNumber, Account.SecondaryNumber, '') AS [Fax NUMBER],
       (SELECT SUM(BalanceDue) FROM TransHeader Bill WHERE TransactionType=8 AND StatusID = 6 AND Bill.AccountID = Account.ID) AS [Balance Outstanding]
FROM Account
LEFT JOIN Address ON Account.BillingAddressID = Address.ID
LEFT JOIN AccountContact PC ON Account.PrimaryContactID = PC.ID
WHERE Account.ID IN (SELECT AccountID FROM TransHeader WHERE TransactionType=8 AND StatusID = 6)

Version Information