7. Using cliqo With QuickBooks Online and PowerShell

You can use cliqo with PowerShell to automate many tasks in QuickBooks online. Here, we will discuss a few of the more common tasks, including:

7.1. Creating Invoices With cliqo and PowerShell

The following example demonstrates how to create a new invoice:

PS c:\cliqo> .\cliqo new invoice new_invoice.json
Invoice created with id 171

And here’s the new_invoice.json supplied to the new command above:

{
    "CustomerRef": {
        "name": "Amy's Bird Sanctuary",
        "type": "",
        "value": "1"
    },
    "Line": [
        {
            "Amount": 100.0,
            "Description": "Weekly Gardening Service",
            "DetailType": "SalesItemLineDetail",
            "Id": "1",
            "LineNum": 1,
            "SalesItemLineDetail": {
                "ItemRef": {
                    "name": "Gardening",
                    "type": "",
                    "value": "6"
                },
                "Qty": 4,
                "ServiceDate": "",
                "TaxCodeRef": {
                    "name": "",
                    "type": "",
                    "value": "TAX"
                },
                "TaxInclusiveAmt": 0,
                "UnitPrice": 25
            }
        }
    ]
}

Tip: In order to create your JSON input for the new command, we recommend first creating a sample of your new record using the QuickBooks Online web interface. then use the get command to show the JSON, as follows:

PS c:\cliqo> .\cliqo --format=json --fields=all get customer 1
{
    "Active": true,
    "Balance": 1086.0,
    "BalanceWithJobs": 1086.0,
    "BillAddr": {
        "City": "Bayside",
        "Country": "",
        "CountrySubDivisionCode": "",
        "Id": "99",
        "Lat": "",
        "Line1": "101 Ocean View",
        "Line2": "Suite 400",
        "Line3": "",
        "Line4": "",
        "Line5": "",
        "Long": "",
        "Note": "",
        "PostalCode": "11360"
    },
    "BillWithParent": false,
    "CompanyName": "Amy's Bird Sanctuary",
    "CurrencyRef": {
        "name": "United States Dollar",
        "type": "",
        "value": "USD"
    },
    "DefaultTaxCodeRef": {
        "name": "",
        "type": "",
        "value": "2"
    },
    "DisplayName": "Amy's Bird Sanctuary",
    "FamilyName": "Lauterbach",
    "FullyQualifiedName": "Amy's Bird Sanctuary",
    "GivenName": "Amy",
    "Id": "1",
    "Job": false,
    "Level": 0,
    "MetaData": {
        "CreateTime": "2017-08-30T16:48:43-07:00",
        "LastUpdatedTime": "2021-03-04T11:02:44-08:00"
    },
    "MiddleName": "",
    "Notes": "",
    "OpenBalanceDate": "",
    "PreferredDeliveryMethod": "Print",
    "PrimaryEmailAddr": {
        "Address": "Birds@Intuit.com"
    },
    "PrimaryPhone": {
        "FreeFormNumber": "(650) 555-3311"
    },
    "PrimaryTaxIdentifier": "",
    "PrintOnCheckName": "Amy's Bird Sanctuary",
    "ResaleNum": "",
    "ShipAddr": {
        "City": "Bayshore",
        "Country": "",
        "CountrySubDivisionCode": "CA",
        "Id": "97",
        "Lat": "",
        "Line1": "4581 Finch St.",
        "Line2": "",
        "Line3": "",
        "Line4": "",
        "Line5": "",
        "Long": "",
        "Note": "",
        "PostalCode": "94326"
    },
    "Suffix": "",
    "SyncToken": "3",
    "Taxable": true,
    "Title": "",
    "domain": "QBO",
    "sparse": false
}

7.2. Creating Accounts With cliqo and PowerShell

Instead of creating a file with the JSOn content, we can pass the JSOn directly to cliqo. In the example below, we first create a PowerShell object representing our new general ledger account. We then convert to JSON and escape quotation marks. And finally call cliqo to create our new account.

# Create new QuickBooks Online customer info with PowerShell

$account = @{
    Name = "Customer Deposits - New York";
    AccountType = "Other Current Liability";
    AccountSubType = "OtherCurrentLiabilities";
} | 
ConvertTo-JSON -compress
$account = $account -replace '"', '\"'
.\cliqo new account $account

7.3. Printing Invoices With cliqo and PowerShell

The following example demonstrates how to download invoice with id 103.

PS c:\cliqo> .\cliqo print invoice 103 invoice_103.pdf
Invoice printed with id 103 to invoice_103.pdf

Note: the id is not the same as the invoice number. To get the Id for a given invoice number (DocNumber), perform a select query like this:

PS c:\cliqo> .\cliqo select invoice --where "DocNumber = '1033'"
103     Geeta Kalapatapu        629.1

7.4. Running Reports With cliqo and PowerShell

The following example demonstrates how to run an Accounts Receivable Aging report:

PS c:\cliqo> .\cliqo report ar
Aged Receivables
2021-03-04
Printed 2021-03-04 11:01:29-08:00

        Current 1 - 30  31 - 60 61 - 90 91 and over     Total
Amy's Bird Sanctuary    200.00          100.00          786.00  1086.00
Bill's Windsurf Shop                                    85.00   85.00
Freeman Sporting Goods                                          0.00
 0969 Ocean View Road                                   477.50  477.50
 55 Twin Lane                                   85.00   85.00
Total Freeman Sporting Goods    0.00    0.00    0.00    0.00    562.50  562.50
Geeta Kalapatapu                                        629.10  629.10
Jeff's Jalopies                                 81.00   81.00
John Melton                                     450.00  450.00
Kookies by Kathy                                        75.00   75.00
Mark Cho                                        314.28  314.28
Paulsen Medical Supplies                                        954.75  954.75
Red Rock Diner                                  226.00  226.00
Rondonuwu Fruit and Vegi                                        78.60   78.60
Shara Barnett                                           0.00
 Barnett Design                                 274.50  274.50
Total Shara Barnett     0.00    0.00    0.00    0.00    274.50  274.50
Sonnenschein Family Store                                       362.07  362.07
Sushi by Katsuyuki                                      160.00  160.00
Travis Waldron                                  414.72  414.72
Weiskopf Consulting                                     375.00  375.00
TOTAL   200.00  0.00    100.00  0.00    5828.52 6128.52

7.5. Extracting Data With cliqo and PowerShell

The following PowerShell commands can be used to retrieve customer with Id 1 and display its name and balance:

# Get QuickBooks Online customer info with PowerShell

$customer = .\cliqo --format=json get customer 1 | ConvertFrom-JSON
Write-Host $customer.FullyQualifiedName
Write-Host $customer.Balance