User Tools

Site Tools


webapi:examples:invoice

How to add an invoice sample

Use this as an example of how to use the Invoice/addInvoice end point to create an invoice in System Five. Take note of the sample JSON and the fields being passed. Review how customers work.

With all end points, the best practice is to only send the nodes that have data. Do not pass empty values. In respect to the addInvoice end point, do not pass information for InvoiceBilling and InvoiceShipping if you do not have data.

The example below shows required JSON to insert an Invoice when you know the Customer ID using the AddInvoice

Assumptions:

  • The InvoiceCustomer value is confirmed as an actual Unique Record ID in the data.
  • The PartUnique values are confirmed as actual Inventory Record IDs in the data.
  • The Tax Amount matches the Tax amounts for the Ship To jurisdiction, as configured in System Five.
  • There is a valid Payment Type in System Five for the ‘W’ InvoiceType in the JSON file.

Common InvoiceType's in a System Five installation

  • “E” Estimate (Unposted and does not do accounting, stock control and cannot have payments)
  • “W” Work Order (Unposted and does not do accounting, stock control is typically reserving inventory depending on settings and supports payments)
  • “A” Accounts Receivable (Completed invoice type which requires a customer. Accounting and stock control finalized)
  • “C” Cash Transactions (Completed invoice type which does not require a customer. Accounting and stock control finalized)

JSON Invoice sample with CustomerUnique from how customers work. Note that InvoiceBilling is not completed.

{
  "Invoice": [
    {
      "InvoiceHeader": {
        "InvoiceSubTotal": 131,
        "InvoiceTaxTotal": 0,
        "InvoiceOrdered": "2020-01-09T22:10:46.416Z",
        "InvoiceDate": "2020-01-09T22:10:46.416Z",
                "InvoiceType": "W",
                "InvoiceSubType": "H",
        "InvoiceDepartment": 1,
        "InvoiceBookMonth": "2020-01-09T22:10:46.416Z",
        "InvoiceCustomer": 31649,
        "InvoiceShipTo": 31649,
        "InvoiceSalesman": 1,
        "ReferenceNo": "000000006"
      },
      "InvoiceTenders": [
        {
          "Type": "W",
          "Amount": 131
        }
      ],
      "InvoiceLines": [
        {
          "PartUnique": 18220,
          "Ordered": 2,
          "Price": 39
        },
        {
          "PartUnique": 19569,
          "Ordered": 1,
          "Price": 28
        },
        {
          "PartUnique": 5941,
          "Ordered": 1,
                  "Description": " Date: 5/24/2019 5:50:11 PM",
          "Price": 22
        }
     ]
    }
  ],
  "ConnectionInfo": {
    "TerminalNumber": 1
  }
}

JSON Invoice sample with customer information entered into InvoiceBilling which will create a new customer. No need to use /Inser_Retail_customer or /Update_retail_Customer. Note that the InvoiceCustomer field is missing as we are not providing an existing customer.

{
  "Invoice": [
    {
      "InvoiceHeader": {
        "InvoiceSubTotal": "35.99",
        "InvoiceTaxTotal": "6",
        "InvoiceOrdered": "2019-11-21",
        "InvoiceDate": "2019-11-21",
        "InvoiceType": "W",
        "InvoiceSubType": "H",
        "InvoiceDepartment": "1",
        "InvoiceBookMonth": "2019-11-21",
        "ReferenceNo": "000000038"
      },
      "InvoiceLines": [
        {
          "PartUnique": "14252",
          "Ordered": "1",
          "Price": "35.99"
        },
        {
          "PartUnique": "5941",
          "Ordered": "1",
          "Description": " Date: 11/21/2019 4:47:11 PM",
          "Price": "14"
        }
      ],
      "InvoiceTenders": [
        {
          "Type": "W",
          "Amount": "55.99"
        }
      ],
      "InvoiceBilling": {
        "AName": "Michelle MaBelle",
        "FirstName": "Michelle",
        "LastName": "MaBelle",
        "Address": "123 some St.",
        "City": "Nowhereville",
        "StateProvince": "BC",
        "Country": "CA",
        "ZipPostal": "V2A 1Z0"
      }
    }
  ],
  "ConnectionInfo": {
    "TerminalNumber": 0
  }
}

Another JSON Invoice sample without customer information entered into InvoiceBilling and using the InvoiceCustomer 125999.

{
  "Invoice": [
    {
      "InvoiceHeader": {
        "InvoiceSubTotal": "35.99",
        "InvoiceTaxTotal": "6",
        "InvoiceOrdered": "2019-11-21",
        "InvoiceDate": "2019-11-21",
        "InvoiceType": "W",
        "InvoiceSubType": "H",
        "InvoiceDepartment": "1",
        "InvoiceBookMonth": "2019-11-21",
        "InvoiceCustomer": "125999",
        "ReferenceNo": "000000038"
      },
      "InvoiceLines": [
        {
          "PartUnique": "14252",
          "Ordered": "1",
          "Price": "35.99"
        },
        {
          "PartUnique": "5941",
          "Ordered": "1",
          "Description": " Date: 11/21/2019 4:47:11 PM",
          "Price": "14"
        }
      ],
      "InvoiceTenders": [
        {
          "Type": "W",
          "Amount": "55.99"
        }
      ]
    }
  ],
  "ConnectionInfo": {
    "TerminalNumber": 0
  }
}

Back to WebAPI Samples

webapi/examples/invoice.txt · Last modified: 2020/02/10 12:11 (4 years ago) by kevin