Customer Account Statements and Payments (Custom)


#1

This Tutorial will demonstrate how to build a Custom Account Handling Screen for Customers.

It allows for Printing detailed Customer Account Statements, making Payments to Customer Accounts (via the built-in Payment Screen), and Crediting Customer Accounts.

:warning: Requires SambaPOS 5.1.56 or higher

##Operations

The Customer Account Operations Screen we will build and Automate is shown on the right.


##Quick Nav:

Account Type and Account for Transfers (for Account Payments via Payment Screen)
Transaction Types
Document Types

Number Generators, Product and Ticket Type (for Account Payments via Payment Screen)

Automation: Automation Commands and Customer Account Screen button addition

Automation: SQL Scripts for Account Statement
Automation: JScript for Payment Processing (Payment Type and CC info)
Report: Account Statement
Printer Setup for Account Statement

Automation: Actions
Automation: Rules

Entity Screen: Account Operations


Purchase history by customer or phone number
How to stop customer accounts adding to my daily reports
Add Funds to SambaCard via Product
Customer Ledger
How do you Reprint a Transaction Account Document?
Specific Entity Search Rule Action
Use ticket lister, or entity grid to display some customers
Report Entity Last payment date
Print bill with customer
Print bill with customer
Save customer orders
Looking at a way to expire membership by removing a cutom data field
Custom Reports From one hour to another during current work period
Doubts related to Inventory and Suppliers
Account Statements with Template Layout
[New 4.1.52] Custom Report Viewer Widget
Sales Per Hour Report
Purchase history by customer or phone number
Customer Purchase History Reporting
Listing samba cards by last used?
Export List of Member Card Balances
Switching/Converting default Currency to Foreign Currency
#2

#3

#Account Type and Account for Transfers

We need an Account to use when making Payments via the built-in Payment Screen. This is more-or-less a “dummy” account that we need to have to be able define the Transaction Type for the special Ticket Type we will use to post payments to Accounts via the Payment Screen.


#4

#Transaction Types

These are the Transaction Types we will need for Customer Accounts. You may already have some of these Account Types - if so, you won’t need to re-create them. The alternate Currency Account Types (USD) are optional, and will be skipped in this Tutorial.

##Customer Account Transaction

Used to pay for Products using a Customer Account

##Customer Cash Payment

Used to post a Cash Payment to a Customer Account

##Customer Credit Card Payment

Used to post a Credit Card Payment to a Customer Account

##Customer Account Payment Transaction

Used to post Payment to a Customer Account via the Payment Screen


#5

#Document Types

These are the Document Types we will need for Customer Accounts. You may already have some of these Document Types - if so, you won’t need to re-create them. The alternate Currency Document Types (USD) are optional, and will be skipped in this Tutorial.

##Customer Cash

Used to post a Cash Payment to a Customer Account.

##Customer Credit Card

Used to post a Credit Card Payment to a Customer Account.


#6

#Ticket Type and Product

We will use special Number Generators, a special Product and special Ticket Type to post payments to Customer Accounts via the Payment Screen.

##Number Generators

We use different Number Generators for Account Payment via Payment Screen so that we do not interfere with “normal” Product purchases and Tickets.

##“Product” for ACCOUNT PAYMENT

##Ticket Type for Account Payment


#7

#Automation Commands

These are the Automation Commands we will use. Only 1 of them has a Mapping.

Account Operations

Load Account Statement

Print Account Statement

Pay Account

##Customer Account Screen - button addition


#8

#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;
  }
}

Increase Ticket Number
#9

#Report for Account Statement

##Account Statement

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

#10

#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


#11

#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


#12

#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 Name Equal Customers

##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 Name Equal ACCOUNT 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 Name Equal AS Pay Account
{SETTING:AS Entity Balance} Greater 0

##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 Name Equal AS 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 Name Equal AS 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 Name Equal AS 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 Name Equal AS 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 Name Equal AS 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 Name Equal AS 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 Name Equal AS 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 Name Equal AS Credit Account
Command Value Is Not Null
{SETTING:AS Entity Balance} Less 0.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 Name Equal AS Credit Account - Apply
Command Value Not Equals Cancel
[=TN('{SETTING:AS Credit Amount}')] Greater 0

##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


Add Funds to SambaCard via Product
Custom report for customer account payments detail
#13

#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

#14

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


#15

… reserved for updates …


#16

#17

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.


#18

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


#19

@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.


#20

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!!