We've been somewhat flooded with requests for suggested tip on receipts recently so I wrote the SIM below. Right now, I'm having a minor issue with it.. when you discount something on the check, it also affects the total tax. Does anyone know how MICROS is calculating the change? When we display the suggested tip we are backing out the discount, but it always comes out some cents off. Not a huge deal, but I would prefer to be able to back it out to the true amount. Any suggestions?
Code:
//Tip on subtotal rather than total due (ie: subtotal is $10, total with tax is $15, tip on $10 instead of $15)?
VAR IGNORE_TAX : A1 = "N" //set to Y to ignore tax
//Tip on total due before discounts were applied?
VAR IGNORE_DISCOUNTS : A1 = "Y" //set to N to tip AFTER discounts
//Tip before tenders have been applied? (ie: total is $20, pay $10, tip on $20 instead of $10 left?)
VAR IGNORE_TENDERS : A1 = "Y" //set to N to tip AFTER tenders
VAR SUGGESTED_PERCENT[3] : $6 //fill this array with suggested tip perccents you would like to use, in the order you want them to print.
SUGGESTED_PERCENT[1] = 00.15
SUGGESTED_PERCENT[2] = 00.18
SUGGESTED_PERCENT[3] = 00.20
EVENT PRINT_TRAILER : SUGTIP
VAR SUBTOTAL : $12 = @TTLDUE
IF IGNORE_TAX = "Y"
CALL REVERSE_TAX( SUBTOTAL )
ENDIF
IF IGNORE_DISCOUNTS = "Y"
SUBTOTAL = SUBTOTAL - @DSC
ENDIF
IF IGNORE_TENDERS = "Y"
CALL REVERSE_TENDERS( SUBTOTAL )
ENDIF
CALL FORMAT_TRAILER( SUBTOTAL )
ENDEVENT
SUB REVERSE_TAX( REF SUBTOTAL )
VAR I : N9
FOR I = 1 TO 8
SUBTOTAL = SUBTOTAL - @TAX[I]
ENDFOR
ENDSUB
SUB REVERSE_TENDERS( REF SUBTOTAL )
VAR I : N9
FOR I = 1 TO @NUMDTLT
IF @DTL_TYPE[I] = "T"
SUBTOTAL = SUBTOTAL + @DTL_TTL[I]
ENDIF
ENDFOR
ENDSUB
SUB FORMAT_TRAILER( VAR SUBTOTAL : $12 )
VAR CALCULATED_TIP : $12
VAR CURRENT_LINE : A80
VAR I : N9
CALL PAD_LINE( CURRENT_LINE, "For your convenience we are")
@TRAILER[ 1 ] = CURRENT_LINE
CALL PAD_LINE( CURRENT_LINE, "providing the following")
@TRAILER[ 2 ] = CURRENT_LINE
CALL PAD_LINE( CURRENT_LINE, "gratuity calculations:")
@TRAILER[ 3 ] = CURRENT_LINE
VAR CURRENT_TRAILER : N2 = 4
FOR I = 1 TO ARRAYSIZE(SUGGESTED_PERCENT)
CALCULATED_TIP = SUBTOTAL * SUGGESTED_PERCENT[I]
FORMAT CURRENT_LINE AS (SUGGESTED_PERCENT[I]*100), "% is $", CALCULATED_TIP
CALL PAD_LINE( CURRENT_LINE, CURRENT_LINE )
@TRAILER[ CURRENT_TRAILER ] = CURRENT_LINE
CURRENT_TRAILER = CURRENT_TRAILER + 1
ENDFOR
ENDSUB
SUB PAD_LINE( REF OUT, VAR LINE : A40)
VAR PADDING : A40 = " " //some padding so we can center the suggested tips
FORMAT OUT AS MID(PADDING,1,(32-LEN(LINE))/2.0), LINE
ENDSUB