Example of PHP SOAP ProcessJournal

Modified on Fri, 24 Dec 2021 at 10:27 AM

Introduction


Below you will find an example of an application that allows you to create general journal entries in Yuki by using PHP via the Accounting-ProcessJournal(sessionID, administrationID, xmlDoc) method.


Example


<?php
$webservice_url = 'http://api.yukiworks.nl/ws/Accounting.asmx?WSDL';
$key = REPLACE WITH WEBSERVICEACCESSKEY';
$admin_id = 'REPLACE WITH ADMINISTRATIONID';
$sess_id = '';

try
{

        $xml = '<Journal xmlns="urn:xmlns:http://www.theyukicompany.com:journal"

                        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

        <AdministrationID>' . $admin_id . '</AdministrationID>

        <AdministrationCoCNumber>12345672</AdministrationCoCNumber>

        <DocumentSubject>Trx import april</DocumentSubject>

        <JournalType>EndOfYearCorrection</JournalType>

        <JournalEntry>

                <ContactName>Apple Sales International</ContactName>

                <ContactCode>9921</ContactCode>

                <EntryDate>2012-12-31</EntryDate>

                <GLAccount>45310</GLAccount>

                <Amount>22.22</Amount>

                <Description>Inkopen hardware</Description>

        </JournalEntry>

        <JournalEntry>

                <ContactName>Apple Sales International</ContactName>

                <ContactCode>9921</ContactCode>

                <EntryDate>2012-12-31</EntryDate>

                <GLAccount>45310</GLAccount>

                <Amount>-22.22</Amount>

                <Description>Retour hardware</Description>

        </JournalEntry>
</Journal>';


        $soap = new SoapClient($webservice_url);

        $res = $soap->Authenticate(array('accessKey' => $key));

        if (!isset($res->AuthenticateResult)) exit();

        $sess_id = $res->AuthenticateResult;


        $xmlvar = new SoapVar('<ns1:xmlDoc>'.$xml.'</ns1:xmlDoc>', XSD_ANYXML);

        $res = $soap->ProcessJournal(array('sessionID' => $sess_id, 'administrationID' => $admin_id, 'xmlDoc' => $xmlvar));


        print_r($res);
}
catch(SoapFault $fault)
{

        print $fault->faultstring;
}
?>


Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select atleast one of the reasons

Feedback sent

We appreciate your effort and will try to fix the article