Custom tip report calculation

Hello! Need help doing some calculations. (SAMBAPOS V5)
Any help and ideas are very much appreciated!!!
The code for the report im using is below and screenshots with more details of what i am trying to achieve

I need to calculate the current user total sales before the tips
i tried doing a calculation similar to [T.TotalAmount]-[CT.Tip]
and many other variations but still unable to get the result.
the value i am getting right now it (total sales + taxes + tips)

Any ideas?

[Server Sales Details: 3,2,3,2,2]
Date:|{DATE}
Server:|{SETTING:CURRENTUSER}
Tip:|||${REPORT CALCULATION TOTAL:(CT=Tip) AND (TU={SETTING:CURRENTUSER})}

[Tickets:1,1,1,1,1,1,]
Ticket|Date|Time|User|Total|Tip|
{REPORT PAYMENT DETAILS:T.TicketNumber,T.Date,P.Time,T.User,[T.TotalAmount]-[CA.Tip],CA.Tip:(TS.Status=Paid) AND (TY=Ticket) AND (TU={SETTING:CURRENTUSER})}
||||${REPORT PAYMENT TOTAL:(TU={SETTING:CURRENTUSER})}|${REPORT CALCULATION TOTAL:(CT=Tip) AND (TU={SETTING:CURRENTUSER})}

You can try using printer expressions like

[={REPORT 1}-{REPORT 2}]

To ensure it converts to numeric values properly you can use TN function like.

[=TN('{REPORT 1}')-TN('{REPORT 2}')]

Thank you for you reply.

here is what i got so far but getting a blank
||||${REPORT PAYMENT TOTAL:[=TN(’{T.TotalAmount}’)-TN(’{CT.Tip}’)] AND (TU={SETTING:CURRENTUSER})}

but not quite working yet, not sure what code or expression to calculate the total of the curren user tickets and also not sure if the tips will be the correct total added tips for current user to substract.

any ideas would be greatly appreciated.

TU= is a 'constraint, not a field.
Should be something like;

||||${REPORT PAYMENT TOTAL:[=TN('{T.TotalAmount}')-TN('{CT.Tip}')]:(TU={SETTING:CURRENTUSER})}

But that wont work either as REPORT PAYMENT TOTAL is not a field type expression, you need a DETAQILS report expression, although saying that you wont as payment details probably doesnt see calculation expression

You want something like;

[=TN({REPORT PAYMENT TOTAL:(TU={SETTING:CURRENTUSER})}) - TN({REPORT CALCULATION TOTAL:(TU={SETTING:CURRENTUSER})})]

The calculation report will need checking though, thats a guess off top of my head.

Looking at the table it would probably be the two report expressions you used on the seperate totals with.

Thank you.

here is what i get now >>

See above, hadnt finnished typing…

seems like there is an error somewhere it deletes everything

Your missing what im saying,
The line would be something like;

|||[=TN({REPORT PAYMENT TOTAL:(TU={SETTING:CURRENTUSER})}) - TN({REPORT CALCULATION TOTAL:(TU={SETTING:CURRENTUSER})})]

NOT put that inside payment report…

oh i see, but still getting a blank response

USE THE SAME EXPRESSIONS YOU HAVE ABOVE;

||||$[=TN({REPORT PAYMENT TOTAL:(TU={SETTING:CURRENTUSER})})-TN({REPORT CALCULATION TOTAL:(CT=Tip) AND (TU={SETTING:CURRENTUSER})})]

SORRY TN NEEDS QUOTES;

||||$[=TN('{REPORT PAYMENT TOTAL:(TU={SETTING:CURRENTUSER})}')-TN('{REPORT CALCULATION TOTAL:(CT=Tip) AND (TU={SETTING:CURRENTUSER})}')]

i tried that already but no luck take a look

SEE AMENDMENT ABOVE…

really all i need is this expression result
||||${REPORT PAYMENT TOTAL:(TU={SETTING:CURRENTUSER})}

and just substract the total amount of the tip for current user

${REPORT CALCULATION TOTAL:(CT=Tip) AND (TU={SETTING:CURRENTUSER})}

but none of the variations i have tried work :frowning:

NICE!!! THERE WORKS NOW!!! you are the man!

AKA see below…

SOLVED
Thank you very much for your help and time!

Sorry for re opening this topic, but … what if I want that same report but for all users.

All user total or individually on one report?

Yes, all users but tip by user

You need to get a list of users after a @
i.e. @report-tag which gives a list to loop through.
Then where that report used CURRENTUSER you use $1 which represents the list loop value

It would look something like
@{USERS LIST REPORT}
{REPORT XX DETAILS:XField, YField, etc etc:(TU=$1)}

Which will give you a table report for each user through the @ and $1.
**THATS OBVIOUSLY NOT THE REPORT NEEDED BEFORE YOU COPY AND PASTE IT