Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Import Counter Sales
11-29-2012, 09:21 PM,
Import Counter Sales

Is there a way of auto-importing counter sales from CSV?

I am planning to write some loading script for my POS into weberp.
11-29-2012, 09:55 PM,
RE: Import Counter Sales
(11-29-2012, 09:49 PM)tim_schofield Wrote: Hi, No there isn't at the moment, and if you look at all the INSERT and UPDATE queries in CounterSales.php that it is fairly complex. You may be better using the API I wrote to do this as it hides much of the complexity.


Hello Tim,

Thank you for your prompt reply. Any doco or example for your API?
12-02-2012, 05:44 PM, (This post was last modified: 12-03-2012, 07:49 AM by phil.)
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:

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']
        SalesOrder = x_server.weberp.xmlrpc_InsertSalesOrderHeader(OrderHeaderDetails,Config['webERPuser'],Config['webERPpwd'])

Then the sales order lines need to be added one at a time:
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]
            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:

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

Forum Jump:

Users browsing this thread: 1 Guest(s)