/bookkeeping/createCustomer.php

This method is used to create a new customer in the customer database. Once created you can register sales towards this customer.

Parameters

int number
The customer number requested for the particular customer. Use the string DEFAULT if you just want the next available customer number to be used.
int groupId
The id of the customer group that the particular customer is in. Use the string DEFAULT if you want to use the default (first) customer group.
int currencyId
The id of the currency that this customer opperates in, this determines what currency the customer is going to be invoiced in. Use the string DEFAULT to use the same currency as that of the company (your company that is).
int paymentTermId
The id of the payment term that this particular client is assigned. Use the string DEFAULT if you want to use the default (first) payment term.
string name
The name of the customer
string attention
The name of the attention person in the company
string address
The addres of the customer
string postcode
The postcode for the customer
string city
The city the customer is in
string country
The country the customer is in
string vatNumber
The vat number of the customer
string invoiceEmail
The invoice mail of the customer - this is the email invoices raised to this customer will be send to.
string phone
The phone number of the customer.
boolean vatExempt
TRUE or FALSE indicating whether the customer is marked as vat-exempt, i.e. foreign clients.
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 : CUSTOMER_NUMBER
The customer number of the paticular customer.
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 the requested customer number is invalid i.e. less than 0.
2006: Currency not found
Occurs if the currency with the particular id is not found.
4001: Invoice layout not found
Occurs if the system is not able to determine an invoice template to be used.
4002: Payment term not found
Occurs if the system can not find the particular payment term, or of there are no payment terms configured at all.
4003: Customer group not found
Occurs if the requested customer group is not found, or if there are no customer groups at all.
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=DEFAULT" .
	"&groupId=DEFAULT" .
	"&currencyId=DEFAULT" .
	"&paymentTermId=DEFAULT" .
	"&name=" . urlencode("Uhasibu accounting LTD") .
	"&attention=" . urlencode("Michael Pedersen") .
	"&address=" . urlencode("Ngong Road") .
	"&postcode=" . urlencode("00100") .
	"&city=" . urlencode("Nairobi") .
	"&country=" . urlencode("Kenya") .
	"&vatNumber=" . urlencode("") .
	"&invoiceEmail=" . urlencode("support@uhasibu.co.ke") .
	"&phone=" . urlencode("0712345678") .
	"&vatExempt=FALSE";

$response = uhasibu("/bookkeeping/createCustomer.php", $package);
if ($response["STATUS_CODE"] != 0) {
	die($response["STATUS_MESSAGE"]);
}
print "number of the newly created customer is " . $response["RESULT"]["CUSTOMER_NUMBER"];