E-conomic is danish accounting system. For us here in Estonia it may seem far and irrelevant, but I'll still try to describe its posiibilities and integration, because it has been expanding for couple of years now and by now it supports 9 countries. Thus this article may be useful for business owners, legal or integration men like me. To contrast it all, this system is often integrated with payment systems, like epay.
Before going to youtube videos to understand how things are done from UI, we, developers tend to ask conceptual or database diagram first. So here it is
As you can see, central objects here are invoice, debtor, product, order, subscription and main functionality is done around them. Smaller tables only specify parameters like currency, taxes and measurement units.
To integrate our application with their API we'll be using SOAP 1.2, which is very poorly documented and number of objects-methods is hardly understandable without knowing the structure above. Here is my example of adding client
$resClient = new SoapClient('https://www.e-conomic.com/secure/api1/EconomicWebService.asmx?wsdl', array('soap_version' => SOAP_1_2));
$resClient->connect(array(
'agreementNumber' => your_service_id,
'userName' => login,
'password' => password ));
$arrExDebtor = $resClient->Debtor_FindByNumber(array('number' => 57945)); //looking up some user by ID
if (!isset($arrExDebtor->Debtor_FindByNumberResult->Number)){
$resClient->Debtor_Create(array(
'number' => 57945,
'debtorGroupHandle' => array('Number' => 3), //add him to group nr 3
'name' => 'Artjom Kurapov',
'vatZone' => 'HomeCountry' //tax zone, if country is not within EU, then = Abroad
));
}
$resClient->Debtor_SetCurrency(array(
'debtorHandle' => array('Number'=> 57945),
'valueHandle' => array('Code'=>978) //yes, its EUR currency code in ISO
));
Note that I've excluded try-catch blocks to make things more compact. Actually you'll need to wrap it around because server may go offline. Also, if you are going to make payments, do take it into account (so that your payment doesnt nesseserily gets affected by this service being down)
So now lets try adding new invoice that will be available as pdf for download
$objInvoice = $resClient->CurrentInvoice_Create(array(
'debtorHandle'=>array('Number'=>57945),
'name'=> 'Artjom Kurapov'
));
$resClient->CurrentInvoice_SetCurrency(array(
'currentInvoiceHandle'=>array('Id'=>$objInvoice->CurrentInvoice_CreateResult->Id),
'valueHandle'=>array('Code'=>$arrUser['currency']
)));
//now lets add invoice line.. you may need cycle here for multiple lines
$objLineHandle = $resClient->CurrentInvoiceLine_Create( array(
'invoiceHandle'=>array('Id'=>$intInvoiceHandle)
));
$intLineID = $objLineHandle->CurrentInvoiceLine_CreateResult->Id;
$intLineNr = $objLineHandle->CurrentInvoiceLine_CreateResult->Number;
$resClient->CurrentInvoiceLine_SetProduct(array(
'currentInvoiceLineHandle'=>array('Id'=>$intLineID,'Number'=>$intLineNr),
'valueHandle'=>array('Number'=> some_product_number_id) //static in this case
));
$resClient->CurrentInvoiceLine_SetDescription(array(
'currentInvoiceLineHandle'=>array('Id'=>$intLineID,'Number'=>$intLineNr),
'value'=> "Product description for pdf"
));
$resClient->CurrentInvoiceLine_SetUnitNetPrice(array(
'currentInvoiceLineHandle'=>array('Id'=>$intLineID,'Number'=>$intLineNr),
'value'=> 50 //price of unit, netto
));
$resClient->CurrentInvoiceLine_SetQuantity(array(
'currentInvoiceLineHandle'=>array('Id'=>$intLineID,'Number'=>$intLineNr),
'value'=>1 //product quantity
));
$resClient->CurrentInvoiceLine_SetUnit(array(
'currentInvoiceLineHandle'=>array('Id'=>$intLineID,'Number'=>$intLineNr),
'valueHandle'=>array('Number' => number_of_unit_for_product) // years,kilograms,meters
));
Comments
And data/process entirely depends on your application logic. For example E-conomic provides methods to fetch invoices in pdf.. some may find that useful, some not.