# Bill a business customer and collect on account

Issue the formal invoice for an order, take payments against the customer’s house account — applied oldest-first, always — and correct a bill with a credit or debit note; an issued invoice is never edited.

Pricing & money · a play in 5 steps.

## The steps

1. Issue the invoice for the order — a numbered financial document. — [issueInvoice](/reference/selling/issueInvoice/)
2. Take a payment against the house account — it applies to the oldest open charges first. — [arPay](/reference/selling/arPay/)
3. Issue a credit note — “we owe you” — against the invoice, and settle it into the house account. — [issueCreditNote](/reference/refunds-and-payment-corrections/issueCreditNote/), [settleCreditNoteToAr](/reference/refunds-and-payment-corrections/settleCreditNoteToAr/)
4. Issue a debit note — “you owe us more” — and settle it the same way. — [issueDebitNote](/reference/refunds-and-payment-corrections/issueDebitNote/), [settleDebitNoteToAr](/reference/refunds-and-payment-corrections/settleDebitNoteToAr/)
5. See who owes what and for how long — the 30/60/90 buckets — and one customer’s ledger. — [arAging](/reference/reading-your-records/arAging/), [arLedger](/reference/reading-your-records/arLedger/)

## The calls

Every operation this use case runs, in the order it first appears, with the request and the response its reference page shows.

### issueInvoice

[issueInvoice](/reference/selling/issueInvoice/) — mutation · Issue the invoice for an order — the formal bill.

**Example request**

```graphql
mutation ExampleIssueInvoice($input: IssueInvoiceInput!) {
  issueInvoice(input: $input) {
    id
    sysId
    type
    caption
    status
    parentId
    rootId
    createdAt
    updatedAt
    revisionNum
    revision
    orderId
    organizationId
    currency
    taxMode
    taxJurisdictionId
    paymentState
    fulfillmentState
    recognitionState
    subtotalMinor
    discountTotalMinor
    taxTotalMinor
    totalMinor
  }
}
```

Variables:

```json
{
  "input": {
    "caption": "Blue jeans",
    "orderId": "01900000-0000-7000-8000-f6d8263a0000"
  }
}
```

Send it with the envelope naming the version: `"extensions": {"at": {"version": {"name":"genesis","number":0}}}`.

**Example response**

```json
{
  "data": {
    "issueInvoice": {
      "id": "01900000-0000-7000-8000-37386ae00000",
      "sysId": "IN-EXMP-0000-000F",
      "type": "Invoice",
      "caption": "Blue jeans",
      "status": "issued",
      "parentId": "01900000-0000-7000-8000-065235280000",
      "rootId": "01900000-0000-7000-8000-a093dd800000",
      "createdAt": "2027-01-31T00:00:00.000Z",
      "updatedAt": "2027-01-31T00:00:00.000Z",
      "revisionNum": 1,
      "revision": "01900000-0000-7000-8000-b7960e180000",
      "orderId": "01900000-0000-7000-8000-f6d8263a0000",
      "organizationId": "01900000-0000-7000-8000-44b781470000",
      "currency": "USD",
      "taxMode": "exclusive",
      "taxJurisdictionId": "01900000-0000-7000-8000-3a64e3820000",
      "paymentState": "<payment state>",
      "fulfillmentState": "<fulfillment state>",
      "recognitionState": "<recognition state>",
      "subtotalMinor": 1,
      "discountTotalMinor": 1,
      "taxTotalMinor": 1,
      "totalMinor": 1
    }
  },
  "extensions": {
    "at": {
      "callId": "01EXAMPLE-CALL-ID",
      "version": {
        "requested": {
          "name": "genesis",
          "number": 0
        },
        "serviced": {
          "name": "genesis",
          "number": 0
        }
      }
    }
  }
}
```

### arPay

[arPay](/reference/selling/arPay/) — mutation · Take a payment against a customer’s house account.

**Example request**

```graphql
mutation ExampleArPay($input: ArPayInput!) {
  arPay(input: $input) {
    id
    sysId
    type
    caption
    status
    parentId
    rootId
    createdAt
    updatedAt
    revisionNum
    revision
    corporateCustomerId
    accountNumber
    paymentTerms
    customerPriceGroupId
    priceListId
    billToContactId
    shipToContactId
    code
    arBalanceMinor
    arCurrency
  }
}
```

Variables:

```json
{
  "input": {
    "orgCustomerId": "01900000-0000-7000-8000-ba56ff800000",
    "amountMinor": 1,
    "reason": "Correcting a miscount."
  }
}
```

Send it with the envelope naming the version: `"extensions": {"at": {"version": {"name":"genesis","number":0}}}`.

**Example response**

```json
{
  "data": {
    "arPay": {
      "id": "01900000-0000-7000-8000-37386ae00000",
      "sysId": "EC-EXMP-0000-000F",
      "type": "OrgCustomer",
      "caption": "Blue jeans",
      "status": "active",
      "parentId": "01900000-0000-7000-8000-065235280000",
      "rootId": "01900000-0000-7000-8000-a093dd800000",
      "createdAt": "2027-01-31T00:00:00.000Z",
      "updatedAt": "2027-01-31T00:00:00.000Z",
      "revisionNum": 1,
      "revision": "01900000-0000-7000-8000-b7960e180000",
      "corporateCustomerId": "01900000-0000-7000-8000-e09097190000",
      "accountNumber": "<account number>",
      "paymentTerms": "<payment terms>",
      "customerPriceGroupId": "01900000-0000-7000-8000-dfbf5aa40000",
      "priceListId": "01900000-0000-7000-8000-7844e9fb0000",
      "billToContactId": "01900000-0000-7000-8000-cd1d9f9e0000",
      "shipToContactId": "01900000-0000-7000-8000-abe45fdf0000",
      "code": "BJ-001",
      "arBalanceMinor": 1,
      "arCurrency": "<ar currency>"
    }
  },
  "extensions": {
    "at": {
      "callId": "01EXAMPLE-CALL-ID",
      "version": {
        "requested": {
          "name": "genesis",
          "number": 0
        },
        "serviced": {
          "name": "genesis",
          "number": 0
        }
      }
    }
  }
}
```

### issueCreditNote

[issueCreditNote](/reference/refunds-and-payment-corrections/issueCreditNote/) — mutation · Issue a credit note — a formal “we owe you” against an invoice.

**Example request**

```graphql
mutation ExampleIssueCreditNote($input: IssueCreditNoteInput!) {
  issueCreditNote(input: $input) {
    id
    sysId
    type
    caption
    status
    parentId
    rootId
    createdAt
    updatedAt
    revisionNum
    revision
    invoiceId
    orderId
    organizationId
    currency
    reason
    settlementState
    baseDeltaTotalMinor
    taxDeltaTotalMinor
    totalDeltaMinor
  }
}
```

Variables:

```json
{
  "input": {
    "caption": "Blue jeans",
    "invoiceId": "01900000-0000-7000-8000-504ef4ed0000",
    "reason": "Correcting a miscount.",
    "lines": [
      {
        "invoiceLineNo": 1,
        "amountMinor": 1
      }
    ]
  }
}
```

Send it with the envelope naming the version: `"extensions": {"at": {"version": {"name":"genesis","number":0}}}`.

**Example response**

```json
{
  "data": {
    "issueCreditNote": {
      "id": "01900000-0000-7000-8000-37386ae00000",
      "sysId": "CR-EXMP-0000-000F",
      "type": "CreditNote",
      "caption": "Blue jeans",
      "status": "issued",
      "parentId": "01900000-0000-7000-8000-065235280000",
      "rootId": "01900000-0000-7000-8000-a093dd800000",
      "createdAt": "2027-01-31T00:00:00.000Z",
      "updatedAt": "2027-01-31T00:00:00.000Z",
      "revisionNum": 1,
      "revision": "01900000-0000-7000-8000-b7960e180000",
      "invoiceId": "01900000-0000-7000-8000-504ef4ed0000",
      "orderId": "01900000-0000-7000-8000-f6d8263a0000",
      "organizationId": "01900000-0000-7000-8000-44b781470000",
      "currency": "USD",
      "reason": "Correcting a miscount.",
      "settlementState": "<settlement state>",
      "baseDeltaTotalMinor": 1,
      "taxDeltaTotalMinor": 1,
      "totalDeltaMinor": 1
    }
  },
  "extensions": {
    "at": {
      "callId": "01EXAMPLE-CALL-ID",
      "version": {
        "requested": {
          "name": "genesis",
          "number": 0
        },
        "serviced": {
          "name": "genesis",
          "number": 0
        }
      }
    }
  }
}
```

### settleCreditNoteToAr

[settleCreditNoteToAr](/reference/refunds-and-payment-corrections/settleCreditNoteToAr/) — mutation · Settle a credit note into the customer’s house account — the credit lands on their AR balance.

**Example request**

```graphql
mutation ExampleSettleCreditNoteToAr($input: SettleCreditNoteToArInput!) {
  settleCreditNoteToAr(input: $input) {
    id
    sysId
    type
    caption
    status
    parentId
    rootId
    createdAt
    updatedAt
    revisionNum
    revision
    invoiceId
    orderId
    organizationId
    currency
    reason
    settlementState
    baseDeltaTotalMinor
    taxDeltaTotalMinor
    totalDeltaMinor
  }
}
```

Variables:

```json
{
  "input": {
    "creditNoteId": "01900000-0000-7000-8000-0206baad0000",
    "expectedRevision": "01900000-0000-7000-8000-e02b2e6c0000",
    "reason": "Correcting a miscount."
  }
}
```

Send it with the envelope naming the version: `"extensions": {"at": {"version": {"name":"genesis","number":0}}}`.

**Example response**

```json
{
  "data": {
    "settleCreditNoteToAr": {
      "id": "01900000-0000-7000-8000-37386ae00000",
      "sysId": "CR-EXMP-0000-000F",
      "type": "CreditNote",
      "caption": "Blue jeans",
      "status": "issued",
      "parentId": "01900000-0000-7000-8000-065235280000",
      "rootId": "01900000-0000-7000-8000-a093dd800000",
      "createdAt": "2027-01-31T00:00:00.000Z",
      "updatedAt": "2027-01-31T00:00:00.000Z",
      "revisionNum": 1,
      "revision": "01900000-0000-7000-8000-b7960e180000",
      "invoiceId": "01900000-0000-7000-8000-504ef4ed0000",
      "orderId": "01900000-0000-7000-8000-f6d8263a0000",
      "organizationId": "01900000-0000-7000-8000-44b781470000",
      "currency": "USD",
      "reason": "Correcting a miscount.",
      "settlementState": "<settlement state>",
      "baseDeltaTotalMinor": 1,
      "taxDeltaTotalMinor": 1,
      "totalDeltaMinor": 1
    }
  },
  "extensions": {
    "at": {
      "callId": "01EXAMPLE-CALL-ID",
      "version": {
        "requested": {
          "name": "genesis",
          "number": 0
        },
        "serviced": {
          "name": "genesis",
          "number": 0
        }
      }
    }
  }
}
```

### issueDebitNote

[issueDebitNote](/reference/refunds-and-payment-corrections/issueDebitNote/) — mutation · Issue a debit note — a formal “you owe us more” against an invoice.

**Example request**

```graphql
mutation ExampleIssueDebitNote($input: IssueDebitNoteInput!) {
  issueDebitNote(input: $input) {
    id
    sysId
    type
    caption
    status
    parentId
    rootId
    createdAt
    updatedAt
    revisionNum
    revision
    invoiceId
    orderId
    organizationId
    currency
    reason
    settlementState
    baseDeltaTotalMinor
    taxDeltaTotalMinor
    totalDeltaMinor
  }
}
```

Variables:

```json
{
  "input": {
    "caption": "Blue jeans",
    "invoiceId": "01900000-0000-7000-8000-504ef4ed0000",
    "reason": "Correcting a miscount.",
    "lines": [
      {
        "invoiceLineNo": 1,
        "amountMinor": 1
      }
    ]
  }
}
```

Send it with the envelope naming the version: `"extensions": {"at": {"version": {"name":"genesis","number":0}}}`.

**Example response**

```json
{
  "data": {
    "issueDebitNote": {
      "id": "01900000-0000-7000-8000-37386ae00000",
      "sysId": "DN-EXMP-0000-000F",
      "type": "DebitNote",
      "caption": "Blue jeans",
      "status": "issued",
      "parentId": "01900000-0000-7000-8000-065235280000",
      "rootId": "01900000-0000-7000-8000-a093dd800000",
      "createdAt": "2027-01-31T00:00:00.000Z",
      "updatedAt": "2027-01-31T00:00:00.000Z",
      "revisionNum": 1,
      "revision": "01900000-0000-7000-8000-b7960e180000",
      "invoiceId": "01900000-0000-7000-8000-504ef4ed0000",
      "orderId": "01900000-0000-7000-8000-f6d8263a0000",
      "organizationId": "01900000-0000-7000-8000-44b781470000",
      "currency": "USD",
      "reason": "Correcting a miscount.",
      "settlementState": "<settlement state>",
      "baseDeltaTotalMinor": 1,
      "taxDeltaTotalMinor": 1,
      "totalDeltaMinor": 1
    }
  },
  "extensions": {
    "at": {
      "callId": "01EXAMPLE-CALL-ID",
      "version": {
        "requested": {
          "name": "genesis",
          "number": 0
        },
        "serviced": {
          "name": "genesis",
          "number": 0
        }
      }
    }
  }
}
```

### settleDebitNoteToAr

[settleDebitNoteToAr](/reference/refunds-and-payment-corrections/settleDebitNoteToAr/) — mutation · Settle a debit note into the customer’s house account — the charge lands on their AR balance.

**Example request**

```graphql
mutation ExampleSettleDebitNoteToAr($input: SettleDebitNoteToArInput!) {
  settleDebitNoteToAr(input: $input) {
    id
    sysId
    type
    caption
    status
    parentId
    rootId
    createdAt
    updatedAt
    revisionNum
    revision
    invoiceId
    orderId
    organizationId
    currency
    reason
    settlementState
    baseDeltaTotalMinor
    taxDeltaTotalMinor
    totalDeltaMinor
  }
}
```

Variables:

```json
{
  "input": {
    "debitNoteId": "01900000-0000-7000-8000-f2e485a00000",
    "expectedRevision": "01900000-0000-7000-8000-e02b2e6c0000",
    "reason": "Correcting a miscount."
  }
}
```

Send it with the envelope naming the version: `"extensions": {"at": {"version": {"name":"genesis","number":0}}}`.

**Example response**

```json
{
  "data": {
    "settleDebitNoteToAr": {
      "id": "01900000-0000-7000-8000-37386ae00000",
      "sysId": "DN-EXMP-0000-000F",
      "type": "DebitNote",
      "caption": "Blue jeans",
      "status": "issued",
      "parentId": "01900000-0000-7000-8000-065235280000",
      "rootId": "01900000-0000-7000-8000-a093dd800000",
      "createdAt": "2027-01-31T00:00:00.000Z",
      "updatedAt": "2027-01-31T00:00:00.000Z",
      "revisionNum": 1,
      "revision": "01900000-0000-7000-8000-b7960e180000",
      "invoiceId": "01900000-0000-7000-8000-504ef4ed0000",
      "orderId": "01900000-0000-7000-8000-f6d8263a0000",
      "organizationId": "01900000-0000-7000-8000-44b781470000",
      "currency": "USD",
      "reason": "Correcting a miscount.",
      "settlementState": "<settlement state>",
      "baseDeltaTotalMinor": 1,
      "taxDeltaTotalMinor": 1,
      "totalDeltaMinor": 1
    }
  },
  "extensions": {
    "at": {
      "callId": "01EXAMPLE-CALL-ID",
      "version": {
        "requested": {
          "name": "genesis",
          "number": 0
        },
        "serviced": {
          "name": "genesis",
          "number": 0
        }
      }
    }
  }
}
```

### arAging

[arAging](/reference/reading-your-records/arAging/) — query · The aging report — who owes what, and for how long (30/60/90 buckets).

**Example request**

```graphql
query ExampleArAging($orgCustomerId: ID!) {
  arAging(orgCustomerId: $orgCustomerId) {
    orgCustomerId
    asOf
    arCurrency
    arBalanceMinor
  }
}
```

Variables:

```json
{
  "orgCustomerId": "01900000-0000-7000-8000-ba56ff800000"
}
```

**Example response**

```json
{
  "data": {
    "arAging": {
      "orgCustomerId": "01900000-0000-7000-8000-ba56ff800000",
      "asOf": "<as of>",
      "arCurrency": "<ar currency>",
      "arBalanceMinor": 1
    }
  },
  "extensions": {
    "at": {
      "callId": "01EXAMPLE-CALL-ID",
      "version": {
        "requested": null,
        "serviced": {
          "name": "genesis",
          "number": 0
        }
      }
    }
  }
}
```

### arLedger

[arLedger](/reference/reading-your-records/arLedger/) — query · A customer’s house-account ledger — every charge and payment, in order.

**Example request**

```graphql
query ExampleArLedger($orgCustomerId: ID!, $from: String) {
  arLedger(orgCustomerId: $orgCustomerId, from: $from) {
    items {
      id
      parentId
      entryType
      amountMinor
      currency
      dueAt
      reason
      orderId
      tenderId
      returnId
      creditNoteId
      debitNoteId
      caption
      createdAt
    }
    nextToken
  }
}
```

Variables:

```json
{
  "orgCustomerId": "01900000-0000-7000-8000-ba56ff800000",
  "from": "<from>"
}
```

**Example response**

```json
{
  "data": {
    "arLedger": {
      "items": [
        {
          "id": "01900000-0000-7000-8000-37386ae00000",
          "parentId": "01900000-0000-7000-8000-065235280000",
          "entryType": "charge",
          "amountMinor": 1,
          "currency": "USD",
          "dueAt": "2027-01-31T00:00:00.000Z",
          "reason": "Correcting a miscount.",
          "orderId": "01900000-0000-7000-8000-f6d8263a0000",
          "tenderId": "01900000-0000-7000-8000-0ae1978a0000",
          "returnId": "01900000-0000-7000-8000-4d4c03d20000",
          "creditNoteId": "01900000-0000-7000-8000-0206baad0000",
          "debitNoteId": "01900000-0000-7000-8000-f2e485a00000",
          "caption": "Blue jeans",
          "createdAt": "2027-01-31T00:00:00.000Z"
        }
      ],
      "nextToken": "<the cursor from the previous page>"
    }
  },
  "extensions": {
    "at": {
      "callId": "01EXAMPLE-CALL-ID",
      "version": {
        "requested": null,
        "serviced": {
          "name": "genesis",
          "number": 0
        }
      }
    }
  }
}
```
