API Forum

This forum is in read-only mode.
Please refer to our API support in case you have any questions.
We can be reached at api@e-conomic.com
e-conomic API developer forum

Book invoice

0
I'm doing some automatic processing work...

I'm currently looking into, how I can automaticly book an invoice and send the PDF as an attached file to the customer.

I've been looking into the SOAP API, but can't see something, that points me in the right direction.

Can anyone give me a clue?
created Mar 7, 2011 by QubixDK
0% Accept Rate
Q 4 A 14 C 0

9 Answers

0
Until now this is what I got:


$debtorHandle = $client-Debtor_FindByNumber(array('number'=105))-Debtor_FindByNumberResult;
$debtorOrders = $client-Debtor_GetOrders(array('debtorHandle'=$debtorHandle))-Debtor_GetOrdersResult-OrderHandle;
$numDebtorOrders = count($debtorOrders);
if($numDebtorOrders  1) {
    $orderHandle = max($debtorOrders);
} else {
    $orderHandle = $debtorOrders;
}
$invoiceHandle = $client-Order_UpgradeToInvoice(array('orderHandle'=$orderHandle))-Order_UpgradeToInvoiceResult;
$invoiceData = $client-CurrentInvoice_GetPdf(array('currentInvoiceHandle'=$invoiceHandle))-CurrentInvoice_GetPdfResult;
touch('tmp_invoice/tmp.txt');
$fp = fopen('tmp_invoice/tmp.pdf', 'w');
fwrite($fp, $invoiceData);
fclose($fp);

After this i need to work on:

CurrentInvoice_BookWithNumber - This shouldn't represent any problem.

Next I need to figure how to get the invoice number.... I've looked at DebtorEntry_GetInvoiceNumber, but here is the part I can't figure out: How do I get the SerialNumber of the Debtor?
answered Mar 8, 2011 by QubixDK
0
Hi,

CurrentInvoice_BookWithNumber books the invoice with a specific number. THIS IS ONLY NECESSARY if you need to control the exact invoice number - if not, you should use CurrentInvoice.Book().

Both of the above returns an Invoice object, on which you can then call .GetPdf().


Best regards,
answered Mar 9, 2011 by Christian Estrup
0
Hi Christian,

Thank you for your reply.


Now I need to get the gross amount (CurrentInvoice_GetGrossAmount).
But it keeps returning NULL.

$invoiceHandle = $client-Order_UpgradeToInvoice(array('orderHandle'=$orderHandle))-Order_UpgradeToInvoiceResult;
$arrInvoicehandle = array('currentInvoiceHandle'=$invoiceHandle);
$invoiceAmount = $client-CurrentInvoice_GetGrossAmount($arrInvoicehandle)-CurrentInvoice_GetGrossAmountResponse;
$invoiceCurrency = $client-CurrentInvoice_GetCurrency($arrInvoicehandle)-CurrentInvoice_GetCurrencyResponse;


$invoiceAmount  $invoiceCurrency both returns NULL.

I've tried moving the lines past this one:

$bookInvoice = $client-CurrentInvoice_Book($arrInvoicehandle)-CurrentInvoice_BookResult;

But nothing works.

What am I doing wrong?
answered Mar 28, 2011 by QubixDK
0
Hmm...

It helps when you read the documentation (or taking a var_dump())...


The correct lines:

$invoiceAmount = $client-CurrentInvoice_GetGrossAmount($arrInvoicehandle)-CurrentInvoice_GetGrossAmountResult;
$invoiceCurrency = $client-CurrentInvoice_GetCurrency($arrInvoicehandle)-CurrentInvoice_GetCurrencyResult-Code;
answered Mar 28, 2011 by QubixDK
0


Hi QubixDK, which documentation did you read about? thanks in advance.
answered Mar 31, 2011 by brjano
0
The only documentation I use is:
https://www.e-conomic.com/secure/api1/E ... rvice.asmx
answered Apr 28, 2011 by QubixDK
0
We've now been running this autoInvoice script for about 1 month.

Each night, where it's running, I get a mail with the order no. and the corresponding invoice number.

Some of the orders come back with no invoice no., and when i check in e-conomic it hasn't been booked.

Howcome?
answered Apr 28, 2011 by QubixDK
0
Well... Apparently, something went wrong when booking the invoice

If your integration has received error ID's back from the API, please post them here (or send them to our API support team at api@e-conomic.com). We/they can then help you figure out what went wrong - and likely also help you prevent similar issues in the future.


Best regards,
answered May 1, 2011 by Christian Estrup
0
Funny thing is... No errors are returned from the page, when I load the page manually.
answered May 2, 2011 by QubixDK
Visma e-conomic A/S
...