Customer Account Statements and Payments (Custom)

SQL Scripts for Account Statement

@@LoadEntityVariables

declare @entityType varchar(255) = 'Customers'
declare @entityId int = 0
declare @entityName varchar(255) = ''
declare @accountId int = 0
declare @accountName varchar(255) = ''
declare @zeroBalanceDate datetime = '2000-01-01T00:00:00.000'
declare @zeroBalanceDatecheck datetime = '2000-01-01T00:00:00.000'

SET @entityId = (SELECT [Value] FROM [ProgramSettingValues] WHERE [Name]='AS Entity Id')
SET @entityName = (SELECT [Name] FROM [Entities] WHERE [Id]=@entityId)

SET @accountId = (SELECT [AccountId] FROM [Entities] WHERE [Id]=@entityId)
SET @accountName = (SELECT [Name] FROM [Accounts] WHERE [Id]=@accountId)

UPDATE [ProgramSettingValues] SET [Value]=@entityName WHERE [Name]='AS Entity Name'
UPDATE [ProgramSettingValues] SET [Value]=@accountId WHERE [Name]='AS Account Id'
UPDATE [ProgramSettingValues] SET [Value]=@accountName WHERE [Name]='AS Account Name'

SET @zeroBalanceDatecheck =
(
select max(date) from
(select date,sum(debit-credit) over (order by date) as balance
from AccountTransactionValues
where AccountId = @accountId) sub
where balance = 0
)

IF (@zeroBalanceDatecheck > @zeroBalanceDate) SET @zeroBalanceDate = @zeroBalanceDatecheck

UPDATE [ProgramSettingValues] SET [Value]=convert(varchar(30),@zeroBalanceDate,126) WHERE [Name]='AS Entity Date_ZeroBalance'

@@GetStatement

declare @entityType varchar(255) = 'Customers'
declare @entityId int = 0
declare @dateFilterBeg datetime = GETDATE()
declare @entName varchar(255) = '@1'
declare @entId int = 0

SET @dateFilterBeg = (SELECT [Value] FROM [ProgramSettingValues] WHERE [Name]='AS Date Filter Beg')

SET @entId = (SELECT isnull([Id],0) FROM [Entities] WHERE [Name]=@entName)

IF @dateFilterBeg = ''
 BEGIN
  SET @dateFilterBeg = '2000-01-01'
END

SET @entityId = (SELECT [Value] FROM [ProgramSettingValues] WHERE [Name]='AS Entity Id')
IF @entId > 0 SET @entityId = @entId


declare @txcount int = 0
declare @i int = 1
declare @balance decimal(7,2) = 0.00
declare @lastZeroDate varchar(50) = '2000-01-01'

declare @tbl_tx_all table (
[Id]   INT IDENTITY(1,1) NOT NULL
, [TxDate] Datetime null
, [TicketId] int null
, [TicketNo] int null
, [Description] varchar(255) null
, [Amount] decimal(6,2) null
, [Balance] decimal(7,2) null
)

declare @tbl_tx_filtered table (
[Id]   INT IDENTITY(1,1) NOT NULL
, [TxDate] Datetime null
, [TicketId] int null
, [TicketNo] int null
, [Description] varchar(255) null
, [Amount] decimal(6,2) null
, [Balance] decimal(7,2) null
)

INSERT INTO @tbl_tx_all ([TxDate], [TicketId], [TicketNo], [Description], [Amount], [Balance])
SELECT
 tv.[Date] as [Date]
,tkt.[Id] as [TicketId]
,CASE
  WHEN tkt.[TicketNumber]>0 Then tkt.[TicketNumber]
  ELSE d.[Id]
 END as [TicketNo]
,CASE
  WHEN [Credit] > 0 Then 'Payment [' + d.[Name] + '] ' + tx.[Name]
  WHEN [Debit] > 0 Then 'Purchase'
 END as [Desc]
,[Debit]-[Credit] as [Amount]
,0 as [Balance]

FROM [AccountTransactionValues] tv
LEFT JOIN [AccountTransactions] tx on tx.[Id] = tv.[AccountTransactionId]
LEFT JOIN [AccountTransactionDocuments] d on d.[Id] = tv.[AccountTransactionDocumentId]
LEFT JOIN [AccountTransactionTypes] tt on tt.[Id] = tv.[AccountTransactionTypeId]
-- Accounts
LEFT JOIN [AccountTypes] at on at.[Id] = tv.[AccountTypeId]
LEFT JOIN [Accounts] a on a.[Id] = tv.[AccountId]
-- Ticket
LEFT JOIN [Tickets] tkt on tkt.[TransactionDocument_Id] = d.[Id]
LEFT JOIN [TicketEntities] te on te.Ticket_Id = tkt.[Id] and te.[EntityTypeId] IN (SELECT [Id] FROM [EntityTypes] WHERE [Name]=@entityType)
-- Entity
LEFT JOIN [Entities] e on e.[Id] = te.[EntityId]
LEFT JOIN [EntityTypes] et on et.[Id] = e.[EntityTypeId]

WHERE 1=1
--AND tv.[AccountId] in (SELECT TOP 1 [AccountId] FROM [Entities] WHERE [Name] = @entityName)
AND tv.[AccountId] in (SELECT TOP 1 [AccountId] FROM [Entities] WHERE [Id] = @entityId)

ORDER BY [Date] ASC


-- get count of records
SELECT @txcount = count([Id]) FROM @tbl_tx_all


-- loop all records to set Last 0 Balance Date
WHILE @i<=@txcount
BEGIN
SET @balance = @balance + (SELECT [Amount] FROM @tbl_tx_all WHERE [Id]=@i)
UPDATE @tbl_tx_all SET [Balance] = @balance WHERE [Id]=@i
--IF @balance = 0 UPDATE [ProgramSettingValues] SET [Value]=(SELECT [TxDate] FROM @tbl_tx_filtered WHERE [Id]=@i) WHERE [Name]='AS Entity Date_ZeroBalance'
IF @balance = 0 SET @lastZeroDate = replace((SELECT convert(varchar(50),[TxDate],126) FROM @tbl_tx_all WHERE [Id]=@i),'T',' ')
SET @i = @i + 1
END

UPDATE [ProgramSettingValues] SET [Value]=@lastZeroDate WHERE [Name]='AS Entity Date_ZeroBalance'
--SELECT isnull(max([TxDate]),'2000-01-01') FROM @tbl_tx_all WHERE [Balance] = 0.00
--print '------------------------------------------- ' + @lastZeroDate

-- loop filtered records to get Balance Brought Forward previous to @dateFilterBeg
SET @balance = 0.00
SET @i = 1

WHILE @i<=@txcount
BEGIN
IF @dateFilterBeg > (SELECT [TxDate] FROM @tbl_tx_all WHERE [Id]=@i)
BEGIN
SET @balance = @balance + (SELECT [Amount] FROM @tbl_tx_all WHERE [Id]=@i)
UPDATE @tbl_tx_all SET [Balance] = @balance WHERE [Id]=@i
END
SET @i = @i + 1
END


-- insert Balance Brought Forward
IF @dateFilterBeg > (SELECT MIN([TxDate]) FROM @tbl_tx_all)
BEGIN
INSERT INTO @tbl_tx_filtered ([TxDate], [TicketId], [TicketNo], [Description], [Amount], [Balance])
SELECT @dateFilterBeg, 0, 0, 'Balance Brought Forward', @balance, @balance
END

-- insert Filtered Transactions
INSERT INTO @tbl_tx_filtered ([TxDate], [TicketId], [TicketNo], [Description], [Amount], [Balance])
SELECT [TxDate], [TicketId], [TicketNo], [Description], [Amount], [Balance] FROM @tbl_tx_all WHERE [TxDate] >= @dateFilterBeg


-- loop records to use filtered amounts and Balance Brought Forward
SELECT @txcount = count([Id]) FROM @tbl_tx_filtered
SET @i=1
SET @balance = 0.00

WHILE @i<=@txcount
BEGIN
SET @balance = @balance + (SELECT [Amount] FROM @tbl_tx_filtered WHERE [Id]=@i)
UPDATE @tbl_tx_filtered SET [Balance] = @balance WHERE [Id]=@i
SET @i = @i + 1
END

select [TxDate], [TicketId], [TicketNo], [Description], [Amount], [Balance] from @tbl_tx_filtered ORDER BY [Id] DESC

JScript for DB Functions

db.ExecStoredScript() and db.getRow()

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

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

JScript for Payment Processing

pay.UpdateDescription()

function UpdateDescription(creditPayment) {
  
  creditPayment = typeof creditPayment !== 'undefined' ? creditPayment : '';
  creditPayment = creditPayment.replace('Customer ','');
  creditPayment = creditPayment.replace(' Payment','');
  
  var dt = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");
  var paymenttype = Data.Get("paymentTypeName");
  var paymentinfo = dt + " [" + paymenttype + "]";

  var cctype='';
  var ccdigits='';
  
  if (paymenttype=='Credit Card' || paymenttype=='Credit Card USD' || creditPayment=='Credit Card' || creditPayment=='Credit Card USD') {
     
    cctype = dlg.AskQuestion("Choose Credit Card type","Amex=AMEX,Master Card=MAST,Visa=VISA,Discover=DISC,Other=OTHR,CANCEL=CANCEL");
    if (cctype=="CANCEL") {
      Data.Set("canContinue",false);
      dlg.ShowMessage("Payment Cancelled");
      return 1;
    }

    ccdigits = dlg.EditValue("Last 4 CC Digits;.{4};;ON","");

    paymentinfo += " (" + cctype + " " + ccdigits + ")";

  }

  creditPayment = (creditPayment != '' ? dt + ' [' + creditPayment + ']' : '');
  if (cctype!='') {
    creditPayment = (creditPayment!='' ? creditPayment + ' (' + cctype + ' ' + ccdigits + ')' : '');
  }
  
  if (paymenttype=='Customer Account' || paymenttype=='Gift Certificate') {
    var accountname = Data.Get("accountName");
    paymentinfo += " (" + accountname + ")";
  }
  
  Data.Set("description", paymentinfo);
  
  //dlg.ShowMessage("Payment Processed\r"+paymentinfo);
  
  if (creditPayment != '') {
    return creditPayment;
  } else {
    return paymentinfo;
  }
}
1 Like

Report for Account Statement

Account Statement

[#Account Statement:2, 1, 1, 1, 1, 1]
>Date| TID| TNo/Doc| Description| Amount| Balance
@@GetStatement
1 Like

Printing Setup for Account Statement

Printer

Printer Template

[ENTITY]
<T>ACCOUNT STATEMENT
<J00>Customer: {ENTITY NAME}|Account: {ACCOUNT NAME}
<J00>Tx Since: {SETTING:AS Date Filter Beg}|Balance: {ENTITY BALANCE}
<F>=
<J00>Date| TID| TNo| Description| Amount| Balance
<F>-
{REPORT SQL DETAILS:@@GetStatement:
F.TxDate.desc,F.TicketId,F.TicketNo,F.Description,F.Amount,F.Balance::
<J00>{0}| {1}| {2}| {3}| {4}| {5}
}
<F>=

Print Job

1 Like

Actions

We need to use quite a few Actions to give us full Custom functionality.

Add Order - ACCOUNT PAYMENT Product

AS Add Order - ACCOUNT PAYMENT

Action Name: AS Add Order - ACCOUNT PAYMENT
Action Type: Add Order

Parameters:

Menu Item Name: ACCOUNT PAYMENT
Portion Name:
Quantity:
Tag:
Order State Name:
Order State:
Price:
Increase Inventory:
Decrease Inventory:
Locked:
Calculate Price:
Can Create Ticket: True

Ask Question

AS Ask Question

Action Name: AS Ask Question
Action Type: Ask Question

Parameters:

Question: [:question]
Buttons: [:buttons]
Automation Command Name: [:AMCname]
Background Color: [:BGcolor]
Transparent Color: [:TPcolor]

Change Ticket Entity

AS Change Ticket Entity

Action Name: AS Change Ticket Entity
Action Type: Change Ticket Entity

Parameters:

Can Create Ticket: True
Can Create Entity:
Entity Type Name: Customers
Entity Name: [:EntityName]
Entity Search Value:
Update Null Entity:
Entity Screen Name:
Entity Screen Search Value:

Change Ticket Type

AS Change Ticket Type

Action Name: AS Change Ticket Type
Action Type: Change Ticket Properties

Parameters:

Ticket Type Name: Account Payment Ticket
Is Pre Order: False
Change Ticket Date: False

Create Transaction Document

AS Create Tx Doc

Action Name: AS Create Tx Doc
Action Type: Create Account Transaction Document

Parameters:

Account Transaction Document Name: [:DocName]
Account Name: [:AccountName]
Account Id: [:AccountId]
Date: [:date]
Description: [:Description]
Amount: [:Amount]

Display Payment Screen

AS Display Payment Screen

Action Name: AS Display Payment Screen
Action Type: Display Payment Screen

Parameters:

Balance Mode: [:BalanceMode]

Execute Automation Command

AS ExecAMC

Action Name: AS ExecAMC
Action Type: Execute Automation Command

Parameters:

Automation Command Name: [:AMCname]
Command Value: [:AMCvalue]
Background: [:BGcolor]
Delay: [:delay]

Execute Script

AS ExecScript

Action Name: AS ExecScript
Action Type: Execute Script

Parameters:

Function: [:func]
Command: [:command]
Run In Background: False

Load Entity

AS Load Entity

Action Name: AS Load Entity
Action Type: Load Enitiy

Parameters:

Entity Type Name: Customers
Entity Name: [:entityName]
Entity Search Value:

Load Ticket

AS Load Ticket

Action Name: AS Load Ticket
Action Type: Load Ticket

Parameters:

Ticket Id: [:ticketId]
Tag Name:
Tag Value:
State Name:
State:

Navigate Module

AS Navigate

Action Name: AS Navigate
Action Type: Navigate Module

Parameters:

Module Name: [:module]
Parameter: [:parm]
Hide Header: [:hideHeader]

Print Entity (Account Statement)

AS Print Account Statement

Action Name: AS Print Account Statement
Action Type: Print Entity

Parameters:

Entity Id: [:EntityId]
Entity Name:
Printer Name: Account Printer
Printer Template Name: Account Statement

Update Entity Data

AS Update Entity Data

Action Name: AS Update Entity Data
Action Type: Update Entity Data

Parameters:

Entity Type Name: Customers
Entity Name: [:entityName]
Field Name: [:fieldName]
Field Value: [:fieldValue]

Update Program Setting (Store Value)

AS Store Value

Action Name: AS Store Value
Action Type: Update Program Setting

Parameters:

Setting Name: [:settingName]
Setting Value: [:settingValue]
Update Type: Update
Is Local: False

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