. 1
( 2)



>>

UGKTVPG IPKVPWQEEC GVCKTRQTRRC GEWFQTR FPC UVPGXG UUGPKUWD GMCV
QV UK IPKVPWQEEC HQ GNQT GJV VCJV IPKVCEKFPK PQQVTCE GXKVUGIIWU [NNWHGRQJ VWD UUGNIPKPCGO #  GTWIK(
System
Events
Accounting Entries
 U G K T V P G I PK V P W Q E E C G E W F Q T R Q V V P G X G P C Q V I PK V E C G T
U C G T W V E K R N CV P G O C F P W H G JV G G U + G OK V PK V P K Q R U K J V V #  T G JV Q J E C G Q V G V CN G T [ G JV Y Q J
F P C G T C U P T G V V C R G J V V C J Y T G V V G D F P C V U T G F P W Q V F T C J F GK T V G X• + U T C G [ G U Q J V T G X 1
 G PK N G RK R U C I G I T CN C P K U C I M E C TV Q V O GV U [ U C I PK F NK W D U P T G VV C R G U G JV H Q N C T G X G U
F G U W G P K O H Q GV CK E Q U U C G P 1  [ G P Q O G JV G V C N W RK P C O F P C M E C TV V C J V U P T GV V C R G O C U G J V
J V K Y T QH F G V P W Q E E C G T C G OK V U • G N R Q G R H Q U T W Q J T Q [ V K EK TV E G N G H Q U T W Q J V V C Y Q N K M G T G J Y N N Q T
[ C R F P C I P K N N K D [ V K N K V W P K UK J V G G U P C E W Q ;  [ G P Q O P C J V T G JV Q U I P K J V Q V [ N R R C P C E U P T G V
V C R G U G J 6  [ G P Q O Q V [ N R R C V U W L V• P Q F G T G J F G DK T E U G F F P C P G G U G X• + U P T G V V C R G J V V W $
 N N Q T [ C R F P C I P KN N K D [ V KN KV W F G F W N E P K G X C J U G N R O C Z G [ O Q 5  V P G X G G J V H Q
U G E P G W S G U P Q E N C K E P C P K H G J V V W Q I PK T W I K H [ D U V P G X G U U G P K U W D Q V U F P Q R U G T V C J V O G V U [ U [ P C
P C G O + T G JV C 4  GN D C [ C 2 U V P W Q E E # T Q GN D C X GK E G 4 U V P W Q E E # T G I F P G . N C T G P G ) U C J E W U
U O G V U [ U I PK V P W Q E E C N C EK U U CN E G J V [N K T C U U G E G P P C G O V• P Q F + O G V U [ U I P K V P W Q E E C [ $
 U O G V U [ U I PK V W Q E E C V W Q I PK [ C N PK V T C R
P G M C V G X• + P Q U T C G [ G XN G Y V Y Q P Y Q P J VK Y F G XN Q X PK O• + U C U V E G L Q T R Q V J I W Q T J V V P C V N W U
P Q E C U C V E G L Q T R V U T K H [ O O Q T (  G O T Q H G O G J V I P K FK T T G X Q P C P G G D G X C J T G J V Q P C T Q F P K M
GPQ HQ UOGVU[U IPKVPWQEEC VWD VWQ FGMTQY UCJ TGGTCE [O [CY GJV VUWL U•VK URCJTG2
#EEQWPVKPI 2CVVGTPU


G O K V T G X Q V G I W Q [ G T Q H G D M T Q Y W Q [ U T W Q J [ P C O Y Q J U C U G W U U K J E W U G F W N E PK N N K Y UV P G O
GGTI C GU GJ 6  G P Q [TGX G T GX QE Q V U V PG OG GTI C HQ U F GTFP W J TQ U PG V [P C O GX C J N N KY VK VWD
UG G [Q NR O G U VK H Q JE CG TQ H U V PG O GGTI C V PGT GH HKF GX C J VQ P [ CO [P CR O QE # [ C Y G O CU
G J V F K C R G T C G N R Q G R N N C V Q 0  I P K [ C R G T C G Y P Q U T G R G J V P Q F G U C D U K P QK V C K T C X V U T K H G J 6
 U K N K X G F G J V G T G J Y U • V C J V F P C Q K T C P G E U UK J V P K U P QK V C K T C X G T C G T G J V G U T W Q E H 1
 GTWI K(
T Q U U G E Q T 2 V P G X ' G N R OK 5
process(Event)
Accounting Entry Event
creates Processor reads
  G T W I K ( U G K TV P G
I P KV P W Q E E C U G V C G T E F P C U V P G X G U F C G T V C JV U U CN E T Q U U G E Q T R C U K J V H Q M P K J V P C E G 9
 M E G J E [ C R U K J P K [ G P Q O G J V T QH [ TV P G I P K V P W Q E E C P C G V C GT E F P C P G V
[ D [N RK V N W O G V C T [ N T W Q J UK J R W M Q QN [ C F U G P F G Y V U C N U T W Q J P G V F G M T Q Y P C O T Q 0 [ P K R 5
V C J V G G U V P G X G G J V PK F C G 4  UK JV G M KN M T Q Y V J IK O U U G E Q T R G J V O T Q H V U GN R OK U UV K P+
 V T C V U N N• + G T G J Y UK UK J V G T Q H G T G J V F P C V U Q O G O U V U G T G V P K J EK J Y U G K T V P G
Q V PK U V P G X G G J V I P K P T W V H Q U U G E Q T R G J V U K V K [ N N C W V E C V W D T G V C N O G J V U U W E UK F N N• + F P C
I P KV U G T GV PK G T C U P T G VV C R G U G J 6  P K G O Q E   P Q KV E C U P C T 6 I P KV P W Q E E # F P C   V P W Q E E #
H Q U P T G V V C R G J V G T G J Y U K U K J 6  V U G T G V P K V U G I I K D G J V U K V C J V U G K TV P G I PK V P W Q E E C G J V H Q
G T W V E W T V U G J V UK V K I P K V P W Q E E C T QH U G T W V E W TV U V W Q D C P G VV K T Y G X • Q J Y GN R Q G R V U Q O T Q (
UGNW4 IPKVUQ2
 U G K T V P G N C K E P C PK H H Q V G U GV C T C R G U C
QV I P K F C G N [ P C R O Q E I P K V CT G P G I G O Q U O QT H P K V J I W Q D U C Y J E K J Y J Y M   V C J V H Q G I CU W
G J V F T Q E G T G Y U C U G K T V P G N C K E P C P K H P Q P C G D Q U N C V J IK O G T G J 6  [ G P Q O G O Q U [ V K T Q J V W C
Z CV C G Y Q G Y V C J V I P K V C EK F PK G I T C J E C U C N N G Y U C [ G P Q O U W G Y Q [ G JV G T G J Y G I T C J E
C Q V U F C G N [ VK EK T V E G N G H Q J Y M   I P K U W T G O Q V U W E C Q 5  G UN G I P K J V G O Q U G D V J IK O [ G J V V W D
UGEPGWSGUPQE NCKEPCPKH GTC GUGJV UGNROCZG [O HQ VUQO TQ( IPKMECTV GTC GY VCJV IPKJV
G J V T Q H V P G X G U K J V H Q U G E P G W S G U P Q E G J V U F T Q E G T   [ T V P ' I PK V P W Q E E # G J 6  F G V Q O Q T R
P G G D U C J G G [ QN R O G P C V C J V T Q [ V K E K T V E G N G H Q J Y M   F G U W U C J T G O V Q U W E C V C J V P Q K V
K P I Q E G T G J V G N C U C G D [ C O U K J 6  U U G P K U W D G J V Q V I P K V U G T G V PK U K V C JV U P G R R C J V C J V I P K J V
G O Q U U G DK T E U G F   V P G X ' P #  U I P K J V G N R O K U [ N TK C H G E P G U U G P K G T C U GK T C F P W Q D G J 6

 U GK T V P G G J V U G V C G T E F P C V P G X G G J V U G U U G E Q T R G N W T V C JV P G J V F P C V P G X G
G JV H Q G R [V V P G X G G J V T QH GN W T G J V UV G I V P G O G G T I C G J V V P G O G G T I C G JV U F P KH T Q U U G E Q T R
G J 6  V C J V T QH V U W L U GK T V P G G J V U G V C T G P G I F P C V P G X G H Q F PK M GN I P K U C U G M C V G N W T I P K
VU Q R J E CG [C Y [ C Y U K J 6    GN W4 IPK V UQ2 PY Q U•V K Q VP K V PGX G HQ F PK M J E C G T QH I PK UU G E
Q T R G J V G V C T C R G U Q V U W I P K Y QN N C G R [ V V P G X G P C I P K E W F Q T V P K [ D U K J V T G F K U P Q E P C E G 9
 [ C Y P Y Q U VK PK J VK Y VN C G F
G D Q V U F G G P V P G X G H Q F P K M J E C ' T G J V Q P C Q V G E K XT G U G P Q O QTH T GH U P CT V G E K XT G U C G V CT R W
G EK X T G U V E G P P Q E U K F G E K X T G U V E G P P Q E N N C E G E K X T G U C G X C J [ V K E K TV E G N G G U W P C E T G O Q V U W E
#  J VK Y V N C G F G D V U W O V C J V U V P G X G [ P C O G T C G T G J V G U C W E G D U I P K J V F G V C E K N R O Q E G VK W S G D
P C E UV P G O G GT I C GU G JV QU P G X G V W D U V P G X G G N F P C J V C J V U V P G O G GT I C G X C J G Y Y Q P Q 5
 T G V C N V C JV J VK Y N C G F P C E G Y Y Q J
G G U N N • G Y V W D U G K EK N Q R Q P U G T C J U F P C G V C T C R G U [ G N V G N R O Q E UK V P G O G G T I C J E C G G O W U U C
N N• G Y V P G O Q O G J V T Q (  G T G J Y G U N G U P Q K V C E K H K O C T U C J VK I PK \ KN C G T V Q P F P C G E C N R G P Q
P K [ E KN Q R C I P K I P C J E H Q [ T C Y G D QV G X C J Q UN C G Y T G X G Y Q *  V K G U W V C J V UV P G O G G T I C G JV N N C
T Q H U GI PC JE V CJ V F P C GE PQ [ EK NQ R C G I P C J E QV G N D C G D Q V GMK N F N W QY GY Q5 P Q O OQ E P K
FN G J G T C U GK EK N Q R P G VH Q V W D V P G T GH HK F G T C U GK EK N Q R G J V P G J Y NN G Y U M T Q Y UK J 6  U V P G O G G T I C
T G JV Q O Q T H F G V C T C R G U G T C V P G O G G T I C G N I PK U C P K U G K E K N Q R G J V N N C V C J V V E C H G J V PK U GK N
G I C V P C X F C G J 6  U G I C V P C X F C U K F Q U N C V W D U G I C V P C X F C U C J UV P G O G G T I C G J V I PK V C T C R G 5
   G T W IK (
V P GOG GTIC GJV VW Q I PKVCT C RG5
findAgreement(Event)
process(Event)
find process()
Accounting Entry
creates Agreement
Event
 T Q U U G E Q T R C G X C J V• P Q F G Y G O G J E U V C J V J V K 9  V K U U G E Q T R F N W Q J U V C J V V P G O
G G T I C G J V F P KH Q V G N D C U K V C J V G X K V E C I P K J V G O Q U U C V P G X G G J V H Q M P K J V P C E G Y F G G F P +
   G T W I K ( I PK U U G E Q T R G JV Q F [ NN C WV E C Q V V K G U W P G J V F P C V P G X G P C T QH V P G O G G T I C
V J I K T G J V F PK H QV G N D C G D Q V F G G P F N W Q Y T Q U U G E Q T R G J 6  V P G O G G T I C G J V H Q V W Q V E GL D Q
P C I PK M C O [ D UK JV Q F FN W Q E G Y UV E GL D Q H Q U O T G V PK I P K M P K J V G T C G Y G E PK 5  V P G O G G T I C
V C JV G U W F P C V P G X G G JV U U G E Q T R Q V G U W Q V F G G P G Y V P G O G G T I C J EK J Y V W Q G T W I KH G Y
V P G X G P C G M C V G Y P G J 9  V P G O G G T I C [ D VK V KN R U U K U U G E Q T R T W Q R W VK N R U Q V [ C Y G P Q Q 5
 [ C FT W V C 5 T Q [ C F P W 5 P Q
U NN CH [ C F P W 5 T G J V G J Y F P C [ C F P W 5 C P Q V G I W Q [ V C J Y F G V C N W E N C E U K G O KV T G X Q G JV Y Q J

UGNWT IPKVUQR GJV PQ  FQKTG2 [VKXKVEGHH' GUW PCE G9 FGVCEKNROQE VCJV VQP [NNCWVEC
UK G O K V I P K N F P C J V P G O G G T I C G J V O Q TH F G V C T C R G U U GN W T I PK V U Q R G J V G X C J G Y G E P 1
 VU WI W# PK
V E GH H G PK U G N W T G J V V Q P [ T C W T D G ( PK V E G HH G P K G T G Y V C JV U GN W T G J V QV I P K F T Q E E C G OK V T G X Q
VCJV [CR VUWO GY PGJV [TCWTDG( PK FGMTQY GOKVTGXQ GOQU VWQDC VUWIW# PK TCGJ GY
H+  T W E E Q [ G J V P G J Y P C J V T G V CN J E W O U V P G X G V W Q D C T C G J P G V H Q G 9  T G JV Q P C J V K Y V K I P K
E C N R G T F P C GN W T I PK V U Q R G P Q V W Q I PK R R C Y U H Q G U C E C [ N R O K U V Q P UK UK J V J V K Y I P KN C G &
 N K T R C PK M E C D G T G Y [ G J V P C J V F G V C E K N R O Q E G T Q O T C H U P QK V C N
W E N C E U G X N Q X P K G O K V T G X Q G T G J Y  G O K V T G X Q U C  T G X Q U T W Q J N N C F P C U T W Q J I P Q N U C ZK U T G X Q
UTW QJ N N C V CGT V G Y G OK VT GXQ U C V J I K G TG XQ UT W Q J N NC I PK V CGT V HQ I PK FC GV UP K VU  [ C / PQ
V C J V G D [ C O V +  O J VK T Q I N C P C H Q V E G R U C [ P C U C Z G N R O Q E U C G D P C E V W D I PK I P C J E U G V C T U C
GN R OK U U C G D [ C O G U G J 6  G I P C J E U G X N G U O G JV U G N W T G JV V C JV V E C H G J V J VK Y I PK N C G F V W Q D C
IPKMNCV O•+ FCGVUP+ JVKY NCGF QV GNROKU [NNCWVEC UK VCJV TGVPKY QV FGUQRRQ UC TGOOWU
T QH G V CT [ VKE KT VE GN G VP GT GHH K F C U C U TG VV C O J E WU V W Q D C I PK M N CV V Q P O•+ GT G * G O KV  U G NWT
PK P QK V CKT CX H Q GU WC E VU G V C GTI G J V JV K Y N C GF Q V U N KC H VK T GX G Y Q J U V P GXG H Q IP KUU G E QTR
G J V P Y Q F M C G T D QV [ C Y N C E K I QN C U W U G XK I G R [ V V P G X G F P C V P G O G G T I C [ D I PK V C T C R G 5
 UV PG O GGT IC G NR
K V N W O V E G HH C F N W Q J U U G I P C J E Y Q J G F K E G F F P C U V P G O G G T I C J E K J Y P Q G T G Y U G N W T I PK V U Q R
J E K J Y G G U Q V U W Y Q N N C F N W Q Y V C JV O UK P C J E G O C V P G O G N R OK P G J V F N W Q E G 9  U G N W T I P K
V U Q R H Q I P K T C J U Y Q NN C P C E G Y F G W N C X K V N W O V P G O G G T I C Q V G N W T I P K V U Q R O Q T H G N Q T G J V I P K
M C O [ $  U V P G O G G T I C P G G Y V G D F G T C J U G D F N W Q J U U G N W T G T G J Y J VK Y G R Q E Q V O UK P C J E G O C
U W U G XK I Q UN C V P G O G G T I C G J V PK J VK Y U V E GL D Q G V C T C R G U U C U GN W T I P KV U Q R G J V I PK V C T C R G 5
 GTWI K(
GTWVEKR GJV QV UGNWT IPKVUQR FPC UGR[V VPGXG IPKFF#
findAgreement(Event)
getRule(EventType)
find process()
Agreement
Event
1 »
1
»
process(Event) 1
»
Accounting Entry Event Type
creates Posting Rule

QVPK RW VK IPKMQQJ FPC VEGLDQ YGP C IPKVCKVPCVUPK UC GNROKU UC GD PCE GNWT YGP C IPKFFC
V C JV Q U F G \K T G V G O C T C R G D P C E U GN W T I PK V U Q 2  U G I P C J E G M C O Q V I PK O O C T I Q T R J E W O Q U
G T K W S G T V• P U G Q F VK V C J V U K T G V V G D U K U K J V [ J Y P Q U C G T G P 1  P QK V C IK X C P G T W V E W T V U C V C F J VK Y
E K I Q N N C P QK V K F P Q E G PK N P K H Q N C G F V C G T I C U G E C N R G T V K V C J V UK UV E G L D Q I PK U W H Q V P K Q R G J 6
  GU NG
 
] VPGOGGT IC UNCWSG VPGOGGTI#VG IG HK GU NG
GU NG
 
] GR[6VPGXG UNCWSG G R[VG HK GU NG
 HK GU NG
GPKVW QTD WU [ D EK IQN IP KU UGE QTR QF    GVC4VG I TGOQV UW%VGI G G GVC4[$[ NR KVNWO
]  IWC PCJ6TGVCN GVCFG H K
] G R[6VPGXG U NCWSG  G R[VG H K
] VPGOGGT IC U NCWSG VPGOGG TI#VG IG H K
GF QE QFWGU R NCTWFGE QT R  G VPGX' UUGEQT R
 OT Q H G J V HQ EK IQ N G X C J F N WQY J EK J Y T QUU GE QT R N CT WFG EQT R C G P K I C OK FN WQ E G9
 U G W S K P J E G V N C T W F G E Q T R I P K U W Q V F G T C R O Q E G I C V P C X F C P C U K I PK U U G E Q T R H Q U V E G R U C V P G T G H
HK F G J V G V C T C R G U Q V U V E G L D Q I PK U W G T G J Y T G F K U P Q E Q V V P K Q R UK J V V C I PK U W C R J V T Q Y U• V +
UGTWVEWTV5 VEGLD1 FPC PQKVKUQROQEG& NCTWFGEQT2
   G T W IK (
 G V C F [ D [ T C X Q V U G N WT I P K Y Q N N #
findAgreement(Event)
getRule(EventType, Date)
find process()
Agreement
Event
1 »
»
1
process(Event) 1
»
Accounting Entry Event Type
effectivity: Date Range
creates
Posting Rule
 G V C F F P C G R [V V P G X G J V Q D Q V I PK F T Q E E C G N W T C
V EG NG U Q V G ND C GD QV UF GG P Y QP VP G OG GTI C GJ 6 T QKX C JGD VP GFP GR GF G O KV G J V G NF PC J Q V

 OGJ V GI P CJE V QP P CE G Y [ N NC
W U W G U W C E G D V P G U G T R NN KV U G T C U P QK V E C U P C T V N C K E P C PK H F P C UV P G X G N C PK I K T Q G J V V C J V [ C Y
C J E W U PK T Q T T G G JV ZKH QV G X C J G 9  T Q T T G G J V Z KH V U W L V Q P P C E G Y G U W C E G D U K U K J 6  U U G E
Q T R G J V H Q UV T C R F G V C EK N R O Q E F P C F T C Y M Y C V U Q O G J V H Q G P Q UK U T Q T T G J VK Y I P KN C G F V C JV
T G X Q E U K F P Q Q U G Y U V P W Q E E C J V K Y I PK N C G F G T C G Y P G J Y V W $  T W Q X G F P G P C O W J H Q O T QH
T G J V Q [ P C PK Q F [ G J V U C V U W L I P Q T Y Q I U I P K J V U U G PK U W D PK Q U GH KN H Q O T QH C U K U U G P K U W $
UGMCVUKO IPKVEGTTQ%
UKJV HQ GNROCZG GPQ VUWL UK  GNW4 IPKVUQ2 EKIQN NCPQKV
K F P Q E G J V G E CN R G T F P C G T WV E W T V U UK JV V P G U G T R G T Q V U R K J U P QK V C N G T U U CN E G U W P G J V F P C G T W V
E W T V U T C N W I G T C F P KH Q V F G G P W Q [ F G V C E K N R O Q E G T Q O U V G I VK U #  F G V C E K N R O Q E Q Q V V Q P U • V K
P G J Y F Q Q I UK EK I Q N N C P QK VK F P Q %  [ E P CH G T Q O I PK JV G O Q U G U W Q V P G J Y F P C UN C P Q KV K F P Q E
GU W Q V PG J Y H Q P QK VU GWS GJ V TG Y UP C Q V P IKU GF 1 1 [ NGT WR C P K V WQ DC I PKM PK JV JVT QY
QUNC U•V+ GVCDGF NCTWFGEQTR UX UVEGLDQ GJV TQH TGVVCO C VUWL V•PUK UKJV VWQDC IPKMPKJ6
 RK J U P Q KV C GN G T U U C N E H Q O T Q H G O Q U [ D F G E CN R G T G D P C E V C J V G T W V E W T V U I PK [ N T G F P W
T C N W I G T C U C J E K I QN N C P QK VK F P Q E G J V P G J Y NN G Y U M T Q Y V +  O U K P C J E G O UK JV U G K N T G F P W
Q U N C V K F P C O U K J R T Q O [ N Q R U G K N T G F P W V P G O G E C N R G T UK J 6  U V E G L D Q H Q G T W V E W T V U G J V P Q
F G U C D P Q KV C I K X C P JV K Y E K I QN N C P QK VK F P Q E H Q V QN C G E C N R G T QV U M G G U J E C Q T R R C V E GL D Q G J 6
 U G J E C Q T R R C N C T W F G E Q T R F P C V E GL D Q G J V P G G Y V G D G E P G T GHH K F G J V H Q V T C G J G J V UK UK J 6
 G V C K T Q K T G V G F G T W V E W T V U T K G J V G X C J Q V [ N G MK N U U G N G T C U V E G L D Q G J V V N W U G T C U C Q 5
 E K I Q N T W Q [ G \ K P C I T Q Q V [ C Y GN I P K U C J V K Y M E K V U Q V W Q [ U G E T Q H
O GV U [ U G JV H Q G R C J U G J 6  W Q [ P Q R W G T W V E W T V U G J V U G E T QH E K I QN P Q K V C IK X C P G J V G U W C E G D
GTWVEWTVU GJV QV GJV RGGM QV GXCJ WQ[ UVEGLDQ QVPK IPKUUGEQTR GJV IPKVCTCRGU [$
 [H K F Q O Q V FT C J [ T G X U G O Q E G D O C T I Q T R F P C GT WV E W T V U G J V
H Q V J I K U N N C G U QN W Q [ G T QH G D U P QK V R G E Z G G U G JV H Q [ P C O G M C V V • P U G Q F V+  G T W V E W T V U T G J V Q P C
G U W Q V T G N R O K U UK V K G T G J Y • U P Q K V R G E Z G ” [ P C O G T C G T G J V G E P K U [ N T CN W E K V T C R G P K N R K E UK F G J V
R G G M P C E Y GH V W D R W UK JV R G G M P C E W Q [ G P KN RK E UK F P G XK )  GV C F F P C G R [V V P G X G V P G O
G G T I C [ D U N C P QK VK F P Q E G JV U G \K P C I T Q V C J V G T W V E W T V U C U G E T Q H P G V C JV J E C Q T R R C N C T W F G E
Q T R C H Q P IK U G F G J V PK G J V I P K J V Q P U K G T G J 6  F G T W V E W TV U N N G Y P QK V WN Q U N C T W F G E Q T R C R G G M
Q V F T C J [ T G X U K VK V E C H G J V O Q T H U G O Q E PK C I V U G I I K D G J 6  PK C I V U G I IK D G J V V• P U K VK V W $
 PK C I I K D C U K U K J V [ N V P G W S G T H [ T G X T W E E Q U G I P C J E
V P G F P G R G F G OK V G E P K 5  G F Q E G E T W Q U G JV I P K I P C J E V W Q J V K Y E K I Q N P Q K V E G N G U V C JV Q V
UGIPCJE GMCO PCE WQ[ [NVPGWSGTH EKIQN PQKVEGNGU GJV GIPCJE WQ[ HK VCJV UK PKCI TQLCO
G J V J E C QT R R C N CT W F G E QT R F GT W V E WT VU N N G Y C Q V J E C QT R R C V E G L D Q P C GT C R O Q E W Q [ H K Q 5
 J E CQT RR C N CTWF GE QT R G JV P K G P KV WQT DWU C I PKF NK WD P CJ V F G VC EK NR
O Q E G T Q O Q P U• V K G N W T I P K V U Q R Y G P C F G G P Q F W Q [ H +  [ C Y V J I K T G J V P K G T W V E W T V U C V C F G J V

 UG V CGTE VP GXG GJ V JE KJ Y U GKT VP G GJ V F P C V PG X G
G JV P G G YV G D N KCT V C R GGM Q V UK V PG O VU WLF C P C [D F G VE GHH C UG KT VP G G J V I PKF PK H QV [GM G J 6
V PG OVU WLF # PC [ D FG VEGHH# U G KT V P ' G J V IPK FP K(
 G P Q F N Q G J V VQ P F PC V PG XG YG P G J V
U G U W I PK U U G E Q T R G T W V WH [ P C V C J V G T W U P G Q V F G G P G Y [ N F P Q E G 5  V P G OV U W L F C P C [ D F GV E G HH C
G T C U GK T V P G J EK J Y F PKH Q V G N D C G D QV F G G P G Y UK J V I P K Q F H Q V T C R U #  V P G X G G J V V U WL F C
G Y P G J Y [N V E G T T Q E U GK T V P G G J V I P KV U W L F C H Q O U K P C J E G O C G X C J G Y V C J V G T W U P G QV F G G P
G Y [ N V U TK (  U I PK J V T G JV Q Q Y V G T W U P G Q V F G G P Q U N C G Y T G X G Y Q J G N R O K U U K J E W O V C J 6
   G T W IK (
V PGXG VPG OVU WLFC GVCT C RG5
0..1 0..1
Adjustment
»
»
Accounting Event
old events old events
   G T W IK (
[NVEGTK F V P GXG UWQ GPQTTG PC IPKV UWL F#
0..1 0..1
Accounting Event
adjusted event replacement
   G T W I K ( V P G X G V P G O V U W L F C G V C T C R G U C J VK Y T Q U V P G X G G J V P G G Y V G D    G T W IK (
M P KN V E G T K F C [ D T G J VK G V P G X G F N Q G J V I PK V U W L F C U C V P G X G Y G P C F T Q E G T G 9    V P G X '
I PK U W P G J Y G X C J W Q [ I QN V P G X G G N D C V W O O K G J V P Q [N G T U P T G VV C R V P G O V U W L F C G J 6

J E K J Y U GK TV P G Y G P C GV C G T E P G J V F P C P G G D G X C J F N W Q J U U G K TV P G V E G T T Q E G J V V C J Y V W Q
G T W I K H G Y J E C Q T R R C U K J V J V K 9    V P G O V U WL F # G E P G T G H HK & UK G W S K P J E G V F T K J V G J V Q 5
UFT Q E GT GJ V GUWT GR Q V UF G G P G P Q G OQU P GJY I PK [Q PP C GD N NK VU P CE V K U G KTV PG
F G U T G X G T V W Q T G VN KH Q V U I PK JV G O Q U Q F P C E G Y J I W Q J V N #  U G K TV P G F G V E G T T Q E P G V F P C
I P K U T G X GT P G V U G KT V P G Y G P [ V P G Y V G V C G T E Q V G X C J G Y U G KT V P G P G V U V E G H H C V P G OV U W L F C
P C H+  U G K T V P G C T V Z G H Q V Q N C U G V C G T E V K V C JV UK U GK T V P G G J V I PK U T G X G T J VK Y O G N D Q T R G J 6
 F GV C GT E GD N NK Y U GKT VP G VE GTT QE GJ V F P C NC WU W U C V PG X G Y G P G J V UU GE
Q T R P G J V P C E W Q [ [ T V P G F N Q G J V F G U T G X G T G X • W Q [ G E P 1  [ TV P G N C P K I KT Q G J V V W Q U N G E P C E
[ N G X KV E G HH G [ T V P G I P K U T G X G T UK J 6  G P Q F U C Y N C U T G X G T G JV [ C F G J V H Q G V C F I P K F T Q E G T C F P C
N C P K I K T Q G J V Q V G V K U Q R R Q V W D N C W S G U K J E K J Y V P W Q O C P C G V C F F GT T W E E Q G O CU G J V G X C J
N N K Y J E K J Y [ T V P G P C U K UK J 6  [ TV P G I P K U T G X G T C V U Q R F P C V P G O V U W L F C G J V [ D F G V E GH H C G T G Y
V C J V U G K T V P G G J V N N C F P K H G Y G T G *    V P G O V U W L F # N C U T G X G 4 UK G W SK P J E G V F P Q E G U G J 6
 FT Q EGT N CK EP C PKH G JV
H Q V T C R V K E KN R Z G P C P Q K V C T G VN C G J V U G M C O V C J V V P G OV U W L F C H Q O T Q H C F G G P G Y Q U F GV K F G
GD VUWL VQPPCE UIPKJV JEW5 NNKD C VWQ IPKFPGU UC JEWU HHQ FGMEKM PGGD GXCJ NNKY UGUUGE
Q T R N C K E P C PK H T G J V Q G U W C E G D Q U N C U K V+  N K C T V V K F W C N C K E P C PK H G J V H Q V T C R U C G N D C V W O OK
[ NN C W U W G T C U G K T V P G G U W C E G D V U W L V Q P UK U K J 6  G N D K U U Q R [ N G T C T U • V K V W D [ U C G U • V +  U G P Q Y G P
JV K Y O G JV I PK E CN R G T [ D T Q U G W N C X TK G J V I P KV K F G [ D T G J VK G V P G X G Y G P G J V JV K Y P G G D G X C J
F N W Q J U [ G J V V C J Y Q V O G J V G I P C J E F P C V P G OV U W L F C G J V [ D F G V E G H H C U G KT V P G G J V N N C F P K H
GY VCJV UPCG O [NROKU V+ VUGKUCG GJV UK  VPG OVUWLF# VPGOGECNRG4 GGTJV GJV H 1
   V P G O VU W L F # G E P G T GH H K & T Q   V P G OV U W L F #
NCUTGXG4  VPGOVUWLF# VPGOGECNRG4UGKTVPG VUWLFC PCE GY U[CY GGTJV GTC GTGJ6
U G KT V P G G J V I P K V U W L F # H Q U [ C 9
P QK VR KTE UGF
P T G V V C R UV K PK F G V U G I I W U U C N N G Y U C O G J V G F W N E PK Q V NK C T V G JV F P G V Z G Q V F G G P NN • W Q [
PG JV   G N W 4 I P KV U Q 2 [ T C F P Q E G 5 G U W W Q [ H+  VK F GV C G T E V C JV V P G X G G J V F P C [ T V P G G JV
P G G Y V G D M PK N C G M C O W Q [ [ TV P G P C GV C G T E W Q [ T G X G P G J Y V C J V U P C G O UK JV G U C E V U GN R OK U
G J V P +    G T W I K ( H Q U G PK N G JV I P QN C P Q KV C K E Q U U C P C JV K Y V R G M G D P C E NK C T V E K U C D G J 6
 GTWI K(
UGKTVPG IPKVNWUGT UVK FPC VPGXG PC PGGYVGD MPKN C IPKRGG-
1
»
Accounting Entry Event
source

 U G W SK P J E G V
T G JV Q G JV H Q G P Q G U W Q V F G G P W Q [ V PK Q R V C J V T G VH #  V P G O G V CV U C H Q V W Q I P K F P G U G J V T Q
F Q K T G R C H Q I P K U Q N E C NK V P W U R C J T G R   V P G O V U W L F # V P G O G E CN R G 4 G U W Q V G N D K U U Q R G D [ C O
V K V PK Q R P K C V T G E C Q V R 7  U G W S K P J E G V G U G J V H Q P Q K V C P K D O Q E C G U W P C E W Q [ U G OK V G O Q 5
V P G O V U WL F C G N I P K U C Q V P K
U V P G O G E C N R G T TK G J V F P C U G K T V P G U W Q G P Q T T G N C T G X G U I P K P K D O Q E [ D T G J V T WH V K G E W F G T P G X G
[ C O G Y F G G F P+  U G K T V P G I PK V C U P G R O Q E P G V P C JV G T Q O Q P Q V F G E W F G T G D Y Q P P C E V P G O
V U WL F C [ T V P G P G V T W 1  U G K TV P G Y G P G J V F P C U GK T V P G F N Q G J V P G G Y V G D G E P G T GH HK F G J V G T C


 VK JV K Y G P Q F U C J O G V U [ U C V C J Y U F T Q E G T J EK J Y CV C F I P K U U G E Q T R G J V U K CV C F V P G X G
H Q F PK M T G JV Q G J 6  V P G X G G J V H Q G E T W Q U G J V V W Q D C P QK V C O T Q H P K P C G O + C V C F G E T W Q U
[ $  [ C Y [ N U C G Y C PK U G O K V G N R W Q E C  C V C F G E T W Q U  O T G V G J V F G U W G X • + G EK V Q P N N • W Q ;
 GV CT WE CP PK G D Q V G X QTR TG V CN U VP GXG GT GJ Y U GU CE JV KY N CG F Q V   VPGO VU WLF #
N C U T G X G 4 U C J E W U O UK P C J E G O V P G T GH HK F C F G G P G Y F P C GN D C V W O O K G D V U W O H Q C V C F
G E T W Q U G J V G T QH G T G J 6  I Q N G J V H Q [ VK T I G V P K G J V U M C G T D V P G X G N C PK I K T Q G J V G I P C J E QV V W D
F GY CN H U CY V PG XG G JV HQ FT QE GT T W Q V CJ V TG X QE UKF VJI K O GY PQ T G V C N V CJ V G WTV GD [ C O V +
 F G I P C J E G D T G X G P P C E C V C F G E T W Q U U VK F G V C G T E UK V P G X G P C G E P 1  U V E GL D Q GN D C V W O O K G T C
U V P G X G V C J V U G K V T G R Q T R N CV K X V U Q O G JV H Q G P Q U V U G I I W U U V P G X G H Q G N Q T NK C T V VK F W C G J 6
MTQY VK IPKMC/
 U V P G X G H Q V UK N C V U WL [ N N C KV P G U U G G T C J E K J Y U I Q N
V K F W C Q V N C T V P G E [ N G V WN Q U D C G T Q H G T G J V U K V P G X G P C H Q C G F K G J 6  U P G R R C J V C J V I P K J V [ T G X G
N N C I Q N C G F K X QT R [ G J V P K C O Q F C P K UV P G X G I P K X C J H Q GU Q RT W R [T C O KT R G JV U K U K J 6
U V PGX G GJ V H Q FT QE GT C RG GM
Q V F G G P W Q [ P G R R C J U I P K J V P K C V T G E [ J Y F P C VU T G F P W Q V T G F T Q P K Q U UV P G X G Q V V E C G T
U PK C O Q F [ P C /  P QK V E C G T C G U W C E U G P Q I P KV U G T GV PK V U Q O G J 6  P Q KV E C G T C G M Q X Q T R V • P Q F
V W D I P K F T Q E G T J V T Q Y G D [ C O G O Q U I P KV U G T GV PK G T C O G J V H Q N N C V Q 0  P G R R C J U I P K J 6
[CFKT( GD FNWQY GVCF FGEKVQP GJV [CFKT( NKVPW PQKVECUPCTV GJV VKOUPCTV
V•PUGQF FPC OGVU[U NCWPCO FNQ PC UGUW U•TWDC$ H+ [CFUGW6 UK GVCF FGTTWEEQ GUQJY FPC
FTCE VKFGTE [O UK VEGLDWU GUQJY GUCJETWR GMCO UK GR[V VPGXG GUQJY VPGXG PC UC FGNGFQO
GD VJIKO UKJ6 FTCE VKFGTE [D [CR FPC [CFUGW6 PQ NCGO C TQH U•TWDC$ QV QI + GNROCZ'
when noticed : DateTime
1
when ocurred : DateTime »
Event Type subject
1 Event
»
P K C O Q F G J V U V E GH H C J E K J Y I P K V U G T GV P K I P K J V G O QU H Q [ T Q O G O G J V U GT W V R C %
:/28

Date getWhenNoticed();
Date getWhenOccurred();
AccountNumber getAccount();
EventType getType();
Date whenOccurred, Date whenNoticed);
Event newEvent (EventType type, AccountNumber account,
interface Event {
 UK J V G M KN G E C H T G V P K P C F N G K [ V J IK O U G P KN
G U Q J V I P Q N C I P K J V G O Q U T Q F T C E M P C D C Q V F G KN R R C P T G V V C R E K U C D G J 6  F G X N Q X P K G T Q O
O G J V G M C O P C E U P T GV V C R T GV C N J I W Q J V N C U I PK J V G N R O K U [ V V G T R G T C G T Q E G J V V C U V P G X '
GFQ% GNROC5
N K C T V V K F W C G J V I P K X C J H Q VKH G P G D G J V U W U T G X U V P G X G
G J V I P K F NK W D H Q V U Q E G J V UK H H Q G F C TV G J 6  G I P C J E C U G U W C E V C J V I P K J V [ T G X G H Q NK C T V V K F W C
F KN Q U [ T G X C UK V N W U G T G J V T G J V G I Q V V W R Q V M T Q Y H Q VK D C GV K W S U K U K J V G NK J 9  P QK V C O T QH PK
V P C X G N G T G J V N N C J V K Y VK T G I IK T V Q V V P G X G P C U F G G P I PK JV J E C '  O G V U [ U T W Q [ QV G I P C J E
C G U W C E V C J V U I PK JV G JV N N C H Q I QN C R G G M Q V V P C Y W Q [ T G X G P G J Y G N D C W N C X G T C U V P G X '
VK GUW QV PGJ9
 J V Q D T Q U G R [ V V P G X G G N R KN V W O U V E GL D W U G N R K VN W O V G I W Q [ F P K H
[ C O W Q [ T C N W EK V T C R P +    G N W 4 I P KV U Q 2 T C N W E K V T C R P K P Q T G V C N U P T GV V C R T G J V T W H U U W E U K F +
P G J Y U G N Q T G U G J V Q V P K O G J V G F K XK F Q V G U P G U U G M C O V K F PK H + T G X G Y Q *  U G E P G T G H G T H Q UV T Q U
NN C G X C J [ N N C W U W U V P G X '  [ T C T VK D T C [ N TK CH UK G R [ V V P G X G P C F P C V E GL D W U C H Q G EK Q J E [ /
 V PGX G GJ V GE KV QP
P C E V C JV [ F Q D J E C G T QH GV C F C F G G P [ C O W Q [ G U C E UK J V P +  I PK EK V Q P G JV I PK Q F [ F Q D
G P Q P C J V G T Q O UK G T G J V H K U T W E E Q UK J 6  U G V C F Q Y V P C JV G T Q O F G G P W Q [ [ NN C P Q K U C E E 1
U G V C F P C J V T G J V C T U G OK 6 G V C &
F G G P N N • W Q [ [ P C R O Q E G P Q J R G N G V C G M K N T G V T Q J U UK [ V K T C N W P C T I G O K V T W Q [ H +
 U K VK G P Q J E K J Y G V C E K F P K Q V [ N T C G N E
GV C F G JV G O CP W Q[ V UGI IWU QU N C + Q5 T GV C N T Q G O KV G JV V C T GJ V KG FGM EK R W Q [ G V CF J E KJY
T C GN E I P K G D V Q P F P C G V C F G P Q I P K M E K R UK T G I P C F G J 6  U G V C F J V Q D F G G P W Q [ T G J V G J Y
T G FK U P Q E U [ C Y N C F N W Q J U W Q [ V W D U G V C F J V Q D F G G P U [ C Y N C V• P Q F W Q [ G U T W Q E H 1
F GV Q P U CY V PG XG G J V G OK V GJ V U K GTG JV [ NF PQ EGU F GTTW EE Q VP GX G G JV G O KV
G J V G JV U K G T G J V [ N V U TK (  F G F G G P G T C V C JV U GV C F Q Y V G T C G T G J V F P C U G V C F F G G P U V P G X '
 U V E GL D Q G V C T
C R G U Q V PK C V C F I P K U U G E Q T R G J V F P C G E T W Q U G J V VK N R U Q V T G J V G J Y I P K T G FK U P Q E J V T Q Y U• V +
 P Q F G T C G R R C VK V P G O G V C V U J E K J Y G F W N E P K V J IK O C V C F I P K U U G E Q T 2  EV G U C Y T Q F P G X G J V
Q J Y T Q H U C Y G I T C J E G J V J E W O Y Q J G F WN E P K F N W Q Y G I T C J E F T C E VK F G T E C P Q C V C F G E T W Q 5


 V P G X G G JV H Q [V KN K D C V W O OK G JV V E G HH C V Q P U G Q F I QN G JV H Q U GV W D K TV V C G J V I PK I P C J %
 V P G X G G J V G V C K V P CV U P K G Y P G J Y I Q N U U G E Q T R G JV GV C G T E G Y V C J V PK G N D CV W O N NK V U G T C G N C U
F P C V P G X G G J 6  I QN U U G E Q T R G N D C V W O C Q V G E P G T G H G T C FN Q J V W D G N D C V W O O K G T C U G U U CN E
G N C U F P C V P G X G G J V V C J V G E K V Q P NN• W Q ;  U K J V I PK Q F H Q G N R O C Z G P C U Y Q J U   G T W I K (
 P IK U G F V P G T T W E P Q E
J VK Y V Q N C U R N G J [V K NK D C V W O OK  [ E P G T T W E P Q E G X C J W Q [ G T G J Y UK G U C E T G J V Q P #  U GV W D K TV V C
U• VK H Q G P Q I PK I P C J E O Q T H G F Q E [ P C V P G X G T R U W J V F P C GN D C V W O O K U C V E GL D Q P C M T C O
P C E V P G O P Q T K X P G T W Q [ H K U K J V I PK Q F T G FK U P Q E V J I K O W Q ; UV T C R G JV G V C T C R G U Q V N WH G U W
G D [ C O VK G N D C V W O OK G O Q U F P C G N D C V W O U K P Q K V C O T Q H P K U• V P G X G G J V H Q G O Q U G E P K 5
 U G WN C X G U G J V G I P C J E Q V [ V K N K D C G J V V G I N N• W Q [ Q U G N D C V W O UK P QK V C O T Q H PK I P K U U G E Q T 2
...
void addResultingEntry(Entry arg);
Set getResultingEntries();
boolean isProcessed();
interface Event...
 V P G X G G J V H Q I PK U U G E Q T R G J V V W Q D C P Q K V C O T QH PK F T Q E G T Q V N W H G U W UK V K P G VH 1
P Q O OQ EP W VQ P
V W D G U C E G JV U [ C Y N C V Q 0  G R [V D W U G J V [ D [ N V E G TK F F G P I K U U C G D F N W Q Y G U C E U K J V PK G R [ V
V P G X G G J V G U W C E G D G D F N W Q Y U K J 6  F Q J V G O [ T Q V E C H G J V O Q T H I P K U U K O UK G R [ V V P G X G G J V
VCJV GEKVQP NN•WQ[ TKCJE IPKMEQT GJV PK HHQ IPK\QF VQP FPC TGFCGT RTCJU C GT•WQ[ H+
Money getAmount();
Vendor getVendor();
Vendor vendor, Money amount);
Date whenOccurred, Date whenNoticed,
Sale newSale (AccountNumber account,
interface Sale extends Event {
 GR [ VDW U
C P K T G J U W Q V G OK V U• V K Q U P QK V C O T Q H P K H Q U VK D V P G T G H HK F G T K W S G T P G V H Q U V P G X G V P G T G H H K &
 GV GN R O Q E P K V C J Y G O Q U U K G E CH T G V P K G J V V C JV V E CH G J V [ N F P Q E G 5  F G V C G T E G E P Q CV C F G U C D
G JV G I P C J E QV [ C Y [ P C H Q M E C N GV G N R O Q E G J V [ NV U TK (  U V P K Q R I PK V U G T G V PK H Q G N R W Q E C FN GK [
U G Q F V K P G G U T G X G U C J FN T Q Y G J V G E CH T G V P K I PK VK E Z G V U Q O G JV V Q P UK UK J V J I W Q J VN #


 F G G P W Q [ N N C UK V C JV
G OK V G J V H Q V U Q /  F Q J V G O I P KV V G U C H Q G E P G U D C G JV [ D [ N P Q F C G T G T C U G V W D K T VV C J E K J Y
[ N G X K V E G H H G G V C EK P W O O Q E P C E W Q ;  U K J V Q F Q V F G G P [N G V W N Q U D C V• P Q F W Q [ T G D O G O G 4
 G M KN F• W Q [ FK C G J V V G I Q V G N D K U U Q R
UC [UCG UC VK GMCO QV UVEGLDQ GJV GIPCTTC FNWQJU WQ[ QU WQ[ RNGJ PCE VPGOPQTKXPG TWQ[
H K UK JV Q F Q V V P C Y [N P Q W Q ;  [ V K N K D C V W O O K U G E T QH P G V P G O P Q T K X P G T W Q [ Y Q J P Q F P G R G F
N N K Y UV T C R G N D C V W O O K F P C GN D C V W O G J V G I P C T T C Q V [ C Y V U G D G J 6  V T C R G N D C V W O O K
GJ V QV G PQ FP C VT C R G N D CV W O GJ V QV GE P GTGH GT G P Q U C J V C J V VEG L D Q FT K J V C G XC J QU NC P CE
W Q ;  G V C I G N G F G J V V T C R GN D C V W O G J V G M C O Q V T G K U C G U • V K Q U F G U U C N E D W U [ N N C W U W U K V C J V V T C R
GN D C V W O O K G J V V C J V G I C V P C X F C G J V U C J F P W Q T [ C Y U K J 6  V T C R GN D C V W O G J V [ D F G E P G T G H G T
V E GL D Q P C G D C V C F GN D C V W O O K G JV I PK V V G N F P W Q T [ C Y T G J V Q G J V V K Q F Q UN C P C E W Q ;
 GTWI K(
VPGXG PC HQ UVTCR GNDCVWOOK FPC GNDCVWO GJV IPKVCTCRGU HQ [CY GP1
amount
vendor
{frozen}
Sale
Perspective
Implementation
whenNoticed
whenOccurred
resultingEntries
account
isProcessed
type
1
Event Process Log {frozen}
Event


U [ C Y N C V Q P U K UK JV V W $  P T G V V C R G O C U G J V P K O G J V V W R + U P T G V V C 2 U K U [ N C P # P K F G G F P +   
[ T V P ' I PK V P W Q E E # J V K Y U G Q I P G V H Q   V P W Q E E # Q U U V P W Q E E C F G N N C E G D F N W Q Y [ G J V U [ C F
G U G J V [ G P Q O H Q P Q K V C E K H K U U C N E T C N W E K V T C R C QV U F P Q R U G T T Q E T G I F GN G J V H Q U G I C R G J 6
MTQY VK IPKMC/
UTG H
U P C T V U C J E W U N N C V C [ G P Q O H Q T G X Q F P C J [ P C P K V N W U G T [N N C W V E C V • P Q F V C J V U I P K J V F T Q E G T
QUNC [GJ6 VWQ IPKOQE [GPQO FPC IPK OQE [GPQ O FTQEGT UGKTVPG JEW5 MQQD NCEK
U[ JR C U[ CF GU QJ V P K TGI FG N C P K [T VP G GJ V UK UK JV I PK F TQE GT H Q [C Y GJ V U [CF G EP GUU K CP GT
OQT( T QH F GU W GD F N W Q J U V K V C J Y P GXG T QH F GU W UK VK V CJY O QTH U G O Q E V K GT GJ Y [ GP Q O
H Q P Q K V C E K H K U U C N E G J V V W Q D C [ N N C KV P G U U G UK F P C [ G P Q O F P W Q T C U G X N Q X G T I PK V P W Q E E #
 U UCROQ % FPC GTC WS 5 GJ V FPC TGKN WEG2 F N 1 G TGY U TQVR KTE UGF
GUQJY FPC [VKVPCWS C UNGTTCD GGTJV C UK VPWQOC GUQJY [TVPG IPKVPWQEEC PC GD FNWQY
UKJ6 UUCROQ% FPC GTCWS5 GJV QV FGTGXKNGF GTC TGKNWEG2 FN1 HQ UNGTTCD GGTJ6 GNROCZ'
 UGKN R
RWU NCEKTVEGNG HQ [TQIGVCE VUQE GJV FPC GUWQJ [O PQ MTQY GJV TQH VEGLQTR GJV GTC UTQVRKTEUGF
F P C    UK V P W Q O C [ C F T W V C 5 U K G V C F G U Q J Y [ T V P G I P K V P W Q E E C P C G D F N W Q Y U K J 6  [ C F
T W V C 5 P Q G U W Q J [ O P Q M T Q Y T Q H U G K N R R W U N C E K T V E G N G P Q    U F P G R U T Q V E C T V P Q E #  GN R O C Z '
VP WQE EC IP KMEGJ E
[O UK TQVRKTEUGF GUQJY FPC [CFUGW6 UK GVCF GUQJY  UK VPWQOC GUQJY [TVPG IPKVPWQEEC
P C G D F N W Q Y U K J 6  [ C F U G W 6 P Q V P W Q E E C I P K M E G J E [ O O Q T H    Y C T F J VK Y +  G N R O C Z '
amount: Money
» »
descriptor when booked : DateTime
Accounting Entry
[G PQO HQ OW U C HQ P QKVCEQ NNC P#
#EEQWPVKPI 'PVT[


 GTWI K(
UTQVRKTEUGF UC GR[V VUQE FPC VEGLQT2
1
Project
»
Entry
Cost Type
1 »
accounting entry
descriptors
Accounting Entry
    G T W I K ( PK U C
U R K JU P Q KV C N GT GV CT C R GU U C GU G J V Y Q JU F N W Q Y G Y N G F Q O T W Q P+  [TV P G G J V T Q H UT Q V R KT E U G F
G J V G T C G R [V V U Q E F P C V E GL Q T R G J 6  G R [V V U Q E C F P C V E GL Q T R C J VK Y [ T V P G J E C G M T C O
Q V V P C Y V J IK O G Y I P K V U Q E D QL I P K Q F G T C G Y H K Q 5  [ T V P G G J V Q V U RK J U P QK V C N G T G V C T C R G U
J V K Y U G U U CN E G V C T C R G U U C U T Q V R K T E U G F G J V N G F Q O [ NN C W U W NN K Y W Q [ N G F Q O T CN W E K V T C R C P +
 F G M Q Q D T Q F G U QN E G T C
[ G J V P G J Y O G J V G I P C J E Q V V Q P V W D G V C V U P G R Q P C PK G T C [ G J V P G J Y U GK T V P G G I P C J E Q V
F G Y QN N C G D [ C O V+  F G I P C J E G D P C E [ TV P G P C P G J Y T Q H U G N W T EKH K E G R U G T C G T G J V P G VH 1
! G X C J [ G J V F N W Q J U U G V C F J E K J 9 ! G N D C V W O O K G D U G K T V P G G J V FN W Q J 5
  [TVP' IPKVPWQEE # IPKUW GTC WQ[ PGJY  VPGX' [D FGUKCT UPQKVUGWS GJV MUC
QV F G G P W Q [ V C JV UK I PK J V V P CV T Q R O K G J 6  F G V C T C R G U Q YV G J V G G U + U G O KV G O Q U U K J V G G U +
U G OK V G O Q 5    [ T V P ' I PK V P W Q E E # Q V U G K N R R C   V P G X ' V C J V G D N N G Y [ C O V K Q U P K C O Q F
G J V U V E G H H C V C J V I PK V U G T G V P K I PK J V G O Q U U C [ T V P G P C H Q M P K J V Q V J E V G T V U C V Q P U• V +
 [ T V P G P C T QH T Q V R K T E U G F G N DK U U Q R G P Q U C U V P W Q E E C H Q M P K J V
V U WL P G JV NK V P W   V P W Q E E # PK F G PK QL [N G U QN E G T C [ G J V G T G J Y G U C E G J V V W Q D C M N C V N N• +
 U V P W Q E E C H Q U V T C R V U W L U C U GK TV P G N N C G O Q U U V P W Q E E C V W Q J VK Y U GK T V P G G G U G O Q 5  G U C E G JV


Q U NK C T V VK F W C P C G F K X Q T R Q V UK J V Q F N N• W Q [ G U P G U G XK U U C R G J V P +  T G J V G I Q V Q Y V G J V M PK N
Q V F G G P W Q [ F P KH NN G Y [ C O W Q [   [ T V P ' I P K V P W Q E E # F P C   V P G X ' I PK U W G T C W Q [ H +
UVPGX' QV IPKMPK.
}
throw new ImmutableEntryException();
else
costType = arg
if (isOpen())
void setCostType (CostType arg) {
HQ UGPKN GJV IPQNC UFQJVG O IPKVVGU QV FCGN FNWQY UKJ6 FGMQQD
G T C [ G J V N KV P W G N D C V W O G D [ C O [ G JV T Q U G OK V N N C V C GN D C V W O O K G D P GV H Q [ C O U GK T V P '
 PTG V VC R
G J V H Q P QK V C EK N R R C T C N W E K V T C R [ P C P K U G R [ V V K E KN R Z G U C T C G R R C [ NN C W U W N N K Y U T QV R K T E U G F G J 6
Date getBookingDate();
Money getAmount();
Project getProject();
CostType getCostType();
Entry newEntry (CostType costType, Project project, Money amount, Date date);
interface Entry {
 T G FN Q J C V C F GN R O K U C [ N V U Q O U K   [ T V P ' I PK V P W Q E E # G V C V U G N R O K U U V K P +
GFQ% GNROC5
V UTKH OK Y U
P C E W Q [ G T W U G M C O V U W L [ VK NK DK U U Q R C U C F P K O P K VK T C G D Q 5  G U P G U G M C O   [ T V P ' I P K
V P W Q E E # P Q F NK W D V C J V U P T G V V C R T G J V Q T G JV G J Y PK U GK N P Q K V E C TV U D C G J V H Q G W N C X G J V V W $
 I PK P Y Q T F P Q P Q K V C K T C X N C V C H [ N V E C Z G V Q P H K I PK [ Q P P C P C Q V V U [ N C P C P C [ P C O [ P C O G T W N
UG K VW CG D GU QJ Y F K C O TG O U WQT GI PC F C GT C U NG F Q O E KTG PG I TG X Q J EW5 IP KJ V [ P C NGF Q O
Q V N G F Q O EK T G P G I T G X Q G O Q U I PK U W G MK N [ N U W Q T G I P C F U F P W Q U UK JV I P K Q &  O GV U [ U N Q TV P Q E
G F Q E G E T W Q U P K U H H K F U C J E W U U G E P G T G H H K F U P K C V P Q E V C J V I P K J V [ P C F G G F P K T Q I PK J V G O Q U H Q
UGKVKVPCWS [HKUUCNE QV VPCY WQ[ TGXGPGJY PTGVVCR UKJV GUW PCE WQ[ TGXGYQ* UVPWQ OC
[T C V G P Q O T QH G F C O GT C U G KT V P G G T G J Y G U C E P Q O O Q E VU Q O G JV U V U G I I W U PT GV V C R G J 6
IPKMECTV HQ NGXGN UKJV GTKWSGT
Q V U G U U G P K U W D V U Q O Q V N C T V P G E [ N V P GK E K H H W U U K [ G P Q O U C G U C E P Q O O Q E G J V U K U K J V F G G F P K
F P C G W N C X [ T C V G P Q O C P K U G I P C J E N N C F T Q E G T UK G U C E U W Q K X D Q V U Q O G J 6  G W N C X G X K V C V
K VP CWS G O QU P K GI PC JE J EC G FT Q EGT Q V FG GP W Q [ T GXG P GJ Y U GKT VP G GU W FN WQ JU W Q;
VK GUW QV PGJ9


VPGXG TCNWEKVTCR C [D FGVCGTE GTGY UGKTVPG JEKJY NNGV PCE WQ[ VCJV IPKTWUP'  GTWIK(
1
»
Accounting Entry Event
source
 U G U Q R T W R I PK V T Q R G T V U W L P C J V G T Q O T Q H M P K N H Q F P K M U K J V F G G P N N • W Q [
 VPGOVUWLF# NCUTGXG4 IPKUW GTC WQ[ H+ FGFFC [TVPG UKJV UCY [JY MUC PCE GNRQGR

 UGITC JE GJ V GNF PCJ Q V UGN W T
IPKVKQR VPGTGHHKF PKCVPQE FPC VUQJ VPGTGHHKF C GD FNWQY VPGOGGTIC GEKXTGU JECG GUCE UKJV P+
[ NR RW U GJ V H Q [ VKN KDC NKCXC GJ V IP KU UGTFFC UG NWT V PGTGHH KF UCJ VW D GVCT VPG TGHHK F C UCJ G PQ JEC'
UPCNR GEKXTGU VPGTGHHKF QV IPKFTQEEC [NVPGTGHHKF GITCJE [CO [PCROQE [VKEKTVEGNG P# GNROCZ'
 GV CT GR Q VC J V U VK PW UU G P KU WD VP GT G HH KF GJ V T QH [T CX U G NWT U C U G OQ E [V KZ GN R O Q E
G T Q /  U V P G X G H Q U F PK M V P G T G HHK F T QH V U K Z G U G N W T V P G T G HH K F G U W C E G D F G V C E KN R O Q E G T C [ G J V
[NVUTK( UPQUCGT NCTGXGU TQH FGVCEKNROQE GTC PQKVEGPPQE GJV GMCO VCJV UGNWT GJ6
MTQY VK IPKMC/
U G Q F V K V C J V
G T W U I P K M C O F P C T W E E Q F N W Q J U P Q K V E G P P Q E V C JV Y Q J I P K T W I K H P K U G O Q E V P G O [ Q N R O G
V C JV H Q J E W /  F G [ QN R O G [ NN WH PK C I U # $ / F P C U V P C V P W Q E E C H Q U P QK N NK O U R G G M V C JV [ VK N K D
C VK XG PK P C J VK Y T G J VQ GJ V Q V U FC GN GP 1 U GXQ O [ G P Q O FP C P GR R CJ U V P G X G U UG PKU W $
 N N K D G J V P Q U O G V K G P K N G J V G D FN W Q Y J E K J Y U G K T V P G G V C G T E F N W Q Y F P C G E K X T G U
G J V G D FN W Q Y V U Q J G U Q J Y I P K F C G T T G V G O G D F N W Q Y G R [ V V P G X G G U Q J Y G N W T I P K V U Q R C U C F G N G F Q O
GD FNWQY UKJ6 IPKTWUCGO UK TGVGO GJV VCJV GEKXTGU GJV TQH FGPKHGF GVCT GJV [D FGUW [VKEKTVEGNG
H Q VP WQOC GJV I PK [ NRK VN W O [ D TG OQV U W E G J V NNK D GY I PKFCGT TGVG O C VGI G Y PG J 9  GN R O C Z '
1
process(Event) »
Accounting Entry Event Type
´ createsª Posting Rule
»
host
1
VPGXG PC QV GUPQRUGT PK GMCO QV UGKTVPG IPKVPWQEEC VCJY UGPKOTGVG&
2QUVKPI 4WNG

 G EK X T G U H Q U N G X G N F G G T I C J VK Y V E C TV
P Q E C I P K P IK U Q V G W F U T G J V Q P Q K V CN U K I G N N C E Q N Q V G W F [ T C X [ C O G U G J V H Q G O Q 5  G N D C N K C X C
U P CN R G EK X T G U N C T G X G U G T C G T G J V G O W U U C NN• +  V P G O RK W S G Y G P H Q P QK V C N N C V U PK T Q G G H V P G O
[ C R G V C N N N C E G E K X T G U C G F W N E P K V J I K O U T G J V Q V W D G U C E U K J V P K G I C U W P Q U W E Q H N N• +  U V P G X G
U W Q K T C X Q V U F P Q R U G T [ V K N K V W G J 6  [ VK NK V W [ V K E K T V E G N G P C G U W N N • G Y G N R O C Z G T W Q T Q (
 G N W T G J V H Q P Q KV C EK N R R C G JV U G V C N W U R C E P G V C J V U U C N E G N W T I P K V U Q R
C G M C O QV U K G T G J V K G X C J + U C P T GV V C R G J V H Q G E P G U U G G J 6  F G \K P C I T Q G D F N W Q J U U G N W T
G U G J V Y Q J UK P Q K V U G W S [ G M G J 6  PK C O G T U C G F K E K U C D G J V V W D U V R G E P Q E G U G J V T Q H U F T Q Y
V P G T G H H K F J V K Y R W G O Q E F N W Q Y G P Q [ T G X G O• +  U V P G X G Q V G U P Q R U G T P K U GK T V P G I PK V P W Q E E C
G V C T G P G I Q V U G N W T I PK V U Q R G U W U O G V U [ U I PK V P W Q E E C V C J V [ C U Q V N CK U T G X Q T V P Q E [ T G X V Q P U• V +
UGNW4 IPKVUQ2 GFQ% GNROC5
 RW
VK I PK V V G U H Q U V U Q E G J V V G UH H Q F P C P K M EK M N NK Y P T G V V C R UK J V H Q U V KH G P G D G J V P G J V G U C G T E PK
U P QK V CK T C X H Q V P W Q O C G J V U #  M E K T V G J V Q F NN K Y E K I QN N C P QK VK F P Q E G O Q U J VK Y G T W F G E
Q T R GN R OK U C P G J V J E W O G I P C J E V• P Q F [ G J V F P C U P Q K V CK T C X H Q GN R W Q E C G X C J [ N P Q W Q [
H+  EK I Q N U K J V T GV N C V C JV U T QV E C H G N KV C N Q X N C T G X G U G X C J W Q [ P G J Y F G U W V U G D G T C F P C U V P G X G
QV UV E C G T V C J V EK I Q N G JV G \K P C I T Q QV J E K J Y PK [ C Y G N D K Z GN H [ T G X C G T C U GN W T I PK V U Q 2
VK GUW QV PGJ9
 GN D C V W O O K G T C U GN W T I PK V U Q R G JV V C JV
UGKNROK UKJ6 VEGHHG PK UK GNWT C VCJV FQKTGR JECG TQH  FQKTG2 [VKXKVEGHH' GUW [NNCWUW
U G N W T I P K V U Q R G T QH G T G J 6  G O K V T G X Q U K G I P C J E U GN W T G T G J Y C G T C V P C V T Q R O K T G J V Q P #

G R [V V PG XG F P C
V P G X G I P K V P W Q E E C G X C J G 9  U V E G R U C GN R O K U G J V J V K Y G F Q E G J V V C I P K M Q Q N V T C V U N N • G 9
G T W V E WT V U G J V R W I P KV V G 5
V P G UGT R   [ T V P ' I P K V P W Q EE #
FP C   V P G X ' G X C J Q UN C G 9  V U Q J G J V U K V P G O G G T I C G E K X T G U G J V G N R O C Z G U K J V P +
    G T W IK (
I P K N N K D [ V K E K T V E G N G T Q H U G U U CN %
1
»
Entry Customer Accounting Event
1 »
» »
´ createsª
1 1
date
Posting Rule Service Agreement Event Type
event type
1 »
host
event type
accounting entry
posting rule
Posting Rule





class AccountingEvent {
private EventType _type;
private MfDate _whenOccurred;
private MfDate _whenNoticed;
private Customer _customer;
private Set resultingEntries = new HashSet();

AccountingEvent (EventType type, MfDate whenOccurred,
MfDate whenNoticed, Customer customer)
{
this.type = type;
this.whenOccurred = whenOccurred;
this.whenNoticed = whenNoticed;
this.customer = customer;
}

Customer getCustomer() {
return customer;
}
EventType getEventType(){
return type;
}
MfDate getWhenNoticed() {
return whenNoticed;
}
MfDate getWhenOccurred() {
return whenOccurred;
}
void addResultingEntry (Entry arg) {
resultingEntries.add(arg);
}
PostingRule findRule() { /*discussed later*/}
void process() {/*discussed later*/}
}

class EventType extends NamedObject{
public static EventType USAGE = new EventType("usage");
public static EventType SERVICE_CALL = new EventType("service call");

public EventType (String name) {
super(name);
}
}

I P K V U G T G V PK G J V Q V M E C D G O Q E NN• G Y U V E G R U C C V C F G J V V C I P K M Q QN V U WL G T• G Y T C H Q 5
 V PG O QO C P K T QKX C JGD
 G R [ 6 [ T V P ' F P C U U C N E C V C F GN R O K U C [ T V P G I PK V P W Q E E C G J V U K R W V Z G 0



class Entry {
private MfDate date;
private EntryType type;
private Money amount;
public Entry (Money amount, MfDate date, EntryType type) {
this.amount = amount;
this.date = date;
this.type = type;
}
public Money getAmount() {
return amount;
}
public MfDate getDate() {
return date;
}
public EntryType getType() {
return type;
}
}
class EntryType extends NamedObject {
static EntryType BASE_USAGE = new EntryType("Base Usage");
static EntryType SERVICE = new EntryType("Service Fee");
public EntryType(String name) {
super(name);
}
}

GN R O K U [ V V G T R Q U N C UK T G O Q V U W %
class Customer extends NamedObject {
private ServiceAgreement serviceAgreement;
private List entries = new ArrayList();
Customer (String name) {
super(name);
}
public void addEntry (Entry arg) {
entries.add(arg);
}
public List getEntries() {
return Collections.unmodifiableList(entries);
}
public ServiceAgreement getServiceAgreement() {
return serviceAgreement;
}
public void setServiceAgreement(ServiceAgreement arg) {
serviceAgreement = arg;
}
}
T Q H G V C T C U FN Q J Q U N C V +  U GN W T I PK V U Q R G J V T Q H V U Q J G JV U C UV E C V P G O G G T I C G EK X T G U G J 6
V P G T GH HK F G X C J P C E U V P G O G G T I C N C W FK X K F P K V C J V U P C G O UK J 6  V P G O G G T I C T CN W E KV T C R V C J V
 U G N W T I P KV U Q R H Q U P Q K V C P K D O Q E V P G T GH H K F F P C U G V C T



class ServiceAgreement {
private double rate;
private Map postingRules = new HashMap();
void addPostingRule (EventType eventType, PostingRule rule, MfDate date) {
if (postingRules.get(eventType) == null)
postingRules.put(eventType, new TemporalCollection());
temporalCollection(eventType).put(date, rule);
}
PostingRule getPostingRule(EventType eventType, MfDate when) {
return (PostingRule) temporalCollection(eventType).get(when);
}
private TemporalCollection temporalCollection(EventType eventType) {
TemporalCollection result = (TemporalCollection) postingRules.get(eventType);
Assert.notNull(result);
return result;
}
public double getRate() {
return rate;
}
public void setRate(double newRate) {
rate = newRate;
}
}
F G V P G O G N R O K UK P QK V E GN N Q E G N W T I PK V U Q R G J V V C JV V E C H G J V UK G T G J V P G O G N G V U GK M EK T V G J 6
GV C G T E Q V F G G P G Y GN W T I P KV U Q R C F F C G Y P G J Y Q 5    [ V T G R Q T 2 N C T Q R O G 6 H Q R C O C U C
VK TGFKUPQE + GNROCZG GNROKU UKJV TQ( RCO GJV PK [GM VCJV TQH PQKVEGNNQE NCTQROGV GJV
 R W V G U P G G D V • P U C J V C J V G R [V V P G X G P C T Q H GN W T C T QH M U C Q V T Q T T G P C
 GN W T I P KV U Q R V E C T V U D C G J V U G U W V P G O G G T I C G E K X T G U G J 6
abstract class PostingRule {
protected EntryType type;
protected PostingRule (EntryType type) {
this.type = type;
}
private void makeEntry(AccountingEvent evt, Money amount) {
Entry newEntry = new Entry (amount, evt.getWhenNoticed(), type);
evt.getCustomer().addEntry(newEntry);
evt.addResultingEntry(newEntry);
}
public void process (AccountingEvent evt) {
makeEntry(evt, calculateAmount(evt));
}
abstract protected Money calculateAmount(AccountingEvent evt);
}



GXCJGD UGUUCNE GJV YQ*
T G FK U P Q E N N• G Y P Q K V E C P K VK Y Q J U Q 6  M T Q Y G O C T H G J V H Q P Q V G N G M U G J V O T Q H U G U U CN E G U G J 6
C U K V C J V  G I C U W F T Q E G T Q V V P C Y G Y [ N V U T K (  U U G E Q T R Q V V P C Y G Y V C JV U V P G X G V P G T GH H K F Q Y V
 I PK U U G E Q T R
GJV QF QV GNWT GJV IPKMUC PGJV FPC GNWT VJIKT GJV IPKFPKH UGXNQXPK IPKUUGEQT2   GTW
I K ( H N G U V K U U G E Q T R Q V F N Q V G D P C E J E K J Y V P G X G G J V J V K Y U PK I G D U U G E Q T R G J 6 ! T G J V G I Q V
N N C VK G TK Y G Y Q F Y Q J    G T W I K ( G N W T I P KV U Q R G J V F P C V P G X G G J V G X C J G Y Y Q P Q 5
}
}
return Money.dollars(usageEvent.getAmount().getAmount() * usageEvent.getRate());
Usage usageEvent = (Usage) evt;
protected Money calculateAmount(AccountingEvent evt) {
}
super(type);
public MultiplyByRatePR (EntryType type) {
class MultiplyByRatePR extends PostingRule{
 G V C T [ D U GK N R K V N W O V C J V G N W T I P K V U Q R H Q U U C N E D W U C G M C O N N• +
Q 5 V P G O G G T I C G EK X T G U G J V P Q F G P KH G F G V C T G J V [ D V K [ N R K VN W O F P C V P G X G G J V O Q T H G I C U W
G JV G M CV QV U F G G P G N W T I P KV U Q R UK J 6  G N W T I P KV U Q R C UK F G G P + U U CN E D W U F P Q E G U G J 6
 TQ V
E W TV U P Q E G J V J I W QT J V P K O G J V U U C R F N W Q Y + U G R [V V P G X G N CT G X GU G X C J V J I K O + H +  G U C E
G JV U [ C Y N C V Q P UK U K J V U U C N E D W U UK JV T QH G R [ V V P G X G P Q V E G R Z G [ N P Q + G T G *  G N W T I P KV U Q R
G JV Q V [ NTG RQT R V EG PP QE Q V GR [ V V P GXG G J V F GG P + VW D C VC F G V CKT R QT R R C G JV T QH UU CN ED W U
GJV FGGP + TQVEWTVUPQE GJV PK GR[V VPGXG GICUW GJV GJV MPKN GJV GMCO + VCJV GEKVQ0
F GFG GP U C
G P Q G V CK T R Q T R R C P C G P K H G F G Y Q F G Y P G J Y V W D U U C N E D W U C F G G P U [ C YN C V• P Q F G 9  C V C F
NCPQKVKFFC FGGP GY PGJY PQOOQE GVKWS UK VPGX' IPKVPWQEE# HQ UGUUCNEDWU IPKMC/
}
}
return getCustomer().getServiceAgreement().getRate();
double getRate() {
}
return amount;
public mf.Quantity getAmount() {
}
this.amount = amount;
super(EventType.USAGE, whenOccurred, whenNoticed, customer);
public Usage(Quantity amount, MfDate whenOccurred, MfDate whenNoticed, Customer customer) {
private Quantity amount;
{
public class Usage extends AccountingEvent
 U U C N E D W U C G PK H G F N N• G Y
V P GXG GU C D TW Q PK G I CUW G JV T Q H G EC N R Q P G X C J G Y U #  VP GX G VC JV UU G E QTR Q V G N WT G V C
KT RQT R R C P C GU W PG JV F PC V PGX G GJ V PK G I CUW G TQ VU Q V FG GP G Y GI CU W G V C NWE N C E Q 6
 P Q K V CN W E N C E G I C U W G J V J V K Y V T C V U N N• G 9  G I T C J E F G Z K H C U G V C T G
P G I V C J V NN C E G E K X T G U C G X C J N N• G Y [ N F P Q E G 5  [ VK E K T V E GN G H Q J Y M [ P C O Q U F G U W T G O Q V U W E






PostingRule
AccountingEvent
process(AccountingEvent)
calculateAmount(AccountingEvent)




UsageEvent MultiplyByRatePR

amount : Quantity
calculateAmount(AccountingEvent)
{type = USAGE}




 GTWI K( G ICU W IP KVCN WENCE G JV TQH FGF GGP GN WT I PKVU QR FPC V PGX G HQ UGU UCNEDW 5




class AccountingEvent {
public void process() {
findRule().process(this);
}
PostingRule findRule() {
PostingRule rule =
customer.getServiceAgreement().getPostingRule(this.getEventType(),
this.whenOccurred);
Assert.notNull("missing posting rule", rule);
return rule;
}...
 V K U U G E Q T R F P C V P G X G P C GV C G T E P G J V P C E G 9
...
}
acm.setServiceAgreement(standard);
new MfDate(1999, 10, 1));
new MultiplyByRatePR(EntryType.BASE_USAGE),
EventType.USAGE,
standard.addPostingRule(
standard.setRate(10);
ServiceAgreement standard = new ServiceAgreement();
acm = new Customer("Acme Coffee Makers");
public void setUpRegular (){
 UG PK N GU G J V I P Q N C U GN WT I PK V U Q R G V CT R Q T R R C G J V
J VK Y V P G O G G T I C G E K X T G U G J V F P C T G O Q V U W E G JV R W V G U G Y O G V U [ U G J V G T W IK H P Q E Q 6
 G U C E P Q O O Q E VU Q O G J V U K U K J V F GTT W E E Q [ G J V GV C F G J V P Q F GU C D
U V P G X G N N C I PK U U G E Q T R O• + [ V K E KN R OK U T Q (  V P G X G G J V H Q G V C F F G T T W E E Q F P C G R [ V V P G X G G J V
Q V U F P Q R U G T T Q E V C J V GN W T G JV T Q H V P G O G G T I C G EK X T G U G JV I PK M U C [ D GN W T G JV F PKH G 9
UG QF V K VCJY FPC F GMQ XPK UK GNWT IP KVU QR C Y Q*     G T W IK (
usage entry
new
get rate
get amount of usage
process (usage event)
get posting rule (usage event type, occurred date)
find rule
process
posting rule
service agreement usage event
multiply by rate

 VP GXG
[ T CV G P Q O C Q V C N W O T QH G N R OK U C U GK N R R C V C J V G P Q EK T G P G I C U K G N W T I P K V U Q R G J V [ N T CN K OK 5
assertEquals (Money.dollars(30), resultingEntry.getAmount());
Entry resultingEntry = (Entry) acm.getEntries().get(0);
evt.process();
acm);
new MfDate(1999, 10, 5),
new MfDate(1999, 10, 5),
EventType.SERVICE_CALL,
Money.dollars(40),
AccountingEvent evt = new MonetaryEvent(
public void testService() {
 U C J E WU G F Q E
JV K Y V P G X G UK J V G V C G T E F N W Q Y G 9  T Q V E W T V U P Q E G J V Q V PK G R [ V V P G X G G J V G F Q E F T C J V Q P
U G Q F G P Q UK JV [ J Y U K J EK J Y U V P G X G H Q U G R [V [ P C O T QH F G U W G D F N W Q E U U C N E UK J 6  [ G P Q O
H Q V P W Q O C P C U F T Q E G T V U WL V C J V V P G X G [ T C V G P Q O GN R OK U C U K U U CN E D W U V P G X G G JV G EK V Q 0
}
}
return amount;
public mf.Money getAmount() {
}
this.amount = amount;
super(type, whenOccurred, whenNoticed, customer);
mf.MfDate whenNoticed, Customer customer) {
MonetaryEvent(Money amount, EventType type, mf.MfDate whenOccurred,
Money amount;
class MonetaryEvent extends AccountingEvent {
 V P G X G G J V J VK Y V T C V U N N• +
 G N W T I P K V U Q R H Q U U CN E D W U T G J V Q F P C G R [ V V P G X G T G J V Q P C V P G X G H Q U U C N E D W U T G J V Q P C F G G P
G Y G U C E UK J V G N F P C J Q 6  U T C N N Q F P G V U W N R G G H G U C D G J V H N C J F G I T C J E U K T G O Q V U W E G J V V P G O
G G T I C F T C F P C V U G J V PK V C J V [ C U U •V G .  P Q U K T G O QV U W E G JV V P G O G G T I C G J V Q V I PK F T Q E E C
F GK HK F Q O UK G GH G U C D UK J V T G X G Y Q *  G E K X T G U G J V T Q H G G H G U C D C U I Q N V P G O V T C R G F G EK X
T G U G J V N N C E G E K X T G U C G M C O G Y T G X G P G J 9  N N C E G E K X T G U C T Q H V U Q E C T G FK U P Q E U• V G N Q 5
GR[ 6 VPG X' FP QEG5 #
UU C NED WU G NR O KU C VUT Q Y V C T Q U VEG LD Q I PKF FC [ NR O KU [D UG N WT I PK VU QR YG P F FC
[ NK U C G QV U W I P K Y QN N C H Q J V I P G T V U G J V U C J V K V W D F G V C E KN R O Q E T G J V C T UK O U K P C J E G O UK J 6
}
assertEquals (Money.dollars(500), resultingEntry.getAmount());
Entry resultingEntry = getEntry(acm, 0);
evt.process();
acm);
new MfDate(1999, 10, 1),
new MfDate(1999, 10, 1),
Unit.KWH.amount(50),
Usage evt = new Usage(
public void testUsage() {




class AmountFormulaPR extends PostingRule {
private double multiplier;
private Money fixedFee;
AmountFormulaPR (double multiplier, Money fixedFee, EntryType type) {
super (type);
this.multiplier = multiplier;
this.fixedFee = fixedFee;
}
protected Money calculateAmount(AccountingEvent evt) {
Money eventAmount = ((MonetaryEvent) evt).getAmount();
return (Money) eventAmount.multiply(multiplier).add(fixedFee);
}
}
 U K J V G M K N V P G O G G T I C G EK X T G U G JV Q V GN W T U K J V F F C G 9
public void setUpRegular (){
acm = new Customer("Acme Coffee Makers");
ServiceAgreement standard = new ServiceAgreement();
standard.setRate(10);
standard.addPostingRule(
EventType.USAGE,
new MultiplyByRatePR(EntryType.BASE_USAGE));
standard.addPostingRule(
EventType.SERVICE_CALL,
new AmountFormulaPR(0.5, Money.dollars (10), EntryType.SERVICE));
acm.setServiceAgreement(standard);
}


G I PCJ% GN W4 C I PKN FPC *
GT W V C P N C T Q R O G V G J V I P K U W G N WT Y G P C F F C [ N K U C G P C E G Y G O KV T G X Q G I P C J E U G N WT G J V H +
G EK X T G U PK G I P C J E C G F W N E PK Q V G F Q E R W V G U T W Q [ HK F Q O P C E G 9  U GN W T I PK V U Q R G JV H Q
 GIT C J E



public void setUpRegular (){
acm = new Customer("Acme Coffee Makers");
ServiceAgreement standard = new ServiceAgreement();
standard.setRate(10);
standard.addPostingRule(
EventType.USAGE,
new MultiplyByRatePR(EntryType.BASE_USAGE),
new MfDate(1999, 10, 1));
standard.addPostingRule(
EventType.SERVICE_CALL,
new AmountFormulaPR(0.5, Money.dollars (10), EntryType.SERVICE),
new MfDate(1999, 10, 1));
standard.addPostingRule(
EventType.SERVICE_CALL,
new AmountFormulaPR(0.5, Money.dollars (15), EntryType.SERVICE),
new MfDate(1999, 12, 1));
acm.setServiceAgreement(standard);
}




event type = USAGE event type = SERVICE CALL
standard : Service Agreement
effectivity = later than Oct 1 1999 effectivity = starts Dec 1 1999


event type = SERVICE CALL
effectivity = starts Oct 1 1999, ends Dec 1 1999




a MultiplyByRatePR an AmountFormulaPR an AmountFormulaPR

entry type = BASE USAGE entry type = SERVICE entry type = SERVICE
multiplier = 0.5 multiplier = 0.5
fixed fee = $10 fixed fee = $15



 GTWI K( VP GOG GTIC GE KXTGU FTC FPCVU GJ V TQH UG NWT IPK VUQ 2




 CN W O T Q H Y G P G JV G U W G Y G V C F T GV C N G J V V C G I T C J E G EK X T G U T QH M U C P G J V G Y H+




public void testLaterService() {
AccountingEvent evt = new MonetaryEvent(
Money.dollars(40),
EventType.SERVICE_CALL,
new MfDate(1999, 12, 5),
new MfDate(1999, 12, 15),
acm);
evt.process();
Entry resultingEntry = (Entry) acm.getEntries().get(0);
assertEquals (Money.dollars(35), resultingEntry.getAmount());
}


VPG OGG T I # F PQEG 5 #
[ NK U C G Q UN C P C E W Q [ V P G O G G T I C I PK V U K Z G P C Q V U GN W T I PK V U Q R Y G P F F C QV [ U C G UK VK U C V U W ,
FKCR YQN TQH [NRRC VJIKO UTQVCNWIGT VCJV GNWT C GMCV U•VG. UVPGOGGTIC YGP RQNGXGF
VC FGITCJE GTC [GJV J YM PCJV UUGN UGUW PQUTGR C HK VCJV [CU VJIK O GNWT C JEW5 GNRQGR
P Q G V CT T C N W I GT G J V F G IT C J E GT C [ G JV V C J V P C J V G T Q O GU W [ G J V H K V W D G V C T V P GT GH H K F C
 V P G O G G T I C TK G J V
G JV UGT C R O Q E V C J V G P Q GN WT I PK VU QR T GJ V Q P C G EW FQT V P K VJI K O G Y UK J V G NF PC J Q 6
 V K O K N Q V G I CU W
class PoorCapPR extends PostingRule {
double rate;
Quantity usageLimit;
PoorCapPR (EntryType type, double rate, Quantity usageLimit) {
super(type);
this.rate = rate;
this.usageLimit = usageLimit;
}
protected Money calculateAmount(AccountingEvent evt) {
Usage usageEvent = (Usage) evt;
Quantity amountUsed = usageEvent.getAmount();
Money amount;
return (amountUsed.isGreaterThan(usageLimit)) ?
Money.dollars(amountUsed.getAmount() * usageEvent.getRate()):
Money.dollars(amountUsed.getAmount() * this.rate);
}
}
G N W T U K J V JV K Y T G O QV U W E V P G T GH H K F C R W V G U P C E G 9
 VK U G U W G N W T I PK V U Q R G P Q P C J V G T Q O H K V U Q J G JV P Q C V C F V W R Q V V U G D U • V K [ N N C W U 7
 G U C E T Q Q R G J V T Q H R C E F P C G V C T I PK F K T T G X Q G J V P K U C G N W T I PK V U Q R G J V P Q U G O K V T G J V Q
VC G V C T EK U C D G J V P K U C V U Q J G J V P Q C V C F V W R G X• + U G O K V G O Q U V C J V G E K V Q P N N• W Q ;
 P Q KV C E KN R W F G G U W Q [
T G X G P G J Y T Q V E C H G T F P C R W G O Q E [ G J V U C U O GN D Q T R T C N W E K V T C R G X N Q U QV U K O G J V P IK U G F
Q V [ C Y V U G D G J 6  G E P C X F C PK U G N W T I P K V U Q R G J V P IK U G F Q V I PK [ T V V W Q D C [ T T Q Y V• P Q &
 G N W T I PK V U Q R I P V K UK Z G
P C H Q G E P CV U P K V P G T G HH K F C I P K M C O [ D U GN W T G T Q O V T Q R R W U P C E W Q [ V C J V F PK H NN • W Q [
U Y Q T I U GN W T H Q V P W Q O C T W Q [ U C V W D P Q O O Q E G D QV U F P GV V C J V U G N W T Y GH V U TK H G J V T Q (
 G N W T Y G P C F G E W F Q T V P K G X • G Y G O K V J E C G U U C N E D W U G N W T I P K V U Q R C F G E W F Q T V P K G X• G Y T C H Q 5
}
assertEquals (Money.dollars(510), resultingEntry2.getAmount());
Entry resultingEntry2 = (Entry) reggie.getEntries().get(1);
assertEquals (Money.dollars(250), resultingEntry1.getAmount());
Entry resultingEntry1 = (Entry) reggie.getEntries().get(0);
evt2.process();
reggie);
new MfDate(1999, 11, 1),
new MfDate(1999, 11, 1),
Unit.KWH.amount(51),
Usage evt2 = new Usage(
evt.process();
reggie);
new MfDate(1999, 10, 1),
new MfDate(1999, 10, 1),
Unit.KWH.amount(50),
Usage evt = new Usage(
public void testLowPayUsage() {
 U G U W G J J E W O Y Q J P Q U F P G R G F N NK D UK J F PK H NN K Y GK I I G 4
}
reggie.setServiceAgreement(poor);
new AmountFormulaPR(0, Money.dollars (10), EntryType.SERVICE));
EventType.SERVICE_CALL,
poor.addPostingRule(
new PoorCapPR(EntryType.BASE_USAGE, 5, new Quantity(50, Unit.KWH)));
EventType.USAGE,
poor.addPostingRule(
poor.setRate(10);
ServiceAgreement poor = new ServiceAgreement();
reggie = new Customer("Reginald Perrin");
private void setUpLowPay (){

 D Q L G J V U G Q F [ N G U Q N E [ V V G T R 4 2 CN W O T Q ( V P W Q O #
G JV UK JV Q F Q V G N W T I P KV U Q R I P K V UK Z G P C G U W [ NN C WV E C P C E +  I P K J V [ T G X G P Q Z CV   V CN H
C G O W U U C U • V G N [ V K E K N R O K U T Q (  G F Q E T G K N T C G G J V Q V Z C V T Q H U G N W T I P K V U Q R [ T C F P Q E G U F F C N N• +
GFQ% GNROC5
U GN WT I P KV U Q R [TC FP QEG U
Q V P K EK I Q N P Q O O Q E G JV V W Q T Q V E C (  U G N W T I PK V U Q R U U Q T E C E K I Q N F G V C E N R W F F P K H F P C  
G N W 4 I P KV U Q 2 I P K U W GT C W Q [ T G X G P G J Y   G N W 4 I P K V U Q 2 [ T C F P Q E G 5 G U W FN W Q J U W Q ;
VK GUW QV PGJ9
 I P K U U G E Q T R T G J V Q G J V N N C T Q H G U W W Q [ V C JV O UK P C J E G O
G O C U G J V G U W QV U R N G J Q UN C V+  P Q F G U C D U C Y Z C V G J V V P G X G G J V I PK V U WL F C V W Q J VK Y Z C V
G JV V U W L F C Q V F G G P W Q [ H K G N D C W N C X [ N T C N W E K VT C R U K V +  U T G J V Q P K N WH G U W V W D U G E P C VU O W E
T K E G O Q U PK C TV Z G F G V P C Y P W P C G D P C E  G I T C J E G E K X T G U G J V T Q H Z C V  V P G X G F P Q E G U G J 6
 V P G X G F P Q E GU C U GV C G T E T G VV C N G J V V C J V U K G E P GT GHH K F G J 6 T G P P C O N C OT Q P G JV P K V C J V
U U G E Q T R F P C V P G X G T G JV Q P C GV C G T E QV UK T G J V Q G J 6 V P G X G N C PK IK T Q G J V V K G XK I F P C GN W T
IPKVUQR [TCFPQEGU GJV GMQXPK QV UK GP1 UKJV QF PCE WQ[ U[CY HQ GNRWQE C U•GTGJ6
MTQY VK IPKMC/
 V K F G G P V C J V U GN W T I P K V U Q R G J V [ D
F G N N C E UK V C JV GN W T I P KV U Q R T G J V Q P C G V C G T E QV U K G V W Q T T G VV G D #  Z C V C F F C Q V U F G G P V C J V
G N W T I P K V U Q R [ T G X G PK E K I QN U K J V G V C EK N R W F Q V V P C Y V• P Q F W Q ;  U G I T C J E G EK X T G U F P C G I C U W
U V K N N C P Q Z C V   V C NH C [ C R Q V U F G G P [ V K N K V W G J V U R C J T G 2  U G Z C V U K G T G J G N R O C Z G F Q Q I
#  T G JV Q P C G M Q X PK Q V U F G G P G N W T I P K V U Q R G P Q G T G J Y U P Q K V C W V K U U U Q T E C G O Q E P G V H Q W Q ;
VEGH HG UVK GTCJ U QV TGFT Q PK G NW T I PKV UQR TGJV Q PC GMQX PK Q V UGNW T I PKV UQR NCTGX G U YQNN #
5GEQP.CT[ 2QUVKPI 4WNG

U K U KJ V QF Q V [C Y GN R OKU #  P QKUT WE GT UUG NF PG P C QV PK
V G I N N• + G U K Y T G J V Q U V P G X G Z C V O Q T H U V P G X G Z C V G V C G T E V• P Q F + G T W U P G F G G P + V C J V G EK V Q 0
}
if (isTaxable()) new TaxEvent(evt, calculateAmount(evt)).process();
makeEntry(evt, calculateAmount(evt));
public void process (AccountingEvent evt) {
class PostingRule...
 U U C N E T G R W U G N W T I P K V U Q R G J V PK F Q J V G O U U G E Q T R G J V I P K [ H
K F Q O [D U K J V QF P C E +  P Q G NWT I P KV U Q R G JV GMQX PK Q V VP GXG P C G V CGT E Q V F GG P P G J V +
 Z C V T Q H G R [ V [ T V P G Y G P C F P C G R [ V V P G X G Y G P C F F C Q V F G G P + UK J V Q F Q V G U T W Q E H 1
}
acm.setServiceAgreement(standard);
new MfDate(1999, 10, 1));
new AmountFormulaPR(0.055, Money.dollars(0), EntryType.TAX),
EventType.TAX,
standard.addPostingRule(
...
ServiceAgreement standard = new ServiceAgreement();
acm = new Customer("Acme Coffee Makers");
public void setUpRegular (){
class Tester...

V U Q R [ T C F P Q E G U G X C J Q V I PK V P C Y H N G U T W Q [ F P KH W Q [ H+  T G J V Q P C O Q TH U GN W T I PK V U Q R Y GH C
 G NW4 I PKV UQ2 [ TC FPQEG 5
NNCE QV VPCY VUWL WQ[ GTGJY UGUCE GNR OKU TQH NNGY UMTQY
 P QK V E GV Q T R N WH G U W C U K T QV E W T V U P Q E G J V PK P QK V
TGU U C G JV Q U PQ KUT WE GT U UG NFP G P C [ D VJ IW CE V GI Q V N WH PK CR FP C [U C G [T CN WE K VTC R U•V +
}
}
Assert.isFalse("Probable endless recursion", base.getEventType() == getEventType());
this.base = base;
base.getWhenNoticed(), base.getCustomer());
super (taxableAmount, EventType.TAX, base.getWhenOccurred(),
public TaxEvent(AccountingEvent base, Money taxableAmount) {
private AccountingEvent base;
class TaxEvent extends MonetaryEvent {
G NR O KU [T GX U K VP GX G Z C V GJ 6  VP GX G Z C V C UU G E
Q T R F P C G V C G T E Q U N C G Y V P G X G P C U U G E Q T R G Y P G J Y Y Q 0 V PK Q R G J V GV C T V U WN NK Q V U G X T G U
VK VW$ VCJV JVKY [CYC VGI PCE WQ[ HK [MEWN [TGX GD NN•WQ[ GTC [GJV VCJY IPKGD UGZC6
    G T W IK (
IPKUUGEQTR GJV QV VPGXG ZCV C IPKFF#
process
tax event
new
usage entry
new
get rate
get amount of usage
process (usage event)
get posting rule (usage event type, occurred date)
find rule
process
posting rule
service agreement usage event
multiply by rate
}
return !(type == EntryType.TAX);
private boolean isTaxable() {
class PostingRule...

 V C J V T Q H V U G V C U• G T G *
}
return result;
}
result.addAll(each.getResultingEntries());
AccountingEvent each = (AccountingEvent) it.next();
while (it.hasNext()) {
Iterator it = secondaryEvents.iterator();
result.addAll(resultingEntries);
Set result = new HashSet();
Set getAllResultingEntries() {
class AccountingEvent...
 T QK X C J G D UK J V G U W V C J V U F Q J V G O G FK X Q T R P G JV P C E G 9
}
secondaryEvents.add(arg);
// only to be called by the secondary event's setting method
void friendAddSecondaryEvent (AccountingEvent arg) {
private List secondaryEvents = new ArrayList();
class AccountingEvent ...
...
Assert.isFalse("Probable endless recursion", base.getEventType() == getEventType());
base.friendAddSecondaryEvent(this);
this.base = base;
base.getWhenNoticed(), base.getCustomer());
super (taxableAmount, EventType.TAX, base.getWhenOccurred(),
public TaxEvent(AccountingEvent base, Money taxableAmount) {
class TaxEvent...
 N CP QK VE GTKF
K D G D QV G U C D G J V F P C [T C F P Q E G U G J V P G G Y V G D M P K N G J V G I P C J E Q V F G G P G Y U K J V Q F Q 6
GFQ% GNROC5
 V P GXG GU C D U• VK FP C V PGX G [T CFP QE GU G J V P G G Y V G D MP KN
N C P QK V E G T K F K D C U G X N Q X P K U K J V  T G J V G I Q V U V P G X G G J V M PK N Q V U K M P K N UK J V I P K P K C V PK C O H Q [ C Y
F Q Q I #  V U TK H G J V O Q T H UV P G X G [ T C F P Q E G U G J V H Q UV N W U G T G J V F P KH P C E W Q [ V C JV G T W U P G QV
F G G P NN • W Q [   V P G O VU W L F # N C U T G X G 4 F P C   G N W 4 I P K V U Q 2 [ T C F P Q E G 5 I PK U W G T C W Q [ H+
GECT6 VPGX' GJV IPKPKCVPKC/
 MT QY VG 0 GN W4 I PKV UQ2
 GU W F N W Q JU
W Q [   U G N W T I P KV U Q R [ T C F P Q E G U G X C J V C JV U GN W T I PK V U Q R [ T C F P Q E G U G X C J V C J V U G N W T I PK




class Tester
public void testUsage() {
Usage evt = new Usage(
Unit.KWH.amount(50),
new MfDate(1999, 10, 1),
new MfDate(1999, 10, 1),
acm);
evt.process();
Entry usageEntry = getEntry(acm, 0);
Entry taxEntry = getEntry(acm, 1);
assertEquals (Money.dollars(500), usageEntry.getAmount());
assertEquals (EntryType.BASE_USAGE, usageEntry.getType());
assertEquals (Money.dollars(27.5), taxEntry.getAmount());
assertEquals (EntryType.TAX, taxEntry.getType());
assert(evt.getResultingEntries().contains(usageEntry));
assert(evt.getAllResultingEntries().contains(taxEntry));
}

P QK V E G T K F P K H Q R G V U C U G F K X Q T R V K U K J V P +  U K V K [ T V P G H Q F P K M G J V G D K T E U G F V C J V [ T V P G P C H Q
U V P G O G N G G J V N N C T G J V G I Q V I PK [ V H Q [ C Y C U K V P W Q E E C P C V W Q D C I P K M PK J V H Q [ C Y F T K J V #
 G W N C X V C JV Q V F G P G R R C J V C J V G I P C J E G V GT EU K F
J E C G Y QPM Q V V P CY W Q [ FP C VU CR GJ V P K V PK QR [ P C V C G W NC X U•V K Y QPM Q V G ND C G D Q V V P C Y
Q UN C W Q [ U K G W N C X V P G T T W E G J V V C J Y Y Q P M Q V V P C Y V U W L V • P Q F W Q [ G T G J Y V P W Q O C P C T Q H
G U W W Q [ I PK J V G O Q U G W N C X G O Q U H Q [ T QV UK J G JV U C V P W Q E E C P C H Q M PK JV Q U N C P C E W Q ;
 G E P C N C D C U C J E W U P QK V C O T Q H P K [ T C O O W U G F K X Q T R T QK X C J G D U C J Q U N C
V K T G X G Y Q J T G P K CV P Q E C P C JV G T Q O UK V P W Q E E C G J 6  V P W Q E E C P C Q V P K VK V W R W Q [ [ T V P G
P C G V CGT E W Q[ T G X G P G J 9  U G K TV P G H Q T G PK C V P Q E C U C O G J V H Q
  [ T V P ' I PK V P W Q E E #
M P K J V QV U K [ C Y F Q Q I #  U K V P W Q Q E E C P C V C J Y V W Q D C M P K J V Q V U [ C Y U W QK T C X G T C G T G J 6
I P K VP WQ EE C I PKX N QXP K U O GN DQT R
V UQ O P K RW R QTE [ GJ V U VP WQ EE C HQ VT C JE G VC TQ RT Q E C T Q U VP WQ EE C VU QE V EG LQT R U V P W Q EE C
M P C D N C P Q U T G R GT C [ G JV T G J V G J 9  G O K V I P Q N C T Q H F P W Q T C P G G D G X C J U V P W Q E E #
deposits(DateRange)
withdrawels(DateRange)
1
»
balance (DateRange)
Entry
balance
Account
TQKXCJGD IPK\KTCOOWU GFKXQTR FPC UGKTVPG IPKVPWQEEC FGVCNGT TGJVGIQV VEGNNQ%
#EEQWPV

G U P GU HQ
V Q N C G M C O P C E N G F Q O C J E W U P G J V U G U W Q J G T C Y H Q M T Q Y V G P C G X C J W Q [ HK V W D G I FK T H [ O
T Q H O G V U [ U I P K V P W Q E E C P C G U W Q V F G PK N E PK V Q P O• +  U GN V V Q D Q Y V H Q N G Y C T F J VK Y P C U C V C J V
H Q M P K J V P C E + J U Q, P C I Q 4 T W Q J VK Y G X C J Q V G O F P C [ F PK % T QH V W Q U GN V V Q D H Q GN R W Q E
C G M CV + P G J 9 V P W Q E E C P C U C V C J V V W Q D C M P K J V P C E + T Q V CT G I F KTH GT [ O P K GV V W $ M E C N $
H Q U G NV V Q D T W QH [ V P G Y V G X C J + H+  [ G P Q O P C JV GT Q O T QH F GU W G D P C E U V P W Q E E C T G X G Y Q *
 U V P W Q E E C [ T C V G P Q O V W Q D C M P K J V [N N C W U W [ G JV U V P W Q E E C V W Q D C M PK JV G N R Q G R P G J 9
 GTWI K(
UTQVRKTEUGF UVK FPC [TVPG PC PGGYVGD PQKVEGTKFPK HQ GXGN C UC VEC PCE UVPWQEE#
Entry Type
1
»
Location Account Entry
1 » 1 »
»
Customer
1
Entry Type
1
»
Location Entry
1 »
»
Customer
1
 U EK V U K T G V E C T C J E T CN K OK U G X C J V C J V U GK T V P G G J V N N C
T G J V G I Q V N N W R [ N K U C G G T Q O W Q [ U Y Q N N C UK JV I P K U 7  U T Q V RK T E U G F U V K F P C [ T V P G G J V P G G Y V G D

 V• P Q F V Q P H K UV PW QE EC H Q U OT GV P K F NT Q Y
  V P W QE E # G UW Q V G U P GU UG M C O VK P G J V
G JV H Q M P K J V G U W [ G J V H+  PK C O Q F G J V G G U UV T G R Z G PK C O Q F G J V Y Q J UK T QV E CH T G JV Q P #
   V P W Q E E # G U W W Q [ H K G U W Q V T GK U C G J E W O G T C   V P G O V U WL F # G E P G T G H HK & F P C
  M T Q Y V G 0 G N W 4 I P KV U Q 2 U C JE WU UPT G VV C R T G J VT W H G O Q 5  P Y Q U VK P Q   [TV P' I PK
V P W Q E E # G U W Q V T Q   V P W Q E E # G U W Q V T G J V G J Y I P K T G F P Q Y HN G U T W Q [ F PK H W Q [ P G VH 1
 G M KN J V K Y U G K T V P G G M K N G T C R
O Q E Q V T GK U C G VK U G M C O UK J 6  U P Q K V R K T E U G F H Q V G U P Q O O Q E C T Q H U G K T V P G G J V NN C T G J V G I Q V
N N W R Q V V P C Y + V W D   [ T V P ' I PK V P W Q E E # I P K U W [ F C G T N C O • + G T G J Y U K G U C E F P Q E G U G J 6
  [VTGRQT2 NCTQR OG6 PCJV
FGVCEKNR OQE GTQ O [PC UK  VPWQEE# VCJV GTWU VQP O•+ JIWQJVNC “  [VTGRQT2 NCT
Q R O G 6 G U W P C E + U G W N C X EK T Q V UK J F P C V P G T T W E F G G P [ N P Q + H +  FN GK H C G U W V U WL P C E + G W N C X
V P G T T W E G J V F G G P [N P Q + H+  G W N C X V C J V QV U G I P C J E H Q [ T Q V U K J C R G G M Q V GN D C G D Q V F P C
U G W N C X N C EK T Q V U K J G WN C X V P G T T W E F G G P + G T G J Y G WN C X G O Q U U K G T G JV G T G J Y U K V U T KH G J 6
 U P Q K V C W VK U V P G T G H H K F H Q G N R W Q E P K   V P W QEE # GU W QV GI TW GJ V NG GH Q V F P G V +
VK GUW QV PGJ9
 F Q K T G R G OK V C T G X Q T Q G V C F G O Q U P Q U V K U Q R G F
FPC UNGYCTFJVKY GEPCNCD GJV VGI QV UK GGU WQ[ TQKXCJGD IPK\KTC OOWU NCEKR[V GJ6
 U P QK V C N W E N C E [ T C O O W U G JV T Q H   IC $[GPQ /
G U W Q V F G G P NN• W Q [ U GK E P G T T W E V P G T G H HK F O Q T H U GK T V P G FN Q J Q V U V P W Q E E C Y QN N C W Q [ H +
 VTQ HHG G JV J VTQ Y
[ N F T C J U• VK V C J V U P C G O U V P W Q E E C [ V R O G V C G T V Q V Y Q J H Q T Q K X C J G D [N F FK H G J V V W D [ T V P G
V U TK H TK G J V P G X K I G T C [ G J V P G J Y [ E P G T T W E T K G J V G U Q Q J E [ NN C E K O C P [ F V C J V U V P W Q E E C G V C G T E
Q V G NDKU UQ R UK V + F PK O P K [ E PGTT WE T CN WE KVT C R C J VKY F G V CGT E UV P W Q E EC G GU W Q[ [ N NC WU W Q5
 [ E P G T T W E G O C U G J V H Q G D N NK Y V P W Q E E C P C P K U G K T V P G G J V NN C V C JV V E G R Z G [N N C W U W W Q ;
U G KT V P G F GN KC V GF GJ V T QH [ ZQT R C U C FGU W GD P CE [T V P G
UK J V T G X G Y Q *  [ T V P G [ T C O O W U G J V Q V PK U V W E V C J V P Q K V C O T Q H PK V G I Q V GN D C G D V• P Q Y W Q [
U P C G O V W D P Q KV C F KN Q U P Q E G J V T G V H C U G V C F T QH G E P C N C D G JV PK C V P K C O NN K Y U K J 6  U GK T V P G
F G X Q O G T G JV H Q G E P C N C D G JV UK G WN C X G U Q J Y [ T V P G GN I P K U C V U WL JV K Y U G K TV P G H Q R O WN E
C G E C N R G T P C E W Q [ O G J V V W Q D C UN K C V G F F G G P T G I P Q N Q P W Q [ F P C [ P C O Q QV G T C G T G J V
H K T G X G Y Q *  V P W Q E E C G J V H Q I P K P G R Q G J V Q V [ C Y G J V NN C M E C D Q I [N N C EK R [ V U GK T V P '
UGEPCNCD TGKNTCG VGI QV UFTCYMECD
G V N C W E N C E Q V U GK TV P G G JV G U W F P C F N G KH C P K G W N C X V P G T T W E G JV G J E C E P C E W Q [ G E P C
N C D V P G T T W E G J V F G G P P G V H Q W Q [ HK G E P C V U P K T Q (  V P W Q E E C G J V O Q T H F G G P W Q [ P QK V C O
T Q H P K H Q F P K M V C J Y P Q F P G R G F NN K Y G W S K P J E G V P Q K V C \ K O K V R Q G J 6  U G E P C N C D G V C N W EN C E W Q [
[CY GJV G\KOKVRQ QV FGGP PGVHQ WQ[ UGKTVPG HQ VPWQ OC GITCN C VGI [NNCWUW WQ[ GEPK5
 U G K TV P G G U Q J V T G X Q P Q KV C O T QH P K I PK \ K T C O O W U I P K FK X Q T R F P C U GK T V P G
H Q P Q K V E G N N Q E C I P K R G G M  P T GV V C R V P W Q E E C G J V Q V U GK V K N C W S N C K V P G U U G Q Y V G T C G T G J 6
MTQY VK IPKMC/


G O KV TG X Q V PW QEE C GJ V O QTH
F G X Q O G T T Q F G F F C UN C V Q V G PK O T G V G F Q V T QK X C J G D GV C T C R G U G F K X Q T R Q V N WH G U W U •V K P G V H 1
}
return balance(MfDate.today());
Money balance() {
}
return balance(DateRange.upTo(date));
Money balance(MfDate date) {
}
return result;
}
if (period.includes(each.date())) result = result.add(each.amount());
Entry each = (Entry) it.next();
while (it.hasNext()) {
Iterator it = entries.iterator();
Money result = new Money (0, currency);
Money balance(DateRange period) {
class Account...
 F GV C EK N R O Q E G T Q O J E W O V C J V V Q P UK P Q K V C O T QH PK [ T C O O W U G J 6
}
entries.add(new Entry(amount, date));
Assert.equals(currency, amount.currency());
void addEntry(Money amount, MfDate date){
private Currency currency;
private Collection entries = new HashSet();
class Account ...
 GN R OKU [T GX UK U G KTV P G I PK VE GN
NQ %  PQ KV C OT QHP K [T C O O WU I PK FK X QTR F P C U GK T V P G T G J V G I Q V I PK
  [T VP' I PKV PWQ EE #
V E GN N Q E H Q I P KV UK U P Q E F T C Y T Q H V J I K C TV U [ T G X [ N N C W V E C U K U V P W Q E E C T Q H T QK X C J G D EK U C D G J 6
GFQ% GNROC5
 T CH Q QV G N VV KN
C [ I Q N C P C G J V I P K J E V G T V U U • V C J V G O T Q H  U G N K H V Z G V QV U VK U Q R G F F P C U N G Y C T F J V K Y U G E P C N C D
U C N Q TV P Q E P QK U T G X G F Q E C H Q M PK JV P C E W Q [ U U G W I + G NK J 9  U P QK V C W VK U G X KV C VK V P C W S P Q P
T Q H   V P W Q E E # G U W P C E W Q [ V C J V U P C G O V C J V M P K J V V• P Q F + T G X G Y Q *  [ G P Q O Q V N Q T V P Q E
P Q UK T G X H Q C G FK G J V I PK [ N R R C U C   V P W Q E E # H Q M P K J V P C E W Q [ F G G F P+  U O GV U [ U N Q T V P Q E
P Q KUT G X H Q C G F K G J V F P C   V P W Q E E # P G G Y V G D [ I Q C N P C G J V G G U Q V VN W E K H H K F V Q P U• V +




Money deposits(DateRange period) {
Money result = new Money (0, currency);
Iterator it = entries.iterator();
while (it.hasNext()) {
Entry each = (Entry) it.next();
if (period.includes(each.date()) && each.amount().isPositive())
result = result.add(each.amount());
}
return result;
}
Money withdrawels(DateRange period) {
Money result = new Money (0, currency);
Iterator it = entries.iterator();
while (it.hasNext()) {
Entry each = (Entry) it.next();
if (period.includes(each.date()) && each.amount().isNegative())
result = result.add(each.amount());
}
return result;
}
 [ G P Q O I PK X T G U P Q E U W J V Q T G \ QV O W U
V U W O U GK T V P G G JV N N C V C J V G N W T N N C T G X Q G J V N NK V U J VK Y V W D U G K T V P G H Q T G D O W P [ P C U Y Q N N C
P Q KV E C U P C T V F G I I GN KV N W O #  T G JV Q P C QV V P W Q E E C G P Q O Q TH V P G O G X Q O G N I P K U C [ NN C T GV KN
[ T G X UK UK J 6  P IK U G VK U Q R R Q H Q G T C J EK J Y U GK T V P G Q Y V U C J T G X G [N P Q P Q K V E C U P C T V F G I I GN
Q Y V #  Q V P K P W T W Q [ V C J V U F P K M Q Y V [ N N C WV E C G T C G T G J V U P Q K V E C U P C T V G U W G Y P G J 9
MTQY VK IPKMC/
 F P W Q T C F G X Q O T G X G [N P Q UK
VK [ G P Q O G V C G T E V Q P P C E W Q [ V P C V P W Q E E C P C T Q (  [ I T G P G G X T G U P Q E UV UK E K U [ J R G MK N J E W O
F G XT GU P Q E U K [ G P Q O [ C Y U K J V P + T G JV Q P C QV P Q KV K F F C G JV F P C V P W Q E E C G P Q O QTH P Q KV
E C T V D W U G J V U V P G O G N G Q Y V U C J U M Q Q D Q V Q F W Q [ I P K J V [ T G X G U W J 6  V K U Q R G F C J VK Y F G E P C
N C D G D V U W O N G Y C T F J V K Y [ T G X G G N R OK U G V K W S UK I P K R G G M Q Q D [ T V P G G N D W Q F F PK J G D C G F K
G J 6  I PK R G G M Q Q D [ T V P G G N D W Q F  [ E P C V P W Q E E C H Q U C G FK G T Q E G J V H Q G P Q F G V P G X P K Q J Y
M P Q O C U C Y G *  U V UK EK U [ J R Q V U K QK GN N C ) V C J Y U V P C V P W Q E E C QV G D N N G Y [ C O G O C P M P Q O
entries equals 0}
{sum of amounts of
1
amount: Money »
Transaction
Account
Accounting
Entry
1 2
QTG\ UK PQKV ECU PCTV C PK UGK TV PG NNC HQ NCVQ V GJ V VCJ V Q U TG JVGIQ V UGKTV PG G TQO TQ QY V M PK.
#EEQWPVKPI 6TCPUCEVKQP

    G T W IK (
UGKTVPG VWQJVKY PQKVECUPCTV IPKVPWQEEC PC TQH OCTICKF UUCNE #
» 1 to
amount: money
Account
Accounting Transaction
1 from
»
U GV C F G V CT C R G U
G JV F T Q E G T F N W Q E G Y Q U U G KT V P G G J V F G G P F N W Q Y G Y G U C E U K J V P+  V P W Q E E C U I P K X C U [ O Q V
V K U Q R G F G J V GT QH G D U [ C F G G T J V T W E E Q F N W Q Y V P W Q E E C I P K M E G J E [ O O Q T H N G Y C T F J V K Y G J V
J EPCT D G OCU GJV VC V PW QE EC V KUQ RG F UI PKX CU [ O Q V VP GTT W E I PKME G J E [ O O QTH [ GP Q O
F G T T GH U P C T V + HK P G X G Q 5  T G J V Q P C Q V V P W Q E E C G P Q O Q TH T GH U P C TV C Q F QV U [ C F G G T J V
M Q QV V K V C JV G U C E G J V U [ C Y N C U C Y VK PK C VK T $ PK F G X KN + P G J 9  V P W Q O C T K G JV H Q P I K U G J V
P K V P G T G H H K F [ N P Q G T C [ NN C G T U G K T V P G Q Y V G J V H K U M T Q Y U K J 6  P QK V E C U P C T V G J V P Q C V C F G J V N N C
G X C J Q V GU Q Q J E P C E W Q [ “ N C P Q KV R Q GT C U G KT V P G G J V P Q KV E C U P CT V F G I I G N Q YV C J V K 9
 P QK V E C U P C T V F G I I GN K V N W O C J VK Y P QK V E C U P C T V F G I I GN Q Y V C V T Q R R W U P C E
W Q [ J I W Q J V P G X G U P Q K V E C U P C T V F G I I G N K VN W O F N K W D Q V I P K [ TV J V T Q Y V Q P U • V K U M T Q Y U U G P
K U W D G J V [ C Y G J V U• V C J V HK Q U J VK Y M T Q Y Q V V U G K U C G G J V G T C U P Q K V E C U P C T V F G I I G N Q Y 6
    G T W IK (
PQKVECUPCTV FGIIGN QYV C HQ GNROCZG P#
amount = -$100
checking: Account
an Entry
Transaction
an Accounting
amount = $100
cash: Account
an Entry

RKNU VKUQRGF GPQ JVKY VPWQEEC MPCD [O QVPK [CR + JEKJY UMEGJE QYV
GXCJ + GTGJY PQKVCWVKU C VPGUGTRGT VJIKO UKJ6 PQKVECUPCTV FGIIGN KVNWO C HQ GNROCZG P#  GTWIK(
amount = $150
checking: Account
an Entry
amount = - $100
Transaction
salary: Account
an Accounting
an Entry
amount = - $50
royalties: Account
an Entry
U V P W Q E E C
GV C K T R Q T R R C G JV Q V [ N V T G R Q T R VK V U Q R W Q [ G T Q H G D P Q KV E C U P C T V C R W F NK W D QV   V E G L D 1
F G U Q R Q T 2 I P K U W J V T Q Y U• VK Q 5  V T Q H H G G T Q O V K D C U G M C V P Q K V E C U P C T V F G I I G N K V N W O C T G X G
Y Q *  [ NK U C G G VK W S P QK V C T G R Q G P Q P K F G V C G T E G D P C E P Q KV E C U P C T V F G I I G N Q YV #  P QK V E C
U P C TV G J V G V C G T E Q V Y Q J PK U G KN [V N W EK HHK F G J V P G VH Q P Q K V E C U P C T V F G I I G N K V N W O C J VK 9
[TVPG PQKVECUPCTV IPKVPWQEEC PQKVCKEQUUC GJV HQ [VKEKNRKVNWO
GJV UK GEPGTGHHKF [NPQ GJV VCJV GEKVQP PQKVECUPCTV FGIIGN KVNWO C TQH OCTICKF UUCN%  GTWIK(
entries equals 0}
{sum of amounts of
1
amount: Money »
Transaction
Account
Accounting
Entry
2..»
1

 GT W U V Q P GT• W Q [ H K T GN R OKU G JV J VK Y VT CV U Q V T G VV GD U• VK V WD
F T C Y T QH V J IK C T V U GV K W S Q UN C UK G U T G X G T G J 6  P Q T G V C N F G I I G N K VN W O Q V G I P C J E F P C F G I I G N
Q Y V JV K Y V T C V U Q V [ U C G U •V K Q 5  T G V C N T G JV Q G J V Q V G P Q O Q T H T Q V E C H G T Q V [ U C G G VK W S [ N N C W U W
U • V K Q U U P QK V E C U P C T V F G I I G N Q Y V V T Q R R W U U P Q KV E C U P C T V F G I I G N KV N W O G M C O Q V [ U C G U •V +
 [ VK N C P QK V E P W H
T K G J V F G G P [ N G V K P K H G F W Q [ H K U P QK V E C U P C T V F G I I G N K V N W O G U W [N P Q Q 5  F GV C E K N R O Q E G T Q O
V KD F QQI C QU N C GT C UP QK VE CU P CTV F GII GN KV N W/ U PQ K V E CU PCT V FG II GN Q Y V U C J [ NP Q PK C O QF
TK G J V G U W C E G D V C J V V P C Y V • P Q F U P Q KV C E KN R R C [ P C O T G X G Y Q *  C U T G X G EK X T Q U N G Y C T F
J VK Y [ P C O O W U G D P C E VK U Q R G F GN I P K U C G T G J Y U GK T V P G V T Q R R W U Q V [ VK NK DK Z G NH T G V C G T I
G JV W Q [ G X K I U P QK V E C U P C TV F G I I G N K VN W /  U P Q K U T G X F G I I G N KV N W O T Q F G I I G N Q Y V G J V G U W
Q V T GJ V GJ Y GF KE GF Q V GX CJ PG J V WQ [   P QK V E C U P C T 6 I PK V P W Q E E # G U W Q V G F K E G F W Q [ H +
!FG I IG . KVN W/ T Q FGI IG . Q Y 6
 G E K T R P Y Q U• VK U F F C [ VK Z G N R O Q E F P C O G V
U [ U C Q V [V K Z GN R O Q E U F F C   P QK V E C U P C T 6 I PK V P W Q E E # U P T G V V C R [ P C O G MK .  [ T C U U G E G P
U• VK N G G H V• P Q F U V T G R Z G P K C O Q F G J V HK G T W V C G H C T V Z G P C U C V K G U W V• P N W Q J U W Q [ T CN W E K V T C R
P +  P T G VV C R G J V G U W QV P G J Y QV U C U V T G R Z G PK C O Q F T W Q [ [ D P G XK T F G D F N W Q J U W Q [ Q 5
GT Q O J EW O GF KX
Q T R V Q P FN W Q Y   P Q K V E C U P C T 6 I P K V P W Q E E # I P K U W “ G I F K T G X G N H Q [ V P G N R U C W Q [ U G XK I
V C JV U I QN G U C D CV C F G J V F P C G F Q E G E T W Q U G J V G PK O C Z G P C E W Q [ G E PK 5  U G T K U G F I P K U C J E
M C GN N N C [ H U KV C U N N G Y [ C O U K J V H Q [ V K N K D C G E C T V F P C I P K I I Q N G J 6  T G V W R O Q E G J V [ D G F C O
GTC UGKTVPG GJV NNC PGJY UK  PQKVECUPCT6 IPKVPWQEE # GUW QV VQP PQUCGT TGJVQP #
T G JV K G  P QKVEC UP C T6 IPKV PW Q EE #
G U W V • P Q Y W Q [   V P W Q E E # G U W V • P Q F W Q [ F P K H W Q [ H K Q 5    V P W Q E E # I P K U W G T• W Q [
HK  PQKVECUPCT6 IPKVPWQEE# GUW QV GUPGU UGMCO [NPQ [NNCGT VK VTCVU C TQ( PTGVVCR
G JV G U W PK C O Q F T W Q [ PK G N R Q G R G J V T G J V G J Y P Q U F P G R G F P T G V V C R U K J V H Q G U W T W Q [ U [ C Y
[PCO P+    P Q KV EC U P CT 6 I PKV P W Q EE # G U W U [ CY N C F NW Q JU W Q[ P C G O V• P U G Q F U K J 6
 VK H Q I PK M PK J V V W Q JV K Y V K G U W G N R Q G R V C J V
I PK V P W Q E E C H Q E K T D C H G J V P K R G G F Q U G D Q V P Y Q T I U• V K F G G F P +  V K G U W GN R Q G R V C J V J I W Q P G
U K J E K J Y F P K H Q V T G K U C G V K D G N V V KN V C J V U G M C O V K V W D F W C T H N N C G V C P K O K N G V • P U G Q F I P K R G G M
[ T V P G G N D W Q F G U T W Q E H Q Y Q 0  [ N U W Q K T GV UK O T C G R R C U U K F F P C T C G R R C Q V [ G P Q O Y Q N N C V U W L
Q V [ U C G Q Q V U• VK I P K R G G M Q Q D [ T V P G G N D W Q F V W Q J V K 9  F W C T H I PK V V C D O Q E U F T Q Y T G J V Q PK T Q
U M C G N I P K V P G X G T R F P C I P K F P K H P Q U V U G T NN C V K [ NN C E K U C $  G E C N R V U TK H G J V P K C G F K F Q Q I C J E W U
U C P G G U U C Y I P K R G G M Q Q D [ T V P G G N D W Q F [ J Y V W Q D C I PK M PK J V J V T Q Y U• V K UK J V T G Y U P C Q 6
VK GUW QV PGJ9

 P QK V E C U P C T V G J V Q V U G K T V P G G T Q O [ P C F F C V• P C E + F G V U Q R G X• + G E P Q F P C V U Q R
P C E + G T Q H G D Q T G \ QV G E P C N C D U GK T V P G G JV NN C V C J V M E G J E QV F G G P +  UV P W Q E E C G J V QV P Q KV
E C U P C T V G J V V U Q R P C E + P G JV U P QK V E C U P C TV G JV NN C G X C J + G E P 1  U N N C E F Q JV G O GV C T C R G U
J I W Q T J V V E G L D Q P QK V E C U P C TV C Q V U G K T V P G F F C Q V G N D C G D Q V F G G P + J E C Q T R R C U K J V J V K 9
 T G J V G I Q V U G E GK R G J V NN C G X C J + G E P Q
UV P W Q E E C G J V Q V VK V U Q R P G J V F P C [ NN C W F C T I P QK V E C U P C TV G J V T G J V G I Q V V W R P C E + V C J V Q U
  V E GL D 1 F G U Q R Q T 2 I PK U W O• + G U C E UK J V P +  P QK V C FK N C X U F G G P F P C G V C G T E Q V V T Q H H G G T Q O

. 1
( 2)



>>