Gift Certificates search doesn't work

@QMcKay
There is other problem, after two times redemption the balance, the used gift certificate will disappear from the Gift Certificate Entity screen search. I have re-checked this time and there is no blank space no more.

If the Balance is depleted, the Entity State is changed from Purchased to Redeemed. Since the Search Screen is set to filter for Purchased only, the GCs that are Redeemed will disappear. This is by design.

@QMcKay
Isn’t it the GCStatus only changed from Purchased into Redeemed if “[=-1*TN(’{ENTITY BALANCE:Gift Certificate}’)-[:ProcessedAmount]]<=0” ?, why if in my case the balance haven’t reaching <= 0 being changed into redeemed ?.

How to use the Gift Certificate balance fully until 0 then ?

You are correct. I just tested that as well, and it appears to be working fine.

##GC Redeemed (update GC data)##

Rule Name: GC Redeemed (update GC data)
Event Name: Payment Processed
Custom Constraint List:
Execute Rule if: Matches All
Payment Type NameEqualsGift Certificate
{ENTITY NAME:Gift Certificate}StartsGC20
[=-1*TN('{ENTITY BALANCE:Gift Certificate}')]Greater0

##Actions:##

GC Balance Update

Constraint: (none)

CertNum: {ENTITY NAME:Gift Certificate}
Bal: [=-1*TN('{ENTITY BALANCE:Gift Certificate}')-[:ProcessedAmount]]
GC Redeem

Constraint: (none)

Account Name: GC Redemptions
CertNum: {ENTITY NAME:Gift Certificate}
Amount: [:ProcessedAmount]
GC Update State GCStatus

Constraint: [=-1*TN(‘{ENTITY BALANCE:Gift Certificate}’)-[:ProcessedAmount]]<=0

CertNum: {ENTITY NAME:Gift Certificate}
Current GCStatus: Purchased
New GCStatus: Redeemed
GC Add Line to Text File

Constraint: [=1+2]>[=2+2]

sometext: {DATE} {TIME}, {ENTITY NAME:Gift Certificate} ([=-1*TN('{ENTITY BALANCE:Gift Certificate}')]), Redeemed [:ProcessedAmount], New Balance [=-1*TN('{ENTITY BALANCE:Gift Certificate}')-[:ProcessedAmount]]
GC Update Ticket Tag GCN

Constraint: (none)

GCName: {ENTITY NAME:Gift Certificate}
GC Update Ticket Tag GCB

Constraint: (none)

GCBalance: [=-1*TN('{ENTITY BALANCE:Gift Certificate}')-[:ProcessedAmount]]
GC Entity Change to Invalid

Constraint: [=-1*TN(‘{ENTITY BALANCE:Gift Certificate}’)-[:ProcessedAmount]]<=0

Display Payment Screen

Constraint: [:RemainingAmount]>0

Close Ticket

Constraint: [:RemainingAmount]<=0


Purchase GC for 500.
Use GC for 120.
GC Balance = 380
GCStatus (Entity State) remains as “Purchased”

Then what i did wrong?, in my case it always 2 times spending the balance and then the GCStatus became Redeemed?.
I have re-checked the “RU GC Redeemed (update GC data)” and it’s like the tutorial.

LOL, I don’t know what you did wrong.

The Rule Debugger is great to see what is being fired, and when, and how many times. But I still use Show Message Action more than anything to debug. It can really tell you a lot of what is happening if you put enough information into the message.

Is the Rule being triggered twice? Do you have it set to Matches All?

Is the Tx Doc or Tx Type not configured properly?

Is another Payment Processed Rule/Event interfering?

@QMcKay
I have tried using Show Message and the values indeed correct, a positive number more than 0, and from rule debugging after the third transaction the “AC GC Update State GCStatus” get invoked believing the balances has reaches <=0.

The rule only triggered once, and it seems there is no other rules overlapping the “AC GC Update State GCStatus”.

I am really need help dude.

@QMcKay

The fix is adding () in constraint, so in “RU GC Redeemed (update GC data)” rule, change “AC GC Update State GCStatus”‘s constraint from "[=-1TN(’{ENTITY BALANCE:Gift Certificate}’)-[:ProcessedAmount]]<=0" into "([=-1TN(’{ENTITY BALANCE:Gift Certificate}’)-[:ProcessedAmount]]<=0)"

One more problem, how to edit Gift Certificate balance ?, for example original Balance “200”, and i am editing it into 100, the Gift Certificate entity reflected the changes but not the accounting (Account Details) nor when i am ordering something through a ticket.

How to make sure all balance changes reflecting into accounting and ticket balance?

Also how remove “Edit Gift Certificates” & “New Gift Certificates” buttons from the Gift Certificates’s entity screen?

So it looks like the Action Constraint is not preventing the action from firing…

[=-1*TN('{ENTITY BALANCE:Gift Certificate}')-[:ProcessedAmount]]

If you do a Show Message with the value computed from above, it should show a value that is greater than zero. If it is not, then that GCStatus is updated to Redeemed.

@QMcKay
Show message of :

[=-1*TN('{ENTITY BALANCE:Gift Certificate}')-[:ProcessedAmount]]

Always showing a positive non-zero values, yet without enclosing with “()” the “AC GC Update State GCStatus” constraint will failed to do the logic test after 2 tries, either it’s a bug in sambapos or it’s a must, new one on v5.

Ping @emre,

Please add feature to automatically deduct or delete blank space from the beginning of a text on text field, thus make it impossible to do the same mistake as i did.

Does the logic on every constraint need to be enclosed by “()” ?, does this a feature or a bug?

We do it for action action parameters but in constraints section space char might be intentionally used.

No it should work fine without parenthesis. That might be something else… I’ll check it.

That’s the strange thing, that specific constraint seems only evaluated twice or thrice and then the constraint being ‘ignored’ unless i am adding parenthesis into the constraint.

Can you create a backup and PM me the zip file?

1 Like

@emre

Done, i hope you will manage to find the problems/bugs. Thanks for taking the time to check it out.

The Balance shown in the Entity Data is simply a visual indicator for quick reference - it is not meant to be edited. Editing it makes no difference to the actual Account Balance.

If you want to edit the actual Account Balance, you will need to create a Tx Doc, add a Transaction to the Doc with an amount that you want to add or subtract to/from the balance, and save the Doc. This is not something you should be doing on a regular basis.

You cannot alter a “Search”-mode Entity Screen. That said, with recent additions in v5, you can use a Custom Entity Screen with an Entity Search Widget. The Widget allows modifications to the buttons.

1 Like

@Prodigy I removed parenthesis from constraint and could use gift certificate multiple times until it fully used. In fact having extra parenthesis does changes how constraint works.

@QMcKay,

Thanks for the pointer, it works fine with custom entity screen :smile:. You are right editing balance would make the accounting details looks awful.

emre,

Strange, I swear it wasn’t works without parenthesis, yeah you are right it works fine without it, probably because i am using 5.1.57 ?, sorry for the false alarm.