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

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

I am planning to write some loading script for my POS into weberp.
Reply
11-29-2012, 09:55 PM,
#2
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.

Thanks
Tim

Hello Tim,

Thank you for your prompt reply. Any doco or example for your API?
Reply
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


Forum Jump:


Users browsing this thread: 1 Guest(s)