Customer Account Statements and Payments (Custom)

Rules

Our Rule set to handle everything …

Ticket Entity Changed - Store Entity Name and Entity Balance

AS Store Account Balance

Rule Name: AS Store Account Balance
Event Name: Ticket Entity Changed
Custom Constraint List:
Execute Rule if: Matches
Entity Type NameEqualCustomers

Actions:

AS Store Value

Constraint:

settingName: AS Entity Name
settingValue: {ENTITY NAME:Customers}

AS Store Value

Constraint:

settingName: AS Entity Balance
settingValue: [=TN('{ENTITY BALANCE:Customers}') > 0 ? TN('{ENTITY BALANCE:Customers}') : 0]

Order Added - Change Ticket Type

AS Order Added - Change Ticket Type

Rule Name: AS Order Added - Change Ticket Type
Event Name: Order Added
Custom Constraint List:
Execute Rule if: Matches
Menu Item NameEqualACCOUNT PAYMENT

Actions:

AS Change Ticket Type

Constraint:


Pay Account via Payment Screen

AS Pay Account - Payment Screen

Rule Name: AS Pay Account - Payment Screen
Event Name: Automation Command Executed
Custom Constraint List:
Execute Rule if: Matches
Automation Command NameEqualAS Pay Account
{SETTING:AS Entity Balance}Greater0

Actions:

AS Add Order - ACCOUNT PAYMENT

Constraint:

AS Change Ticket Entity

Constraint:

EntityName: {SETTING:AS Entity Name}

AS Display Payment Screen

Constraint:

BalanceMode: True

Account Operations (button clicked)

AS Account Operations

Rule Name: AS Account Operations
Event Name: Automation Command Executed
Custom Constraint List:
Execute Rule if: Matches
Automation Command NameEqualAS Account Operations
{ENTITY ACCOUNT NAME: Customers}Is Not Null

Actions:

Close Ticket

Constraint:

AS Store Value

Constraint:

settingName: AS Entity Id
settingValue: {CALL:db.getRow("SELECT Id FROM Entities WHERE Name='{ENTITY NAME:Customers}'")}

AS ExecAMC

Constraint:

AMCname: AS Load Account Statement
AMCvalue: {SETTING:AS Entity Id}
BGcolor:
delay:

Show Account Screen

AS Show Account Screen

Rule Name: AS Show Account Screen
Event Name: Automation Command Executed
Custom Constraint List:
Execute Rule if: Matches
Automation Command NameEqualAS Show Account Screen

Actions:

AS Navigate

Constraint:

module: Accounts
parm: Customer Accounts
hideHeader: True

Set Statement Variables

AS Set Statement Variables

Rule Name: AS Set Statement Variables
Event Name: Automation Command Executed
Custom Constraint List:
Execute Rule if: Matches
Automation Command NameEqualAS Set Statement Variables

Actions:

AS Store Value

Constraint:

settingName: AS Entity Id
settingValue: [=TN('[:CommandValue]')]

AS Store Value

Constraint:

settingName: AS Entity Name
settingValue:

AS Store Value

Constraint:

settingName: AS Account Id
settingValue: 0

AS Store Value

Constraint:

settingName: AS Account Name
settingValue:

AS Store Value

Constraint:

settingName: AS Date Filter Beg
settingValue: [=('{SETTING:AS Date Filter Beg}'!='' ? '{SETTING:AS Date Filter Beg}' : '2010-01-01')]

AS ExecScript

Constraint:

func: db.ExecStoredScript('@@LoadEntityVariables')
command:

AS Load Entity

Constraint: [=TN(‘{SETTING:AS Entity Id}’)]>0

entityName: {SETTING:AS Entity Name}

AS Store Value

Constraint:

settingName: AS Entity Balance
settingValue: {ENTITY BALANCE}

AS Update Entity Data

Constraint:

fieldName: Date ZeroBalance
fieldValue: {SETTING:AS Entity Date_ZeroBalance}

Load Account Statement

AS Load Account Statement

Rule Name: AS Load Account Statement
Event Name: Automation Command Executed
Custom Constraint List:
Execute Rule if: Matches
Automation Command NameEqualAS Load Account Statement

Actions:

AS ExecAMC

Constraint:

AMCname: AS Set Statement Variables
AMCvalue: [:CommandValue]
BGcolor:
delay:

AS Navigate

Constraint: [=TN(‘{SETTING:AS Entity Id}’)]>0

module: Entity
parm: Account Statement
hideHeader: True

Print Account Statement

AS Print Account Statement

Rule Name: AS Print Account Statement
Event Name: Automation Command Executed
Custom Constraint List:
Execute Rule if: Matches
Automation Command NameEqualAS Print Account Statement

Actions:

AS ExecAMC

Constraint:

AMCname: AS Set Statement Variables
AMCvalue: [:CommandValue]
BGcolor:
delay:

AS Print Account Statement

Constraint:

EntityId: [:CommandValue]

Load Ticket (Display Ticket)

AS Load Ticket

Rule Name: AS Load Ticket
Event Name: Automation Command Executed
Custom Constraint List:
Execute Rule if: Matches
Automation Command NameEqualAS Load Ticket

Actions:

MSG TEST

Constraint: [=TN(‘{SETTING:AStid}’)]==0

MessageToDisplay: Select a Ticket

Display Ticket

Constraint: [=TN(‘{SETTING:AStid}’)]>0

TicketId: [=TN('{SETTING:AStid}')]

Set Date Filter

AS Date Filter

Rule Name: AS Date Filter
Event Name: Automation Command Executed
Custom Constraint List:
Execute Rule if: Matches
Automation Command NameEqualAS Date Filter
{SETTING:ASDF}Is Not Null

Actions:

AS Store Value

Constraint:

settingName: AS Date Filter Beg
settingValue: {SETTING:ASDF}

AS ExecAMC

Constraint: 1==2

AMCname: AS Load Account Statement
AMCvalue: {SETTING:AS Entity Id}
BGcolor:
delay:

Credit Account - Ask Amount and Payment Type

AS Credit Account - Ask Values and Payment Type

Rule Name: AS Credit Account - Ask Values and Payment Type
Event Name: Automation Command Executed
Custom Constraint List:
Execute Rule if: Matches
Automation Command NameEqualAS Credit Account
Command ValueIs Not Null
{SETTING:AS Entity Balance}Less0.01

Actions:

AS Store Value

Constraint:

settingName: AS Credit Amount
settingValue: [?Amount of Credit;;;ONC]

AS Ask Question

Constraint:

question: Customer Account Credit\rCustomer : {SETTING:AS Entity Name}\rAccount : {SETTING:AS Account Name}\rCredit Amount : [=F('{SETTING:AS Credit Amount}')]\r\rSelect Method of Payment
buttons: Cash=Customer Cash:Orange;Gray,Cash USD=Customer Cash USD:Green;Gray,Credit Card=Customer Credit Card:Black;Gray,Credit Card USD=Customer Credit Card USD:Blue;Gray,Cancel=Cancel:Red;Gray
AMCname: AS Credit Account - Apply
BGcolor: Purple
TPcolor:

Credit Account - Apply

AS Credit Account - Apply

Rule Name: AS Credit Account - Apply
Event Name: Automation Command Executed
Custom Constraint List:
Execute Rule if: Matches
Automation Command NameEqualAS Credit Account - Apply
Command ValueNot EqualsCancel
[=TN('{SETTING:AS Credit Amount}')]Greater0

Actions:

AS Store Value

Constraint:

settingName: AS Payment Type
settingValue: [:CommandValue]

AS Store Value

Constraint:

settingName: AS Credit Amount
settingValue: [=TN('{SETTING:AS Credit Amount}')]

AS Store Value

Constraint:

settingName: AS Credit Description
settingValue: {CALL:pay.UpdateDescription('{SETTING:AS Payment Type}')}

MSG TEST

Constraint:

MessageToDisplay: Desc:{SETTING:AS Credit Description} Typ:[='[:CommandValue]'.substr(9,11)] cur:[='{SETTING:AS Payment Type}'.slice(-3)] PT:{SETTING:AS Payment Type} Cr:{SETTING:AS Credit Amount} AccId:{SETTING:AS Account Id} {DATE} {TIME}

AS Create Tx Doc

Constraint: [=TN(‘{SETTING:AS Credit Amount}’)]>0

DocName: [:CommandValue]
AccountName:
AccountId: {SETTING:AS Account Id}
date: {DATE} {TIME}
Description: [:CommandValue] - Credit Payment - {SETTING:AS Credit Description}
Amount: [=TN('{SETTING:AS Credit Amount}')]

AS Navigate

Constraint:

module: Entity
parm: Account Statement
hideHeader: True

Entity Screen for Account Operations

This is what we want to build…


Create an Entity Screen first:

:bulb: Now use one of the Automation Command buttons to navigate to the Entity Screen, then right-click and select Design Mode to start adding Widgets…


Label Widget

Name: Entity Details
Text:

<size 1> <br/></size><bold>     Entity:</bold> [{SETTING:AS Entity Id}] {SETTING:AS Entity Name}     <bold>Account:</bold> [{SETTING:AS Account Id}] {SETTING:AS Account Name}<br/>     <bold>Balance:</bold> {SETTING:AS Entity Balance}     <bold>Last 0 Balance:</bold> {SETTING:AS Entity Date_ZeroBalance}<br/>     <bold>Transactions Since:</bold> {SETTING:AS Date Filter Beg}

Print Account Statement - Automation Command Button Widget

Command name value: AS Print Account Statement
Value: {SETTING:AS Entity Id}
Caption: <size 50><sym>⎙</sym></size><br/>Print Account Statement

Date Filter - Editor Widget

Command name: AS Date Filter
Refreshing Widgets: Account Statement,Entity Details
Local Setting Name: ASDF

Display Ticket - Automation Command Button Widget

Command name value: AS Load Ticket
Value:
Caption: Display<br/>Ticket

Pay Account - Automation Command Button Widget

Command name value: AS Pay Account
Value: {SETTING:AS Account Id}
Caption: Pay<br/>Account[=('{SETTING:ISCURRENTWORKPERIODOPEN}'!='TRUE' ? '<size 16><br/>Workperiod must be Open to Pay Account</size>' : '')]
Validation: '{:ISCURRENTWORKPERIODOPEN}'=='TRUE'

Add Credit - Automation Command Button Widget

Command name value: AS Credit Account
Value: {SETTING:AS Account Id}
Caption: Add<br/>Credit[=('{SETTING:ISCURRENTWORKPERIODOPEN}'!='TRUE' ? '<size 16><br/>Workperiod must be Open to Credit Account</size>' : '')]
Validation: '{:ISCURRENTWORKPERIODOPEN}'=='TRUE'

Choose Different Account - Automation Command Button Widget

Command name value: AS Show Account Screen
Value:
Caption: Choose<br/>Different<br/>Account

Report Grid - Custom Report Viewer Widget

Name: Account Statement
Report Name: Account Statement
Parameters: Customers,{SETTING:AS Entity Id}
Setting Mappings:

ASdate=Account Statement.1
AStid=Account Statement.2
AStno=Account Statement.3
ASdesc=Account Statement.4
ASamt=Account Statement.5
1 Like

I will try to add in some explanations of the Automation when I get time…

… reserved for updates …

For anyone wondering how to add an action multiple times like AS Store Value in this tutorial.
Just add the action then move back to Action List, right click and click Display All Values as many times as required.
I have just discovered this so im not sure if its the correct way to do this.

3 Likes

It is correct way. It’s one of many hidden features.

2 Likes

@silentbob another very similar tip is the same can be done with products to allow multiple buttons on same menu category which is sometimes handy for increased speed when using products with portions and pre-selected tags etc.

2 Likes

Thanks a lot @QMcKay for this, I look forward to having this function very much.
I am working my way through the tutorial, and have a few questions. I don’t have some of the Automation Commands or Actions that are shown in the tutorial.

The Automation Commands I’m missing: AS Show Account Screen, AS Set Statement Variables, AS Date Filter, AS Credit Account. For these I have manually typed them into the Rules screens rather than select from the dropdown list, is this correct or do I need to create the Automation Commands?

The Actions I’m missing: Display Ticket and MSG TEST, please can screenshots of these actions be uploaded so I can create them.

I’m nearly there, I just need these small bits to finish.

Thanks again.

P.S is there a plan to have this as a Configuration Task or DB Import at some point? There are a lot of steps and I can easily see people (mainly myself) making a mistake along the way, and finding where the mistake is will be a nightmare!!

2 Likes

Yes, type them in manually. No need to create them. There is no reason to create an Automation Command unless it will be used as a button somewhere. In this case, we don’t need buttons, so there is no need to create them. They will still work properly when manually entered - just be sure no typos.


Display Ticket is just as it sounds - it is a Display Ticket Action…

##Display Ticket##

Action Name: Display Ticket
Action Type: Display Ticket
###Parameters:###
Ticket Id: [:TicketId]

MSG TEST is a Show Message Action. You do not need to put this Action in your Rules - it was just used for debugging. You can skip it, but here it is anyway…

##MSG TEST##

Action Name: MSG TEST
Action Type: Show Message
###Parameters:###
Message: [:MessageToDisplay]

I do not plan to make a Configuration Task for this. I will supply DB Import files however. In time…

1 Like

Has anyone managed to implement this?
I keep getting the following error.

User Explanation:

User said ""
-----------------------------

[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.DispatcherOperation.Wait(TimeSpan timeout)
   at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherOperation operation, CancellationToken cancellationToken, TimeSpan timeout)
   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
   at Samba.Presentation.Services.Common.ExtensionMethods.PublishEvent[TEventSubject](TEventSubject eventArgs, String eventTopic, Boolean wait)
   at Samba.Presentation.Services.Implementations.AutomationModule.NotificationClient.<>c.<NotifyEvent>b__3_0(ActionData x)
   at Samba.Services.Implementations.AutomationModule.ActionDataBuilder.InvokeFor(Action`1 dataAction)
   at CallSite.Target(Closure , CallSite , Object , Action`1 )
   at Samba.Services.Implementations.AutomationModule.RuleExecutor.ExecuteWithLogging(Object dataParameter, Action`1 dataAction)
   at Samba.Services.Implementations.AutomationModule.RuleExecutor.ExecuteWith(Object dataParameter, Action`1 dataAction)
   at Samba.Services.Implementations.AutomationModule.NotificationService.NotifyEvent(String eventName, Object dataParameter, Int32 terminalId, Int32 departmentId, Int32 userRoleId, Int32 ticketTypeId, Action`1 dataAction)
   at Samba.Presentation.Services.Implementations.AutomationModule.NotificationClient.NotifyEvent(String eventName, Object dataObject)
   at CallSite.Target(Closure , CallSite , INotificationClient , String , Object )
   at Samba.Modules.AccountModule.AccountSelectorViewModel.OnAutomationCommandSelected(AccountScreenAutmationCommandMap obj)
   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.Primitives.ToggleButton.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 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.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.DispatcherOperation.Wait(TimeSpan timeout)
   at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherOperation operation, CancellationToken cancellationToken, TimeSpan timeout)
   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
   at Samba.Presentation.Services.Common.ExtensionMethods.PublishEvent[TEventSubject](TEventSubject eventArgs, String eventTopic, Boolean wait)
   at Samba.Presentation.Services.Implementations.AutomationModule.NotificationClient.<>c.<NotifyEvent>b__3_0(ActionData x)
   at Samba.Services.Implementations.AutomationModule.ActionDataBuilder.InvokeFor(Action`1 dataAction)
   at CallSite.Target(Closure , CallSite , Object , Action`1 )
   at Samba.Services.Implementations.AutomationModule.RuleExecutor.ExecuteWithLogging(Object dataParameter, Action`1 dataAction)
   at Samba.Services.Implementations.AutomationModule.RuleExecutor.ExecuteWith(Object dataParameter, Action`1 dataAction)
   at Samba.Services.Implementations.AutomationModule.NotificationService.NotifyEvent(String eventName, Object dataParameter, Int32 terminalId, Int32 departmentId, Int32 userRoleId, Int32 ticketTypeId, Action`1 dataAction)
   at Samba.Presentation.Services.Implementations.AutomationModule.NotificationClient.NotifyEvent(String eventName, Object dataObject)
   at CallSite.Target(Closure , CallSite , INotificationClient , String , Object )
   at Samba.Presentation.Common.Services.CommandExecutionService.ExecuteAutomationCommand(String commandName, String commandValue, Object dataObject)
   at CallSite.Target(Closure , CallSite , ICommandExecutionService , String , String , Object )
   at Samba.Modules.AutomationModule.ActionProcessors.ExecuteAutomationCommand.Process(ActionData actionData)
   at Samba.Services.Common.RuleActionTypeRegistry.ProcessAction(String actionType, ActionData actionData)
   at Samba.Services.Implementations.AutomationModule.AutomationService.ProcessAction(String actionType, ActionData actionData)
   at Samba.Modules.AutomationModule.AutomationModule.<OnInitialization>b__5_0(EventParameters`1 x)
   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)

Inner Exception 2
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.DispatcherOperation.Wait(TimeSpan timeout)
   at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherOperation operation, CancellationToken cancellationToken, TimeSpan timeout)
   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
   at Samba.Presentation.Services.Common.ExtensionMethods.PublishEvent[TEventSubject](TEventSubject eventArgs, String eventTopic, Boolean wait)
   at Samba.Presentation.Services.Implementations.AutomationModule.NotificationClient.<>c.<NotifyEvent>b__3_0(ActionData x)
   at Samba.Services.Implementations.AutomationModule.ActionDataBuilder.InvokeFor(Action`1 dataAction)
   at CallSite.Target(Closure , CallSite , Object , Action`1 )
   at Samba.Services.Implementations.AutomationModule.RuleExecutor.ExecuteWithLogging(Object dataParameter, Action`1 dataAction)
   at Samba.Services.Implementations.AutomationModule.RuleExecutor.ExecuteWith(Object dataParameter, Action`1 dataAction)
   at Samba.Services.Implementations.AutomationModule.NotificationService.NotifyEvent(String eventName, Object dataParameter, Int32 terminalId, Int32 departmentId, Int32 userRoleId, Int32 ticketTypeId, Action`1 dataAction)
   at Samba.Presentation.Services.Implementations.AutomationModule.NotificationClient.NotifyEvent(String eventName, Object dataObject)
   at CallSite.Target(Closure , CallSite , INotificationClient , String , Object )
   at Samba.Presentation.Common.Services.CommandExecutionService.ExecuteAutomationCommand(String commandName, String commandValue, Object dataObject)
   at CallSite.Target(Closure , CallSite , ICommandExecutionService , String , String , Object )
   at Samba.Modules.AutomationModule.ActionProcessors.ExecuteAutomationCommand.Process(ActionData actionData)
   at Samba.Services.Common.RuleActionTypeRegistry.ProcessAction(String actionType, ActionData actionData)
   at Samba.Services.Implementations.AutomationModule.AutomationService.ProcessAction(String actionType, ActionData actionData)
   at Samba.Modules.AutomationModule.AutomationModule.<OnInitialization>b__5_0(EventParameters`1 x)
   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)

Inner Exception 3
Type:        Microsoft.ClearScript.ScriptEngineException
Message:     Object expected
Source:      ClearScript
Stack Trace: at Microsoft.ClearScript.ScriptEngine.ThrowScriptError(IScriptEngineException scriptError)
   at Microsoft.ClearScript.Windows.WindowsScriptEngine.ThrowScriptError(Exception exception)
   at Microsoft.ClearScript.Windows.WindowsScriptEngine.<>c__DisplayClass51_0`1.<ScriptInvoke>b__0()
   at Microsoft.ClearScript.ScriptEngine.ScriptInvoke[T](Func`1 func)
   at Microsoft.ClearScript.Windows.WindowsScriptEngine.ScriptInvoke[T](Func`1 func)
   at Microsoft.ClearScript.Windows.WindowsScriptEngine.Execute(String documentName, String code, Boolean evaluate, Boolean discard)
   at Samba.Services.Implementations.ExpressionModule.ExpressionEngine.Invoke(String expression, String function, Object dataObject, Object[] args)
   at Samba.Services.Implementations.ExpressionModule.ExpressionService.InvokeScript(String handlerFunction, Object dataObject)
   at System.Dynamic.UpdateDelegates.UpdateAndExecute3[T0,T1,T2,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2)
   at Samba.Modules.AutomationModule.ActionProcessors.ExecuteScript.Process(ActionData actionData)
   at Samba.Services.Common.RuleActionTypeRegistry.ProcessAction(String actionType, ActionData actionData)
   at Samba.Services.Implementations.AutomationModule.AutomationService.ProcessAction(String actionType, ActionData actionData)
   at Samba.Modules.AutomationModule.AutomationModule.<OnInitialization>b__5_0(EventParameters`1 x)
   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)

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

[Assembly Info]

mscorlib, Version=4.0.0.0
DevExpress.Xpf.LayoutControl.v14.1, Version=14.1.11.0
System.Xml, Version=4.0.0.0
DevExpress.Xpf.Grid.v14.1, Version=14.1.11.0
System, Version=4.0.0.0
DevExpress.Xpf.Grid.v14.1.Core, Version=14.1.11.0
WindowsBase, Version=4.0.0.0
System.Xaml, Version=4.0.0.0
Samba.Domain, Version=1.0.0.0
System.Core, 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
System.ComponentModel.Composition, Version=4.0.0.0
PresentationCore, Version=4.0.0.0
DevExpress.Xpf.Core.v14.1, Version=14.1.11.0
Samba.Services, Version=1.0.0.0
Samba.Presentation.Services, Version=1.0.0.0
System.Windows.Forms, Version=4.0.0.0
System.Drawing, Version=4.0.0.0
Stateless, Version=1.0.0.0
Samba.Persistance, Version=1.0.0.0
PropertyTools, Version=2012.4.14.1
Samba.Localization, Version=1.0.0.0
ReachFramework, Version=4.0.0.0
Samba.Infrastructure.Data, Version=1.0.0.0
EntityFramework, Version=6.0.0.0
FluentValidation, Version=3.4.0.0
Omu.ValueInjecter, Version=2.3.0.0
Microsoft.Practices.ServiceLocation, Version=1.0.0.0
Microsoft.CSharp, Version=4.0.0.0

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

if i disable the “AS Set Statement Variables” rule it does not crash.
With this disabled I opened the debugger and noticed the command value does not seem to be passing to the second automation command.


I have been at this since this tutorial was posted and I cant seem to get it working.
I have also tried a different database with only sample data to rule out a conflict with any of my modifications

The Action in that Rule is set to run a JScript function:

I just noticed the function shown there is not in the Tutorial. I have added it… thanks for letting me know.

function ExecStoredScript(script) {
  var r = sql.Exec(script);
  return r;
}

function getRow(sqlcmd) {
  var r = sql.Query(sqlcmd).First;
  return r;
}

On the param: is Account Statement the name of the Entity Screen? When I select it it just navigates me to the POS Customer Search Entity Screen, (Its top of the sort list) Is this how its supposed to work or should it navigate directly to the Account Operations Entity Screen.

Also when I press Account Operations from the accounts page It will not work. It works fine from a ticket.

When I remove the Constraint: [=TN(‘{SETTING:AS Entity Id}’)]>0 It navigates but does not display any data so it looks like {SETTING:AS Entity Id} Is not being passed from the accounts screen.

Yes, Account Statement is the name of the Entity Screen. I have added this to the last step of the Tutorial (Entity Screen Design).

EDIT: I got this working.
I created a separate Automation Command to use on the accounts screen. And then created the following rule.

Where the payment transaction description is formatted?
I found the Description Template for the account credit.
I just want it to show “Customer Cash Payment” or *Customer Credit Card Payment"

Is it possible to set the format for the date filter ####-##-##

I have added a new rule to reset “AS Date Filter Beg” when the “Date Filter - Editor Widget” is cleared.
Without this “AS Date Filter Beg” remains on the last value entered into the Editor Widget.
If I can get “AS Entity Date_ZeroBalance” working I plan to have it default to this date if it is available

Is there any reason why db.ExecStoredScript(’@@LoadEntityVariables’) is not updating “AS Entity Date_ZeroBalance”

I have executed the following query on my database and the result is correct
select max(date) from (select date,sum(debit-credit) over (order by date) as balance from [SambaPos5].[dbo].[AccountTransactionValues] where AccountId = 78) sub where balance = 0

Result is 2015-12-12 23:28:03.973

EDIT: the AS Set Statement Variables rule seems to be missing a AS Store Value action to save this data

2 Likes

When making payment to account via Payment Screen, part of the description is fixed. A portion of the description is added via the pay.UpdateDescription() script. But if you are trying to get rid of “Ticket Number:” etc, I do not think this can be done. Have not looked into it.

Yes, the Editor Widget has an Edit Mask parameter…

\d{0,4}-\d{0,2}-\d{0,2}

Sorry I cannot find any reference to “NV Close Screen” in the Forums. On the Account Screen it references this automation command. Do you mean close ticket?

It is an unmapped Automation Command, which when clicked navigates to the Main Menu (Nav Screen).

It is not included in the Tutorial because it isn’t necessary for the functionality of this setup, but it is something that I include on all of my Account Screens so that I don’t need to click Main Menu in the bottom-right of the SambaPOS screen.


##Automation Command


##Action

##NV Show Navigation Screen##

Action Name: NV Show Navigation Screen
Action Type: Navigate Module
###Parameters:###
Module Name: Navigation
Parameter:

##Rule

##NV Close Screen##

Rule Name: NV Close Screen
Event Name: Automation Command Executed
Custom Constraint List:
Execute Rule if: Matches
Automation Command NameEqualsNV Close Screen

##Actions:##

NV Show Navigation Screen

Constraint: (none)


1 Like

Thank you. I’m getting better at this but I still need my hand held a little longer, lol.