Cusom report for entity states

I am still working on a good method to track customers who owe me money (have a debt on their customer account) at the moment. To work out who owes me money at the moment I need to store an “Arrival Date” for the customer. (I’m not bothered about customers with a balance to pay a long way off in the future).

I was initially setting a ticket tag with the arrival date, but I am starting to see limitations of this approach.

I am now looking to set an Entity State to store the arrival date. I have been able to set the entity state using an action and I can read it using the action below:

Little question: Why does {ENTITY STATE:Arrival} work? How does SambaPOS know I am referring to the Customer entity and not the Table entity?

The problem I now have is how to use this Entity state in a Custom Report?

I have tried using the various report tags that mention Entity States, but I get nothing outputted by any of them.

Ideally, I would like to get fields EntityName,EntityBalance,EntityState:Arrival from a custom report and ideally filter this report on a specific date range, such as Last 30 Days && Next 4 Days

Any ideas how I read these Entity States? So far, most examples I have found seem to be related Employee Time Clocks which seem to use Entity State Logs, which seems to be different to Entity States???

It must be working it out based on the state name.
Im not sure if you can specify entity in that tag like {ENTITY STATE:EntityType:StateName} - dont think you can, this tag is typically used within the entity section of a template so it would know entity type from the section.
Typically I prefix my custom states or use unique names. My hotel setup didnt have duplicate states on multiple entities but have RStatus for Room Status so I knew I can specify that perticular state.
You probably want to try and do is use a report expression and specify the entity name in it like {REPORT ENTITY DETAILS:EntityState:(EN={ENTITY NAME:Customers})} - thats not acurate just a sample/idea.

Thanks @JTRTech, I am confused about how I pull an Entity state in to a {REPORT ENTITY DETAILS} tag? The report below correctly pulls John’s balance, how can I also include the “Arrival” entity state?

[Test1:1,1,1,1,1]
{REPORT ENTITY DETAILS:E.Balance:(EN=John Smith)}

That’s what I figured, maybe because it a unique state name accrosss all entities SambaPOS is making that assumption

For me…
{ENTITY STATE:Customers:Arrival} Does not work (in a Show Message pop-up)
{ENTITY STATE:Arrival} Does work (in a Show Message pop-up)

What are you setting up?
You might be better to use custom data fields. Thats what I used for arrival/departure and booking details synced from PMS API into samba. An these are easily available with report expressions and print templates.
It depends what your trying to do whats best.
Arrival sounds like data rather than a state, generally I keep states for mapping buttons and order type automation/scripting. I have very few entity states beyond the default status and one to enable/disable rooms who arent checked in and filtering customers which is status anyway.

It can depend on the Rule/Event from which you read Entity-related Data (Name, States, Custom Fields). Certain Rules require the Entity Type while others do not, and in some Rules, the Entity Type must be omitted.

There are some particular Global Tags that you can use if you find it confusing:

{ENTITY CUSTOMDATA BY NAME:<ET>.<EN>:<FN>}
{ENTITY STATE BY NAME:<ET>.<EN>:<ST>}

where:

<ET> = EntityType
<EN> = EntityName
<FN> = CustomData FieldName
<ST> = StateName

For example:

{ENTITY CUSTOMDATA BY NAME:Customers.John:Phone}
{ENTITY STATE BY NAME:Customers.John:ArrivalDate}

P.S. I rarely use those Tags, but there are a few cases where I found them helpful. Generally when I build something, I just put a Show Message Action at the top the Rule, and have it display both formats to know what is available for that Rule, and go from there.

1 Like

Thanks @QMcKay

ENTITY STATE BY NAME does retrieve the Entity state.

If I am storing a date is there anything powerful I can do like I can with a Ticket Tag (The TTDR filter seems to work very well).

I now have this which is displaying the three key pieces of info that I want, but it seems inefficient to be doing 2 of the same REPORT ENTITY DETAILS commands.

[Test2:1,1,1]
@{REPORT ENTITY DETAILS:E.Name,E.Balance.sum:(ET=Customers):{0}::($2 != 0):,}
{REPORT ENTITY DETAILS:E.Name,E.Balance.sum:(EN=$1):{0}|{1}|{ENTITY STATE BY NAME:Customers.$1:Arrival}}

Should I be doing this in a more efficient way?

Try doing it outside the details report expression;

{REPORT ENTITY DETAILS:E.Name,E.Balance.sum:(EN=$1):{0}|{1}}|{ENTITY STATE BY NAME:Customers.$1:Arrival}

I see what you are getting at, my I don’t get anything outputted after the first report (The additional Entity State report tag gives no output. In fact, even if I just try to force some text there it doesn’t output anything - Is the syntax you suggested above valid?

@{REPORT ENTITY DETAILS:E.Name,E.Balance.sum:(ET=Customers):{0}::($2 != 0):,}
{REPORT ENTITY DETAILS:E.Name,E.Balance.sum:(EN=$1):{0}|{1}}|{ENTITY STATE BY NAME:Customers.John Smith:Arrival}

Outputs only Names and Balanes
@{REPORT ENTITY DETAILS:E.Name,E.Balance.sum:(ET=Customers):{0}::($2 != 0):,}
{REPORT ENTITY DETAILS:E.Name,E.Balance.sum:(EN=$1):{0}|{1}}|myColumn|anotherColumn

Outputs only Names and Balanes

I’m not familier with that expression, Qs post is first time I have seen so not sure.
Test on its own and find the issues.

1 Like