Inserting New Invoice

Discussion in 'Developers Forum' started by pratheesh, Dec 2, 2008.

  1. pratheesh New Member

    Hi Duane,
    I'm using php with nusoap to insert a new Invoice. It works if I do not include any <Lines><anyType>.... items, but if i Include any <Lines>.. i get an error stating
    [StatusDetail] => Unable to cast object of type 'System.Object' to type 'KashFlow.InvoiceLine'

    following is the parameter format
    $invarr = array(
    'UserName'=>$username,
    'Password'=>$password,
    'Inv'=>array(
    'InvoiceNumber'=>25,
    'InvoiceDate'=>$date->format(DATE_RFC3339),
    'DueDate'=>$date->format(DATE_RFC3339),
    'CustomerID'=>434366,
    'Lines'=>array(
    'anyType'=>array(
    'Quantity'=>150.0000,
    'Description'=>'Test',
    'Rate'=>30.0000,
    'ChargeType'=>812270,
    'VatRate'=>21.0000
    )
    )
    )
    );
    When using the above the values in <anyType> element are removed i.e <Lines><anyType></anyType></Lines> is what actually goes as part of the request to the webservice.

    I started testing the api today and was pretty happy when I got things working quickly today but this issue has me stumped.:(

    i'm praying that you dont ask me to formulate the whole XML request manually.
  2. DuaneJackson Administrator

    There are a few people who have commented on having difficulties with Invoice lines from PHP. We should have a new stand alone function by the end of the week to add lines to an invoice.

    Duane
  3. pratheesh New Member

    Brilliant. That will be fantastic.
    Thank you.
  4. Chris McGrath New Member

    I was having this problem too originally. I had to upgrade the soap lib I'm using (soap4r) to get an option to generate explicit types. This added an xsi:type='InvoiceLine' to the anyType element and that got it working for me.

    Cheers,

    Chris
  5. Sandy New Member

  6. pratheesh New Member

    Thanks Guys,
    That was fast. Will test it and let you know how I fare.
  7. pratheesh New Member

    Okay we have a slight problem. InsertInvoiceLine does its job if I use an existing Invoice with atleast one InvoiceLine item,
    but my issue is with GetInvoice functions. Any invoice without any line item returns with 0 as the InvoiceDBID and InvoiceNumber
    i.e [InvoiceDBID] => 0 [InvoiceNumber] => 0
    Because of this I cannot use InsertInvoiceLine function

    I've tried using GetInvoice and GetInvoicesForCustomer
  8. pratheesh New Member

    Any Solution ?

    Hi Guys,
    Any idea why i'm getting '0' values for InvoiceID and InvoiceNumber for any invoices without an InvoiceLine item ?

    Pratheesh
  9. Sandy New Member

    pratheesh,

    The GetInvoiceByID bug has been fixed and you're now able to see the invoice details even if there's no invoice line.

    I've also added an invoice line to an invoice without any any lines and it works without any errors. Have a look at the return value, it should return the new invoice line id.
  10. pratheesh New Member

    Hi Sandy,
    Thats Excellent. Just tested it and its working perfectly.

    I'm happy :)

    Just an afterthought- Currently InsertInvoice returns the InvoiceNumber , whereas the InsertInvoiceLine requires the InvoiceID. This means i have to make an additional call to GetInvoice. This could be removed if the InsertInvoice function would also return the InvoiceID.

    Thanks and Regards,
    Pratheesh
  11. DuaneJackson Administrator

    Hi Pratheesh,

    Changing existing functions will break other peoples integrations.

    The best thing for us to do would be to change the InsertInvoiceLine to take an invoice number instead of an ID I think.

    Duane
  12. pratheesh New Member

    Hi Duane,
    You are right. Changing the InsertInvoiceLine will be better. That will solve the problem.

    Pratheesh
  13. pratheesh New Member

    Just thought of something. I remember someone mentioning potential problem with client changing the InvoiceNumber. Eventhough this wouldnt be an issue for us, but still it might be an idea to create a new function InsertInvoiceLinebyNumber/ID to provide both option.
  14. Sandy New Member

    New WebMethods

    Pratheesh

    Tried to email (x3) earlier on today and it seems like your mail server is down or something:confused:.

    Just wanted to let you know that WebMethods you require have been added to the API.

    They are:

    • GetReceipts
    • GetJournals
  15. philsmy New Member

    Hi Chris,
    What did you do to get this?! I am setting
    @port.generate_explicit_type = true

    And still don't get anything. I believe I have the latest soap4r.
  16. Chris McGrath New Member

  17. philsmy New Member

    Thanks!
    Downloading and installing from svn worked.
    I had assumed that this fix was in the latest gem as supposedly it was done 4 months ago!

    Phil

Share This Page