Skip to content
English
  • There are no suggestions because the search field is empty.

Example of PHP SOAP ProcessSalesInvoices

Introduction

Below you will find an example of an application that allows you to create sales invoices in Nmbrs Accounting 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;
}
?>