Options

Create Invoice with multiple items on it and edit quantity via API

AcolyteJonathanAcolyteJonathan Member Posts: 5

Hopefully, this is a simple answer but I would like to create an invoice with multiple items using the WaveAPI. So far, I have figured out how to create a blank invoice, with one item and for a particular customer. But I am unable to figure out how to change the quality/price of the item and create multiple items for the invoice. Surely this is an easy adjustment to the mutation?

Comments

  • Options
    RobVGRobVG Member Posts: 53 admin

    Hi @AcolyteJ,

    I will try to use this example with some additional inputs provided.

    Mutation:

    mutation CreateInvoice ($input: InvoiceCreateInput!) {
      invoiceCreate(input: $input) {
        didSucceed
        inputErrors {
          message
          code
          path
        }
        invoice {
          id
          createdAt
          modifiedAt
          status
          invoiceNumber
          invoiceDate
          poNumber
          customer {
            id
            name
            # Can add additional customer fields here
          }
          currency {
            code
          }
          dueDate
          amountDue {
            value
            currency {
              symbol
            }
          }
          amountPaid {
            value
            currency {
              symbol
            }
          }
          taxTotal {
            value
            currency {
              symbol
            }
          }
          total {
            value
            currency {
              symbol
            }
          }
          items {
            product {
              id
              name
              # Can add additional product fields here
            }
            description
            quantity
            price
            subtotal {
              value
              currency {
                symbol
              }
            }
            total {
              value
              currency {
                symbol
              }
            }
            account {
              id
              name
              subtype {
                name
                value
              }
              # Can add additional account fields here
            }
            taxes {
              amount {
                value
              }
              salesTax {
                id
                name
                # Can add additional sales tax fields here
              }
            }
          }
          lastSentAt
          lastSentVia
          lastViewedAt
        }
      }
    }
    

    Variables (where items is an array):

    {
      "input": {
        "businessId": "QnVzaW5lc3M6N2FmMWNmYjgtOGE4MC00M2Y1LWExM2QtMzBjNzM4MzkzNGI3",
        "customerId": "QnVzaW5lc3M6N2FmMWNmYjgtOGE4MC00M2Y1LWExM2QtMzBjNzM4MzkzNGI3O0N1c3RvbWVyOjMwODAwMDkx",
        "items": [
          {
            "productId": "QnVzaW5lc3M6N2FmMWNmYjgtOGE4MC00M2Y1LWExM2QtMzBjNzM4MzkzNGI3O1Byb2R1Y3Q6MzQyNzk5Nzk=",
            "description": "A19 non-dimmable",
            "quantity": "12",
            "unitPrice": "2.99"
          },
          {
            "productId": "QnVzaW5lc3M6N2FmMWNmYjgtOGE4MC00M2Y1LWExM2QtMzBjNzM4MzkzNGI3O1Byb2R1Y3Q6MzM3NjYzMzE=",
            "description": "Pack of 12",
            "quantity": "1",
            "unitPrice": "4.99"
          }
        ]
      }
    }
    

    Example output:

    {
      "data": {
        "invoiceCreate": {
          "didSucceed": true,
          "inputErrors": null,
          "invoice": {
            "id": "QnVzaW5lc3M6N2FmMWNmYjgtOGE4MC00M2Y1LWExM2QtMzBjNzM4MzkzNGI3O0ludm9pY2U6OTEzMzM4MDUxNjI1NzYyOTI3",
            "createdAt": "2019-03-21T13:38:12.000Z",
            "modifiedAt": "2020-04-14T22:10:14.285Z",
            "status": "DRAFT",
            "invoiceNumber": "206",
            "invoiceDate": "2020-04-14",
            "poNumber": "",
            "customer": {
              "id": "QnVzaW5lc3M6N2FmMWNmYjgtOGE4MC00M2Y1LWExM2QtMzBjNzM4MzkzNGI3O0N1c3RvbWVyOjMwODAwMDkx",
              "name": "Smith Consulting"
            },
            "currency": {
              "code": "USD"
            },
            "dueDate": "2020-04-14",
            "amountDue": {
              "value": "40.87",
              "currency": {
                "symbol": "$"
              }
            },
            "amountPaid": {
              "value": "0.00",
              "currency": {
                "symbol": "$"
              }
            },
            "taxTotal": {
              "value": "0.00",
              "currency": {
                "symbol": "$"
              }
            },
            "total": {
              "value": "40.87",
              "currency": {
                "symbol": "$"
              }
            },
            "items": [
              {
                "product": {
                  "id": "QnVzaW5lc3M6N2FmMWNmYjgtOGE4MC00M2Y1LWExM2QtMzBjNzM4MzkzNGI3O1Byb2R1Y3Q6MzQyNzk5Nzk=",
                  "name": "LED Bulb"
                },
                "description": "A19 non-dimmable",
                "quantity": "12",
                "price": "2.99",
                "subtotal": {
                  "value": "35.88",
                  "currency": {
                    "symbol": "$"
                  }
                },
                "total": {
                  "value": "35.88",
                  "currency": {
                    "symbol": "$"
                  }
                },
                "account": {
                  "id": "QWNjb3VudDo2Mzk3MjU3Mjc5MTQxODIzMTc7QnVzaW5lc3M6N2FmMWNmYjgtOGE4MC00M2Y1LWExM2QtMzBjNzM4MzkzNGI3",
                  "name": "Sales",
                  "subtype": {
                    "name": "Income",
                    "value": "INCOME"
                  }
                },
                "taxes": []
              },
              {
                "product": {
                  "id": "QnVzaW5lc3M6N2FmMWNmYjgtOGE4MC00M2Y1LWExM2QtMzBjNzM4MzkzNGI3O1Byb2R1Y3Q6MzM3NjYzMzE=",
                  "name": "AAA Batteries"
                },
                "description": "Pack of 12",
                "quantity": "1",
                "price": "4.99",
                "subtotal": {
                  "value": "4.99",
                  "currency": {
                    "symbol": "$"
                  }
                },
                "total": {
                  "value": "4.99",
                  "currency": {
                    "symbol": "$"
                  }
                },
                "account": {
                  "id": "QWNjb3VudDo2Mzk3MjU3Mjc5MTQxODIzMTc7QnVzaW5lc3M6N2FmMWNmYjgtOGE4MC00M2Y1LWExM2QtMzBjNzM4MzkzNGI3",
                  "name": "Sales",
                  "subtype": {
                    "name": "Income",
                    "value": "INCOME"
                  }
                },
                "taxes": []
              }
            ],
            "lastSentAt": null,
            "lastSentVia": "NOT_SENT",
            "lastViewedAt": null
          }
        }
      }
    }
    

    Hopefully that can help set you on the right path :smiley:

  • Options
    AcolyteJonathanAcolyteJonathan Member Posts: 5

    @RobVG This is it! Thank you so much!

  • Options
    Azad_MohamedAzad_Mohamed Member Posts: 3

    @RobVG Is there any way to get last payment date along

Sign In or Register to comment.