Issue: Get Error: 2 or more same Sequence Elements contained

if i open a table mean ticket i get an error and samba crashes.

[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.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 more than one matching element
Source:      System.Core
Stack Trace: at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable`1 source, Func`2 predicate)
   at Samba.Domain.Models.Accounts.AccountTransactionDocument.UpdateSingletonTransactionAmount(Int32 transactionTypeId, String transactionName, Decimal amount, Decimal exchangeRate, IEnumerable`1 accountDataList)
   at Samba.Domain.Models.Tickets.Calculation.UpdateCalculationTransaction(AccountTransactionDocument document, Decimal amount, Decimal exchangeRate, IEnumerable`1 accountDataList)
   at Samba.Domain.Models.Tickets.Ticket.CalculateServices(IEnumerable`1 calculations, Decimal sum)
   at Samba.Domain.Models.Tickets.Ticket.GetPreTaxServicesTotal()
   at Samba.Domain.Models.Tickets.Ticket.Recalculate()
   at Samba.Presentation.Services.Implementations.TicketModule.TicketService.RecalculateTicket(Ticket ticket, Boolean forceRecalculation)
   at Samba.Modules.PosModule.TicketViewModel.ClearSelectedItems()
   at Samba.Modules.PosModule.TicketViewModel.ResetTicket()
   at Samba.Modules.PosModule.PosViewModel.OnTicketEvent(EventParameters`1 obj)
   at Microsoft.Practices.Prism.Events.EventSubscription`1.InvokeAction(Action`1 action, TPayload argument)
   at Microsoft.Practices.Prism.Events.EventSubscription`1.<>c__DisplayClass2.<GetExecutionStrategy>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)

on opening ticket i have noticed bill discount has been put twice.


is there any way i can remove one of the bill discount

How you can get two discount on one ticket?

i also dont know how the operator manage to do but there is possibility

Once i got same error with opening tables entity, just restore yesterday data. hope you have backup as well. :smiley:

that not a good idea… today transactions will be effected

there are other means to do it

Of course. it’s necessary to find other mean to solve it. it just hard to recreate your situation.

Have you read this?

i had already done this
manage -> accounts -> transaction -> ticket number -> edit
delete the duplicate line

but i thought there might be some other way also because after removing the duplicate i can still see the balance with duplicate calculation.

is there any way to lock ticket if one user has opened the ticket so that no other person can use the same ticket

in order to prevent 2 same calculations

I had put together a basic setup to prevent a ticket being opened twice at the same time.
its in V5 beta if you have access;
http://forum.sambapos.com/t/tutorial-prevent-ticket-being-opened-by-multiple-users-terminals/5290?u=jtrtech
Also did a only allow user to be logged in on one terminal at a time;
http://forum.sambapos.com/t/tutorial-single-user-sessions-prevent-same-user-logging-in-on-multiple-termianls/5291?u=jtrtech

2 Likes

so only can be done in v5

I posted in V5 beta section as wasnt sure if any of the features I used were available in v4 as was first week of being on beta team.
I’m pretty sure there isn’t anything specific to V5 but was playing it safe.

welcome and congrats

You sure are fighting using v5…

I’ll be happy to hear details about how it happened -if possible - but I guess because of a reason if terminal 1 stops responding for a while operator goes in front of terminal 2 and adds same discount to the ticket again. When terminal 1 connection restored and changes submitted to database double discounts happens. Sounds like a rare issue but seems like pretty possible.

I’ve reproduced this case unnaturally on my development system and added an additional concurrency feature to ensure that won’t happen again for discounts. We’ll keep allow opening tickets from multiple terminals but if one terminal adds discounts before terminal 2 submits changes terminal 2’s changes won’t save.

Please let me know if that happens again after next V5 version.

you have produced almost correctly…as in my case cashier 1 give discount from its system and cashier 2 give discount from his terminal simultaneously.

that’s good all calculation type that we have to manually enter should be locked for concurrency

well i have two database one running on v5 other still on v4. so i am not fighting but need to get good hands on v5 features. as there are others still testing v5 on test database not on production db.

Many of us are using it in production including me. Probably more than you think.

…and now i am one of them :slight_smile:

1 Like