Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Import Counter Sales
12-02-2012, 05:44 PM, (This post was last modified: 12-03-2012, 07:49 AM by phil.)
#3
RE: Import Counter Sales
To create the order with the API is a two part you need to create the header then the lines all individually.

The python code to do this is:

Code:
OrderHeaderDetails['deliverydate'] = OrderHeaderDetails['orddate']
    OrderHeaderDetails['confirmeddate'] = OrderHeaderDetails['orddate']
    OrderHeaderDetails['datepackingslipprinted'] = OrderHeaderDetails['orddate']
    OrderHeaderDetails['deliverto'] = Row['brname']
    OrderHeaderDetails['ordertype'] = Row['tpe']
    OrderHeaderDetails['printedpackingslip'] = 1
    OrderHeaderDetails['fromstkloc'] = Config['Location']
    OrderHeaderDetails['customerref'] = 'POS-' + Config['POS_ID'] + ' ' + str(Row['transno'])
    OrderHeaderDetails['shipvia'] = Config['DefaultShipper']
    try:
        SalesOrder = x_server.weberp.xmlrpc_InsertSalesOrderHeader(OrderHeaderDetails,Config['webERPuser'],Config['webERPpwd'])

Then the sales order lines need to be added one at a time:
Code:
for OrderLine in OrderLines:
        OrderLineDetails['stkcode'] = OrderLine['stockid']
        OrderLineDetails['unitprice'] = OrderLine['price']
        OrderLineDetails['quantity'] = OrderLine['qty']
        OrderLineDetails['discountpercent'] = OrderLine['discountpercent']
        OrderLineDetails['itemdue'] = OrderHeaderDetails['orddate']
        OrderLineDetails['actualdispatchdate'] = OrderHeaderDetails['orddate']
        OrderLineDetails['orderno'] = SalesOrder[1]
        try:
            SalesOrderLine = x_server.weberp.xmlrpc_InsertSalesOrderLine(OrderLineDetails,Config['webERPuser'],Config['webERPpwd'])

Then to invoice the order I wrote a new method that does all the inserts and updates necessary to complete as though the sale is a native webERP invoice - simply:

Code:
InvoiceArray = x_server.weberp.xmlrpc_InvoiceSalesOrder(SalesOrder[1],Config['webERPuser'],Config['webERPpwd'])

You then need to process the credit notes and receipts/payments too I guess. It is not a trivial exercise. The beauty of the API is you can do this from virtually any language which has XML-RPC functionality. I have done it from Vala/Genie, Python and PHP.

If you need a remote off-line sales system that integrates back to webERP then my Counter-Logic POS system would be ideal for you.
Phil Daintree
webERP Admin
Logic Works Ltd
http://www.logicworks.co.nz
Reply


Messages In This Thread
Import Counter Sales - by avocado - 11-29-2012, 09:21 PM
RE: Import Counter Sales - by phil - 12-02-2012, 05:44 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)