[Resolved] Rounding by Ticket Total Exactly Type!

@madiha what @emre just suggested works great I just tested it on your db. Much cleaner and easier to do and less chance of conflicts with rule events.

:exclamation: However one issue still remains @emre and I know you fixed it with the test versions we are testing but 4.1.82 it still rounds 0. Even with custom calculation.

What do you mean by still rounds 0? sorry I’m not fully aware of the issue :slight_smile:

Example if ticket total = 0 it adds .05 to ticket. or if total = 4.40 it makes it 4.45

I noticed in the latest test version we are using it does not do this.

BTW I found a workaround that works… use the custom calculation as @emre described then add a Ticket Total Changed rule and put in an Update Ticket Calculation action with Remove Calculation set to true.


Until we can get a definite answer on the rounding of 0 issue what I posted above works. I just tested it thoroughly.

hmm… OK I understand what is going on and why it works fine on test version.

If it is already setup can you try this one ? A little math magic that assumes 0.05 is 1/20

result = (round up (Ticket.PSum + Ticket.PreSum + Ticket.Tax) * 20)/20 - (Ticket.PSum + Ticket.PreSum + Ticket.Tax)

That works as well. So he can use that. for now.

Ok @madiha here is what you do.

Delete all your rules and actions that are related to the calculation you had.

Make the following Script by navigating to Automation > Scripts

Script:

result = (round up (Ticket.PSum + Ticket.PreSum + Ticket.Tax) * 20)/20 - (Ticket.PSum + Ticket.PreSum + Ticket.Tax)

Handler:

Calculation_Auto Round

Change your Ticket Calculation as follows:

Set a Calculation Selector as follows:

3 Likes

so at last @emre had to step in… see i told he will save alot of time.

i will try the script and update

1 Like

Sometimes exploring things is good. It helps you get an understanding you wouldn’t have if someone just gave you the answers. But yeah I am glad you got an answer that works for you. It also helps Samba grow if more people attempt things and break things vs just getting step by steps all the time.

You typically will test things so I didnt really direct those comments at you.

ya we should try first then come to an experty

yeah its working now thank you both @kendash and @emre for resolving my issue

1 Like

well didnt know how it works that’s why couldnt try

1 Like

@Jesse and @emre one issue is occuring if i book table while using the steps @Jesse provided. an exception is thrown

takeaway is working fine
after playing around noticed the custom calculation for rounding is causing the problem

so i just added rate to the custom rounding template type and its working fine…dont knw the reason though

the ticket is loaded with default value 0.05


and if take orders the value changes

explaining that a default value is needed in entity selection but y not in takeaway???

is there any other solution to this please share thanks

Did you tried this ?

no i havent try that…would hv if the server wouldnt had been down

you mean just add round up action through rule instead of calculators

if i leave it by adding dum value will it effect?

how do i mention rounding rate is custom
Update Ticket Calculation action after first item added to ticket. (eg. ticket state changes from new to new orders

Use the Event Ticket State Updated Custom Constraint of State Equals New Orders

Put the action inside this rule event.

1 Like

and in action what rate do define

None it is using custom. You just need to fire the Calculation.

like this

Try it see what happens.

no use again an exception thrown


[General Info]

[Exception Info 1]
Top-level Exception
Type: System.Reflection.TargetInvocationException
Message: Exception has been thrown by the target of an invocation.
Source: mscorlib
Stack Trace: at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.UnsafeInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Delegate.DynamicInvokeImpl(Object[] args)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.DispatcherOperation.InvokeImpl()
at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Windows.Threading.DispatcherOperation.Invoke()
at System.Windows.Threading.Dispatcher.ProcessQueue()
at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.Run()
at System.Windows.Application.RunDispatcher(Object ignore)
at System.Windows.Application.RunInternal(Window window)
at System.Windows.Application.Run(Window window)
at Samba.Presentation.App.Main()
Inner Exception 1
Type: System.InvalidOperationException
Message: Sequence contains no matching element
Source: System.Core
Stack Trace: at System.Linq.Enumerable.Single[TSource](IEnumerable1 source, Func2 predicate)
at Samba.Domain.Models.Tickets.Ticket.UpdateEntity(Int32 entityTypeId, Int32 entityId, String entityName, Int32 accountTypeId, Int32 accountId, String entityCustomData, String notes)
at Samba.Presentation.Services.Implementations.TicketModule.TicketService.UpdateEntity(Ticket ticket, Entity entity, Int32 accountTypeId, Int32 accountId, String entityCustomData)
at Samba.Presentation.Services.Implementations.TicketModule.TicketService.UpdateEntity(Ticket ticket, Entity entity)
at Samba.Modules.PosModule.PosViewModel.OnEntitySelectedForTicket(EventParameters1 eventParameters) at Microsoft.Practices.Prism.Events.EventSubscription1.InvokeAction(Action1 action, TPayload argument) at Microsoft.Practices.Prism.Events.EventSubscription1.<>c__DisplayClass2.b__0(Object[] arguments)
at Microsoft.Practices.Prism.Events.EventBase.InternalPublish(Object[] arguments)
at Microsoft.Practices.Prism.Events.CompositePresentationEvent`1.Publish(TPayload payload)
at Samba.Presentation.Services.Common.ExtensionMethods.Publish[TEventsubject](TEventsubject eventArgs, String eventTopic, Action expectedAction)


You did disable the other Calculation Selector right?

1 Like