Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
API create a credit note
02-01-2012, 09:43 AM,
#1
API create a credit note
I recently added an API method that invoices a sales order producing all the entries for sales analysis, stock quantities, dealing with assembly items and taxes together with all the associated GL entries using the same logic as we have in ConfirmDispatch_Invoice.php

I need to do a similar thing for returns (Credit Notes) the difference is that there is no sales order here and the API needs to take the header data and returned lines as a structure (associative array) and the lines as an array of associative arrays.... What would the method signature look like??

Would appreciate any pointers on how to best acheive this and any pit-falls with this approach!

I will also need to do another API method for sending debtor payments to webERP and do the allocations to invoices it is paying.

Am I inventing the wheel here? I am slightly surprised that these functions have not been considered before, or done in only a very limited way.
Phil Daintree
webERP Admin
Logic Works Ltd
http://www.logicworks.co.nz
Reply
02-03-2012, 08:47 AM,
#2
RE: API create a credit note
Figured it out ... and half way though development.

The existing methods for creating invoices and credit notes are quite limited and really destroy the functionality in the rest of the system. e.g. they don't handle tax, stock updates at all (nor assembly items), cost of sales GL entries, sales analysis. Chatting with Tim, they were developed for a specific project where that stuff was not required and only limited functionality of webERP was required.

The InvoiceSalesOrder method does a reasonably comprehensive job, although it cannot handle serialised or lot controlled stock. The CreateCreditNote method will also have the same short coming but otherwise do all the normal updates and inserts that a credit note created in webERP would do.

This work is all for my POS system - has been quite a good project!!
Phil Daintree
webERP Admin
Logic Works Ltd
http://www.logicworks.co.nz
Reply
02-05-2012, 08:13 AM, (This post was last modified: 02-05-2012, 10:51 AM by phil.)
#3
RE: API create a credit note
There was the beginnings of an interesting discussion on the IRC chat about this....
I think Tim's idea was to create these very low level API functions to

get a list of customers,
allow the client to iterate through and retrieve details of customers as another method at quite a low level ... if there was something to be done you could do it over 10 or 15 API calls with the various update and insert API calls.


However, to achieve any transaction of substance this would then would involved a whole lot of code in the client application and to roll back partial changes in the event of trouble down the track would all require manual coding to acheive at every reversal step as well.

With my methods I have made them do the whole higher level transaction - e.g. InvoiceSalesOrder - does the whole lot, updates the order lines invoiced, does all the inserts for debtortranstaxes, stockmoves, stockmovestaxes, debtortrans, salesanalysis, locstock, gltrans, systypes etc etc... if one of the elements of the transaction fails then the whole lot is rolled back - using a database transaction to wrap the whole thing in. To me this is a better strategy and more useful to "would be" integrators wanting to use the API, rather than these very low level functions that previously existed.

I hope these new functions open up some possibilities to integrators.
Phil Daintree
webERP Admin
Logic Works Ltd
http://www.logicworks.co.nz
Reply
02-06-2012, 07:55 AM,
#4
RE: API create a credit note
An excellent philosophy Tim and one that I absolutely swear by Smile

I believe writing code to use the API is excessively complex as it stands. Of course, I am hoping these functions make it simpler for folks to really use the API rather than get buried in low level complexity.
Phil Daintree
webERP Admin
Logic Works Ltd
http://www.logicworks.co.nz
Reply
02-06-2012, 09:59 AM, (This post was last modified: 02-06-2012, 10:02 AM by phil.)
#5
RE: API create a credit note
By low level I mean, the existing API functions basically did just a single insert or reads. Really too simple to be of much use to integrators - they don't want to delve into webERP logic - they want methods that apply webERP logic given some external data IMHO. As it was, the logic of webERP has to be re-created by using any number of reads inserts and updates - using many API calls rather than presenting integrators with the webERP logic already coded up in single transactions. All that is required to create an invoice now is to present the API method with an order number and the webERP logic is applied to create the webERP invoice directly. I've not changed the salesorder API methods, one still needs to create the header then the lines are all individual API calls. To me it would have been better to send parameters for the header as an associative array and a parameter for the lines as an array of associative arrays - as I did for the CreateCreditNote function.

The existing functions were really just methods to get at and insert the webERP data and didn't really expose any webERP logic.

I think this is what Lindsay meant when he steered away from the API for creating webERP invoices from an external application as it was "too much like reinventing the wheel" - which of course it was!
Phil Daintree
webERP Admin
Logic Works Ltd
http://www.logicworks.co.nz
Reply
11-15-2012, 10:08 AM, (This post was last modified: 11-22-2012, 02:09 PM by TimJones.)
#6
RE: API create a credit note
I would also like to know the technical details of the API. I think a lot of people (myself included) could benefit from knowing more about what you did. Do you have a good resource you could refer me to for setting up a Payday Loans Online API? Thanks in advance!


Reply
11-15-2012, 11:53 AM,
#7
RE: API create a credit note
Hi Tim,

Unfortunately, there is limited documentation on the API - the best resource really is the code but it is not easy to follow I fear.
I wrote up a starter on how to use the API at

http://www.weberp.org/wiki/APIDocumentation

and the rest of the API documentation is from the manual that you can only view once logged in.

I note you are wanting to set up a credit card API - there is no such API method available at the moment.
Phil Daintree
webERP Admin
Logic Works Ltd
http://www.logicworks.co.nz
Reply
03-25-2013, 09:22 PM,
#8
RE: API create a credit note
Hi everyone ,

I want to ask you ,how we can use the API_stock functions of webERP in our php code ? I am trying to develop a new module for webERP and I need to use function "InsertStockItem" in my code. So please help me to implement a solution for this problem ^_^
Reply
03-26-2013, 06:08 AM, (This post was last modified: 03-26-2013, 06:09 AM by phil.)
#9
RE: API create a credit note
@namaster I see you posted the same question on a lot of different threads - I have deleted all the others - don't want to clutter the place unnecessarily with duplication please.

There is another thread which has some good detail on using the API - once you have an understanding of using one API method and I think the example is getting the location stock balances method - then all the other API methods are called in a similar way. Best to review the other thread in detail and get comfortable with using the API - then the insertion of stock items will be straight forward.

See

http://www.weberp.org/forum/showthread.p...hlight=API
Phil Daintree
webERP Admin
Logic Works Ltd
http://www.logicworks.co.nz
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)