Patch Draft Invoice

A draft invoice that has not yet been posted and is in status “Ready” can have some modifications applied to it prior to being posted. This can be achieved by using the Patch Draft Invoice call to modify specific elements of the invoice.

Request Parameters

PropertyTypeDescriptionRequired
idIntegerThis is the Fusebill generated ID of the draft invoice you wish to modify.Yes
notesStringBilling agents can write notes on draft invoices. Once posted the note is final. [Max Length: 500 characters]Optional
poNumberStringThe value in the PO Number field within the draft invoice. [Max Length: 255 characters]Optional
netTermsSetBooleanThis primes Fusebill to change the invoice's net terms to something different than default. Pair this with netTerms to define which value to set.Optional
netTermsEnum:{Net0, Net5, Net7, Net10, Net15, Net21, Net30, Net45, Net60, Net75, Net90, MFI1, DayOfMonth1, DayOfMonth2, DayOfMonth3, ... DayOfMonth29, DayOfMonth30, DayOfMonth31}Set non-default net terms on the invoice. Requires netTermsSet to be trueOptional
draftChargesList of objects. Definition belowThe set of draft charges belonging to the draft invoice you wish to modify or deleteOptional

Draft Charges Object

PropertyTypeDescription
idIntegerThis is the Fusebill generated ID number of draft charge you wish to modify or delete.
operationEnum:{Update, Delete}Indicates whether the draft charge is to be deleted or updated
nameStringThis is the name of the charge. [Max Length: 2000 characters]
descriptionStringThis is the description for the charge. [Max Length: 2000 characters]
quantityDecimalThis is the unit quantity of the charge
unitPriceDecimalThis is the price per unit
rangeQuantityDecimalFor non standard pricing, indicates the value used to calculate the price per unit. If the pricing model is Tiered, override the draftChargeTiers list instead
proratedUnitPriceDecimalThe price per unit of quantity if the charge is subject to proration.
draftDiscountsList of Objects. Defined belowThe set of draft discounts for this draft charge you wish to insert, modify, or delete
draftChargeTiersList of Objects. Defined belowIf the charge is based on a subscription product or purchase using the Tiered pricing model, then this list breaks down the draft charge into its tiers

Draft Discount Object

PropertyTypeDescription
idIntegerThe Fusebill generated ID of the draft discount. Required for the update and delete operations
configuredDiscountAmountDecimalThe dollar amount or percentage configured for the discount, depending on discountType
discountTypeEnum: {Percentage, Amount, AmountPerUnit}Indicates how configuredDiscountAmount is interpreted for calculating the discount
descriptionStringThe displayed description for the charge discount [Max Length: 2000 characters]
operationEnum: {insert, update, delete}Indicates whether this is a new draft discount (insert), or if this is a modification/deletion of the draft discount with ID id

Draft Charge Tier Object

PropertyTypeDescription
unitPriceDecimalThe price per unit of quantity in this tier
labelStringThe label of this charge tier that will appear on the invoice. [Max Length: 100 characters]
quantityDecimalHow much of the charge's quantity is portioned to this tier. Note that if a patch is made such that the sum of draft charge tier quantities is no longer equal to the draft charge quantity, this has the effect of changing the draft charge quantity
sortOrderIntegerIndicates whether this update is to the draft charge tier in position 1 (top in the list), position 2 (second to the top in the list), etc
Examples
curl -X PATCH "https://secure.fusebill.com/v1/DraftInvoices/" \
	-H "Content-Type: application/json" \
	-H "Authorization: Basic {APIKey}" \
	-d "{id:{draftInvoiceId},notes:'I patched this note onto the draft invoice.'}"
//Json Payload
string jsonData =
  "{id:{draftInvoiceId},notes:'I patched this note onto the draft invoice.'}";
//Setup API key
string apiKey = "{APIKey}";
//Configure URI
WebRequest request = WebRequest.Create("HTTPS://secure.fusebill.com/v1/DraftInvoices/");
//Add Content type
request.ContentType = "application/json";
//Add Api key authorization
request.Headers.Add(HttpRequestHeader.Authorization, "Basic " + apiKey);
//Set request method
request.Method = "PATCH";
//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 = {"id":{id},"notes":'I patched this note onto the draft invoice.'}
#Pass in your URI, Payload and Headers
r = requests.patch('https://secure.fusebill.com/v1/DraftInvoices', data=json.dumps(payload), headers=headers)
print(r.content)
{
  "id": 123532,
  "notes": "note value",
  "poNumber": "PO 8000",
  "draftCharges": [
    {
      "id": 132563645,
      "operation": "update",
      "description": "newDescription",
      "name": "newName",
      "quantity": 2
    }
  ],
  "netTermsSet": true,
  "netTerms": "Net90"
}
{
  "id": 123532,
  "notes": "note value",
  "poNumber": "PO 8000",
  "netTermsSet": true,
  "netTerms": "Net90",
  "draftCharges": [
    {
      "id": 132563645,
      "operation": "update",
      "name": "newName",
      "description": "newDescription",
      "quantity": 2,
      "unitPrice": 40.5
    },
    {
      "rangeQuantity": 4,
      "operation": "update",
      "id": 132563646
    },
    {
      "proratedUntPrice": 3.5,
      "operation": "update",
      "id": 132563647
    },
    {
      "id": 132563648,
      "operation": "update",
      "draftDiscounts": [
        {
          "configuredDiscountAmount": 3,
          "discountType": "Amount",
          "description": "$3 off",
          "operation": "insert"
        },
        {
          "id": 34324,
          "configuredDiscountAmount": 3,
          "discountType": "Amount",
          "description": "$3 off",
          "operation": "update"
        }
      ],
      "draftChargeTiers": [
        {
          "unitPrice": 3.99,
          "label": "0 to 4",
          "quantity": 4,
          "sortOrder": 1
        },
        {
          "unitPrice": 2.99,
          "label": "4 up",
          "quantity": 4,
          "sortOrder": 2
        }
      ]
    }
  ]
}
Response
{  
   "billingPeriodId":182592,
   "effectiveTimestamp":"2017-02-11T05:00:00",
   "status":"Projected",
   "poNumber":null,
   "draftCharges":[  
      {  
         "transactionId":0,
         "chargeTypeId":null,
         "transactionType":"Charge",
         "quantity":1.0,
         "unitPrice":15.99,
         "amount":15.99,
         "taxableAmount":15.99,
         "subscriptionPeriodId":0,
         "draftInvoiceId":0,
         "name":"Monthly Charge",
         "description":null,
         "effectiveTimestamp":"2017-02-11T05:00:00",
         "proratedUnitPrice":null,
         "startServiceDate":"2017-02-11T05:00:00",
         "endServiceDate":"2017-03-11T05:00:00",
         "rangeQuantity":null,
         "draftDiscount":null,
         "draftDiscounts":[  

         ],
         "status":"Projected",
         "productItems":null,
         "canProrateCharge":false,
         "postable":true,
         "id":1008956,
         "uri":null
      }
   ],
   "subtotal":15.9900,
   "totalDiscount":0.0,
   "total":15.9900,
   "taxes":[  

   ],
   "paymentSchedules":[  

   ],
   "customer":{  
      "reference":"1337",
      "companyName":"Stolen Bikes",
      "fullName":"Mr John Doe",
      "contactName":"Mr John Doe",
      "primaryPhone":"613-555-5555",
      "primaryEmail":"[email protected]",
      "billingAddress":null,
      "shippingAddress":null,
      "invoicePreference":{  
         "signature":"<p><strong>Kennedy Consulting</strong>  \r</p>\n<p>,   \r</p>\n<p><em>Kennedy Consulting |  | [][1]</em></p>\n<p>[1]: </p>\n",
         "standingPoNumber":null,
         "invoiceNotes":null
      }
   },
   "notes":null,
   "shippingInstructions":null,
   "customerReferenceValue":"1337",
   "terms":"Net5",
   "id":169033,
   "uri":"https://secure.fusebill.com/v1/DraftInvoices/169033"
}
{
    "ErrorId": 0,
    "HttpStatusCode": 400,
    "Errors": [
        {
            "Key": "Api Error",
            "Value": "Charges cannot be edited when the draft invoice is in status Pending"
        }
    ]
}
Language
Authorization