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

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?

Thank you JRTech. While you encouraged me :slight_smile: today I have successfully tested and getting response. An image is attached here:

Now I am facing following issues.
How I can execute script regarding relevant bill information to be posted for getting response from web.service. Either 1st I have to query data and thereafter execute script. Objective is when cashier press print button of a specific ticket number, same could be posted and get response in a ticket with response (string) converted in qr code.
Regards

1 Like

Samba template will render qr from the numerical code.
You would want to use update ticket tag action and use the call function in the tag value field.
So in the rule when updating tag it runs script and uses returned tax id into ticket tag.

@JRTech yes, QRcode is not an issue…However my query is in image you can see. JSON data is a sample array, whereas in restaurant every bill is required to be posted in the web service to get response back…How a specif bill with return response can be printed.

As I said before look at my PMS topic, its all in there.
Your need to feed in the Ticket Number etc as variables.

You will call the script in update ticket tag action like
{CALL:FBR.getInvoice("{TICKET NUMBER}","{TICKET TOTAL}","{etc.}")}

Then in your script it would be;
function getInvoice(var1,var2,varEtc){ …etc…}

I would like more information about it to sent the gov
objects in JSON format.

1 Like