/sale/getOutstandingInvoiceByCustomer.php

This method is used retreive a list of invoices for a particular customer, that are outstanding - i.e. not fully collected and therefor you can register payments towards these.

Parameters

int number
The customer number of the customer that you add a work item to - be sure that customer numbers are unique.
int companyId
The company id of the Uhasibu account required
string login
The login for the API user, logins are typically emails
string password
The password for the API user

Return values

int RESULT_AMOUNT
Contains the amount of result rows in the result set
array RESULT
Array containing the individual result rows
int RESULT : NUMBER
The invoice number of the paticular invoice.
date RESULT : INVOICE_DATE
The date on which the invoice was created (invoiced), the date is formated accordingly to the settings in Uhasibu (see: Uhasibu-> settings -> company information.
date RESULT : DUE_DATE
The date on which the invoice is due, the date is formated accordingly to the settings in Uhasibu (see: Uhasibu-> settings -> company information.
int RESULT : FULL_AMOUNT
Contains the original invoice amount for the full invoice.
Be alert that the amount is an integer representing the lowest nominator in the particular currency (i.e. cents for Kenyan Shillings).
If you want to have the amount represented in a decimal representation you 'just' need to divide the number by 100.
int RESULT : OUTSTANDING
Contains the still outstanding amount for the particular invoice.
Be alert that the amount is an integer representing the lowest nominator in the particular currency (i.e. cents for Kenyan Shillings).
If you want to have the amount represented in a decimal representation you 'just' need to divide the number by 100.
int RESULT : CURRENCY_ID
The id of the currency the numbers are in.
int RESULT : CURRENCY
The currency symbol for the particular currency in ISO-4217 format.
int STATUS_CODE
The status code of the function call, any code different from 0 is an error code
string STATUS_MESSAGE
A textual description of the status code in a few words

Potential error messages

2001: Invalid customer number
Occurs if no customer is found with the specified customer number
1007: Internal error
This is an unexpected error, and could indicate a bug in Uhasibu, if you see this bug occur then please report it to Uhasibu support.
1001: Invalid credentials
Occurs when no user is found within the given companyId using the login and password provided
1002: Missing access rights
Occurs when the user credentials provided does not have access-rights to use the required part of the system.
1003: Account expired
Occurs when the company is expired i.e. due to missing subscription payment.
1006: Requests method not supported
Occurs when the request is neither a POST nor GET HTTP request type

Examples

PHP example
$APIVersion = "20120401";

function uhasibu($method, $package) {
	global $APIVersion;
	$url = "www.uhasibu.co.ke/api/" . $APIVersion . $method;
	$curl = curl_init();
	curl_setopt($curl, CURLOPT_URL, $url);
	curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
	curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
	curl_setopt($curl, CURLOPT_POST, true);
	curl_setopt($curl, CURLOPT_POSTFIELDS, $package); 
	$response = curl_exec($curl);
	curl_close($curl);
	return json_decode($response, TRUE);
}

$package = 
	"companyId=**COMPANYID**" .
	"&login=" . urlencode("**USERNAME**") .
	"&password=" . urlencode("**PASSWORD**") .
	"&number=1000";

$response = uhasibu("/sale/getOutstandingInvoiceByCustomer.php", $package);
if ($response["STATUS_CODE"] != 0) {
	die($response["STATUS_MESSAGE"]);
}

foreach ($response["RESULT"] AS $invoice) {
	print "Invoice Number: " . $invoice["NUMBER"];
	print "Invoiced date: " . $invoice["INVOICED_DATE"];
	print "Due date: " . $invoice["DUE_DATE"];
	print "Original full amount: " . ($invoice["FULL_AMOUNT"] / 100);
	print "Outstanding: " . ($invoice["OUTSTANDING"] / 100);
	print "Currency id: " . $invoice["CURRENCY_ID"];
	print "Currency: " . $invoice["CURRENCY"];
}

See Also