Sambapos Script for Self Hosted HTTP Service and post data in URL

In Pakistan Tax Authorities has introduced live integration of POS including Sambas and also shared method of integration https://help.fbr.gov.pk/?p=6148. Sambapos is best product and has been implemented across the glob including our homeland. Need help and questions are given as under:-

  1. We need a building script at bill print event to call and receive data on self hosted local service as mentioned in above provided URL guidelines.
  2. If script is enough that excellent or can we use SQLserver 2016 store procedure to send and receive data to tax authorities.
  3. Basically, on the printed bill there is requirement of tax authorities invoice number received in call response and qr code printing. After that sharing sale data through URL.
    Your help in this respect will facilitate many users/clients.
    Thank you and regards,

Scripts are very flexable and capable of almost anything.
Looking at the link it’s just a json web post which isnt too tricky and they have a fill documentation there.
Take a look at my PMS intergration for hotel.
I use scripts and json format data in similar way there;

I have changed to question rather.than request as samba can do this, there is the functionality, just needs setting up.

Hello @Shafiqch is it a requirement now or is it a future requirement? If its required now you can always contact support@sambapos.com and inquire about it. Our dev team is working hard on some new exciting features so I wouldn’t expect a quick turnaround, however in regions that we have a large demand for this we will build a connection to these devices.

Thank you for response, however there is no special device. Sambapos has to interact with a service and it will generate a number. That number will be printed on the bill along with qr code. Simply after reading material in the web I believe using script is the solution. But I m not much aware about coding script therefore shared requirement for assistance.
Regards

Is this required now by government? Or is it future?

Its Required now in Pakistan

I would send a message to support@sambapos.com with these details. The dev team has a very tight schedule right now though. I would not expect an immediate fix for this solution. Please provide them information about it and supporting documentation about the requirement from the government.

AOA,
Though as of today I remained unsuccessful for integration Sambapos with the local host web service, however, today I am thinking a new way. My queries in this respect are as under:

  1. I dont want to touch database or front end for any api call, rather, I want to fetch data from printer at bill print stage, is it possible?
  2. Once I fetched data from virtual printer or thread etc , how I can call localhost web-service and get response back for final printing in real printer?
  3. If this method will successful, I believe it will resolve many issues without going into lengthy process.
    What will all technical experts suggest?

Sounds more complicated to me.
Looking at that you request tax id/invoice number from gov.
So surely it’s as simple as the point at which you want to generate gov id, print bill say before printing you call gov api from samba, get number, assign to ticket tag and then print?
That would all happen in automation. User wouldn’t see anything different other than that after pressing print etc the gov I’d would show on ticket.

Thank you JRTech for your response, but I am stuck how to post and get back response on a ticket tag. Moreover it also needs quries from different tables, discount, and tax charged along with entity status which is complex for an ordinary user like me.
Alternatively I think capturing data from printer makes life easier. Data captured through virtual printer from spooler can be posted for getting response or id from web service.
Moreover this method will help me in other software applications where database is embedded and direct access to tables is not possible.
If you could help regarding samba I can share you anydesk id.
Thank you and regards

Your suggested method is outside the scope of samba. virtual printers etc are outside the scope of samba.
Is this virtual printer something provided by the gov?
Couldn’t see any virtual printer at the linked docs.
Sounds like your hoping it will be a cross platform solution? However I would imagine any virtual printer type setup with require print to be in a specific format. That would be doable in samba but other systems may not offer the same level of customisation on templates.

All i see at that link is api details.

I dontnunderstan you reply. You dont need to look to sql. You use printer type expressions or samba graphql api within script in samba to get all info needed. Submit to gov and then use response to update ticket tag.
Order, ticket, discount, tax and entity data is all accessible within samba automation and could be fed into a script.

Thank you JRTech for response.
Virtual printer is not a requirement of Gov. I was searching on internet and it sounds me very attractive solution, therefore I posted in topic. Since every document is sent through window sploor hence it can be captured. Virtual printer is a service/bridge between POS and physical printer.
I will try ghrafql as u suggested.

I’d depends on what flow you want.
You will likely not even need graphql but without knowing your intended flow it’s hard to give fill details.

If you could share email I will send you detail flow. Basically requirement is just sending ticket information at the stage of final settlement of ticket in sambapos to a localhost service which is a window service available in control panel (Administrative service). In response service generate a number which is sent back to POS. The number thereafter is printed in QRcode. Printing qr code is not an issues and I have tested successfully, however I m struct in building script or Any other solution to accomplish the task.
So far I tried following:

  1. Outside of sambapos a dll was created, configured with sql server. Whenever a record is inserted in ticket table a trigger is run to call api. However this solution failed because restaurant business requirement we need to call api at the time of settlement.
  2. I also tried to invoke dll with sambapos script, but still facing trouble.
  3. Now trying virtual printer option.
    I m not a developer and just an accounting expert. But I love IT, open source erp implementation, accounting and inventory software implementation. Therefore hit and trail is the only option for me.
    Regards

Did you look at the PMS topic I linked.
All you need will be in there.
You would call a sambapos script with values required as inputs.
In script use the post helper function, the returned value of scripts goes back to flow.

From my understanding what you will likely have is on final payment rule have an update ticket tag action. The tag value will use the {CALL:xxx} expression with ticket number etc as input variables.
Script will need to take those input vars and format in json as it would in your other attempt and post to your local host endpoint.
The response to the post would then be parsed and that tax code extracted and returned by script.
This would then return that value in place of the origional call setting the ticket tag

Yes, that is the requirement and you correctly explained. I will try e build a script, with required fields, however my confusion is mapping fields with required json format. Still I try and share the response

You would need to know how to do that either way if your going to use their local host api. Sure it was using json in the linked docs.

As I said that PMS topis should be ideal for you as it spans from my very early experiences in samba scripting so starts basic. Jesse, Q and Emre helped allot with advice.

That is the solution I am looking for :-
Shafiq Chohan

@Shafiqch just remember, modifying samba to do itself may take a little time but no extra cost or recurring costs :wink:

1 Like

Good work. Can you send me more details?