FD1 Client Protocol
 
Library Developer Home FD1 Client Protocol Home Concepts Reading Data Writing Data Protocol Defined Servers Connect & Authenticate Proxies & Tunnels
Webhooks & Firehoses Programming Support Logging Minor Facts State Facts Response Format How To Guides eCommerce Sites Custom Point of Sale Customer Access Bulk Downloads Major APIs / Endpoints All Endpoints Products Sales SalesBuilder Session Get Attribute Sale Capture General Purpose Data Capture Devices Barcode Scanners Eftpos IoT Sensors Power Outlets Printing Scales Security Cameras Purchasing / Supply Side Purchase Orders Invoices Invoice Payments Document Capture Rare APIs / Endpoints SSL Certificates API Key Management Diagnositics PosGreen Server to Client Messages Overview Resources / Objects Purchase Order Invoice Payable Invoice Payment Product Supplier Location Sale Lines Sale Delivery Details Sales Price Maps Employees Carriers Payments Product Kits Department 1 Customers

Get Purchase Orders Header

Example

POST /fd1/purchaseorders/get_purchaseorder_header
{
  "a": "purchaseorders.get_purchaseorder_header",
  "q": {
    "cust_ponum": 12345
  }
}
Or
GET /fd1/purchaseorders/get_purchaseorder_header?cust_ponum=12345

Example - Fetching with Additional Details

The following query requests a purchase order header, and additional supporting information. This is done via a "qo" parameter defining the return object structure

POST /fd1/purchaseorders/get_purchaseorder_header
{
  "a": "purchaseorders.get_purchaseorder_header",
  "q": {
    "cust_ponum": 12345
  },
  "qo": {
    "spid": true,
    "physkey": true,
    "entrydt": true,
    "ship_to_location": true,
    "storename": "ship_to_location.name",
    "supplier": {
        "name": "supplier.name",
        "myob_externalid": "supplier.myob_externalid",
        "gst": "supplier.gst"
    },
    "indispute": "purchaseorder.indispute.count",
    "approvedtopay": "purchaseorder.approvedtopay",
    "received_using_pocost": "purchaseorder.received.value.pocost"
  }
}
Or using a GET
// Define the structure we want
let qo = {
    spid: true,
    physkey: true,
    entrydt: true,
    ship_to_location: true,
    storename: "ship_to_location.name",
    supplier: {
        name: "supplier.name",
        myob_externalid: "supplier.myob_externalid",
        gst: "supplier.gst"
    },
    indispute: "purchaseorder.indispute.count",
    approvedtopay: "purchaseorder.approvedtopay",
    received_using_pocost: "purchaseorder.received.value.pocost"
}

// convert that to a URI query string. 
const urifmt = encodeURIComponent(JSON.stringify(qo));

// Do the query
// The "urifmt" is technically a constant string, so you can simply enter the value, but creating an object first
// can make development clearer.  Your decision.
fetch("/fd1/purchaseorders/get_purchaseorder_header?cust_ponum=12345&_qo="+urifmt).then(....)

When run, the response should look as follows. Note that "rows" is always an array, even for known single value responses.

{
  data: {
    rows: [
        {
            spid: 12345,
            physkey: "KLKIRIU383BN9284HGNNB3DDE",
            entrydt: "2023-08-06 14:53:26",
            ship_to_location: 4,
            storename: "Seatoun Main Street",
            supplier: {
                name: "Acme Widgets",
                myob_externalid: "U9DG28374GFHF86",
                gst: "123-456-789"
            },
            indispute: 1,
            approvedtopay: 516.85,
            received_using_pocost: 827.14
        }    
    ]
  }
}