post https://secure.fusebill.com/v1/purchases/split
This call is only relevant for a purchase which is tracking items and using target order quantity. It is used to split a draft purchase into two draft purchases, one of which will be ready for finalization.
For example, If the quantity
of a purchase is 12, and the targetOrderQuantity
is 14, then this call can split the purchase into two objects. The one with quantity
12 will have targetOrderQuantity
12, and the new purchase will have quantity
0, and targetOrderQuantity
2. This keeps track of the two unfulfilled tracked items.
Request Parameters
Property | Type | Description | Required |
---|---|---|---|
purchaseId | Integer | The Fusebill generated ID of the purchase | Yes |
dontSplit | Boolean | If true, the target order quantity is simply set to the quantity, and no new purchase is created. If false, a new purchase is created with the target order quantity set to the unfulfilled quantity | Optional. False by default |
Examples
curl -X POST "https://secure.fusebill.com/v1/Purchases/split" \
-H "Content-Type: application/json" \
-H "Authorization: Basic {APIKey}" \
-d "{purchaseId:12345}"
//Json Payload
string jsonData = "{purchaseId:123456}";
//Setup API key
string apiKey = "{APIKey}";
//Configure URI
WebRequest request = WebRequest.Create("HTTPS://secure.fusebill.com/v1/Purchases/split");
//Add Content type
request.ContentType = "application/json";
//Add Api key authorization
request.Headers.Add(HttpRequestHeader.Authorization, "Basic " + apiKey);
//Set request method
request.Method = "POST";
//Add the json data to request
using (var streamWriter = new StreamWriter(request.GetRequestStream()))
{
streamWriter.Write(jsonData);
streamWriter.Flush();
streamWriter.Close();
}
//Perform the request
var httpResponse = (HttpWebResponse)request.GetResponse();
//Record the response from our request
var result = "";
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
result = streamReader.ReadToEnd();
}
#Import library JSON
import json
#Import library Requests
import requests
#Pass in a dictionary to the Headers parameter
headers = {'Authorization' : 'Basic {APIKey}', 'Content-Type' : 'application/json'}
#Pass in a dictionary to the Payload parameter
payload = {"purchaseId":555846}
#Pass in your URI, Payload and Headers
r = requests.post('https://secure.fusebill.com/v1/Purchases/split',
data=json.dumps(payload), headers=headers)
print(r.content)
{
"purchaseId": 123456
}
Response
{
"originalPurchase": {
"customerId": 16177079,
"code": "trackedSerial",
"effectiveTimestamp": "2020-09-16T18:51:13",
"taxableAmount": 2.000000,
"amount": 2.000000,
"modifiedTimestamp": "2020-09-16T18:51:31.132369Z",
"salesforceId": null,
"netsuiteLocationId": "12",
"productId": 25188589,
"name": "trackedSerial",
"description": null,
"status": "Draft",
"quantity": 1.000000,
"targetOrderQuantity": 1.000000,
"isTrackingItems": true,
"pricingModelType": "Standard",
"customFields": [],
"discounts": [],
"priceRanges": [
{
"min": 0.000000,
"max": null,
"amount": 2.000000,
"conditionAmount": null,
"variableAmount": null
}
],
"productItems": [
{
"reference": "123456789",
"name": "someName",
"description": "someDescription",
"purchaseId": 2058207,
"customerId": 16177079,
"productId": 25188589,
"status": "Active",
"createdDate": "2020-09-16T18:51:13",
"modifiedDate": "2020-09-16T18:51:14.063",
"id": 2083480,
"uri": "https://secure.fusebill.com/v1/purchaseproductitems/2083480"
}
],
"couponCodes": [],
"earningSettings": {
"earningInterval": "",
"earningNumberOfIntervals": null,
"earningTimingInterval": "EarnImmediately",
"earningTimingType": "StartOfInterval"
},
"id": 2058207,
"uri": "https://secure.fusebill.com/v1/Purchases/2058207"
},
"newPurchase": {
"customerId": 16177079,
"code": "trackedSerial",
"effectiveTimestamp": "2020-09-16T18:51:13",
"taxableAmount": 0.0,
"amount": 0.0,
"modifiedTimestamp": "2020-09-16T18:51:31.132369Z",
"salesforceId": null,
"netsuiteLocationId": "12",
"productId": 25188589,
"name": "trackedSerial",
"description": null,
"status": "Draft",
"quantity": 0.0,
"targetOrderQuantity": 2.000000,
"isTrackingItems": true,
"pricingModelType": "Standard",
"customFields": [],
"discounts": [],
"priceRanges": [
{
"min": 0.000000,
"max": null,
"amount": 2.000000,
"conditionAmount": null,
"variableAmount": null
}
],
"productItems": [],
"couponCodes": [],
"earningSettings": {
"earningInterval": "",
"earningNumberOfIntervals": null,
"earningTimingInterval": "EarnImmediately",
"earningTimingType": "StartOfInterval"
},
"id": 2058208,
"uri": "https://secure.fusebill.com/v1/Purchases/2058208"
}
}
{
"ErrorId": 0,
"HttpStatusCode": 400,
"Errors": [
{
"Key": "Api Error",
"Value": "This purchase cannot be split, because it does not use Target Order Quantity."
}
]
}