Transact 3POS
Transcript of Transact 3POS
-
8/2/2019 Transact 3POS
1/14
1998 Braid ed Matrix, Inc. All Rights Reserved
Accounting Transactions III: Batch ProcessingBy Lincoln Stoller, Ph.D.
This is the th i rd in a fou r -a r t i c le se r ie s exp lo r ing d if fe ren t typ es o f
accoun t ing t ran sact ion s . In th e fi rs t a r t icle , Accoun t ing Tran sact ion s ,
I, Dim ens ions v .3 , n .6 , Sep tem ber / October 19 94 , we cons ide r ed the
bas ic log ica l and re la t ion a l st ru c tu re o f t r an sac t ion s . In th e second
ar t ic le , Accoun t ing t ra n sact ion s Dimen sion s v .4 , n .2 , Janu ary
/ Fe b r u a r y 1 9 9 5 , we u s e d c a s h t r a n s a ct io n s a s a c o n c r e t e e x a m p l e . In
th i s a r t i c le we focus on th e t echn ique o f ba tch p rocess in g , which we
d eve lop in th e con tex t o f po in t -o f -sa le (POS) t r an sac t ion s .
Batching Defined:
Batch in g is a genera l t echn iqu e in wh ich d a ta p rocess in g is don e in a
se r ie s o f st ages . In fo rm at ion i s on ly pa r t i a l ly p rocessed a t th e t ime
it s e n t e r e d a n d it s r e c o ve r e d a t a la t e r t i m e i n o r d e r t o c o m p l e t e t h e
pr ocess in g . Well ca ll the f ir s t p a r t o f the p r ocess ba tch p r epar a t ion
a s it in v o lv e s en t e r i n g d a t a a n d p a r t ia l ly u p d a t in g t h e r e s t o f t h e
d a tab ase . Th e second p a r t o f the p rocess, which well ca ll ba tch
p r o c e ss in g , in v o l ve s r e c o ve r in g t h e p r e p a r e d it e m s a n d c o m p le t in g
th e da ta f ile up d a t ing p rocess .
In t h i s exam ple POS t ra n sac t ion s crea t e ne w record s in a t r a n sac t ion
a n d a c o m p o n e n t f ile a n d a ls o u p d a t e b a la n c e s in a n a c co u n t f ile ( se e
f igur e 2 ) . Ba tch p rep ara t ion cons i st s o f s to r ing da ta in th e t r an sac t ion
r e c o r d s b u t n o t u p d a t in g t h e c o m p o n e n t o r a c co u n t r e co r d s . Wh e n
t h e b a t c h i s p r o c e s s ed we will u p d a t e a l l t h e r e l a t e d f ile s fo r m a n y
POS record s a t on ce .
Ther e a re m an y fam il ia r exam p les o f s t aged d a ta p rocess in g . For
in s t a n c e y o u r a c co u n t s fo r o n -lin e s e r v ic e s a r e u p d a t e d e v e r y fe w
d ays to r e f lec t pa s t usage . Un ited Parce l Se rv ice uses han d h e ld
c o m p u t e r s t o l o g d e liv e r y in f o r m a t io n wh i ch is d o wn l o a d e d t o a
c e n t r a l sy s t em a n d b a t c h p r o c e ss e d .
Ba tch p rocess ing o f fe r s severa l ben ef it s an d su f fe r s severa l
d r a wb a c k s. On t h e p o s i t iv e s id e , d a t a e n t r y i s fa s t e r a n d b a t c hp rocess in g a l lows an ex t ra d egree o f con t r o l . On th e n ega t ive s ide i t is
m o r e co m p le x a n d r e q u i r es m o r e t r a in i n g b o t h t o m a n a g e a n d t o
p rogram . Wel l cons ide r each o f these i ssues in d e ta i l
The Benefits:
-
8/2/2019 Transact 3POS
2/14
Accounting Transactions II: Cash TransactionsCopyright 1995, Lincoln Stoller
page 2
Pa r t i a lly e n t e r i n g d a t a i s fa s t e r t h a n fu l ly p r o c e s sin g t h e d a t a
b e c a u s e i t d e f e r s se v e r a l st e p s . Th e s e st e p s n e e d t o b e d o n e la t e r ,
a n d t h e b u r d e n o f b a t c h m a n a g e m e n t a d d s a d d it io n a l p r o c e ss in g .
Oft e n , t h e t o t a l a m o u n t o f t im e r e q u i r e d t o p r e p a r e a n d p r o c e ss
en t r i e s is grea t e r th an i f a l l p rocess in g is don e in to ta l fo r each en t ry .
Bu t wh a t s im p o r t a n t is t h a t d a t a e n t r y a p p e a r s t o b e fa s t e r b e c a u s et h e u s e r r e g a i n s t h e s y s t e m s a t t e n t i o n a f t e r a s h o r t e r d e l a y .
Ba tch p rocess in g add s ext ra con t ro l by enab lin g the use r o r
a d m in i st r a t o r t o m o d i fy , o r a d d i n f o r m a t i o n t o t h e b a t c h e d e n t r ie s
before th e ir f in a l p rocess in g . The u se r d oesnt h ave to be a s
concern ed wi th accuracy o r c la r i ty and can focus in s tead on dea lin g
wit h t h e im m e d i a t e s it u a t i o n .
For a sp ec if ic exam ple cons ide r th e p r ocess o f p reven t ing du p lica te
e n t r i e s. Th i s is a d a t a i n t e n s iv e t a s k t h a t u s u a l ly r e q u i r e s t h e r e v i ew
of man y en t r i e s . Whi le you cou ld check a g iven en t ry aga ins t a l lp o s si b le e n t r ie s e ve r y t i m e a n e w e n t r y i s m a d e , b u t t h e r e a r e o t h e r
t e c h n i q u e s y o u c a n u s e fo r a g r o u p o f e n t r i e s t h a t c a n s p e e d t h e
p rocess con s id e rab ly . In t h i s case a ba tch p rocess in g st ra tegy would
shor ten to ta l p r ocess in g t im e .
Fina l ly , by se lec t in g which p rocesses to d e fe r an d which p rocesses to
p e r f o r m im m e d i a te ly , t h e p r o g r a m m e r c a n p r e v e n t b o t t le n e c ks t h a t
c o u l d s l o w o r e v e n p r e v e n t e n t r i e s. In t h e e x a m p le s we v e d e a lt w i t h
in p r ev iou s a r t ic le s each t r an sac t ion u pd a tes an accoun t ba lance f ie ld
s t o r e d in a n a c co u n t r e c o r d . Wh e n m a n y u s e r s n e e d a c ce s s t o t h e
s a m e a c co u n t e a c h u s e r will h a v e t o e it h e r wa it t h e ir t u r n fo r r e c o r daccess o r cance l the i r en t r y .
An y s it u a t i o n wh e r e m u l t ip l e u s e r s a c ce s s fe w r e c o r d s is a p o t e n t ia l
bo t t l eneck . Th e top ic o f ha nd lin g bo t t l enecks i s a d iscuss ion o f it s
own so le t i t su f f ice to say th a t b o t t l enecks can bo t h s low th e sys tem
an d p lace it a t a g rea te r r i sk fa i lu r e . Ba tch p r ocessing can com ple te ly
d e f e r a c ce s s t o c e n t r a l ly u s e d r e c o r d s a t t h e b a t c h p r e p a r a t io n s t a ge .
Fina l p rocessin g can focuses on u pd a t ing a cen t r a l ly used record s .
T h e u p d a t e p r o c e ss fu n n e l s a ll in f o r m a t io n t h r o u g h t h i s b o t t le n e c k ,
b u t b e c au s e t h e b a t c h is h a n d le d b y t h e p r o gr a m m e r t h e i n fo r m a t i onc a n b e s cr e e n e d , s u m m e d , o r o t h e r wis e p r e p a r e d t o m in i m i z e
con ten t ion an d rep e t i t ive act ions . In ad d it ion , th e ba tch can b e
p r o c e ss e d a t a t i m e wh e n n e t wo r k t r a f fic a n d d a t a c o n t e n t io n is lo w.
Avoid in g bo t t l enecks is p rob ab ly the m os t comp el ling reason to
e m p l o y b a t c h p r o c e ss in g . Div id i n g d a t a e n t r y i n t o a u s e r e n t r y p h a s e ,
a n d a c a r e f u l ly c o n t r o lle d u p d a t e p r o c e ss r e l ie v e s t h e s y s t e m
-
8/2/2019 Transact 3POS
3/14
Accounting Transactions II: Cash TransactionsCopyright 1995, Lincoln Stoller
page 3
d es igner o f ma n y speed l im ita t ions an d m os t o f th e d i ffi cu lty record
of content ion.
The Drawbacks:
T h e t wo m a i n d r a wb a c k s of b a t c h p r o c e ss in g a r e t h e d e la y i n g a in i n g
fu l l a c ce s s t o t h e i n fo r m a t io n a n d t h e e xt r a p r o g r a m m in g t h a t s
r e q u i r e d . Th e r e a r e a l so le s s im m e d i a t e d r a wb a c k s t h a t a r is e wh e n
t h e b a t c h p r o c e ss in g i s e m p lo y e d t o wo r k a r o u n d s y st e m lim it a t io n s .
Ba tch p rocess in g is no t a s im p le p rocess and whi le i t can r eso lve
som e ha rd ware l im i ta t ion s it a l so im p oses i t s own b ur d en s . Even i f
t h e p r o c e ss is d e s ig n e d s o a s n o t t o h in d e r u s e r s, it m a y d o s o la t e r
when sys tem spec i fi ca t ions chan ge .
I r e m e m b e r 2 0 y e a r s a g o , a t t h e Un i ve r s it y o f Ca l if o r n i a , wh e n u s e r s
d i d h a v e n o t d i r e c t a c ce s s t o ce n t r a l p r o c e s so r s . Pr o g r a m s we r e r e a d
in t o c a r d r e a d e r s a n d q u e u e d t o r u n i n a b a t c h . Dep e n d i n g o n t h e
le n g t h o f t h e p r o g r a m a n d t h e p r i or i ty o f t h e a c co u n t y o u r p r o g r a m
w o u ld b e r u n s o m e t im e b e t we e n t e n m in u t e s a n d t e n h o u r s la t e r .
Im s u r e MIS wa s p e r fe c t ly h a p p y b u t i n r e t r o s p e c t t h e s e we r e
d a r k d a y s fo r c o m p u t e r u s er s .
It i s easy fo r sys tem d es igner s to fo rge t t h a t a su ccess fu l des ign i s
d e t e r m in e d b y h o w we ll it h e l p s t h e u s e r s , a n d n o t b y h o w we ll it
wo r k s ju d g e d o n e n g i n e e r in g c r it e r ia . Sy s t e m s a r e b e c o m i n g m o r e
in te ra c t ive and da ta m ore imm ed ia te ly ava i lab le . Ba tch p rocess in g
r u n s co u n t e r t o t h e se t r e n d s .
Point of Sale Transactions:
A p o in t - o f-s a le t r a n s a c t io n is a t r a n s a c t io n e n t e r e d a t t h e t i m e a s a le
is m a d e a n d wh i ch m u s t p e r f o r m a c co r d in g t o t h e u s e r s t im e
cons t r a in t s . By use r s t im e cons t ra in t s we m ean th e t im e-f ram e o f
t h e sa l e s e v e n t , wh i c h m a y b e le s s t h a n t h e t im e t h e p r o g r a m
r e q u ir e s t o e n t e r a n d u p d a t e a ll t h e d a t a . If t h e u s e r n e e d s t o r e ga in
con t r o l im m edia te ly , ba tch p r ocess in g o ffer s a so lu t ion .
Wel l con sid er a s im p le cash sa le involving two a ccoun ts , a Sales
accoun t , and a Cash accoun t . The am oun t o f th e sa le is cred ited to th e
Sa les accoun t an d d eb i ted to th e Cash a ccou n t . Th ere wi ll be d if fe ren tsa les accoun ts to t r ack d i ffe ren t typ es o f sa les, which th e use r
spe cif ies a t th e po int of sa le .
Analysis of the Batch Process
Batch p rocess in g in vo lves sepa ra t in g da ta en t ry in to b a tch
p r e p a r a t io n a n d b a t c h p r o c es sin g . Th e fir s t i n v o lv e s e n t e r in g d a t a
-
8/2/2019 Transact 3POS
4/14
Accounting Transactions II: Cash TransactionsCopyright 1995, Lincoln Stoller
page 4
an d p re l im inar y sto ra ge , th e second in vo lves b r ing in g the da ta fil e
fu l ly u p t o d a t e .
The d a ta f low d iagram (DFD) in Figure 1 shows wha t occur s don e
wh e n a u s e r e n t e r s a POS t r a n s a c t io n . Pr o c e s se s a r e r e p r e s e n t e d b y
ova ls , d a ta s to re s a re rep resen ted b y rec tan g les . Lin es com ing from
r e c t a n g l es t o o v a ls r e p r e s e n t t h e u s e r d r a wi n g in f o r m a t i o n fr o m t h e
d a t a s t o r e s . Lin e s f r o m t h e o v a l t o t h e r e c t a n g l e s r e p r e s e n t t h e
pr ocess o f sto r ing in fo rm at ion .
Customer Sales Type
Batched Transaction
POSEntry
User
select
locate
create
Component
Account
Processed Transaction
ProcessBatch
Administrator create
update
update
locate
Figure 1: Batched POS Transaction Data Flow Diagrams.
T h e t o p p o r t i o n o f fig u r e 1 s h o ws t h e p r e p a r a t io n s t a ge . T h e u s e r
spec if ie s a d a te , cus tom er , sa les ca tegory , and sa les am ou n t . The
cus tom er m us t co r respo nd to a record in th e Cus tom er f ile . The sa les
ca tegory i s chosen f rom a l is t o f m an da to ry ca tegor ies . A m in imal
am ou n t o f f ile up d a t ing takes p lace a t th is st age . In p a r t icu la r ,
c o m p o n e n t r e c o r d s a n d a c co u n t r e c or d s a r e n o t m o d ifie d .
The bo t tom of f igur e 1 shows the f in a l p rocess in g . Here we re tu rn to
t h e p a r t i a lly p r o c e ss e d r e c o r d s , r e a d t h e t e m p o r a r y i n f o r m a t i o n
-
8/2/2019 Transact 3POS
5/14
Accounting Transactions II: Cash TransactionsCopyright 1995, Lincoln Stoller
page 5
s t o r e d wit h t h e m , a n d u p d a t e t h e r e l a te d r e c o r d s in t h e Co m p o n e n t
an d th e Accoun t f ile s .
Structure Chart
One of th e consequ ences o f sp lit t ing POS in to two p ar t s i s the n eed to
s u p p o r t t wo in t e r f a c es : o n e f o r d a t a e n t r y ( b a t c h p r e p a r a t io n ) a n d
a n o t h e r fo r b a t c h p r o c e ss in g . A b l u e p r in t fo r t h e s e a r e a s is s h o wn in
th e fo llowin g Sys tem St ru c tu r e Ch ar t ( figu re 2 ) .
Figur e 2 shows two d i s t in c t in te r face a reas . The d a ta en t ry a r ea , on
top , is con t ro l led th rou gh an in pu t layou t . Th is layou t supp or t s the
lo o k -u p o f cu s t o m e r a n d t y p e - o f-s a le i n f o r m a t io n , a n d o ff er s t h e
usu a l op t ion o f accep t ing o r can ce ling th e en t r y .
T h e b a t c h p r o c e s sin g a r e a , sh o wn b e l ow, u s e s a n o u t p u t la y o u t t o
d i s p la y c u r r e n t s a l e s e n t r ie s . T h e o u t p u t s c r e e n i s t h e a p p r o p r i a t e
p lace to han d le ba tch p r ocess in g sin ce th i s i s an ac t ion t ha t ap p l ie s toa se lec t ion o f sa les records . Th is ou t pu t screen sup po r t s the u sua l
ad d , m odi fy , de lete , sea rch , so r t , an d subse t se lec t ion op t ions .
The ou tpu t layou t a l so sup po r t s a m enu labe led Ba tch Process ing
t h a t a l lo ws t h e u s e r t o l o ca t e r e c o r d s q u e u e d fo r p r o c e ss in g a s we ll
as to in i t ia te p rocessin g . Ba tch p r ocess in g is p laced in a m en u so tha t
it c a n b e p r o t e c t e d wit h a p a s swo r d .
-
8/2/2019 Transact 3POS
6/14
Accounting Transactions II: Cash TransactionsCopyright 1995, Lincoln Stoller
page 6
Figure 2 . Dat a Ent ry and Bat ch Processing St ruct ure Chart .
User POS ent ry
Locate
Customer
Select
Sales Type
Specify Sales
Amount
Ent er or
Cancel
Must exist in
database.
Chose from
mandit ory choice
l ist .
Amount > 0 .
Bat ch Processing
Locate
Bat ched Sales
Process
Bat ched Sales
Find all batched
sales
transactions.
Act on batched
records in the
current selection.
Information Requirements
POS en t r ie s s to re wh a t wel l r e fe r to a s ex te rn a l and in te r n a l
in fo rm at ion . Ex te rna l in fo rm at ion h as to with th e wor ld ou t s ide th e
d a t a b a s e a n d in c l u d e s a l l t h e in f o r m a t io n a b o u t t h e a c t u a l POS e v e n t
an d h ow it s to be h an d led . In te rn a l in fo rm at ion cons i st s o f th e da ta
r e q u i r e d t o s u p p o r t t h e r e la t io n a l st r u c t u r e a n d p e r f or m a n c e
r e q u ir e m e n t s . Th e s e in c lu d e p r im a r y o r fo r e ig n k e y s , d e r iv e d a n d
d e n o r m a liz e d i n fo r m a t io n , fla g v a lu e s a n d c o m p o u n d k e y s.
External Data Dictionary:
The Extern al Data Dictiona ry (EDD), in ta ble 1, lists th e inform ation
t h a t t h e u s e r s e n t e r s a n d wh i ch r e f le c t t h e u s e r s u n d e r s t a n d in g . It
a l so i n c lu d e s t h e b u s i n e s s r u l es t h a t g o ve r n t h i s d a t a .
Table 1: External Data Dictionary
-
8/2/2019 Transact 3POS
7/14
Accounting Transactions II: Cash TransactionsCopyright 1995, Lincoln Stoller
page 7
It e m Fie ld
T y p e
Enter
- a b l e
Description
Date d a t e y es In it ia lized t o cu r r en t d a t e .
Sa le s a m o u n t r ea l y es Mu st b e p o sit ive .Cu stom er n a m e a lp h a y es Lo oked u p fr o m t h e cu sto m er file .
Typ e o f sa le in d ica t o r a lp h a y es Selected fr om p op u p m en u , u sed
t o d e t e r m in e t h e v a lu e a s sig n e d
to th e Su b typ e fie ld .
File Structure and the Internal Data Dictionary
T h e a r t i cl es in t h is s e r ie s a l l m a k e u s e o f a s t r u c t u r e wh e r e
t ran sac t ion in fo rm at ion i s s to red in a Tra n sac t ion fi le tha t is in a o n e-to -m an y re la t ion with a Com po n en t f il e . Each t ran sac t ion h as a s in g le
t r a n s a c t io n r e co r d a n d m u l t ip l e co m p o n e n t r e c o r d s .
The wh ole fi le s t ru c tu r e con s is t s o f a Tran sac t ion f il e (wh ich s to res
in fo rm at ion comm on to a l l comp onen ts ), a Com pon en ts f ile , a sub f ile
u s e d fo r t e m p o r a r y s t o r a g e ( a t ta c h e d t o t h e T r a n s a ct io n file ) , a n d t h e
accou n ts f ile . This is shown in f igur e 3 .
Account Component Transact ion
sfComponentID
Dat e
Type
Subtype
sfComponent
BatchProcess
Relat edRec_ ID
L
D
A
A
*
B
L
ptr_AccountID
ptr_TransID
Debit_Amount
ID
Name
Balance
L
L
RAccount_ID
Debit_Amt
SaveToDisk
DeleteFrmDisk
CompRecNum
L
R
B
B
L
L
A
R
Figure 3: 4D transaction and accounts fi le structure.
We ca n e a s ily u s e t h i s s t r u c t u r e t o s u p p o r t b a t c h p r o c e ss in g b y
stor in g the in i t ia l POS inform at ion in th e Tran sact ion f ile an d
d e l a y in g t h e c r e a t io n o f co m p o n e n t s a n d t h e u p d a t in g o f a cc o u n t s
u n t i l a l a te r t ime . We wil l a l so ad d a few ext ra f ie lds to th e
t ran sac t ion f il e to be t te r sup po r t ba tch p rocess ing . Refe r r ing to the
f il e st ru c tu r e o f Figur e 3 an d th e fun c t ion s li st ed in t ab le 1 , we can
c o m p le t e t h e i n t e r n a l d a t a d ic t io n a r y t h a t i s g iv e n i n t a b le 2 .
-
8/2/2019 Transact 3POS
8/14
Accounting Transactions II: Cash TransactionsCopyright 1995, Lincoln Stoller
page 8
Table 2: Internal Data Dictionary
It e m Fie ld
T y p e
Enter
- a b l e
Description
Tr a n sa ct ion ID lon gin t n o Un iq u e a n d r eq u ir ed .
Tr a n sa ct ion typ e a lp h a n o Se t to POS fo r en tr ie s cr ea ted th rou gh
th is layou t .
Su b t y p e a lp h a n o Set to BAR_ , REST, or CATR.
Re la ted recor d ID lon gin t n o Se t to se lected cu st o m er ID.
Ba t ch Pr o ce ss b oolean n o Se t t o Tr u e fo r a ll n e w r eco r d s.
Balancing accou n t in form at ion:
Accou n t ID lon gin t n o Assign ed a ccor d in g to u se r se lect io n .
Sa ve t o d isk b oolean n o Used to h a n d le r ecor d m od ifica t ion s.
De le te fr om d isk b oolean n o Used to h an d le r ecor d m od ifica t ion s.
Comp onen t record
n u m b e r
lon gin t n o Rea d fr o m exist in g co m p on en ts wh en
th ey exis t . Set to -1 i f th ey d on t exist .
Used to ha n d le record m odi fica t ions
wh i ch a r e n o t d i s cu s s e d h e r e .
Interface:
POS Transaction List
Dif fe r e n t t y p e s o f t r a n s a ct io n s a r e d i s t in g u i sh e d b y t h e v a lu e s
ass igned to th e ir t r an sac t ion Type f ie ld . POS t ran sac t ion s can b e
lis t e d s e p a r a t e ly f r o m o t h e r t r a n s a ct io n s b y d is p la y in g o n l y t h o s e
t ran sac t ion s assigned a POS typ e . The Tran sac t ion fi le ou tpu t l ayou t
i s spec ia lly des ign ed fo r POS-typ e recor d s . We can d raw in fo rm at ion
fr o m t h e r e l a t e d c o m p o n e n t r e c o r d s , o r s u b r e c or d s in t h e c a se o f
b a t c h e d r e c o r d s , t o d i sp l a y t h e t r a n s a ct io n a m o u n t . T h e o u t p u t
layou t i s shown in f igur e 4 .
-
8/2/2019 Transact 3POS
9/14
Accounting Transactions II: Cash TransactionsCopyright 1995, Lincoln Stoller
page 9
Dat e Cust omer Type of Sale Amount
Search Sort Add Delet e Ret urnSelect
Figure 4: Transact ion fi le out put layout f or POS t ransact ions.
Dat e Cust omerNam SaleType SaleAmt
T h e f u n c t i on s l is t ed in t h e s t r u c t u r e c h a r t ( f ig u r e 2 ) a r e h a n d l e d
t h r o u g h b u t t o n s in t h e f o o t e r a r e a o r t h r o u g h t h e Ba t c h P r o ce s sin g
m e n u a s so c ia t e d wi t h t h is la y o u t a n d a r e s h o wn in fig u r e 5 . T h e
o th er fun c t ion s lis t ed in the foo te r a rea a r e in c lu ded fo r
com ple ten ess bu t wont be d iscussed .
Figure 5 : Menu associat ed wit h t he POS t ransact ions layout .
Find Bat ched Sales
Process Select ed Bat ch
T h e t wo i t e m s o n t h e Ba t c h Pr o c e s sin g m e n u a l lo w t h e u s e r t o v i e w
t h e r e c or d s q u e u e d f o r b a t c h p r o c e ss in g , a n d t o p r o c e s s t h e b a t c h e d
record s in th e cur r en t se lec t ion . By red uc ing the cur ren t se lec t ion t o
a n y s u b s e t t h e u s e r is a b l e t o c o m p le t e p r o c e ss in g f o r a n y p a r t i cu l a rb a t c h e d e n t r i e s.
POS Input Layout
POS e n t r y is d o n e t h r o u g h a i n p u t l a y o u t s t o r e d i n t h e t r a n s a ct io n
f ile . The spec i fi ca t ions requ i re tha t t h e layou t sup po r t :
lo o k -u p o f c u st o m e r b y n a m e ,
a lis t o f r e q u ir e d s a le s t y p e s t h a t t h e u s e r ca n c h o o s e fr o m ,
a p r e p r o g r a m m e d k n o wle d g e o f wh i ch a c c o u n t s to u s e fo r e a c hsa les type .
The i ssue o f wh ich accou n ts to use fo r each sa les typ e dese rves som e
exp lana t ion . Because were d o ing dou b le -en t ry b ookkeep ing we
a lways log a deb it an d a c red it fo r each t r an sac t ion . The c red it i s to
on e o f the sa les accoun ts and , in th is s im p lif ied examp le , th e d eb i t is
to a s in gle cash accoun t .
-
8/2/2019 Transact 3POS
10/14
Accounting Transactions II: Cash TransactionsCopyright 1995, Lincoln Stoller
page 10
In t h is exam p le were go ing to h an d le res taur an t sa les. Here a sa le o f
liq u e u r c r e d i t s a b a r - r e la t e d s a le s a c co u n t , fo o d p u r c h a s e d in t h e
r e s t a u r a n t c r e d i t s a r e s t a u r a n t a c c o u n t , a n d o ff-s it e f o o d s e r v ic e
c red i t s a ca te r in g accoun t . Each a l t e rn a t ive in vo lves a d i ffe ren t sa les
a c co u n t a n d is t a g ge d wit h a o n e o f t h e 4 c h a r a c t e r s a le s co d e s s h o wn
in t a b l e 3 .
Table 3: Accou n ts a s soc ia ted with each o f type o f sa le .
Sa les Cod e Deb it Accou n t Cr ed it Accou n t
BAR_ Cash Ba r Sa les
REST Cash Re st a u r a n t Sa les
CATR Cash Ca te r in g Sa les
Figure 6 : POS input layout .
Date
Customer
Type o f Sale
Amount
Ent er
Cancel
Sales Ent ry
5 / 2 5 / 9 5
Rest aurant
0.00
T h e i n p u t la y o u t s h o wn in fig u r e 6 h a s f o u r e n t e r a b le f ie ld s . Th en a m e f ie ld h a s a s cr i p t t h a t c h e c k s t h e c u s t o m e r s n a m e a g a in s t
c u s t o m e r s s t o r e d in t h e d a t a b a s e , th e s a le s t y p e is h a n d l e d u s in g a
cho ice l is t , an d th e sa les amo un t screen s da ta so th a t on ly po s it ive
v a lu e s c a n b e e n t e r e d .
W h e n t h e u s e r p r e s s es t h e Ent er b u t t o n t h e la y o u t p e r f or m s t h e
followin g fun ct ion s:
-
8/2/2019 Transact 3POS
11/14
Accounting Transactions II: Cash TransactionsCopyright 1995, Lincoln Stoller
page 11
It lo c a t e s a n d a s sig n s a t r a n s a ct io n r e c o r d ID n u m b e r . Th i s n u m b e r
is st o r e d i n a s e p a r a t e c o u n t e r r e c o r d t h a t n e e d s t o b e in c r e m e n t e d
every t im e a t r a n sac t ion ID is a s sign ed .
It s to res the cu s tom er s ID in a f ie ld in t h e t r an sac t ion record .
It s t o r e s t h e e n t r y d a t e a n d s e t s th e Ba t c h P r o ce s s fie ld t o t r u e .
It c o n s id e r s t h e t y p e o f sa l e a n d c r e a t e s t wo s u b r e c o r d s . On e s t o r e s
th e ID of th e accou n t to b e deb ited ( th e cash accoun t in th is case ) and
t h e d e b i t a m o u n t wh ile t h e o t h e r s t o r e s t h e ID o f t h e c r e d it a c co u n t
a n d cr e d it a m o u n t .
No t ic e t h a t s u b r e c o r d s a r e o n l y b e in g u s e d f o r t e m p o r a r y d a t a
s to rage . Once the ba tch i s p r ocessed th e subr ecord in fo rm at ion wil l
be cop ied to o th e r f ile s and th e sub record s wil l be d e le ted . Th is i s
im p o r t a n t s in c e s u b r e c o r d s a r e ge n e r a l ly a p o o r m e t h o d fo r
p e r m a n e n t d a t a s t or a g e.
Batch Processing Procedure
The t ra n sac t ion f ile con ta ins record s tha t h ave been fu lly p rocessed
an d r ecord s tha t a r e await ing ba tch p rocess in g . Fu l ly p r ocessed sa les
t r a n s a ct io n s a r e l in k e d t o t wo r e c o r d s i n t h e c o m p o n e n t s file wh i ch ,
in tu r n , each re la te to an accoun t . Ba tched t ran sac t ion s use
s u b r e c o r d s t o s t o r e t e m p o r a r y i n f o r m a t io n , f u lly p r o c e ss e d
t r a n s a ct io n s h a v e n o s u b r e c o r d s .
Pr o c e ss in g b a t c h e d r e c o r d s i s s tr a i gh t f o r wa r d a n d in v o l v es t h efollowin g s tep s .
Loca te th e record s in th e cur r en t se lec t ion fo r wh ich Ba tch Process =
Tr u e .
Lo o p t h r o u g h t h e s e le c tio n c r e a t in g a c o m p o n e n t r e co r d fo r e a c h
s u b r e c o r d a n d c o p y i n g s u b r e c o r d in f o r m a t io n t o i t . At t h e s a m e t im e
u p d a t e t h e d e b i t b a la n c e s t o r e d wit h e a c h r e la t e d a c c o u n t .
T h e s a m p l e c o d e o f fig u r e 7 s h o ws o n e wa y t o i m p le m e n t t h is lo o p .
No tic e t h a t r e l a t e d a c c ou n t r e c o r d s m u s t b e u n lo c ke d in o r d e r f o r
t h e i r b a l a n c e s t o b e u p d a t e d . If a n a c c o u n t is lo c k ed t h e n t h et ran sac t ion i t s r e la ted to shou ld n o t be p rocessed .
The loop i s execu ted a f te r s t a r t in g a 4 th Dim ens ions t r an sac t ion u s in g
t h e Start Transact ion c o m m a n d . T h e sim p l e st a p p r o a c h wo u ld b e
t o b lin d ly u p d a t e r e la t e d f ile s b a s e d o n t h e r a t io n a l t h a t t h e wh o l e
4D t ran sact ion cou ld be can ce led i f a locked a ccoun t is encoun te red .
-
8/2/2019 Transact 3POS
12/14
Accounting Transactions II: Cash TransactionsCopyright 1995, Lincoln Stoller
page 12
T h a t wo u l d b e a p o o r a l go r it h m b e c a u s e a s ig n ific a n t a m o u n t o f
p rocessing t im e cou ld b e lost d ue to a s ing le locked record . We u se a
m ore in te l ligen t a lgor ith m in wh ich a ll the accoun ts a s soc ia ted with
e a c h t r a n s a ct io n a r e p l a ce d i n a r e a d / wr it e st a t e b e f o r e m a k in g a n d
m o d i fic a t io n s . As a r e s u l t we n e v e r m a k e a n y c h a n g e s t h a t m ig h t
n eed to b e ro l led b ack and , a s lon g as a l l r e fe renced a ccoun ts can beloca ted , we can a lways va l id a te th e t r an sac t ion .
` Procedure ProcessBatch
` Processes all batched sales transact ions in t he current t ransact ion select ion.
` Uses a 4D t ransaction t hat never needs to be rolled back, under normal circumstances.
c_Longint ($ j;$k;$NumBatched;$NumDone;$NumNot Done;$NumComps)
$NumDone:=0
$Error :=None
Search ([ Transact ion] ;[Transaction]Bat chProcess =True ; * )
Search ([ Transact ion] ; & [Transact ion] Type =SALE )
$NumBatched:=Records in select ion ([ Transact ion] )
If ($NumBatched>0)
Confirm ( Ready t o process +St ring($NumBat ched)+ bat ched t ransact ions. )
If ( OK=1)
Start Transaction
For ($ j;1;$NumBatched)
Search ([ Account] ;[Account ] ID=[ Transact ion] sfComponent 'Account _ID;*)
Apply to Subselect ion (Search( [Account ] ;
| [Account]ID=[Transaction]sfComponent'Account_ID;*))
Search ([ Account] )
Apply t o Selection (Account];[Account]Name:=[Account] Name)
If ( Records in set ( LockedSet ) =0 )
$NumComps:=Records in Subselection ([ Transact ion]sfComponent)
For ($ k;1;$NumComps)
Create Record ([ Component])
[ Component ] ref_ TransID:=[ Transact ion]Trans_ID
[Component]ref_AcctID:=[Transaction]sfComponent'Account_ID
[Component]DebitAmount:=[Transaction]sfComponent'DebitAmount
Save record ([ Component])
Search ([ Account ] Account _ID=[ Component] ref_Acct ID)
If ( Records in select ion ( [ Account ] ) >0 )
-
8/2/2019 Transact 3POS
13/14
Accounting Transactions II: Cash TransactionsCopyright 1995, Lincoln Stoller
page 13
[ Account] DebitBalance:=[ Account ] DebitBalance
+ [Component]DebitAmount
Else ` Uh oh, big problem, stay calm.
$Error:= Account with ID = +St r ing ([ Component ]ref_AcctID)
+ is not in the database. Sales transaction with ID = + St r ing ( [ Transact ion] Trans_ID)
+ needs t o be correct ed.
$k:=$ k+$ NumComps ` Exit t he inner loop.
$ j:= $j +$ Num Bat ched ` Exit t he out er loop.
End if
Save record ( [Account ] )
Next Subrecord ([ Transaction] sfComponent)
End for
$NumDone:=$NumDone+1
End if
Next Record ( [ Transact ion] )
End for
If ( $ Er r o r= No n e )
Validat e Transact ion
$NumNotDone:=$NumBat ched-$NumDone
$SayLocked:= Num ($ NumNotDone>0 )* (St ring ($ NumNotDone)
+ sales couldnt be processed because relat ed accounts were in use. )Alert ( If I ve count ed cor rect ly +St r ing ($NumDone)
+ batched t ransactions have been processed. +$SayLocked)
Else
Cancel Transact ion
Alert ( $ Er r o r )
End if
End if
Else
Alert ( There are no bat ched sales t ransactions in t he select ion, you silly human!)
End if
Figure 7 : the b a tch p rocessing p rocedu re .
T h i s a lg o r it h m m a k e s u s e o f t h e fa c t t h a t a n y r e c o r d m o d i fie d a n d
saved wh ile a 4D t ran sac t ion i s in p r ocess rem ains locked to a l l o th e r
u s e r s u n t i l t h e t r a n s a ct io n is c o m p le t e d . We co m b i n e t h is wit h t h e
-
8/2/2019 Transact 3POS
14/14
Accounting Transactions II: Cash TransactionsCopyright 1995, Lincoln Stoller
page 14
fa c t t h a t t h e Ap p ly t o Se le c t io n c o m m a n d s a v es a ll t h e r e c o r d s i n t h e
select ion to wh ich i t is app l ied .
Not ice th e Apply t o Select ion loca ted in th e m id d le o f th is
p r o c ed u r e . T h is co m m a n d d o e s n o t c h a n g e a n y v a lu e b e c a u s e it
a s s igns th e accoun t n am e to i t se lf , bu t s t il l s aves each recor d . If any
o f t h e r e c o r d s i n t h e s e le c t io n a r e l o ck e d t h e y a r e p la c e d i n t h e 4 D
sys tem se t LockedSe t , which we te s t . If the r e a r e locked accou n ts
we s k ip d i r e c t ly t o t h e n e xt s a le s t r a n s a ct io n . If t h e r e a r e n o r e c o r d s
in LockedSe t we a re a ssured th a t th e Accoun t recor d s wil l r em ain
un locked fo r the du ra t ion o f the t r an sac t ion . Th is is im por tan t s in ce
it e n a b le s u s t o p r o c e e d i n t o t h e in n e r l o o p wit h o u t f u r t h e r c o n c e r n
abou t locked accoun ts .
We a ls o t e st f o r t h e u n l ik e ly e v e n t t h a t a r e fe r e n c e d a c c o u n t h a s
b e e n d e l e t e d s in c e t h e b a t c h wa s p r e p a r e d . T h is sh o u l d b e p r e v e n t e d
b y t h a t p a r t o f t h e d a t a b a s e t h a t h a n d l e s a c co u n t s , b u t s h o u l d ar e fe r e n c e d a c c o u n t b e a b s en t w e p e r f or m a t e s t t h a t w ill p r e v e n t t h e
e n t r y o f a o n e - sid e d t r a n s a ct io n . If a r e fe r e n c e d a c co u n t c a n n o t b e
loca ted th e whole 4D t ran sac t ion i s can ce led an d th e use r i s in fo rmed
o f t h e p r o b l e m .
On c e t h e b a t c h u p d a t e is co m p l e t e, a s su m in g t h e r e a r e n o r e fe r e n c e s
to n on ex is ten t accoun ts , we is sue th e Validat e Transact ion
c o m m a n d t o s a v e o u r c h a n g e s t o d i sk . We th e n t e ll t h e u s e r h o w
m a n y it e m s w e r e p r o c es se d .
One sm al l bu t s ign i fican t po in t i s tha t we d on t so lic it an y resp on se
f rom th e use r u n t i l a f t e r the 4 D t ran sac t ion i s com ple te . Th is way a
p o ten t ia lly l a rge set o f locked accoun ts a re u n locked as soon as
poss ib le .
Overview
In th i s a r t i c le weve examined POS accoun t ing t ran sac t ion s an d ba tch
pr ocess in g . POS t ran sac t ions a r e a good cand ida te fo r ba tch ing
b e c a u s e t h e y r e q u i r e m in i m a l d e la y a n d b e c a u s e a d m in i st r a t o r s m a y
wan t to rev iew POS en t r ie s be fo re f in a l p rocess in g . Th a t i s, ba tch
p r o c e ss in g s e r v es b o t h t h e e n d - u s e r a n d t h e a d m in is t r a t o r .
Ba tch p r ocessing i s no t l im ited to accoun t ing . It i s a gener a l
t e ch n iq u e u s efu l a n y w h e r e d a t a e n t r y c a n b e b r o k e n in t o t w o p a r t s.
It is an o f ten a t t r ac t ive , th ou gh ra re ly op t im al , t echn iqu e fo r
im p r o v in g s y s t e m p e r f o r m a n c e . It is b e s t u s e d s p a r in g ly a n d o n l y
when th e log ic o f th e s itu a t ion sup p or t s a s t aged p rocess in g
a p p r o a c h .