GQL [Payments] table BUG


#1

EDIT: this issue has been reported in the past, and has not yet been fixed. See Post #5 where there is a link to the original Bug Report Topic, which also includes the Cause of this Issue. See Post #6 as well which contains a video clearly showing the Issue.

EDIT2: this issue is much worse than I originally thought. It has nothing to do with Entities whatsoever. Make a partial Payment to a Ticket and close it. Open the Ticket, and immediately Close it. At this point, the [Payments] table now contains records for the Ticket which are corrupt (NULL values).


-----------------------------
[General Info]

Application: SambaPOS
Version:     5.2.3
Region:      en
DB:          SQ
Machine:     QBOOK
User:        Quentin
Date:        2018-04-02
Time:        17:00

User Explanation:

Quentin said "Merge Tickets attempt"

-----------------------------

[Exception Info 1]

Top-level Exception
Type:        System.NullReferenceException
Message:     Object reference not set to an instance of an object.
Source:      Samba.Domain
Stack Trace: at Samba.Domain.Models.Tickets.Ticket.RemovePayment(Payment py)
   at System.Collections.Generic.List`1.ForEach(Action`1 action)
   at Samba.Domain.Models.Tickets.Ticket.RemoveData()
   at Samba.Services.Implementations.TicketModule.TicketServiceBase.<>c.<MergeTickets>b__51_14(Ticket x) in C:\Users\vehbi\Source\Repos\sambapos-v5-pro\Samba.Services\Implementations\TicketModule\TicketServiceBase.cs:line 726
   at System.Collections.Generic.List`1.ForEach(Action`1 action)
   at Samba.Services.Implementations.TicketModule.TicketServiceBase.MergeTickets(IEnumerable`1 ticketIds, AppState appState) in C:\Users\vehbi\Source\Repos\sambapos-v5-pro\Samba.Services\Implementations\TicketModule\TicketServiceBase.cs:line 726
   at Samba.Presentation.Services.Implementations.TicketModule.TicketService.MergeTickets(IEnumerable`1 ticketIds)
   at Samba.Presentation.ClientLibrary.Modules.PosModule.TicketListViewModel.OnMergeTickets(String obj) in C:\Users\vehbi\Source\Repos\sambapos-v5-pro\Samba.Presentation.ClientLibrary\Modules\PosModule\TicketListViewModel.cs:line 97
   at Microsoft.Practices.Prism.Commands.DelegateCommand`1.<>c__DisplayClass6.<.ctor>b__2(Object o)
   at Microsoft.Practices.Prism.Commands.DelegateCommandBase.Execute(Object parameter)
   at Microsoft.Practices.Prism.Commands.DelegateCommandBase.System.Windows.Input.ICommand.Execute(Object parameter)
   at MS.Internal.Commands.CommandHelpers.CriticalExecuteCommandSource(ICommandSource commandSource, Boolean userInitiated)
   at System.Windows.Controls.Primitives.ButtonBase.OnClick()
   at System.Windows.Controls.Button.OnClick()
   at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
   at System.Windows.UIElement.OnMouseLeftButtonUpThunk(Object sender, MouseButtonEventArgs e)
   at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent)
   at System.Windows.UIElement.OnMouseUpThunk(Object sender, MouseButtonEventArgs e)
   at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
   at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
   at System.Windows.Input.InputManager.ProcessStagingArea()
   at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
   at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
   at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
   at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at System.Windows.Interop.HwndSource.InputFilterMessage(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 System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

-----------------------------

[Assembly Info]

mscorlib, Version=4.0.0.0
Samba.Services, Version=1.0.0.0
Samba.Domain, Version=1.0.0.0
Samba.Infrastructure.Data, Version=1.0.0.0
System.ComponentModel.Composition, Version=4.0.0.0
Samba.Presentation.Services, Version=1.0.0.0
System.Core, Version=4.0.0.0
PresentationCore, Version=4.0.0.0
DevExpress.Xpf.LayoutControl.v16.2, Version=16.2.6.0
System.Xml, Version=4.0.0.0
DevExpress.Xpf.Grid.v16.2, Version=16.2.6.0
System, Version=4.0.0.0
DevExpress.Xpf.Grid.v16.2.Core, Version=16.2.6.0
WindowsBase, Version=4.0.0.0
System.Xaml, Version=4.0.0.0
PresentationFramework, Version=4.0.0.0
Samba.Infrastructure, Version=1.0.0.0
Microsoft.Practices.Prism, Version=4.0.0.0
System.Runtime.Serialization, Version=4.0.0.0
Microsoft.Practices.Prism.MefExtensions, Version=4.0.0.0
DevExpress.Xpf.Core.v16.2, Version=16.2.6.0
System.Windows.Forms, Version=4.0.0.0
System.Drawing, Version=4.0.0.0
Samba.Persistance, Version=1.0.0.0
Stateless, Version=1.0.0.0
PropertyTools, Version=2012.4.14.1
Samba.Localization, Version=1.0.0.0
ReachFramework, Version=4.0.0.0
EntityFramework, Version=6.0.0.0
FluentValidation, Version=3.4.0.0
Microsoft.CSharp, Version=4.0.0.0
Omu.ValueInjecter, Version=2.3.0.0
Microsoft.Practices.ServiceLocation, Version=1.0.0.0
DevExpress.Data.v16.2, Version=16.2.6.0
WindowsInput, Version=1.0.4.0

-----------------------------

[System Info]

Operating System
-Microsoft Windows 10 Home
--CodeSet = 1252
--CSDVersion = 
--CurrentTimeZone = -360
--FreePhysicalMemory = 4167040
--OSArchitecture = 64-bit
--OSLanguage = 1033
--ServicePackMajorVersion = 0
--ServicePackMinorVersion = 0
--Version = 10.0.15063

Machine
-QBOOK
--Manufacturer = HP
--Model = HP Spectre x360 Convertible     
--TotalPhysicalMemory = 8496979968
--UserName = QBOOK\Quentin

-----------------------------


#2

Maybe this was caused by a Time Change on my computer? I noticed it was an hour ahead (ie. 11:30), and changed it to the proper time (ie. 10:30).

The Ticket would have been created at say, 11:26.

At the time of the Merge attempt (ie. 11:20 correct time), the original Ticket Creation Time (11:26) had not been reached yet.

image


Well, enough time has passed now, and I still cannot Merge the Tickets. Not sure why …

image


#3

Tried another Merge, this time with 15088 and 15090 and it still crashes. Maybe the “problem” ticket is 15090 which is the “common denominator” here so far …


Nope! This is a try with 15088 and 15105, still crashes. Must be a Payment Type on the Ticket(s) that it is having trouble with?


#4

Nothing out of the ordinary here …


#5

I was having deja vu here. I think this BUG reported a long time ago is probably the cause, and it has not been fixed …

EDIT: yup, take a look at that, same bug, still not fixed …

SELECT
 p.[Id]
,p.[TicketId]
,t.[TicketNumber]
--,p.[PaymentTypeId]
--,p.[DepartmentId]
,p.[Name]
,p.[Date]
,p.[AccountTransactionId]
,p.[Amount]
--,p.[TenderedAmount]
--,p.[UserId]
--,p.[TerminalId]
,p.[AccountTransaction_Id]
,p.[AccountTransaction_AccountTransactionDocumentId]
,p.[Description]
,p.[ExchangeRate]
FROM [Payments] p
JOIN [Tickets] t on t.[Id]=p.[TicketId]
WHERE 1=1
and p.[PaymentTypeId]=4
and p.[AccountTransaction_Id] is null
ORDER by t.[TicketNumber], p.[Date]


@Tayfun, please refresh the Developers regarding this bug that was originally reported January 21 2018, since it has not been fixed (running SambaPOS 5.2.3 [2017-11-25 10:44:00]).

Direct them to the Topic linked above for a good walkthrough on steps to reproduce the problem and the Cause of the Issue, or the next post which has a video showing the Cause of the Issue …


#6

A video clearly illustrating the Cause of the Issue …

When an Entity is changed When a Ticket which contains partial Payments is Closed, the [Payments] table in the Database has NULL values written into:

,p.[AccountTransaction_Id]
,p.[AccountTransaction_AccountTransactionDocumentId]


SELECT
 p.[Id]
,p.[TicketId]
,t.[TicketNumber]
,t.[IsLocked]
,t.[IsClosed]
--,te.[EntityTypeId]
,et.[Name] as [EntityType]
--,te.[EntityId]
,te.[EntityName]
--,p.[Date]
--,p.[Description]
,p.[Name]
,p.[Amount]
,p.[AccountTransaction_Id] as [TxId]
,p.[AccountTransaction_AccountTransactionDocumentId] as [DocId]
,tt.[Name] as [TxType]
,tv.[Name] as [TxName]
,tx.[Name] as [TxName2]
,dt.[Name] as [DocType]
,doc.[Name] as [DocName]

--,p.[PaymentTypeId]
--,p.[DepartmentId]
--,p.[AccountTransactionId]
--,p.[TenderedAmount]
--,p.[UserId]
--,p.[TerminalId]
--,p.[Description]
--,p.[ExchangeRate]
FROM [Payments] p
JOIN [Tickets] t on t.[Id] = p.[TicketId]

LEFT JOIN [AccountTransactionValues] tv on tv.[Id] = p.[AccountTransaction_Id]
LEFT JOIN [AccountTransactions] tx on tx.[Id] = tv.[AccountTransactionId]
LEFT JOIN [AccountTransactionDocumentTypes] dt on dt.[Id] = tv.[AccountTransactionDocumentId]
LEFT JOIN [AccountTransactionTypes] tt on tt.[Id] = tv.[AccountTransactionTypeId]
LEFT JOIN [AccountTransactionDocuments] doc on doc.[Id] = p.[AccountTransaction_AccountTransactionDocumentId]

LEFT JOIN [TicketEntities] te on te.[Ticket_Id] = t.[Id]
LEFT JOIN [Entities] e on e.[Id] = te.[EntityId]
LEFT JOIN [EntityTypes] et on et.[Id] = te.[EntityTypeId]
WHERE 1=1
--AND p.[Id] > 34789

ORDER BY p.[Id]

[5.2.3] Issue Compilation
#7

I think I solved it. Please let me know if it works fine or not on next update.


SambaPOS 5.2.8 Release
#8

Confirmed fixed in Beta 5.2.7 / Release 5.2.8/10 …