A sales receipt in QuickBooks Desktop is a record of a sale to a customer, such as a payment by cash, check, or credit card. Each sales receipt has several line items, which are the products or services sold.

To see all of the request parameters and response fields for , check out our client library’s amazing autocomplete.

Fetching sales receipts

The following example fetches all sales receipts for the specified EndUser, including the line items:

Fetching all sales receipts with line items
const salesReceipts = await conductor.qbd.salesReceipt.query(
  "{{END_USER_ID}}",
  { IncludeLineItems: true },
);

Creating sales receipts

To create a sales receipt in QuickBooks Desktop from scratch, you either need the identifiers (e.g., ListID) of the required associated objects, or you must create the associated objects first.

The following example uses mock data to create a sales receipt in QuickBooks Desktop, which also requires creating a mock customer, account, and service-item using the add() method of each object. The add() method returns the created object, which contains the ListID identifier to associate the objects with each other.

Creating a sales receipt
const END_USER_ID = "{{END_USER_ID}}";
// Use unique names for mock objects because QBD requires each to be unique.
const UNIQUE_SUFFIX = Math.random().toFixed(6);

const customer = await conductor.qbd.customer.add(END_USER_ID, {
  Name: `Test Customer ${UNIQUE_SUFFIX}`,
});

// A sales receipt cannot be empty, so we must create an item to add to the
// sales receipt, and every item requires an account, which we create first.
const account = await conductor.qbd.account.add(END_USER_ID, {
  Name: `Test Income Account ${UNIQUE_SUFFIX}`,
  AccountType: "Income",
});

// Create a service-item for the sales receipt with the account we just created.
const serviceItem = await conductor.qbd.itemService.add(END_USER_ID, {
  Name: `Construction Work ${UNIQUE_SUFFIX}`,
  SalesOrPurchase: {
    Price: "100.00",
    AccountRef: {
      ListID: account.ListID,
    },
  },
});

const salesReceipt = await conductor.qbd.salesReceipt.add(END_USER_ID, {
  CustomerRef: {
    ListID: customer.ListID,
  },
  SalesReceiptLineAdd: [
    {
      Quantity: 5,
      ItemRef: {
        ListID: serviceItem.ListID,
      },
    },
  ],
});