Customer Account Statements and Payments (Custom)



i have done all the steps for customer account above but i don’t seem to get it right can some please help me

i can’t see any for the account customer statements and also when i have posted all the tickets for the customer account


Show your code here so we can help you. Highlight it and press the code format button so we can read it clearly.



I have implented a modified version of this excellent accounts handling screen and is working fine except I am trying to automatically set the AS Entity ID from a previous automation.

I am using this for my hotel booking system and instead of working on the Customer entity, it is operating on a unique Bookings Entity which is dedicated to a Hotel Booking.

As part of my booking process (developed from JTRTech Hotel booking system) I have a check out process which is initiated by the selection of the Entity from a screen called bookings which displays the active booking entities. I wish to move directly from this checkout automation direct to the Account Operations and return to check out when account is settled.

Currently on your automation you identify the AS Entity ID from a selection on the Accounts screen using the following {CALL:db.getRow(“SELECT Id FROM Entities WHERE Name=’{ENTITY NAME:Bookings}’”)}

I simply want to get the Entity ID from the already selected entity and I am sure there is a simple syntax for this but I cannot find it. My automation is based around names and custom data fields whereas your script requires the entity ID.

I thought {REPORT ENTITY ID} or {ENTITY ID} or something like this would work but does not.

Can you point me at an expression that will give me the current entity ID?


That is exactly what the db.getRow() function does via the SELECT statement contained therein. It finds the Entity Id from the currently selected Entity Name.

The button on the POS/Ticket screen shows use of the db.getRow() function. This is not the same
as the button on the Account Screen. You might think they are the same because they have the same Button Header, but the Automation Commands are different, and their respective Rules do different things …

So this is the button on the POS/Ticket Screen …

Here is a slightly different way to get the ID from the Name on the POS/Ticket screen, that uses a report tag rather than the getRow function …

{REPORT SQL DETAILS:SELECT e.[Id] FROM [Entities] e WHERE e.[Name]='{ENTITY NAME:Customers}':F.Id}

The button on the Account Screen works differently, because the [:CommandValue] passed from the Account Screen is either the Account Id or the Entity Id. And this is the reason that I chose to use Entity Ids rather than Entity Names… just to keep subsequent operations consistent…

And the Rule for the Account Screen button… you will notice that the POS/Ticket Rule executes this Rule as well, after it gets the Entity ID, by using an Execute Automation Command Action…


In any case, there are Tags to access the Entity Name, Id, associated Account, etc …

These are found in the Printer Template Help:

--Entity Values-- 

Depending which Rule you are executing, {ENTITY ID} might not be granular enough. So you might need to use something like {ENTITY ID:Bookings}. This type of syntax is common to Entities so that we can specify the Type of Entity that we want to operate on, particularly when a Ticket has more than one Type of Entity assigned to it.



Many thanks for the very clear explanation. Not only did you give me the answer but it has helped me to further understand the process.

It’s late here in sri Lanka but tomorrow I will be able to implement this.

Thanks again.


Well as usual for me nothing is ever simple. I have a strange behaviour with the AS Set Statement Variables Rule.

I have added some additional variables to use in the printing and generation of the Statement Template, particularly in the Header section. The aim of this is print invoices for guests that reflect their Room number, Guest Name, Check in Date etc.

I first tried to insert Report Tags for the entity data but they would not work on this entity screen. I then wrote code for setting 4 new variables

AS Guest Name
AS Room Number
AS Arrival Date
AS Departure Date

These are set from the Custon Data Fields for the relevant Booking Entity.

So when I go to the Accounts Screen and Highlight a booking account and execute AS Account operations everything works fine, the account screen is loaded and all the variable are set.

However when I execute AS Account Operations directly from my Guest Check out automation, the variables do not set set properly. Your script works fine to get the entity settings but my new settings which are supposed to read the entity custom data do not update.

My first thought was that the entity was not loaded so I loaded the entity in my automation but that made no difference.

Should I be creating a ticket before executing the AS Account Operations maybe? My thought is that selecting an account from the account screen maybe opens a ticket by entity selection.


No Ticket required. Selecting Account from Account Screen does not create a Ticket. It is not necessary.

Show how/where you did that. Was it done in the AS Set Statement Variables Rule?


Yes added the new variable with an entity data expression which works fine after account is selected from the account screen but not when I try point the automation directly . added variable settings after your script call


I would need to see exactly what you have done. But here is how this works … you might need to add to the SQL Script …



So I am still having some issues inconsistent operation of the AS Set Statement Variables rule. I have not tried to grab these values using the SQL script as I am unsure of the sytax to read Custom Data from the entity. So this is the rule I use.

Sorry screen grab is not perfect but you get the idea.

However I do know that this Rule works BUT only if the Account is selected from the Accounts screen.

This is what I get after pressing the Account Operations Button

As you can see the Room number, Guest Name etc are all clearly set by the rule above and this works fine.

What I am trying to do is Call the Account screen direct from my Guest check out automation. This automation is initiated by staff selecting a Room entity from a custom Entity Screen this process checks a few things regarding balance etc and the final 2 rules are as follows

As you can see I set AS Entity ID, and the CommandValue to the Booking Entity ID and the test message confirms this is all correct.

But I get this result

I have followed both options through the Rule Debugger and the Command Value is correct at all stages. My test messages all work up to the Set Variables Rule but the rule does not set the variables when called via my automation.

Simply put I feel that there is an action Hard coded in the select account screen operation that I have not included in my automation, hence the actions I have put in to set the Command Value and Load entities.

I hope this has an easy fix because my SQL skills are pretty non existant currently (although I think I will have to learn)

EDIT … In typing this I notice that the Account Balance is being set by the rule on both options (using {ENTITY BALANCE}. It must therefore apply only to setting values from Custom Data calls.


If this helps any these are the Rule Debugger results for each option

  1. Selected from Accounts screen and working

  2. Selected from Check out automation and NOT working


There is, sort of. When coming from the Accounts Screen, SambaPOS is aware of the Entity Type, because the Account Type is tied to the Entity Type.

Here is what I think is happening… these tags that you are using are not aware of the Entity Type from where they are being used (they are out of context):

{ENTITY DATA:Guest Name}
{ENTITY DATA:Checked In}

So I think you need to be more specific. For example, if the Entity Type is “Booking Entity”, you could try this:

{ENTITY DATA:Booking Entity:Room}
{ENTITY DATA:Booking Entity:Guest Name}
{ENTITY DATA:Booking Entity:Checked In}

Another thing you could try when it comes to getting Entity Data is this specific Tag, which should work in any context, because it forces you to specify the Entity Type:

ENTITY CUSTOMDATA BY NAME:X Entity Custom Data by entity name: <ET>.<EN>:<FN>

{ENTITY CUSTOMDATA BY NAME:entityType.entityName:customDataFieldName}

So it might look like this (if your Entity Type is called “Booking Entity”):

{ENTITY CUSTOMDATA BY NAME:Booking Entity.{SETTING:AS Entity Name}:Room}


Thanks again @QMcKay .

Thats fixed it and I think for all future automation I create its good practice to define specific reference to entities in this manner. It keeps it very clean and removes any ambiguity on which Entity is being referenced.

Thanks for your assistance.:smiley:


I’m trying to implement this, so far I have got the everything in play until this point, having issues navigating to the entity screen…I tried to use the AS account operations but it isn’t loading. I need help please


this is what i did

but still when I click on a customer and then account operations, it just click…nothing shows up


The button is constrained in the associated Rule so that it will not fire unless the selected Entity has an Account, and since you cannot select an Entity from the Navigation Screen, there is no need to configure those Navigation Settings. The button “click” in this case is handled by the Rule. If you have no Rule for the button, then you would use the Navigation Settings.

You can try removing the 2nd Constraint here to see if it works for you …


Thanks @QMcKay that worked perfectly…



I have been operating this system as per the previous comments for some time now and generally all is working ok, all variables are getting set properly etc etc.

I am however getting a problem on some accounts not displaying on the load statement function. The account balance is fine but no transactions are being displayed. If I go to the inbuilt accounts screen the transactions are detailed and are valid.

I thought this was a random problem caused by my system calling the automation from a couple of different operational processes but in all cases all the variables are properly set. On trying to fault find this process I think I have found the cause but have no idea how to resolve.

I had set up a Room account as standard and posted a sale transaction of 100 rupees to the account. This worked fine and the Account Operations button loaded the transaction on the Account Statement Screen. All good at this stage.

I then made an interim cash payment (which guests do quite often) of 50 rupees leaving a balance of 50 on the account.

This is what the screen displays

When checking the core accounts screen i get this

It looks to me like the load statement script or automation is filtering out all transactions prior to any payment or credit to the account. I am trying to follow the scripts to see what might cause this but my script knowledge is pretty average so I was hoping you knew a quick answer.


Hi @QMcKay

I have tried to implement this on a vanilla install of .61 (without any foreign currencies for now), but I am having an issue when it comes to paying credit on to a customer account. I get the message “Can’t complete this operation while zero priced orders exists.

Steps to produce this error…

  1. Create a customer and a customer account
  2. Sell a product to this customer using their account
  3. Select the customer again when creating another ticket (outstanding balance is correctly displayed next to the customer name).
  4. Click Account Operations
  5. Click Pay Account
  6. Click All
  7. Click Cash

After I close the pop-up message, I am left with a ticket screen as you can see below:

Any pointers would be appreciated!