# Print Last Bill

**URL:** <https://forum.sambapos.com/t/print-last-bill/24200>\
**Category:** V5 Question\
**Created:** [May 8, 2021, 3:28am UTC](https://forum.sambapos.com/t/print-last-bill/24200 "2021-05-08T03:28:28Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Muzzargh](https://forum.sambapos.com/user_avatar/forum.sambapos.com/muzzargh/32/55913_2.png) [@Muzzargh](https://forum.sambapos.com/u/Muzzargh)\
**Post date:** [May 8, 2021, 3:28am UTC](https://forum.sambapos.com/t/print-last-bill/24200/1 "2021-05-08T03:28:28Z")

</div>

Should the steps in this post: [Print Last Receipt via Automation Command - #8 by QMcKay](https://forum.sambapos.com/t/print-last-receipt-via-automation-command/2866/8)  
Work in the current version?

---

<div class="post-metadata">

**Author:** ![Jesse](https://forum.sambapos.com/user_avatar/forum.sambapos.com/jesse/32/61493_2.png) [@Jesse](https://forum.sambapos.com/u/Jesse)\
**Post date:** [May 8, 2021, 3:32am UTC](https://forum.sambapos.com/t/print-last-bill/24200/2 "2021-05-08T03:32:35Z")

</div>

Yes it will work just fine.

---

<div class="post-metadata">

**Author:** ![Muzzargh](https://forum.sambapos.com/user_avatar/forum.sambapos.com/muzzargh/32/55913_2.png) [@Muzzargh](https://forum.sambapos.com/u/Muzzargh)\
**Post date:** [May 10, 2021, 11:05am UTC](https://forum.sambapos.com/t/print-last-bill/24200/3 "2021-05-10T11:05:45Z")

</div>

Then I’ve done something wrong 😔

Here’s what I have so far.

I’ve created the Store Last Ticket Id Action:

![StoreLastTicketId](https://forum.sambapos.com/uploads/default/original/3X/1/2/12dfc3574e04220d41f3c86200fdc14847973ee7.png)

This is a little bit different here because I don’t print a bill with every transaction. 99.9% of customers don’t want one so it’s just a waste of paper so I’ve put the action into the Settle Rule:  
 ![Settle Rule](https://forum.sambapos.com/uploads/default/original/3X/7/1/71bc61c52d28f9fedff97028ce2e727ac5e26979.png)  
(I’ve put the Store Last Ticket ID Action above the Display Payment Screen Action since taking this screenshot)

Created the Automation command button:

![PLB AC](https://forum.sambapos.com/uploads/default/original/3X/b/5/b555db24e805c62d6f3878ef7e2ab347fd7247a1.png)

 ![PLB AC Mapping](https://forum.sambapos.com/uploads/default/original/3X/9/6/960ff8ea7de41b7a1ba213e07fb62834f331c218.png)

Created the Load Ticket action:

![Load Ticket](https://forum.sambapos.com/uploads/default/original/3X/c/a/ca30098f01640c15bed3cc457cc175b1b2386001.png)

and Created the Rule for the Automation command button:

 ![PLB1](https://forum.sambapos.com/uploads/default/original/3X/b/b/bb1229daf7a67c989b5af19aab7c96350981bb74.png)  
 ![PLB2](https://forum.sambapos.com/uploads/default/original/3X/8/f/8f6a9458c13b0a74b387a504bf3b28efe7ebb07f.png)

If I run with this I get:

![Last Ticket ID 0](https://forum.sambapos.com/uploads/default/original/3X/2/0/208b0457439dd5934d8ac7b20a2f678ccc39ab80.png)

and the subsequent print is a list of the ‘Bill’ template with placeholders and variable etc.

If I change the Settle rule ‘StoreLastTicketId’ action to {TICKET NO} (like on the printer template) from {TICKET ID} I get the actual last ticket number displayed in the above message.

However the last ticket number was 27584 but the ticket that prints is 13716  
If I create another ticket, 27585, the ticket that prints is 13717

I hope that all makes sense?

---

<div class="post-metadata">

**Author:** ![Muzzargh](https://forum.sambapos.com/user_avatar/forum.sambapos.com/muzzargh/32/55913_2.png) [@Muzzargh](https://forum.sambapos.com/u/Muzzargh)\
**Post date:** [May 10, 2021, 11:11am UTC](https://forum.sambapos.com/t/print-last-bill/24200/4 "2021-05-10T11:11:39Z")

</div>

One thing I did notice is that the original post has no ‘TicketId’ in the Refresh Ticket Action where my Action has that field. Should I put {SETTING:LastTicketId} into that field?

---

<div class="post-metadata">

**Author:** ![Jesse](https://forum.sambapos.com/user_avatar/forum.sambapos.com/jesse/32/61493_2.png) [@Jesse](https://forum.sambapos.com/u/Jesse)\
**Post date:** [May 10, 2021, 11:29am UTC](https://forum.sambapos.com/t/print-last-bill/24200/5 "2021-05-10T11:29:27Z")

</div>

Ticket iD does not exist until after you submit the ticket. Ticket ID is only generated when it creates the ticket in the database. Store it in Ticket Closed event.

---

<div class="post-metadata">

**Author:** ![JTRTech](https://forum.sambapos.com/user_avatar/forum.sambapos.com/jtrtech/32/21270_2.png) [@JTRTech](https://forum.sambapos.com/u/JTRTech)\
**Post date:** [May 10, 2021, 11:33am UTC](https://forum.sambapos.com/t/print-last-bill/24200/6 "2021-05-10T11:33:38Z")

</div>

Also, you shouldn’t need to load ticket, you can pass ticket id into the print job action directly 😉  
Just make a new execute print action with ticket id field carried into the action.

Plus Jessie comment about ticket id.  
My print last bill is on the mark ticket closed rule which I think is before ticket closing with balance 0 constraint.

---

<div class="post-metadata">

**Author:** ![Muzzargh](https://forum.sambapos.com/user_avatar/forum.sambapos.com/muzzargh/32/55913_2.png) [@Muzzargh](https://forum.sambapos.com/u/Muzzargh)\
**Post date:** [May 10, 2021, 11:40am UTC](https://forum.sambapos.com/t/print-last-bill/24200/7 "2021-05-10T11:40:58Z")

</div>

Thanks guys, I’ll try this after work tomorrow, cheers.

---

<div class="post-metadata">

**Author:** ![Muzzargh](https://forum.sambapos.com/user_avatar/forum.sambapos.com/muzzargh/32/55913_2.png) [@Muzzargh](https://forum.sambapos.com/u/Muzzargh)\
**Post date:** [May 12, 2021, 8:16am UTC](https://forum.sambapos.com/t/print-last-bill/24200/8 "2021-05-12T08:16:21Z")

</div>

Hmmm, no joy with that either. I tried both suggestions. Still the only way to get an actual ticket number in the message is to use {TICKET NO} (instead of {TICKET ID}) in the StoreLastTicketId action.  
 ![Capture](https://forum.sambapos.com/uploads/default/original/3X/9/b/9bd3d3dc687cb200e380e3e502c469aa6f8090cc.png)

But even then, nothing prints 😟  
Maybe I’ll delete and try again from scratch.

---

<div class="post-metadata">

**Author:** ![JTRTech](https://forum.sambapos.com/user_avatar/forum.sambapos.com/jtrtech/32/21270_2.png) [@JTRTech](https://forum.sambapos.com/u/JTRTech)\
**Post date:** [May 12, 2021, 8:38am UTC](https://forum.sambapos.com/t/print-last-bill/24200/9 "2021-05-12T08:38:42Z")

</div>

What rule event is that in?

---

<div class="post-metadata">

**Author:** ![Muzzargh](https://forum.sambapos.com/user_avatar/forum.sambapos.com/muzzargh/32/55913_2.png) [@Muzzargh](https://forum.sambapos.com/u/Muzzargh)\
**Post date:** [May 12, 2021, 10:14am UTC](https://forum.sambapos.com/t/print-last-bill/24200/10 "2021-05-12T10:14:25Z")

</div>

It was in the Settle rule then I tried the Close rule then Closing? Rule (sorry can’t remember the exact rule name, I’m at home right now).

---

<div class="post-metadata">

**Author:** ![JTRTech](https://forum.sambapos.com/user_avatar/forum.sambapos.com/jtrtech/32/21270_2.png) [@JTRTech](https://forum.sambapos.com/u/JTRTech)\
**Post date:** [May 12, 2021, 3:24pm UTC](https://forum.sambapos.com/t/print-last-bill/24200/11 "2021-05-12T15:24:29Z")

</div>

See this old tutorial of mine.

> [@Tutorial: Basic Print Last Bill/Receipt Button (JTRTech)](https://forum.sambapos.com/t/tutorial-basic-print-last-bill-receipt-button-jtrtech/5588):
>
> I know there are other similar tutorials but wanted to upload a simple quick one for ‘Print Last Bill’ First you’ll need to setup a rule to log the last paid ticket. This is uses a update program setting action used in many setups and your likely to already have so havent’t gone into that. You could use local but I have used ‘not local’ and logged against program setting of LASTBILL\_{:CURRENTTERMINAL} Have added the two constraints to only log tickets that are closed with no remaining balance…

---

<div class="post-metadata">

**Author:** ![Muzzargh](https://forum.sambapos.com/user_avatar/forum.sambapos.com/muzzargh/32/55913_2.png) [@Muzzargh](https://forum.sambapos.com/u/Muzzargh)\
**Post date:** [May 13, 2021, 3:57am UTC](https://forum.sambapos.com/t/print-last-bill/24200/12 "2021-05-13T03:57:25Z")

</div>

I’ve solved it!!!

Basically my Refresh Ticket Action had the TicketId field (because I had copied from another Refresh Ticket Action). When that field was empty a value of 0 was passed on instead of the actual ticket id.

Thanks for all the help guys!

---

<div class="post-metadata">

**Author:** ![Muzzargh](https://forum.sambapos.com/user_avatar/forum.sambapos.com/muzzargh/32/55913_2.png) [@Muzzargh](https://forum.sambapos.com/u/Muzzargh)\
**Post date:** [May 13, 2021, 4:01am UTC](https://forum.sambapos.com/t/print-last-bill/24200/13 "2021-05-13T04:01:09Z")

</div>

And just an FYI…

I added a widget to my main screen:

 ![Main Screen](https://forum.sambapos.com/uploads/default/original/3X/9/b/9be21a9f6f390f3e8fc715d5adcc574a9ab692c4.png)  
 ![PLB Button Settings](https://forum.sambapos.com/uploads/default/original/3X/2/3/230b4361cae90bf8ca483334ed317386f8d27d6f.png)

I can run the command from here just fine. 🤓
