Execute Print Job Action - Parameters not working in ticket

I’ve been trying to get this to work all night so that I can pass parameters to an SQL query in a print job, but I can’t get this to produce anything other than text ($KEY). I’ve seen it used in reports by @QMcKay but a prior post form Emre seems that it should work in the print job (the point of the option in the action). The reason for this is I’m trying to print receipts based {PAYMENT DATA} or P.Id so that I we can have separate receipts for multiple customers making CC payments on the same ticket.

https://forum.sambapos.com/t/sambapos-5-1-61-beta/11464/346

@Jesse I have this working now, but I’m running into an issue with the print job action not firing when displaying a ticket.

Process

  1. Get all Payment IDs from the current ticket (I am able to do this with a SQL QUERY)
  2. Loop through Payment IDs and run a print job action to reprint individual payment receipts.

If I run this process from the navigation screen it works fine. To test it I just tossed in some static print job parameters. When I fire the action within a ticket the parameters come through fine, but it seems like the print action doesn’t fire.

Is there anything restricting this? I need to be able to process it within a ticket to get the {TICKET ID}.

It appears the $KEY parameter isn’t passing to the print job when using the automation command inside a ticket.

Any IDEAS?

Hey @josephrussell try putting <J00>Card Payment|{REPORT PAYMENT DETAILS:P.TenderedAmount} inline and dont use [PAYMENTS] section.

I haven’t finalized the print template, but I’m not using a the payments section. I’m trying to report on the JSON PaymentData by pulling from an {REPORT SQL DETAILS} based on the payment ID.

This works fine except for when I execute the rule inside a ticket.

It needs to have <J00> in front of it.

EDIT: NM I see what you did… you added that in the field outpout.

The output has <L00> in front of it. Its really the print parameter isn’t sending in a ticket.

Can you paste the raw text here… I will test the same thing you are doing.

I’m creating a process for reprinting credit card signature slips. This means I need to print a slip per payment.

Current Print Template

[LAYOUT]
<T>Receipt
<L00>Date:{DOCUMENT DATE}
<L00>Time:{DOCUMENT TIME}
<L00>{DESCRIPTION}
<F>-
<F>

{REPORT SQL DETAILS:SELECT
jsonData.[pdauth_code]
,jsonData.[pdCardHolderName]
,jsonData.[pdCardBrand]
,[Amount]
,[Date]
FROM [Payments] p

CROSS APPLY OPENJSON(p.[PaymentData])
-- this WITH portion allows explicit definition of the schema JSON Keys for output
-- and gives references to the columns/fields above in the SELECT portion
-- we can also use these as filters in the WHERE clause below
WITH (   
pdTransactionID         varchar(1000) '$.TransactionID'
,pdauth_code        varchar(1000) '$.auth_code'
,pdCardHolderName        varchar(1000) '$.CardHolderName'
,pdCardBrand        varchar(1000) '$.CardBrand'
) jsonData
WHERE 1=1
AND [PaymentData]!=''
AND [ID]='@1'
ORDER BY [Date]
;$KEY
:F.Date
,F.pdauth_code
,F.pdCardHolderName
,F.pdCardBrand
,F.Amount::
<L00>PID\: $KEY
<L00>DATE\: {0}
<L00>AUTH\: {1}
<L00>NAME\: {2}
<L00>CARD\: {3}
<L00>AMOUNT\: {4}}

Automation Command Rule

{REPORT SQL DETAILS:SELECT [Id] FROM [Payments] p WHERE [TicketId]=@1;{TICKET ID}:F.Id::$KEY={0},}

Value Looped Rule

image

Since passing values through the execute print job parameter doesn’t appear to be working while in a ticket, a temporary solution for this to:

  1. Store the passed value in a local variable
  2. Update the print template to use the variable {SETTING:Variable}
1 Like

I just switched my printer from ESC/POS to HTML After doing so, the loop isn’t working. When processing multiple payment receipts from the same ticket its printing the same payment data. If I put a message action in the rule then it prints properly. Its like the the update setting action is updating the variable a second time before the the print rule is able to run the query in the print template. Any thoughts?

For example, the two tickets on the left have no message box in the rule and the two on the right have a message box to prompt the payment id in the loop rule. We might need the print parameter to make this work properly.

2 Likes

So I changed the print job priority to High and it seems to work fine now. I still think we need to be able to pass parameters to the print job rather than assign variables for this sort of action. As long as its working I’m happy.

Getting very close to having my bill/cc slip where I want it.

IMG_2880

Joe if you could share your receipt template that would be wonderful. We have another USA client that would be interested.

Its the template you provided me with some minor modifications. I’ll gladly post it, but quick question. Is there any easy way to post on the forum that escapes the <tags> without manually inserting a \ to every line?

Highlight code before submitting and click the code button of editor bar.
</>

@JTRTech Thanks, I should have known that. Really tired…

Jesse- Here is the template I’m using right now. I’m calculating the tip recommendations based on the amount from the Payments table. Also I have my logo preloaded to the scanner since it improves both quality and speed for my specific printer. I’m still cleaning up the template.

[LAYOUT]
<EC>

-- Logo is being printed using stored printer logo and built in printer settings
-- Alternative Method "Slower" <img src="C:\Users\josep\Documents\SambaPOS5\plogo.png">

<div style="font-size:13px;text-align:center;font-family:'Helvetica'">113 E Holly Street<br>Bellingham, WA 98226<br>(360) 933-4301<br></div>
<div style="font-size:13px;text-align:center;font-weight:bold;font-family:'Helvetica'">Order @ HorseshoeCafe.com</div>

-- <div style="margin:0 0 0 0;padding:0 0 0 0;border:3 0 0 0;border-color:black">
-- <div style="font-size:20px;font-weight:normal;text-align:left;font-family:'Helvetica'">{TICKET TYPE} ORDER # {TICKET NO}</div>
-- <div style="font-size:17px;font-weight:normal;text-align:left;font-family:'Helvetica'">{ENTITIES}</div>
-- <div style="font-size:17px;font-weight:bold;text-align:left;font-family:'Helvetica'">&zwnj;</div>
-- <div style="font-size:15px;text-align:left;font-family:'Calibri'">{NOTE}</div>
-- <div style="font-size:25px;font-weight:bold;text-align:right;font-family:'Helvetica'">[Table: [{ENTITY NAME:Table}]]</div>

<div style="margin:0 0 0 0;padding:0 0 0 0;border:1 0 0 0;border-color:black">
<div style="font-size:13px;font-weight:bold;text-align:left;font-family:'Helvetica'">
<table>
<tr>
<td width="25">Qty</td>
<td width="180">Item</td>
<td width="38" align=right>Price</td>
</tr>
</table>
</div>

<div style="margin:0 0 0 0;padding:0 0 0 0;border:1 0 0 0;border-color:black">
{ORDERS}
<div style="font-size:15px;text-align:center;font-family:'Helvetica'"><br/>{TICKET QUANTITY SUM} Item(s)</div>
<div style="font-size:15px;font-weight:bold;text-align:justify;font-family:'Calibri'">
<table>
<tr>
<td align="left">Subtotal</td><td align="right">${PLAIN TOTAL}</td>
</tr>
</table>
</div>

{DISCOUNTS}

[<div style="font-size:15px;font-weight:normal;text-align:justify;font-family:'Calibri'">
<table>
<tr>
<td align="left">Discount</td><td align "right">-${ORDER TAG TOTAL:Seafood & Crab Boil Discount}</td>
</tr>
</table>
</div>]

[<div style="font-size:15px;font-weight:normal;text-align:justify;font-family:'Calibri'">
<table>
<tr>
<td align="left">Line Discount</td><td align "right">-$[=F(TN('{ORDER TAG TOTAL:Discount Item Custom Value}')*-1+TN('{ORDER TAG TOTAL:Price Override}')*-1+TN('{ORDER TAG TOTAL:Discount Item Custom Percent}')*-1,'0.00')]</td>
</tr>
</table>
</div>]

[<div style="font-size:15px;font-weight:normal;text-align:justify;font-family:'Calibri'">
<table>
<tr>
<td align="left">Transaction Discount</td><td align "right">-$[=F(TN('{CALCULATION TOTAL:Discount Ticket Total Percent}')*-1,'0.00')]</td>
</tr>
</table>
</div>]

[<div style="font-size:15px;font-weight:normal;text-align:justify;font-family:'Calibri'">
<table>
<tr>
<td align="left">Staff Discount 10%</td><td align "right">-$[=F(TN('{CALCULATION TOTAL:Staff Discount}')*-1,'0.00')]</td>
</tr>
</table>
</div>]

[<div style="font-size:15px;font-weight:normal;text-align:justify;font-family:'Calibri'">
<table>
<tr>
<td align="left">Owner Discount 100%</td><td align "right">-$[=F(TN('{CALCULATION TOTAL:Manager Discount}')*-1,'0.00')]</td>
</tr>
</table>
</div>]

[<div style="font-size:15px;font-weight:normal;text-align:justify;font-family:'Calibri'">
<table>
<tr>
<td align="left">Loyalty Discount 10%</td><td align "right">-$[=F(TN('{CALCULATION TOTAL:Loyalty Discount}')*-1,'0.00')]</td>
</tr>
</table>
</div>]

[<div style="font-size:15px;font-weight:bold;text-align:justify;font-family:'Calibri'">
<table>
<tr>
<td align="left">Discount Total</td><td align "right">-$[=F(TN('{ORDER TAG TOTAL:Discount Item Custom Value}')*-1+TN('{ORDER TAG TOTAL:Discount Item Custom Percent}')*-1+TN('{ORDER TAG TOTAL:Price Override}')*-1+TN('{CALCULATION TOTAL:Discount Ticket Total Percent}')*-1+TN('{CALCULATION TOTAL:Staff Discount}')*-1+TN('{CALCULATION TOTAL:Manager Discount}')*-1+TN('{CALCULATION TOTAL:Loyalty Discount}')*-1,'0.00')]</td>
</tr>
</table>
</div>
<F>-]


{TAXES}
{SERVICES}

<div style="font-weight:bold;margin:0 0 0 0;padding:0 0 0 0;border:1 0 0 0;border-color:black">

<div style="font-size:22px;font-weight:bold;text-align:justify;font-family:'Calibri'">
<table>
<tr>
<td align="left">Total</td><td align "right">${TICKET TOTAL}</td>
</tr>
</table>
</div>

-- {PAYMENTS}
-- <div style="font-size:15px;font-weight:bold;text-align:justify;font-family:'Calibri'">
-- <table>
-- <tr>
-- <td align="left">Credit Charge</td><td align="right">${TENDERED TOTAL}</td>
-- </tr>
-- </table>
-- </div>
-- <div style="font-size:15px;font-weight:bold;text-align:justify;font-family:'Calibri'">
-- <table>
-- <tr>
-- <td align="left">Change</td><td align="right">${CHANGE TOTAL}</td>
-- </tr>
-- </table>
-- <table>
-- <tr>
-- <td align="left">{TICKET TAG:GCN}</td>
-- <td align="right">{TICKET TAG:GCB}</td>
-- </tr>
-- </table>
-- </div>
-- </div>

-- <F>
-- <F>
-- <div style="font-size:15px;font-weight:bold;text-align:center;font-family:'Calibri'">
-- <L00>Thank You
-- </div>

-- <EC>
-- <BAR>{TICKET ID}
-- <QR>{TICKET ID}
-- <div style="margin:0 0 0 0;padding:0 0 0 0;border:3 0 0 0;border-color:black">
-- <div style=font-size:13px;text-align:left;font-family:'Calibri'">{TICKET TYPE} via {:CURRENTTERMINAL} {USER NAME}</div>
-- <div style=font-size:13px;text-align:left;font-family:'Calibri'">{TICKET NO} {TICKET DATE} {TIME}</div>

{REPORT SQL DETAILS:SELECT [Id]
,jsonData.[pdauth_code]
,jsonData.[pdCardHolderName]
,jsonData.[pdCardBrand]
,jsonData.[pdAccount]
,[Date]
,[Amount]
,[Name]
FROM [Payments] p
CROSS APPLY OPENJSON(p.[PaymentData])
-- this WITH portion allows explicit definition of the schema JSON Keys for output
-- and gives references to the columns/fields above in the SELECT portion
-- we can also use these as filters in the WHERE clause below
WITH (   
 pdTransactionID varchar(1000) '$.TransactionID'
,pdauth_code varchar(1000) '$.auth_code'
,pdCardHolderName varchar(1000) '$.CardHolderName'
,pdCardBrand varchar(1000) '$.CardBrand'
,pdAccount varchar(1000) '$.Account'
) jsonData
WHERE 1=1
AND [Name]='Credit Card'
AND [Id]='@1'
;{SETTING:PaymentId}
:F.Date
,F.Amount
,F.Id
,F.pdauth_code
,F.pdCardHolderName
,F.pdCardBrand
,F.pdAccount::
<div style="font-size\:15px;font-weight\:bold;text-align\:justify;font-family\:'Calibri'">
<table>
<tr>
<td align="left">Credit Charge</td><td align="right">${1}</td>
</tr>
</table>
</div>
<div style="font-size\:15px;font-weight\:bold;text-align\:center;font-family\:'Calibri'">
Thank You
</div>
<div style="font-weight\:normal;margin\:20 10 0 20;padding\:0 0 0 0;font-size\:15px;text-align\:left;font-family\:'Calibri'">
<table>
<tr><td width="250"><span style='font-weight\:bold;text-decoration\:underline;'>Payment Details</span></td></tr>
<tr><td width="250">ACCOUNT\: {6}<br />CARD HOLDER\: {4}<br />CARD TYPE\: {5}<br />DATE\: {0}<br />AUTH\: {3}<br />CHARGE\: ${1}<br /></td></tr>
</table>
</div>

<div style="font-weight\:normal;margin\:20 10 0 20;padding\:0 0 0 0;border\:1 1 1 1;border-color\:black;font-size\:15px;text-align\:center;font-family\:'Calibri'">
<table border="1">
<tr>
<td style="background-color\:black;"><SPAN STYLE="color\:black;font-weight\:bold;">TIP</span></td>
</tr>
</table>
<table>
<tr>
<td width="30"><span style='font-size\:20px;'>&#10063;</span></td>
<td width="30" align=left>15%</td>
<td width="80">Tip\: $[=F(Math.round((TN('{1}') * 0.15)*100)/100,'0.00')]</td>
<td width="80">Total\: $[=F(Math.round((TN('{1}') * 0.15)*100)/100 + {TICKET TOTAL},'0.00')]</td>
</tr>
<tr>
<td width="30"><span style='font-size\:20px;'>&#10063;</span></td>
<td width="30" align=left>18%</td>
<td width="80">Tip\: $[=F(Math.round((TN('{1}') * 0.18)*100)/100,'0.00')]</td>
<td width="80">Total\: $[=F(Math.round((TN('{1}') * 0.18)*100)/100 + {TICKET TOTAL},'0.00')]</td>
</tr>
<tr>
<td width="30"><span style='font-size\:20px;'>&#10063;</span></td>
<td width="30" align=left>20%</td>
<td width="80">Tip\: $[=F(Math.round((TN('{1}') * 0.20)*100)/100,'0.00')]</td>
<td width="80">Total\: $[=F(Math.round((TN('{1}') * 0.20)*100)/100 + {TICKET TOTAL},'0.00')]</td>
</tr>
<tr>
<td width="30"><span style='font-size\:20px;'>&#10063;</span></td>
<td width="30" align=left>25%</td>
<td width="80">Tip\: $[=F(Math.round((TN('{1}') * 0.25)*100)/100,'0.00')]</td>
<td width="80">Total\: $[=F(Math.round((TN('{1}') * 0.25)*100)/100 + {TICKET TOTAL},'0.00')]</td>
</tr>
<tr>
<td width="30"><span style='font-size\:20px;'>&#10063;</span></td>
<td width="100" align="center">$&#95;&#95;&#95;&#95;&#95;&#95;&#95;&#95;&#95;&#95;&#95;</td>
<td width="100" align="center">$&#95;&#95;&#95;&#95;&#95;&#95;&#95;&#95;&#95;&#95;&#95;</td>
</tr>
<tr>
<td width="30"><span style='font-size\:20px;'>&zwnj;</span></td>
<td width="100" align="center">Custom Tip</td>
<td width="100" align="center">Total</td>
</tr>
</table>
</div>
}

<div style="font-size:15px;font-weight:normal;text-align:center;font-family:'Calibri'">
<table>
<tr>
<td><br /><Span Style="font-weight:bold">MERCHANT COPY</span></td>
</tr>
<tr>
<td><span style="font-size: 9pt">I agree to pay the above total amount <br>according to the card issuer agreement.<br></span></td>
</tr>
<tr><td>&zwnj;</td>
</tr>
</tr>
<tr><td>X&#95;&#95;&#95;&#95;&#95;&#95;&#95;&#95;&#95;&#95;&#95;&#95;&#95;&#95;&#95;&#95;&#95;&#95;&#95;&#95;&#95;&#95;&#95;&#95;&#95;&#95;&#95;&#95;<br /><br /></td>
</tr>
<tr><td>&zwnj;</td>
</tr>
</table>
</div>

{ENTITIES}

[DISCOUNTS]
<div style="font-size:15px;font-weight:bold;text-align:justify;font-family:'Calibri'">
<table>
<tr>
<td align="left">{CALCULATION NAME} {CALCULATION AMOUNT}%</td><td align="right">${CALCULATION TOTAL}</td>
</tr>
</table>
</div>

[PAYMENTS]
<div style="font-size:15px;font-weight:bold;text-align:justify;font-family:'Calibri'">
<table>
<tr>
<td align="left">{PAYMENT NAME}</td>
<td align="right">${TENDERED}</td>
</tr>

<tr>
[<td align="left">[Cardholder</td>
<td align="right">{PAYMENT DATA:CardHolderName}]</td>]
</tr>
</table>
</div>


[ORDERS]
-- Default format for orders
<div style="font-weight:normal;font-size:13px;text-align:right;font-family:'Calibri'">
<table>
<tr>

<td width="25" align=center><span style="font-weight:bold">{QUANTITY}</span></td>
<td width="135" align=left><span style="font-weight:bold">{PRODUCT NAME}  {PORTION}</span></td>
-- <td width="35"> ${PRICE}</td>
<td width="35"> &zwnj;</td>
<td width="5">&zwnj;</td>
<td width="38"><span style="font-weight:bold">${TOTAL AMOUNT}</span></td>
</tr>

</table>
</div>

{SORTED ORDER TAGS}

[ORDERS:Gift]
-- Format for gifted orders
<div style="font-weight:normal;font-size:13px;text-align:right;font-family:'Calibri'">
<table>
<tr>

<td width="25" align=center><span style="font-weight:bold">{QUANTITY}</span></td>
<td width="140" align=left><span style="font-weight:bold">{NAME}</span></td>
<td width="45"> ${PRICE}</td>
<td width="1">&zwnj;</td>
<td width="40"><span style="font-weight:bold">FREE</span></td>

</tr>
</table>
</div>

{SORTED ORDER TAGS}



[ORDERS:Void]
-- Do not print


[SORTED ORDER TAGS]
-- Format for order tags
[<div style="font-size:12px;text-align:left;font-family:'Calibri'">
<table>
<tr>
<td width="25">***</td>
<td width="190">Line Discount: {ORDER STATE:DStatus}</td>
<td width=45 align=right>-£[=F(TN('{ORDER TAG TOTAL:Discount Item Custom Value}')+TN('{ORDER TAG TOTAL:Discount Item Custom Percent}')*-1),'0.00']</td>
</tr>
</table>
</div>]

[<div style="font-size:10px;text-align:left;font-family:'Calibri'">
<table>
<tr>
<td width="25">***</td>
<td width="190">Price Override: {ORDER STATE:PStatus}</td>
<td width=45 align=right>-£[=F(TN('{ORDER TAG TOTAL:Price Override}')*-1),'0.00']</td>
</tr>
</table>
</div>]


<div style="font-size:13px;text-align:left;font-family:'Calibri'">


<table>
<tr>

<td width="25">&zwnj;</td>
<td width="140" align=left>[={ORDER TAG QUANTITY}>1?'{ORDER TAG QUANTITY} x ':'']{ORDER TAG NAME} {ORDER TAG NOTE}</td>
<td width="45" align=right><span style="font-weight:normal">[${ORDER TAG TOTAL PRICE}]</span></td>
<td width="40">{ITEM TAG:Receipt Name} </td>
<td width="40">&zwnj;</td>

</tr>
</table>


[TAXES]
<div style="font-size:15px;font-weight:bold;text-align:justify;font-family:'Calibri'">
<table>
<tr>
<td align="left">{TAX NAME}</td><td align="right">${TAX AMOUNT}</td>
</tr>
</table>
</div>
 
[ENTITIES:TablesDONOTUSE]
-- Table entity format
<L00>{ENTITY NAME}

[ENTITIES:Customer]
-- Customer entity format
<div>Customer: {ENTITY NAME} {ENTITY DATA:Phone}</div>

[SERVICES]
<div style="font-size:15px;font-weight:bold;text-align:justify;font-family:'Calibri'">
<table>
<tr>
<td align="left">{CALCULATION NAME}</td><td align="right">${CALCULATION TOTAL}</td>
</tr>
</table>
</div>
1 Like

Good tip but if you notice I added one extra step to it. Instead of using the auto code highlight button use ``` before and after your code and it will auto format it with colors for language.

2 Likes

For the credit settlement we’re making the slip a lot smaller.

image

2 Likes

Joe,

That is really cool. I would love if you can email me your final setup. It would really go a long way to help us improve our US integration. I don’t have the time I used to for this. My days are endless meetings and supporting dealers.