Example of PHP SOAP ProcessSalesInvoices

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 sales invoices in Yuki by using PHP via the ProcessSalesInvoices(sessionID, administrationId, xmlDoc) method.


Example


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

try
{

        $xml = '<SalesInvoices xmlns="urn:xmlns:http://www.theyukicompany.com:salesinvoices"

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

                <Reference>XX-1234</Reference>

                <Subject>Testfactuur - 1</Subject>

                <PaymentMethod>ElectronicTransfer</PaymentMethod>

                <Process>true</Process>

                <EmailToCustomer>false</EmailToCustomer>

                <Layout />

                <Date>2012-06-22</Date>

                <DueDate>2012-07-22</DueDate>

                <PriceList />

                <Currency />

                <Remarks />

                <Contact>

                        <ContactCode>1122</ContactCode>

                        <FullName>Apple Sales International</FullName>

                        <FirstName />

                        <MiddleName />

                        <LastName />

                        <Gender>Male</Gender>

                        <CountryCode>NL</CountryCode>

                        <City>Rotterdam</City>

                        <Zipcode>1234 AA</Zipcode>

                        <AddressLine_1>Bergweg 25</AddressLine_1>

                        <AddressLine_2 />

                        <EmailAddress>info@test.nl</EmailAddress>

                        <Website />

                        <CoCNumber />

                        <VATNumber />
                        <ContactType>Person</ContactType>

                </Contact>

                <InvoiceLines>

                        <InvoiceLine>

                                <Description>Regel 1</Description>

                                <ProductQuantity>2</ProductQuantity>

                                <Product>

                                        <Description>Product 1</Description>
                                        <Reference>TP-1122</Reference>

                                        <Category xsi:nil="true" />

                                        <SalesPrice>14.88</SalesPrice>

                                        <VATPercentage>6.00</VATPercentage>

                                        <VATIncluded>true</VATIncluded>

                                        <VATType>2</VATType>

                                       <GLAccountCode></GLAccountCode>
                                        <Remarks />

                                </Product>

                        </InvoiceLine>

                </InvoiceLines>

    </SalesInvoice>
</SalesInvoices>';

$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->ProcessSalesInvoices(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