Free Essay

Pharma

In:

Submitted By nickliab
Words 41707
Pages 167
UGKTVPG IPKVPWQEEC GVCKTRQTRRC GEWFQTR FPC UVPGXG UUGPKUWD GMCV QV UK IPKVPWQEEC HQ GNQT GJV VCJV IPKVCEKFPK PQQVTCE GXKVUGIIWU [NNWHGRQJ VWD UUGNIPKPCGO #  GTWIK(

 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

Events

System Accounting Entries

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

T Q U U G E Q T 2 V P G X ' G N R OK 5

 GTWI K(

  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

Event reads Processor creates

process(Event) Accounting Entry



 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 C G [ 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

V P GOG GTIC GJV VW Q I PKVCT C RG5 process(Event)    G T W IK (

 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



process() findAgreement(Event) Event

find

Agreement

creates

Accounting Entry

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 W I 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 JI KG 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

GTWVEKR GJV QV UGNWT IPKVUQR FPC UGR[V VPGXG IPKFF#

 GTWI K(

process() findAgreement(Event)

Event Type



1

Event

1

find



getRule(EventType) process(Event)

Posting Rule

Agreement

✻ creates 1
Accounting Entry



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

GPKVW QTD WU [ D EK IQN IP KU UGE QTR QF   

 OT Q H G J V HQ EK IQ N G XC J F N WQY J EK J Y T QUU GE QT R N CT WFG EQT R C G P KI 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 +

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

UGTWVEWTV5 VEGLD1 FPC PQKVKUQROQEG& NCTWFGEQT2
 G V C F [ D [ T C X Q V U G N WT I P K Y Q N N # getRule(EventType, Date)

   G T W IK (

 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



process() findAgreement(Event) Event Type



1

Event

1

find



process(Event)

effectivity: Date Range

Posting Rule

Agreement

✻ creates Accounting Entry

1

 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

V PGXG VPG OVU WLFC GVCT C RG5

   G T W IK (

[NVEGTK F V P GXG UWQ GPQTTG PC IPKV UWL F#

   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



0..1

replacement

old events

0..1 ✻
Accounting Event Accounting Event Adjustment



0..1 adjusted event old events

   G T W IK (

0..1

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

NCUTGXG4

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

UGKTVPG IPKVNWUGT UVK FPC VPGXG PC PGGYVGD MPKN C IPKRGG-

 GTWI K(

Event source

1



Accounting Entry

 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 P G O V U WL F C G N I P K U C Q V P K

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 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 TG 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'

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 %



subject

1



:/28

when ocurred : DateTime when noticed : DateTime Event



1

Event Type

 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 '

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 '

 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

interface Event { Event newEvent (EventType type, AccountNumber account, Date whenOccurred, Date whenNoticed); EventType getType(); AccountNumber getAccount(); Date getWhenOccurred(); Date getWhenNoticed();

GFQ% GNROC5

VK GUW QV PGJ9



 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 interface Event... boolean isProcessed(); Set getResultingEntries(); void addResultingEntry(Entry arg); ...

 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+ interface Sale extends Event { Sale newSale (AccountNumber account, Date whenOccurred, Date whenNoticed, Vendor vendor, Money amount); Vendor getVendor(); Money getAmount();

 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 ;

VPGXG PC HQ UVTCR GNDCVWOOK FPC GNDCVWO GJV IPKVCTCRGU HQ [CY GP1 vendor amount

 GTWI K(

type account whenOccurred whenNoticed

Sale {frozen} Event {frozen} Implementation Perspective

1

isProcessed resultingEntries Event Process Log



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 '

[G PQO HQ OW U C HQ P QKVCEQ NNC P#



when booked : DateTime amount: Money Accounting Entry

#EEQWPVKPI 'PVT[



✻ descriptor UTQVRKTEUGF UC GR[V VUQE FPC VEGLQT2

 GTWI K(

    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


Entry accounting entry



Accounting Entry

1


descriptors

Project

1

Cost Type

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.

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 '  PT G V V C 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 interface Entry { Entry newEntry (CostType costType, Project project, Money amount, Date date); CostType getCostType(); Project getProject(); Money getAmount(); Date getBookingDate();

 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 +

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 W QT GI PC F C GT C U NG F Q O E K TG P G I TG X Q J EW 5 I P K J 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 G XG P G J Y U G KT V P G GU W F N WQ JU W Q ;



void setCostType (CostType arg) { if (isOpen()) costType = arg else throw new ImmutableEntryException(); }

GFQ% GNROC5
V UTKH OK Y U

VK GUW QV PGJ9

VPGXG TCNWEKVTCR C [D FGVCGTE GTGY UGKTVPG JEKJY NNGV PCE WQ[ VCJV IPKTWUP'  GTWIK(

 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

Event source

1



Accounting Entry

 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 '

VPGXG PC QV GUPQRUGT PK GMCO QV UGKTVPG IPKVPWQEEC VCJY UGPKOTGVG&



Event Type host

1 1

2QUVKPI 4WNG



process(Event) Posting Rule



´ createsª

Accounting Entry

 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 +

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 %

    G T W IK (



Accounting Event Event Type

✻ 1 event type



1
Service Agreement Posting Rule

✻ 1 host accounting entry event type date posting rule

Customer

1 ✻

✻ 1
Posting Rule Entry ´ createsª

 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  V PG O QO C P K T QKX C JGD 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

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

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

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


 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 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 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 GN R O K U [ V V G T R Q U N C UK T G O Q V U W %

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

 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  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 VK TGFKUPQE + GNROCZG GNROKU UKJV TQ( RCO GJV PK [GM VCJV TQH PQKVEGNNQE NCTQROGV GJV 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 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

GXCJGD UGUUCNE GJV YQ*

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

 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 class MultiplyByRatePR extends PostingRule{ public MultiplyByRatePR (EntryType type) { super(type); } protected Money calculateAmount(AccountingEvent evt) { Usage usageEvent = (Usage) evt; return Money.dollars(usageEvent.getAmount().getAmount() * usageEvent.getRate()); } }

 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/ public class Usage extends AccountingEvent { private Quantity amount; public Usage(Quantity amount, MfDate whenOccurred, MfDate whenNoticed, Customer customer) { super(EventType.USAGE, whenOccurred, whenNoticed, customer); this.amount = amount; } public mf.Quantity getAmount() { return amount; } double getRate() { return getCustomer().getServiceAgreement().getRate(); } }

 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



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

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

 GTWI K(


PostingRule AccountingEvent process(AccountingEvent) calculateAmount(AccountingEvent) UsageEvent amount : Quantity {type = USAGE} MultiplyByRatePR calculateAmount(AccountingEvent)

 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 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)); acm.setServiceAgreement(standard); } ...
UG QF V K VCJY FPC F GMQ XPK UK GNWT IP KVU QR C Y Q*

 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
    G T W IK (



process

usage event

find rule

get posting rule (usage event type, occurred date)

process (usage event)

get amount of usage

service agreement

get rate multiply by rate posting rule

new

usage entry

 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 public void testService() { AccountingEvent evt = new MonetaryEvent( Money.dollars(40), EventType.SERVICE_CALL, new MfDate(1999, 10, 5), new MfDate(1999, 10, 5), acm); evt.process(); Entry resultingEntry = (Entry) acm.getEntries().get(0); assertEquals (Money.dollars(30), resultingEntry.getAmount());

 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 class MonetaryEvent extends AccountingEvent { Money amount; MonetaryEvent(Money amount, EventType type, mf.MfDate whenOccurred, mf.MfDate whenNoticed, Customer customer) { super(type, whenOccurred, whenNoticed, customer); this.amount = amount; } public mf.Money getAmount() { return amount; } } 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 resultingEntry = getEntry(acm, 0); assertEquals (Money.dollars(500), resultingEntry.getAmount()); }

 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



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

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


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

 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
G I PCJ% GN W4 C I PKN FPC *
 G IT C J E

 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+

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

 GTWI K(

 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 effectivity = later than Oct 1 1999

standard : Service Agreement event type = SERVICE CALL effectivity = starts Oct 1 1999, ends Dec 1 1999

event type = SERVICE CALL effectivity = starts Dec 1 1999

a MultiplyByRatePR entry type = BASE USAGE

an AmountFormulaPR entry type = SERVICE multiplier = 0.5 fixed fee = $10

an AmountFormulaPR entry type = SERVICE multiplier = 0.5 fixed fee = $15

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()); }

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


[ 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 , 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 FKCR YQN TQH [NRRC VJIKO UTQVCNWIGT VCJV GNWT C GMCV U•VG. UVPGOGGTIC YGP RQNGXGF 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 VC FGITCJE GTC [GJV J YM PCJV UUGN UGUW PQUTGR C HK VCJV [CU VJIK O GNWT C JEW5 GNRQGR 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  V P G O G G T I C TK G J V  V K O K N Q V G I CU W

VPG OGG T I # F PQEG 5 #

 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 public void testLowPayUsage() { Usage evt = new Usage( Unit.KWH.amount(50), new MfDate(1999, 10, 1), new MfDate(1999, 10, 1), reggie); evt.process(); Usage evt2 = new Usage( Unit.KWH.amount(51), new MfDate(1999, 11, 1), new MfDate(1999, 11, 1), reggie); evt2.process(); Entry resultingEntry1 = (Entry) reggie.getEntries().get(0); assertEquals (Money.dollars(250), resultingEntry1.getAmount()); Entry resultingEntry2 = (Entry) reggie.getEntries().get(1); assertEquals (Money.dollars(510), resultingEntry2.getAmount()); }

 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 private void setUpLowPay (){ reggie = new Customer("Reginald Perrin"); ServiceAgreement poor = new ServiceAgreement(); poor.setRate(10); poor.addPostingRule( EventType.USAGE, new PoorCapPR(EntryType.BASE_USAGE, 5, new Quantity(50, Unit.KWH))); poor.addPostingRule( EventType.SERVICE_CALL, new AmountFormulaPR(0, Money.dollars (10), EntryType.SERVICE)); reggie.setServiceAgreement(poor); }



 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
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 ; U GN WT I P KV U Q R [TC FP QEG U

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 class PostingRule... public void process (AccountingEvent evt) { makeEntry(evt, calculateAmount(evt)); if (isTaxable()) new TaxEvent(evt, calculateAmount(evt)).process(); }

 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 class Tester... public void setUpRegular (){ acm = new Customer("Acme Coffee Makers"); ServiceAgreement standard = new ServiceAgreement(); ... standard.addPostingRule( EventType.TAX, new AmountFormulaPR(0.055, Money.dollars(0), EntryType.TAX), new MfDate(1999, 10, 1)); acm.setServiceAgreement(standard); }



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 NNCE QV VPCY VUWL WQ[ GTGJY UGUCE GNR OKU TQH NNGY UMTQY
 G NW4 I PKV UQ2 [ TC FPQEG 5

 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 + class TaxEvent extends MonetaryEvent { private AccountingEvent base; public TaxEvent(AccountingEvent base, Money taxableAmount) { super (taxableAmount, EventType.TAX, base.getWhenOccurred(), base.getWhenNoticed(), base.getCustomer()); this.base = base; Assert.isFalse("Probable endless recursion", base.getEventType() == getEventType()); } }

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

IPKUUGEQTR GJV QV VPGXG ZCV C IPKFF#

    G T W IK (



class PostingRule... private boolean isTaxable() { return !(type == EntryType.TAX); }

process

usage event

find rule

get posting rule (usage event type, occurred date)

process (usage event)

get amount of usage

service agreement

get rate

multiply by rate posting rule

new

new

usage entry

process tax event

 V C J V T Q H V U G V C U• G T G * class AccountingEvent... Set getAllResultingEntries() { Set result = new HashSet(); result.addAll(resultingEntries); Iterator it = secondaryEvents.iterator(); while (it.hasNext()) { AccountingEvent each = (AccountingEvent) it.next(); result.addAll(each.getResultingEntries()); } return result; }

 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

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

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 [

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 TaxEvent... public TaxEvent(AccountingEvent base, Money taxableAmount) { super (taxableAmount, EventType.TAX, base.getWhenOccurred(), base.getWhenNoticed(), base.getCustomer()); this.base = base; base.friendAddSecondaryEvent(this); Assert.isFalse("Probable endless recursion", base.getEventType() == getEventType()); ... class AccountingEvent ... private List secondaryEvents = new ArrayList(); void friendAddSecondaryEvent (AccountingEvent arg) { // only to be called by the secondary event's setting method secondaryEvents.add(arg); }

 N CP QK VE GTKF

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

  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



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 XG PG J 9  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 #

  [ T V P ' I PK V P W Q E E #

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

TQKXCJGD IPK\KTCOOWU GFKXQTR FPC UGKTVPG IPKVPWQEEC FGVCNGT TGJVGIQV VEGNNQ%



balance balance (DateRange) withdrawels(DateRange) deposits(DateRange) Account

#EEQWPV

1


Entry

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

UTQVRKTEUGF UVK FPC [TVPG PC PGGYVGD PQKVEGTKFPK HQ GXGN C UC VEC PCE UVPWQEE#

 GTWI K(

 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

Entry







Entry

1




Account



1

1

1



1

1 1
Entry Type Customer Location

Entry Type Customer Location



 V• P Q F V Q P H K

  V P W Q E E # G UW Q V G U P GU UG M C O VK P G J V

UV PW QE EC H Q U OT GV P K F NT Q Y

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

 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

F G V C E KN R O Q E G T Q O [ P C UK

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

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  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 W QEE # GU W QV GI TW GJ V NG GH Q V F P G V +

VK GUW QV PGJ9
  IC $[GPQ /

 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 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 class Account... Money balance(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())) result = result.add(each.amount()); } return result; } Money balance(MfDate date) { return balance(DateRange.upTo(date)); } Money balance() { return balance(MfDate.today()); }

 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 class Account ... private Collection entries = new HashSet(); private Currency currency; void addEntry(Money amount, MfDate date){ Assert.equals(currency, amount.currency()); entries.add(new Entry(amount, date)); }

 GN R OKU [T GX UK U G KTV P G I PK VE GN U GK T V P G T G J V G I Q V I PK

NQ %  PQ KV C OT QHP K [T C O O WU I PK FK X QTR F P C

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

  [T VP' I PKV PWQ EE #

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 QH

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

P Q UK T G X H Q C G FK G J V I PK [ N R R C U C P Q KUT G X H Q C G F K G J V F P C



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

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

Account

#EEQWPVKPI 6TCPUCEVKQP

1



amount: Money

Entry

{sum of amounts of entries equals 0}

2

1

Accounting Transaction

QY V M PK.



UGKTVPG VWQJVKY PQKVECUPCTV IPKVPWQEEC PC TQH OCTICKF UUCNE #
1 to ✻
J EPCT D G OCU GJV VC

    G T W IK (

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

PQKVECUPCTV FGIIGN QYV C HQ GNROCZG P#



checking: Account

cash: Account

Account

1 from
U GV C F G V CT C R G U

amount = -$100

amount = $100

an Entry

an Entry

✻ an Accounting Transaction

amount: money Accounting Transaction

    G T W IK (

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(

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(

checking: Account royalties: Account salary: Account Account

1



amount: Money

amount = $150 amount = - $100 amount = - $50 Entry an Entry an Entry an Entry {sum of amounts of entries equals 0}

2..✻

1

an Accounting Transaction Accounting Transaction

U V P W Q E E C



 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 VE CU PCT V FG II GN Q Y V UC 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

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

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

  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

GU W V• PQ Y WQ [ HK

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+ 

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 #   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 [  PQKVECUPCT6 IPKVPWQEE# GUW QV GUPGU UGMCO [NPQ [NNCGT VK VTCVU C TQ( PTGVVCR

  P Q K V E C U P C T 6 I P K V P W Q EE # G U W U [ C Y N C F N W 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 UK P QK V E C U P C T V F G I I G N K VN W O C G E P K U F T C Y M Y C G T Q O V K D F Q Q I C U K G U C E F G I I G N K V N W O G J 6

  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

FGIIG. KVNW/ GFQ% GNROC5 public void testBalanceUsingTransactions() { revenue = new Account(Currency.USD); deferred = new Account(Currency.USD); receivables = new Account(Currency.USD); revenue.withdraw(Money.dollars(500), receivables, new MfDate(1,4,99)); revenue.withdraw(Money.dollars(200), deferred, new MfDate(1,4,99)); assertEquals(Money.dollars(500), receivables.balance()); assertEquals(Money.dollars(200), deferred.balance()); assertEquals(Money.dollars(-700), revenue.balance()); } void withdraw(Money amount, Account target, MfDate date) { new AccountingTransaction (amount, this, target, date); }

 J V K Y M T Q Y Q V T G K U C G V Q N C U P Q K V C N W RK P C O T Q H G F Q E G J V U G M C O U K J 6

 VE GL D Q V PW QEE C GJ V P Q F QJ VG O G N D CV KWU C G FK X QTR

QV GUPGU UGMC O VK [NVEGTKF TQVEWTVUPQE PQKVECUPCTV IPKVPWQEEC IPKUW PCJV TGJVC4 P QK VP GX P QE I PKF QE F P C T Q VEW TV UP QE G J V T QH UU GEE C GI CME C R H Q PQ KV C PKD O Q E C U K U K J V C X C , P +  U P Q K V E C U P C T V H Q U U G E Q T R G J V P K P C J V T G J V Q U G K T V P G G V C G T E V• P C E W Q [ V C J V Q U F GV EK T V U G T G D Q V [ T V P G T Q H T Q V E W TV U P Q E G J V G M C O Q V F G G P V U WL W Q [ U K J V J VK 9 public class AccountingTransaction { private Collection entries = new HashSet(); public AccountingTransaction(Money amount, Account from, Account to, MfDate date) { Entry fromEntry = new Entry (amount.negate(), date); from.addEntry(fromEntry); entries.add(fromEntry); Entry toEntry = new Entry (amount, date); to.addEntry(toEntry); entries.add(toEntry); }

V E G L D Q P QK V E C U P C TV I PK V P W Q E E C G N R OK U C U F G G P V U W L [N N C G T G U C E F G I I G N Q Y V G J V F G G F P+

GU C E F GII GN Q Y V T GN R OKU G JV J V K Y I PK V T C V U U G U C E F G I I G N K VN W O F P C F G I I G N Q Y V G J V J V Q D T Q H G F Q E G N R O C U W Q [ G X K I N N• +

FGIIG. QY6 GFQ% GNROC5


 P Q K V E C U P C T V G J V V U Q R P G J V P C E + P Q K V E C U P C T V G J V Q V U G K T V P G F G F F C G X• + G E P 1 class Entry... private Money amount; private MfDate date; private Account account; private AccountingTransaction transaction; Entry(Money amount, MfDate date, Account account, AccountingTransaction transaction) { // only used by AccountingTransaction this.amount = amount; this.date = date; this.account = account; this.transaction = transaction; }

UMP K N [ C Y QY V GJ V IP KP KC VP K C O J V KY N CG F Q V T GKU C G J EW O V K U GMC O J EK J Y

GN D C V W O O K G T C U G K T V P '  V P W Q E E C G JV F P C P QK V E C U P C TV G J V J V Q D F P C [ T V P G G J V P G G Y V G D U P Q K V CK E Q U U C N C P QK V E G TK F K D G X T G U G T R Q V U U CN E [ T V P G V P G T G H H K F C I P K U W O• + G U C E UK J V P + class Transaction... public void add (Money amount, Account account) { if (wasPosted) throw new ImmutableTransactionException ("cannot add entry to a transaction that's already posted"); entries.add(new Entry (amount, date, account, this)); }

 F G VU Q R P G G D [ F C GT N C

V • P U C J P Q K V E C U P C T V G J V I P K F K X Q T R P QK V E C U P C T V G J V Q V U G K T V P G U F F C F Q J V G O F F C G J 6  PK CN R Z G Q V T G N R O K U F C V C U I PK JV U G M C O VK V W D M P C D J U KV K T $ F N Q [ O G N F P C J V • P F N W Q Y U K J 6  P QK V E C U P C T V G N Q J Y G J V T Q H G V C F G P Q G X C J + G N R O C Z G U K J V J V K Y Q 5 public class AccountingTransaction { private MfDate date; private Collection entries = new HashSet(); private boolean wasPosted = false; public AccountingTransaction(MfDate date) { this.date = date; }

 T Q V E W T V U P Q E F P C U F N G K H G J V J VK Y I P K V T C V U G F Q E G J V N C G X G T N N• +



F G I I G N K VN W O C G U W Q V F T C Y M Y C Q U U• VK [ J Y Q V U V PK Q R U U G PK U W D V U Q R F P C R W V G U U K J V N N #

H Q G O Q U U P QK V E C U P C TV F G I I G N Q Y V F G G P [ N P Q W Q [ HK V C J V U K U Y G P F Q Q I G J 6  P QK V E C U P C TV

 P QK V E C U P C T V F G I I G N K VN W O C J VK Y G E C H T G V P K F G I I G N Q Y V G J V V P G O G N R O K P C E W Q [ G O K V G J V

 UK J V G M K N G F Q E J V K Y P Q K V E C U P C T V G J V G U W P G J V P C E +

 class AccountingTransaction... public void post() { if (!canPost()) throw new UnableToPostException(); Iterator it = entries.iterator(); while (it.hasNext()) { Entry each = (Entry) it.next(); each.post(); } wasPosted = true; } public boolean canPost(){ return balance().isZero(); } private Money balance() { if (entries.isEmpty()) return Money.dollars(0); Iterator it = entries.iterator(); Entry firstEntry = (Entry) it.next(); Money result = firstEntry.amount(); while (it.hasNext()) { Entry each = (Entry) it.next(); result = result.add(each.amount()); } return result; } class Entry... void post() { // only used by AccountingTransaction account.addEntry(this); } AccountingTransaction multi = new AccountingTransaction(new MfDate(2000,1,4)); multi.add(Money.dollars(-700), revenue); multi.add(Money.dollars(500), receivables); multi.add(Money.dollars(200), deferred); multi.post(); assertEquals(Money.dollars(500), receivables.balance()); assertEquals(Money.dollars(200), deferred.balance()); assertEquals(Money.dollars(-700), revenue.balance());

class Account... void withdraw(Money amount, Account target, MfDate date) { AccountingTransaction trans = new AccountingTransaction(date); trans.add(amount.negate(), this); trans.add(amount, target); trans.post(); }



FGVCGTE [NNCKEKHHQ U•VK GTQHGD VEGLDQ PC HQ UNKCVGF GJV FTQEG4

VEGLD1 FGUQRQT2
[EPGTTWE GXKVCP TKGJV PK UGKEPGTTWE VPGTGHHKF HQ UGKPQO UWQKTCX UFNQ*

IC$[GPQ/
 G V C F C P G X K I G W N C X G N I P K U C U P T W V G T V C J V P Q K V E GN N Q E #

[VTGRQT2 NCTQROG6
GXKVEGHHG UK VEGLDQ GJV PGJY GVCEKFPK QV VEGLDQ GJV JVKY GIPCT GVCF C FTQEG4

FQKTG2 [VKXKVEGHH'
U V P W Q E E C F P C U GN W T I PK V U Q R H Q G T W V E W T V U J R C T I #

MTQYVG0 GNW4 IPKVUQ2



   GT W IK( PK U V E GLD Q GJ V U FN GK [ UK J 6 N K T R # H Q J V   G J V P Q F G U U G E Q T R F P C N K T R # J V  P Q F G F T Q E G T [N N C P K IK T Q U C Y V P G X G UK J 6  J E T C / PK G I C U W [ V K EK T V E G N G H Q U T W Q J J Y M   H Q F T Q E G T C G X C J G Y [ C U U• V G N Q 5 UG KT VP G NC OT QP T Q H Q F WQ [ VC J V [ C Y G O CU G JV UK J V G V C NW E N CE P CE W Q[ P G G D G XC J F N WQ J U V P W Q O C Y G P G J V V C J Y U K J EK J Y [ T V P G Y G P C V U Q R W Q [ P G J 6  P I K U G V K U Q R R Q J V K Y V P W Q O C G O C U G J V F P C G V C F F G T T W E E Q G O C U G JV I P K U W [ TV P G U W QK X G T R G JV H Q N C U T G X G T G N R OK U C UK [T VP G G P 1 U GKT V P G Y GP Q Y V G V CGT E W Q [ FG VU WL F C GD Q V U FGG P V C J V [T V PG JE CG T Q(

MTQY VK IPKMC/

 UK JV G NFP C J Q V [ CY G NR O KU C UV PG UGT RGT N CUT GXG 4  VE GHH G VG P G OC U G J V G XC J N NK Y V C J V U GK T V P G Y G P G V C G T E Q V F G G P W Q [ P G J V I PK V U WL F C P G J Y U GK T V P G V K F G V• P C E W Q [ H +

 UGKT VPG VPGOGECNRGT VEGTTQE IPKVCNWENCE PGJV FPC UGKTVPG IPKUTGXGT IPKVUQR [D UGKTVPG IPKVKUKZG VUWLF#



replacement event

adjusted event

amount = 60 kwh amount = 50 kwh original Usage Event new Usage Event resulting entries

4GXGTUCN #.LWUVOGPV

resulting entries amount = $600 amount = ($500) amount = $500 reversing Usage Entry replacing Usage Entry original Usage Entry

V P G O V U WL F C G J V T G V H C U V E G L D 1     G T W I K (

 P K C I C F G V U W L F C G D V• P F N W Q J U Q U F P C F G V U W L F C P G G D U C J V K V C J V T C G N E V K G M C O Q V F G V U W L F C U C V P G X G V C J V M T C O Q UN C G 9  V P G X G N C PK I K T Q G JV P Q O G J V V W R QV F C G V U P K G U P G U U G M C O VK Q 5  U GK T V P G I PK U T G X G T G J V G U T G X G T V C J V U GK T V P G G E W F Q T R Q V V P C Y V • P Q F G Y G U C E V C J V PK F P C T G V CN F G V U WL F C V G I H N G UV K [ C O V P G X G Y G P G J V G U W C E G D U K U K J 6  G P Q Y G P G JV V Q P F P C V P G X G FN Q G J V P Q U T C G R R C [ TV P G I PK U T G X G T G J V V C J V F G U K T R W U G D V J I K O W Q ;      G T W IK ( H Q G T W V E W T V U G J V PK UV N W U G T UK J 6  J Y M   P G G D GXCJ FNWQJU VPWQ OC GJV FPC GFC O UCY GMCVUKO C VCJV G\KNCGT GY GPW, VU PQ PGJ6

V P G O V U WL F C G T Q H G D U V P G X '     G T W I K (

replacement event

adjusted event

amount = 60 kwh when occurred = 1 Oct 99 when noticed = 15 Oct 99 has been adjusted = false amount = 50 kwh when occurred = 1 Oct 99 when noticed = 5 Oct 99 has been adjusted = true original Usage Event

amount = 50 kwh when occurred = 1 Oct 99 when noticed = 5 Oct 99

new Usage Event

a Usage Event

resulting entries

resulting entries

amount = $500 date = 5 Oct 99

amount = $600 date = 15 Oct 99 amount = ($500) date = 15 Oct 99 amount = $500 date = 5 Oct 99 reversing Usage Entry replacing Usage Entry

a Usage Entry

original Usage Entry



   T G D Q V E Q P Q J Y M   T QH G I C U W Y G P C J VK Y VK V U WL F C P G J V F P C  T G D Q V E Q P Q J Y M   T QH G I C U W N C PK I K T Q P C G V C G T E G Y G F Q E V U G V T W Q PK Q 5  F G V UK Z G T G X G P V P G X G F N Q G J V V C J V T C G R R C V K G M C O U G E P C N C D [ P C V C J V Q U V P G X G FN Q G J V V U WL F C Q V V P G X G Y G P G J V V P C Y G 9  GN R OK U [N G X KV R G E G F U K V P G O V U W L F C T QH F G G P G Y V C JV T Q K X C J G D N C P T G V Z G G J 6    G N W 4 I P K V U Q 2 T Q H G F Q E G N R O C U G J V P Q F G U C D U K G F Q E GN R O C U U K J 6

GFQ% GNROC5


 VPGOVUWLF# NCUTGXG4 FPC  VPGOVUWLF# VPGOGECNRG4 HQ PQKVCP  VPGOVUWLF# VPGOGECNRG4 GUW QV VUGD U•VK PGJV GNDCVWO   V P G O V U WL F # G E P G T G H H K &

K D O Q E C QV W Q [ F C GN N N K Y UK J 6  V C J V T G VH C GN D C V W O O K F P C G V C F P K C V T G E C QV R W G N D CV W O G T C U G K T V P G F P K H N N• W Q [ P G V H 1  GT C U G KTV P G G JV H+  P Q KV C OT QH P K G J V G GU Q V V P C Y UT GU W T W Q [ Y Q J P Q F P G R G F N N K Y O G J V P G G YV G D G EK Q J E G JV [N N C W U 7  G X KV C P T G VN C N C RK E P K T R G J V U K  F P W Q T C G X C J Q V P K C R C N N K V U P G V H Q G T C [ G J V G U G J V T GV NK H P C E W Q [ G NK J 9  U T K C R F G U T G X G T P K [ P C O U G K TV P G H Q V Q N C J V K Y R W F P G W Q [ F P C U G O K V Y G H C U K J V Q &  G T Q H G D F C J W Q [ G P Q [ T G X G T Q H U GK T V P G G G T J V G X C J W Q [ G P Q F G T• W Q [ G E P Q  U G K T V P G H Q V Q N C PK V N WUGT [G JV V C J V UK GI C V P CXF CU KF P KC O T KGJ 6  W Q [ U W JV F P C GN D C V W O O K G T C U GK T V P G P G J Y G XK V C P T GV N C G N R O K U V U Q O G JV G T C U N C U T G X G 4

 VPGOVUWLF# VPGOGECNRG4 GUW V•PCE

VK GUW QV PGJ9

 N N G Y U C U G K T G W S G U C D C V C F T W Q [ V E G HH C [ N N C W U W N N K Y U K J V F G X N Q X PK G D P C E C V C F H Q V QN C G E PK 5  P QK V C O T Q H P K U K J V T QH U T G VN KH V C J V F Q J V G O [ T G W S C G F K X Q T R Q V F G G P NN• W Q [ Q 5  F G F WN E Z G U TK C R N C U T G X G T G J V N N C J V K Y U GK T V P G G J V G G U Q V V P C Y P G V H Q N N• [ G J V U G K T V P G H Q V UK N C G G U Q V U V P C Y G P Q [ P C H K V C J V U P C G O U K J V Q 5  U T K C R N C U T G X G T G U G J V P K U G K T V P G H Q V Q N C PK U V N W U G T

  V P G O V U W L F # N C U T G X G 4 I PK U 7



 V P G X G F GV U W L F C G J V U G M C V V C J V T QV E W T V U P Q E C J VK Y F GV C G T E U K V P G X G I PK V U WL F C G J V “ T Q V E W T V U P Q E G JV P K U GK N G E P G T G HH K F [N P Q G J V V P G X G T C N W I G T C U C U U C N E G O C U G J V UK V P G X G I P K V U WL F C G JV P QK V C V P G O GN R O K U K J V P +

 V P G X G F G V U W L F C G J V I PK U T G X G T G F W N E P K Y Q P V U W O V P G X G P C I P K U U G E Q T 2  F G U U G E Q T R UK V P G X G G J V P G J Y U G O Q E J E C Q T R R C G J V Q V G I P C J E F P Q E G U G J 6  F G V U WL F C P G G D [ F C G T N C V• P U C J V P G X G F G V U WL F C G J V V C J V U G T W U P G Q U N C V+  V P G X G V P G O G E C N R G T G J V F P C F G V U WL F C G J V P G G YV G D M PK N G J V R W U V G U T Q V E W TV U P Q E UK J 6

 class Tester... public void setUp(){ setUpRegular(); setUpLowPay(); usageEvent = new Usage( Unit.KWH.amount(50), new MfDate(1999, 10, 1), new MfDate(1999, 10, 1), acm); eventList.add(usageEvent); eventList.process(); } public void testAdjustment() { Usage adjustment1 = new Usage ( Unit.KWH.amount(70), new MfDate(1999, 10, 1), new MfDate(1999, 10, 15), usageEvent); eventList.add(adjustment1); eventList.process(); assertEquals(Money.dollars(700), acm.balanceFor(EntryType.BASE_USAGE)); assertEquals(Money.dollars(38.5), acm.balanceFor(EntryType.TAX)); class AccountingEvent... private AccountingEvent adjustedEvent, replacementEvent; AccountingEvent (EventType type, MfDate whenOccurred, MfDate whenNoticed, AccountingEvent adjustedEvent) { if (adjustedEvent.hasBeenAdjusted()) throw new IllegalArgumentException (The " + adjustedEvent + " is already adjusted"); this.type = type; this.whenOccurred = whenOccurred; this.whenNoticed = whenNoticed; this.adjustedEvent = adjustedEvent; adjustedEvent.replacementEvent = this; } protected boolean hasBeenAdjusted() { return (replacementEvent != null); }

class AccountingEvent... public void process() { Assert.isFalse ("Cannot process an event twice", isProcessed); if (adjustedEvent != null) adjustedEvent.reverse(); findRule().process(this); isProcessed = true; } void reverse() { Collection entries = new HashSet(getResultingEntries()); Iterator it = entries.iterator(); while (it.hasNext()) { Entry each = (Entry) it.next(); Entry reversingEntry = new Entry( each.getAmount().reverse(), whenNoticed, each.getType()); getCustomer().addEntry(reversingEntry); this.addResultingEntry(reversingEntry); } reverseSecondaryEvents(); } private void reverseSecondaryEvents(){ Iterator it = getSecondaryEvents().iterator(); while (it.hasNext()) { AccountingEvent each = (AccountingEvent) it.next(); each.reverse(); } }



I PKUU GE QTR VPGX G HQ VTCR VPG OVU WLFC GJV I PKYQJU OCT ICKF GE PGW SG 5

 GTWI K(

 replacement event process [adjusted event != null] reverse * get information * create reversing entry adjusted event an existing Entry secondary event of adjusted event * reverse find rule continues with usual process

P GG D G XC J FN W Q J U [ T V P G V C JV V C J Y F P C [ TV P G N C P K IK T Q G JV P G G Y V G D G E P G T G HHK F G J V U PK C V P Q E V C J V [ T V P G G P Q V U W L J VK Y V P G O V U WL F C G J V G M C O W Q [

  VPGO VU WLF # V PGOGEC NRG4 J V K 9

 [T VP G VP G O

GECNRGT GJV FPC [TVPG IPKUTGXGT C GTQO QYV GMC O WQ[ [TVPG NCPKIKTQ JECG TQ( UGKTVPG H Q V Q N C PK UV N W U G T V K V W D UK J V Q F Q V [ C Y GN R OK U C UK Y G P G M C O Q V F G G P W Q [ G M C V U K O C F P K H W Q [ P G J Y U GK T V P G G J V VK F G V• P C E W Q [ H +

  V P G O V U W L F # N C U T G X G 4  U GK T V P G

FGFTQEGT PGGD GXCJ FNWQJU VCJY FPC FGFTQEGT UCY VCJY PGGYVGD VPGTGHHKF GJV VEGNHGT JEKJY UGKTVPG JVKY VPGXG UWQGPQTTG PC VUWLF#



amount = 60 kwh amount = 50 kwh replacement event adjusted event original Usage Event new Usage Event

&KHHGTGPEG #.LWUVOGPV

resulting entries resulting entries

amount = $100 amount = $500 adjusting Usage Entry original Usage Entry

GE C N R GT F P C G UTG X GT G OC U G J V Q & U GU W

Q T R G O C U G J V H Q J E W O G U W Q V UK NN G Y T G J V C T M T Q Y P G G U G X• + J EK J Y G X K V C P T G V N C G J 6

  VPG O VU WLF # NC UTGXG4 V C J V J E C Q T R R C I P KUU G E
 FT C Y M Y C V W D G N D KUU Q R P K U V P G X G Q Y V P G G Y V G D

E P G T G H HK F G J V V W Q G T W I KH Q V U G N W T I P K V U Q R G J V PK U V T C O U [ T C U U G E G P G J V I P K F NK W $  U G K T V P G I P KV U WL F C G U G J V G V CN W E C E Q V Y Q J V W Q G T W I KH QV [ T V W Q [ U C U G O Q E P Q KV C E K N R O Q E G J 6

MTQY VK IPKMC/
 U V P G O G E CN R G T

F P C UN C U T G X G T G J V J I W Q T J V [ C Y T W Q [ M T Q Y Q V I P K X C J P C JV T G J V C T V P G O V U WL F C T C N W EK V T C R C [ D FG UW CE G E PGT GHH KF G JV G G U [ NKU C G P C E WQ ; T GT CG NE U IP KJ V GM C O P CE QUN C VK G V C GTE QV G X C J W Q [ U G KTV P G H Q V P W Q O C G JV P Q P Y Q F V W E U K J V U G Q F V U W L V Q 0  UV U G I I WU     GT W I K ( U C [ T V P G I P K V U W L F C G P Q J VK Y U G K TV P G U W Q G P Q T T G N C T G X G U Z KH P G VH Q P C E W Q [ F G G F P+
[TV PG G PQ JVKY U VPGX G NCT GXGU IP KI PCJ %

 GTWI K(

amount = 50kwh amount = 50kwh amount = $500 :Usage Event :Usage Event :Entry

old events

new events

amount = 50kwh amount = 80kwh amount = $800 :Usage Event :Usage Event :Adjustment :Entry

amount = 50kwh amount = 75kwh amount = $750 :Usage Event :Usage Event :Entry amount = ($550) :Entry



V PW QE EC G IC UW GJ V HQ [ RQ E C I PK M CV U P C G O U K J V [N N CK V P G U U '  U V P W Q E E C Y Q F C J U H Q V G U C G V C G T E QV U K R G V U V U T KH G J 6
U GKTVP G NCTG XGU JVKY VPW QEEC GICU W C JVKY GOQ VUWE C VP KQR I PKVTCV U GJ 6

    G T W IK (

 U W Q G P Q T T G G T C Y Q P M Y Q P G Y V C J V U GK T V P G G J V I P K P K C V P Q E V P W Q E E C G I C U W C J VK Y T G O Q V U W E C J V K Y P K I G D G 9  G EK V E C T R PK M T Q Y V J I K O V K Y Q J UK U K J V [ T C O O W U G V K T V C U• V C J 6  UV P W Q E E C Y Q F C JU G J V F P C UV P W Q E E C N C GT G J V P G G Y V G D U G E P G T GH HK F G J V V U Q R F P C G V C N W EN C E P G J 6  U V P W Q E E C Y Q F C J U H Q V G U G V C T C R G U C PK O G J V Q F V W D



amount = $500

:Entry

amount = $800

Usage Account

: Customer :Entry amount = $750 :Entry

U V PW QEE C YQ FC JU G J V Q V U N CUT G XGT I P KU W F GUU GE QTR GT C U V PG X G Y G P G JV Y Q0

UVP WQEEC YQFCJ U R W IPK VVG 5

 GTWI K(


:Entry amount = $500 :Entry amount = $800 :Entry amount = $750 Usage Account : Customer shadow account :Entry amount = $500 :Entry amount = $800 :Entry amount = $750

:Entry amount = $500

:Entry amount = $800

:Entry amount = $750

Usage Account balance = $2050

: Customer shadow account balance = $1500

:Entry amount = $500

:Entry amount = $800

:Entry amount = $750

:Entry amount = $500 :Entry amount = $500

:Entry amount = ($800) :Entry amount = $500

:Entry amount = ($750) :Entry amount = $500


[T V P G P C VU Q R F P C V P W Q E E C N C GT F P C Y Q F C JU G J V H Q G E P C N C D G J V G T C R O Q E G Y P G J 6  G E P G T G H HK F G J V T Q H
U GKTVP G YGP FPC UNCUTG XT GT GJ V IPKV UQR TGVH #

    G T W IK (

 G X Q D C V W Q D C F G M N C V G X •+ T Q K X C J G D V P G O V U W L F C G JV V W Q [ T T C E P C E F Q J V G O U U G E Q T R U• V +  V P G X G T G J V Q [ P C G M KN V U WL F GN W F G J E U G D Q V V K U Y Q NN C V P G X G P C U C V P G O V U WL F C G J V I PK V C G T 6      G T W I K ( V P G OV U W L F C G J V U G U U G E QT R V C J V E K I Q N G J V J V K Y T G JV G I Q V V P G OV U W L F C T C N W EK V T C R C H Q UN K C V G F G J V U F T Q E G T V C J V U U CN E V P G OV U W L F C P C G M C O Q V F Q Q I U •V K [ C Y F G NN Q TV P Q E C PK E K I QN G J V I P K T Q V E C H U C N N G Y U C P Q U G Q I V C J Y H Q M E C T V R G G M QV T G F T Q P+ U VP WQ EE C Y Q F C J U F P C N C P K I T Q G J V P G G Y V G D G E P G T GH HK F G J V U V P W Q E E C N C PK IK T Q G J V Q V V U Q R – U V P W Q E E C Y Q F C J U G J V V U PK C I C UV P G X G Y G P G J V U U G E Q T R – U V P W Q E E C Y Q F C J U G J V VU P K C I C U V P G X G F N Q G JV GUT G X GT – UV P W Q E E C Y Q F C JU G JV G V C GT E – UC URGVU GUQJV G\KTCOOWU PCE G9
 FGFTCEUKF

GD Y QP PCE UVP WQEEC YQFCJ U GJ 6 [TV PG IPK VUW LFC GJV IPK VUQ R FPC I PKVCGTE TG VH #

 GTWI K(

amount = $500

:Entry

balance = $1500

amount = $800

Usage Account

:Entry

amount = $750

:Entry

: Customer amount = ($550) :Entry



V P G O V U WL F C P C G V C G T E QV G F Q E R W V G U E K U C D U P K C V P Q E V P G O V U WL F #  F N W Q JU [ N D C D Q T R F P C

NC UTGXG4 TQH G O C U GJ V QF F NW QE W Q;

 G E CN R G P Q P K I P K U U G E Q T R V P G O V U W L F C T Q H F G F G G P

 VPGO VU WLF #

G F Q E G J V H Q NN C V U Q O N C G V C TV P G E P Q E P C E W Q [ U U CN E V P G X G V P G O V U WL F C P C I PK M C O [ $

GFQ% GNROC5
G NDK UU QR OK FP C FGX N QXP K PG GY VG D GT GJ YG OQ U U K C VC F N CU TGX GT G JV I P K V E W T V U P Q E G T J I W Q J VN C G N D K U U Q R Q U N C U K I P K T Q V E C H G T G U T G X G T G J 6  V N W E K H H K F Q Q V V QP U K TQ( 

M P K J V Q V V P C Y U V T G R Z G PK C O Q F G JV Y Q J P Q U F P G R G F [ NN C W U W F P C G N R O K U V Q P UK   V P G O V U W L F # G E P G T G H HK & F P C   V P G O V U WL F # N C U T G X G 4 P G G Y V G D G E K Q J E G J V Q U P G X '

G U W I PK N N G E P C E VK E K N R Z G G G U Q V V P C Y [ G J V H + V W Q F GK T T C E G T C U V P G O V U WL F C G JV Y Q J V W Q D C

 VPGOVUWLF# GEPGTGHHK& QV  VPGOVUWLF# NCUTGXG4 OQTH IPKTQVECHGT [NGVCPWV  VPGOVUWLF# GEPGTGHHK& GUW [TCOOWU C TGHGTR [GJV HK  VPGOVUWLF# NCUTGXG4

 V P W Q E E C J E C G T Q H V P W Q E E C Y Q F C JU F P C N C W V E C G J V H Q G E P C N C D G J V P G G Y V G D G E P GT G H

HK F G JV V U WL UK U GK TV P G I P KV U W L F C G J V H Q G W N C X G J 6  T Q V C P K OK T E UK F G P Q [ N P Q U K G T G J V [ C Y V C JV U C V P W Q E E C P C G X C J W Q [ P G J Y V U GK U C G U K U K J 6  U T Q V C P K OK T E UK F G O C U G J V J VK Y U GK T V P G V G I Q V F G G P W Q [ U G KT V P G J EV C O Q 6  Q YV G JV P G G Y V G D G E P GT G HH K F G J V G V W R O Q E P C E W Q [ Q U U G K T V P G N C P K I K T Q J E K J Y J E V C O V P G O G E CN R G T G J V O Q T H U G K T V P G J EK J Y V W Q G T W I K H Q V F G G P W Q [ G U W C E G D U K UK J 6  F G U W I PK G D U K

  V PW Q EE # P G J Y F GU W PT G V V C R U K J V G GU Q V F P G V +
VPG XG V PG O VUW LFC PC I PKMC /

VK GUW QV PGJ9
    G T W IK (



old events

0..1 ✻
Accounting Event Adjustment



0..1 old events

class Tester... // original events usageEvent = new Usage( Unit.KWH.amount(50), new MfDate(1999, 10, 1), new MfDate(1999, 10, 15), acm); eventList.add(usageEvent); Usage usage2 = new Usage (// snip constructor args eventList.add(usage2); Usage usage3 = new Usage (// snip constructor args eventList.add(usage3); eventList.process();

VPGXG GJV UUGEQTR GY PGJY PK UMEKM TQKXCJGD VPGOVUWLFC GJ6

UK JV G M KN G F Q E J VK Y V P G O V U WL F C G J V R W V G U P G J V P C E W Q ;

 public class Adjustment extends AccountingEvent ... private List newEvents = new ArrayList(); private List oldEvents = new ArrayList(); public Adjustment(MfDate whenOccurred, MfDate whenNoticed, Subject subject) { super(null, whenOccurred, whenNoticed, subject); } public void addNew(AccountingEvent arg) { newEvents.add(arg); } public void addOld(AccountingEvent arg) { if (arg.hasBeenAdjusted()) throw new IllegalArgumentException ("Cannot create " + this + ". " + arg + " is already adjusted"); oldEvents.add(arg); arg.setReplacementEvent(this); } // replacement events MfDate adjDate = new MfDate(2000,1,12); Usage new1 = new Usage (// snip constructor args Usage new2 = new Usage (// snip constructor args Usage new3 = new Usage (// snip constructor args Adjustment adj = new Adjustment(adjDate, adjDate, acm); adj.addOld(usageEvent); adj.addOld(usage2); adj.addOld(usage3); adj.addNew(new1); adj.addNew(new2); adj.addNew(new3); eventList.add(adj); eventList.process();

class Adjustment... private java.util.Map savedAccounts; public void process() { Assert.isFalse ("Cannot process an event twice", isProcessed); adjust(); markProcessed(); } void adjust() { snapshotAccounts(); reverseOldEvents(); processReplacements(); commit(); secondaryEvents = new ArrayList(); secondaryEvents.addAll(oldEvents); } public void snapshotAccounts() { savedAccounts = getCustomer().getAccounts(); getCustomer().setAccounts(copyAccounts(savedAccounts)); } void reverseOldEvents() { Iterator it = oldEvents.iterator(); while (it.hasNext()) { AccountingEvent each = (AccountingEvent) it.next(); each.reverse(); } } void processReplacements() { AccountingEvent[] list = (AccountingEvent[])newEvents.toArray(new AccountingEvent[0]); for (int i = 0; i < list.length; i++){ list[i].process();} } public void commit() { AccountType[] types = AccountType.types(); for (int i = 0; i < types.length; i++) { adjustAccount(types[i]); } restoreAccounts(); } public void adjustAccount(AccountType type) { Account correctedAccount = getCustomer().accountFor(type); Account originalAccount = (Account) getSavedAccounts().get(type); Money difference = correctedAccount.balance().subtract(originalAccount.balance()); Entry result = new Entry (difference, MfDate.today()); originalAccount.addEntry(result); resultingEntries.add(result); } public void restoreAccounts() { getCustomer().setAccounts(savedAccounts); }


G J V U V P W Q E E C U • T G O Q V U W E G J V U G M C O U K J V V E G H H G P+  T G O Q V U W E G J V P K UN C P K I K T Q G J V H Q [ R Q E C G M C O F P C G E C N R GH C U C Q V U V P W Q E E C N C P K IK T Q G J V G X Q O Q V T G K U C G V K F P W QH + G U C E U K J V P +

 I PK R R C Y U F P C I P K Y Q F C J U G JV N N C J V K Y F G U W H P Q E V G I V • P Q F [ G J V U V P W Q EE C N CP KI KTQ G JV QV GE PGT GHG T C U F N Q J G P Q [P C HK [ CY V C J6 U N CP KIKT Q F GV UW LF C G JV J V K Y U V P W Q E E C U• T G O Q V U W E G J V G E CN R G T + G P Q F NN C U• V C J V G E P 1  U V P W Q E C N C P K IK T Q F G X C U G J V Q V O G JV U F F C F P C U G K T V P G I PK V U W L F C G JV U G P K O T G V G F P Q K V C T G R Q VK O O Q E G J V P G J 6 U V P W Q E E C U T G O Q V U W E G J V V U P K C I C U U G E QT R F P C G U T G X GT G JV Q F + P G J 6  U V P W Q E E C Y Q F C J U



VCJV UK JVIPGTVU U•V+ UGKTVPG IPKVNWUGT GJV HQ [VKZGNROQE GJV UG\KOKPKO QUNC VWD UGKTVPG G JV H Q N K C TV V K F W C P C G X C GN V Q P U G Q F VK V C JV UK P T GV V C R UK JV H Q HH Q G F C T V [ G M G J 6

VK GUW QV PGJ9
 UV P G X G FN Q

G U Q J V J V K Y [ VK N K D C V K F W C G J V J V K Y F G P T G E P Q E Q Q V V • P G T C W Q [ P T G VV C R U K J V I P K U W G T C W Q [ H K [N N C W U W J I W Q J VN C U G U Q R T W R I PK I I Q N T QH V P G X G F N Q G J V Q V O G J V M PK N N NK V U V W D U P Q KV E G N NQE [GM GJV OQTH OGJV GXQ OGT VJIK O WQ[ UTGJVQ P+ [NVGNR OQE UGKTVPG FNQ GJV GVGNGF P C E W Q [ U G U C E G O QU P +  U I P K J V V P G T GH H K F P C G O [ C O U G K T V P G F N Q G JV H Q F K T I P K V V G )  GW N CX VE GT T Q E G J V G X C J NN K Y J E K J Y U GK T V P G Y G P GV C G T E Q V [ C Y T C N W I G T G J V PK V P G X G Y G P G J V U U G E Q T R P G J V F P C O G J V H Q F K T V G I V P G X G FN Q G J V P Q U G K T V P G G J V N N C F P K H W Q [ V P G X G T G J V Q P C U V U WL F C V C J V V P G X G P C V G I W Q [ P G J 9  [ I GV C T V U V P G O V U WL F C GN R OK U C G VK W S UK U K J 6

MTQY VK IPKMC/

 U G K T V P G G J V H Q G W N C X G J V I PK V K F G T Q U G P Q Y G P J V K Y O G J V I P K E C N R G T F P C U G K T V P G FN Q G J V I P K X Q O G T T G J V K G [ D U G K T V P G V E G T T Q E P K V U W L F C U V P G OV U W L F C V P G O G E C N R G 4

U G P Q Y G P J VK Y O G J V I PK E C N R G T F P C U GK T V P G F N Q G J V I P K X Q O G T [ D V P G X G P C V U W L F #



replacement event

adjusted event

amount = 60 kwh amount = 50 kwh original Usage Event new Usage Event resulting entries

4GRNCEGOGPV #.LWUVOGPV

resulting entries amount = $600 amount = $500 replacing Usage Entry original Usage Entry entries {destroyed} entries :customer

 VK Q F P W Q U H K F P C V P G X G F GV U W L F C P C U C J I P K U U G E Q T R G T C G Y V P G X G G J V HK G G U Q V M E G J E G Y F Q J V G O U U G E Q T R G J V P K P G J 6 class AccountingEvent private AccountingEvent adjustedEvent, replacementEvent; public AccountingEvent (EventType type, MfDate whenOccurred, MfDate whenNoticed, AccountingEvent adjustedEvent) { if (adjustedEvent.hasBeenAdjusted()) throw new IllegalArgumentException ("Cannot create " + this + ". " + adjustedEvent + " is already adjusted"); this.type = type; this.whenOccurred = whenOccurred; this.whenNoticed = whenNoticed; this.adjustedEvent = adjustedEvent; adjustedEvent.replacementEvent = this; } protected boolean hasBeenAdjusted() { return (replacementEvent != null); }

 U V P G X G V P G O G E C N R G T F P C F GV U W L F C G J V T Q H F N GKH F P C T Q V E W TV U P Q E Y G P C J VK Y V T C V U G 9 G D QV U F G G P V P G X G I P KV P W Q E E C P Q F Q J V G O U U G E Q T R G J V V C J V U K G E P G T GHH K F PK C O G J 6 

 U V P G X G F N Q H Q P QK V GN G F G J V GN F P C J Q V F G T G V N C

  G N W 4 I P KV U Q 2 T Q H G F Q E GN R O C U G J V P Q F G U C D U K G F Q E G N R O C U U K J 6

GFQ% GNROC5
 U GT WV E W T V U I P KV P W Q E E C [ G M G J V Q V F G M P K N T G I P Q N Q P V W D U V P G X G FN Q G JV QV F G M P KN F P W Q T C U G K TV P G FNQ GJV RGGM PGXG VJIKO WQ; PQKVCOTQHPK IPKUUGEQTR HQ FTQEGT GVGNR OQE C GXCJ W Q [ P G J V FN W Q J U W Q [ J E K J Y UV P G X G F N Q G J V R G G M W Q [ U C I P Q N U #  N K C T V V K F W C G T K V P G G J V GU QN V Q P U G Q F V K U O GN DQT R [ VK NK DC VK FW C U C J  G W S G J E T Q V P G O G V CV U NN K D C H Q V W Q I PK F P G U G JV T Q F QK T G R N C K E P C P KH C H Q F P G G J V G D [ C O F Q K T G R I P K U Q N E G J 6  G X K V C P T G V N C G J V G U W W Q [ V C J V T G V H C

  V P G OV U W L F # V P G O G E C N R G 4 V J I W Q J V N #

F GG F P K QU

  V P G O V U WL F # V P G O G E C N R G 4 G U W W Q [ F G U QN E G T C U V P W Q E E C G J V G T G J Y V PK Q R G O Q U N K V P 7   VPGOVUWLF# GEPGTGHHK& TQ  VPGOVUWLF # NCUTGXG4 TGJVKG JVKY  VPG OVUWLF# V P G O G E C N R G 4 U G PK D O Q E P Q K V C W VK U P Q O O Q E V U Q O G J 6  VK G U W V • P C E W Q [ G OK V G J V H Q V U Q O   V P G O V U W L F # V P G O G E CN R G 4 J V K Y O G N D Q T R [ G M G J V UK G I C V P C X F C U K F V C J 6
U GKT V PG FN Q GJ V H Q UKU CD G JV P Q N NK D C V W Q I PK F P G U U C JE WU P Q K V E C G N D C U T G X G T TK G O Q U P G M C V G X• W Q [ H K O G N D Q T R I K D C UK J E K J Y U GK T V P G N C PK I K T Q G J V H Q G E C T V Q P G X C J W Q [ U P C G O T G X G Y Q J [ V K EK N R O K U UK J 6  U G K TV P G I P KV U W L F C F P C U N C U T G X G T H Q U U C O G J V O Q TH U GK T V P G V E G T T Q E G JV V W Q G T W IK H Q V G X C J W Q [

  V P G OV U W L F # G E P G T G H HK& FPC  VPGOVUWLF# NCUTGXG4 JVK9 UGKTVPG VEGTTQE GJV GTC GGU WQ[ UGKTVPG [NPQ GJV 

public void process() { Assert.isFalse ("Cannot process an event twice", isProcessed); if (adjustedEvent != null) adjustedEvent.undo(); findRule().process(this); isProcessed = true; } public void undo() { Entry[] entries = getResultingEntries(); for (int i = 0; i < entries.length; i++) getSubject().removeEntry(entries[i]); undoSecondaryEvents(); resultingEntries = null; } private void undoSecondaryEvents(){ Iterator it = getSecondaryEvents().iterator(); while (it.hasNext()) { AccountingEvent each = (AccountingEvent) it.next(); each.undo(); } }





Similar Documents

Premium Essay

Pharma

...www.pwc.com/us/pharma Aspiring giants How small pharmas can drive to $1 billion — and beyond PwC’s PRTM Management Consulting Aspiring giants Executive summary Amid the volatile blend of opportunity and challenge that characterizes the global pharmaceutical industry, only a few small companies have managed to catapult their revenue over the $1 billion mark over the past two decades. Whether they chose to expand their therapeutic area focus and product portfolios, enter new geographies, or grow their core business, these aspiring giants pursued three distinct strategies to jump-start growth:  Leveraged core product and technology capabilities to launch differentiated products  Used mergers and acquisitions to gain new products and/or expand geographic presence  Built a strong, stable leadership team armed with a compelling vision and relentless drive The experiences of these winning companies offer lessons for today’s smaller pharma companies harboring the ambition to reach the $1 billion revenue mark. To achieve this milestone, these companies will need to excel in three areas: expanding a core area of expertise to deliver niche and valueadded products, adopting an acquisition and partnering mindset to expand product offerings and geographic presence, and attracting and retaining talented leaders. Focusing on these fronts can help position a pharma company to become a growth leader—rather than merely a follower—in tomorrow’s...

Words: 4167 - Pages: 17

Premium Essay

Pharma

...GCC Pharmaceutical Industry March 31, 2013 Alpen Capital was awarded the “Best Research House” at the Banker Middle East Industry Awards 2011 GCC Pharmaceutical Sector | March 31, 2013 Page | 2 Table of Contents 1. 1.1. 1.2. 1.3. 1.4. EXECUTIVE SUMMARY............................................................................ 6 Scope of the Report .................................................................................. 6 Key Growth Drivers .................................................................................. 6 Key Challenges ........................................................................................ 6 Trends .................................................................................................... 7 2. 2.1 2.2 2.3 2.4 2.5 2.6 2.7 GCC PHARMACEUTICAL INDUSTRY OVERVIEW ...................................... 8 GCC Pharmaceutical Market Overview ............................................................. 8 The UAE Pharmaceutical Market .................................................................... 11 The Saudi Arabian Pharmaceutical Market ...................................................... 13 The Kuwaiti Pharmaceutical Market ............................................................... 15 The Qatari Pharmaceutical Market ................................................................. 16 The Bahraini Pharmaceutical Market .............................................................. 17 The...

Words: 27542 - Pages: 111

Premium Essay

Pharma

...RESEARCH PROJECT ON “TRAINING AND DEVELOPMENT IN PHARMASUITICAL INDUSTRY WITH SPECIAL REFERENCE OF MANKIND PHARMA LTD” SUBMITTED IN PARTIAL FULFILLMENT OF DEGREE OF BACHELOR OF BUSINESS ADMINISTRATION SESSION (2011-2014) SUBMITTED TO: SUBMITTED BY: XYZ XYZ BBA III University Roll No. SUBMITTED TO ACKNOWLEGDEMENT “Gratitude is the hardest of emotions to express and one often does not find adequate words to convey what one feels and trying to express it” The present project file is an amalgamated of various thoughts and experiences .The successful completion of this project report would have not been possible without the help and guidance of number of people and specially to my project guide .I take this opportunity to thank all those who have directly and indirectly inspired, directed and helped me towards successful completion of this project report. I am also immensely indebted to my project guide, MS. Divya Vaid Lecturer, ICL, for his illumining...

Words: 8569 - Pages: 35

Free Essay

Pharma

...Respected Sir/Madam, I xxxx completed Bachelors in xyz College of xyz affiliated to University, Mumbai with 50% Following this, I was involved in research and has been working as an Analyst for Plant pharmaceuticals in Quality Control Department of Alapati Pharma company. I was Kindled with an ambition of higher education that would give a desired push to my career. With a strong will to pursue my further studies in Canada, I prepared for the IELTS examination and scored 6.5 bands. I am prepared to further deepen and refine my expertise through Biotechnology Course which has led me to take admission in one of the top Colleges, Centennial College, Canada. I was brought up in a well educated family and this helped me to maintain a consistent and excellent academic record; I secured Distinction marks in SSC and Intermediate. During my Bachelors, I submitted many research papers in worldwide and India wide seminars like IPC, IPA, National seminars where 12 of my Research papers were published in Medical and Pharmacy Journals. I was also awarded a "Gold medal" for a Seminar conducted by Indian Pharmaceutical Congress which provided me a wonderful platform to meet the top heads of Pharmaceutical Industry in the country. I Started my career as an Asst. Manufacturing Chemist in Triomed Formulations India(Pvt) Ltd as soon as i was graduated. Then i opted for a Subject Knowledge Enhancement Course (Student...

Words: 741 - Pages: 3

Free Essay

Pharma

...NERACA PEMBAYARAN Neraca Pembayaran (balance of payments) adalah suatu catatan dari aktifitas ekonomi yang meliputi perdagangan barang/jasa, transfer keuangan yang dilakukan antara penduduk dalam negeri dengan penduduk luar negeri selama periode waktu tertentu, biasanya selama satu tahun. Pencatatan transaksi dilakukan dengan pembukuan berpasangan(double entry bookeeping) Neraca pembayaran dapat dibagi atas beberapa komponen yaitu neraca berjalan dan neraca modal. * Neraca berjalan (current account) adalah ukuran perdagangan barang dan jasa internasional suatu negara yang paling luas, komponen utamanya adalah neraca perdagangan yaitu selisih antara ekspor dan impor. Jika ekspor lebih tinggi dari impor maka terjadi surplus, sedangkan jika impor lebih tinggi daripada ekspor maka terjadi defisit neraca perdagangan. Faktor-faktor yang mempengaruhi neraca berjalan : 1. Inflasi Jika laju inflasi sebuah negara meningkat relatif terhadap inflasi negara-negara mitra dagangnya, neraca berjalannya akan menurun. 2. Pendapatan Nasional Jika tingkat pendapatan nasional sebuah negara meningkat dengan persentase relatif lebih tinggi daripada negara lain, neraca berjalannya akan menurun. 3. Restriksi Pemerintah Biasanya pemerintah mengenakan tarif (pajak yang dikenakan ataus produk impor) dan kuota (batas maksimum atas barang yang diperbolehkan untuk diimpor ke dalam sebuah negara) untuk mempengaruhi neraca berjalan. 4. Nilai tukar (kurs) valuta Jika nilai valuta suatu negara...

Words: 688 - Pages: 3

Free Essay

Pharma

...Impact of the economic recession on the pharmaceutical sector February 2010 I.M. Buysse (UU) Supervised by: R.O. Laing (WHO) A.K. Mantel (UU) WHO COLLABORATING CENTRE FOR PHARMACOEPIDEMIOLOGY & PHARMACEUTICAL POLICY ANALYSIS Impact of the economic recession on the pharmaceutical sector Table of contents Executive summary ................................................................................................................................. 3 Introduction ............................................................................................................................................ 6 Background ............................................................................................................................................. 8 History of recessions ............................................................................................................................................................. 8 Asian Crisis 1997-2000 .......................................................................................................................................................... 9 Economic crisis 2008-2009.................................................................................................................................................. 12 WHO involvement in assessing the impact of the recession .............................................................................................. 14 Hypotheses ...................

Words: 25253 - Pages: 102

Premium Essay

Pharma

...THE PHARMACEUTICAL MARKET: INDIA - REVIEW The Indian pharmaceutical market is highly competitive and remains dominated by low-priced, domestically-produced generics. Despite having the second largest population in the world and a growing middle class with high healthcare expectations, India accounts for less than 2% of the world pharmaceutical market in value terms. In one of the world's better performing economies, spending on pharmaceuticals accounts for less than 1% of GDP and average per capita spending remains one of the lowest levels in the region. India’s biopharmaceutical sector is currently experiencing double digit growth and this is expected to continue, driven by the vaccines market. Growth drivers include education and increased awareness of disease prevention, increases in disposable income and government participation in immunisation programmes. Continued growth is also expected in the diagnostic and therapeutic segments, including cancer and diabetes. India is already known as the diabetes capital of the world and the number of diabetes patients in India is expected to grow to 70 million by 2025. Cancer therapies are also lucrative for many Indian companies due to high unmet need, increased awareness and the comparative affordability of domestically produced drugs. The Indian pharmaceutical industry is responsible for around 10% of world pharmaceutical production. Over the last few years, a number of Indian pharmaceutical companies have been targeted...

Words: 578 - Pages: 3

Premium Essay

Pharma

...The key issue affecting the pharmaceutical industry is the ability of the pharmaceutical industry to remain profitable and returning a high rate of return that has been historically been so. The Pharmaceutical industry is an industry in which the entry barriers are very high as the companies in the business must spend a large amount of money on research. And the research may only yield results in some cases, only 3 out of 10 drugs recoup their costs and takes around $800 Million and 15 years to release a new drug. The companies that dominate the industry usually have dominant companies in that rely upon very few of their drugs for returning revenues. As a standing testimony, 55% of Pfizers revenues are generated from just 3 drugs ($28 billion dollars!). Whilst there are challenges of prices and new regulations, the industry offers new opportunities 3 Alternatives: 1) Research and Develop drugs in the areas of chronic care, Healthier living such as nutritional business. As people from the baby boom age grow wiser and start to look for ways to prolong life with the least bit of worries for reliance on healthcare, there is a shift in people moving for nutritional drugs. 2) Research and develop in the areas of preventive medicine, diagnostics, genetic testing. It’s an age long drug that cannot seem to go wrong. With the increase in awareness in people, there is an increase in their wanting to try newer things, Genetic and generic medicines being an example of that. People...

Words: 380 - Pages: 2

Premium Essay

Pharma

...14th November 14 14th November 14 Word Count: 1465 Word Count: 1465 08 Fall 08 Fall Abbreviations: CL Compulsory Licensing NGO’s Non-governmental Organisation’s R&D Research and Development RDT Rapid Detection Tests TRIPS Trade- Related Aspects of Intellectual Property Rights WTO World Trade Organisation Abbreviations: CL Compulsory Licensing NGO’s Non-governmental Organisation’s R&D Research and Development RDT Rapid Detection Tests TRIPS Trade- Related Aspects of Intellectual Property Rights WTO World Trade Organisation Table of Contents Table of Contents 2 Introduction 2 Factors effecting the control of malaria 3 What is the role of the pharmaceutical companies? 5 Recommendations 6 Reference List 8 Introduction This report aims to address the issues regarding the availability of drugs in the developing world in addition to what measures the developed world could use to ease the burden, including the evaluation of the options available and the potential cumulative effects that would accompany these processes. For the purpose of this paper, the author will concentrate on the infection rates in humans of Malaria in Sierra Leone. Although malaria is deemed as a preventable disease many factors inhibit the eradication of infection rates. In the recent World Malaria Report (2013) Sierra Leone is ranked as the country with the fifth highest prevalence rate per capita in addition to fifty percent of the population...

Words: 2477 - Pages: 10

Premium Essay

Big Pharma

...The effect of big pharma on healthcare EN 1320 26 May 2013 The effect of big pharma on healthcare Big pharmacy has always been a hot button issue, for as long as I can remember. It is proven that the large drug companies are using unethical practices to help boost sales. These practices in turn cost the patient more at the counter in the pharmacy. This also leads to shady practices by physicians. Fortune magazine reported that in 2008, the pharmaceutical industry continued to be in the top three most profitable industries in the United States for the past two decades. Studies show that marketing strategies used by pharmaceutical representatives such as education, samples, office support, and patient resources can increase brand recognition and influence prescribing. This leads to patients being influenced to spend more money on the brand name drugs, rather than the cheaper generic versions that work exactly the same. References Insert References Here. Place the cursor at the beginning of this line, and then, on the CiteWrite menu, click Format, Write Bibliography. For more help with your references, click Start, Programs, Dr Paper, Dr Paper Help, and go through the instructions under Using CiteWrite for your References. If you just have one or two references, you might want to just type them by hand, following these examples: Hall, K. G. (2005, August 29). Web page title. Website title. Retrieved September 25, 2005, from http://www.kansas.com/mld/kansas/12506343...

Words: 276 - Pages: 2

Premium Essay

Pharma Industry

...The Pharmaceutical industry in the Global Economy Summer 2005 Larry Davidson* and Gennadiy Greblov Indiana University Kelley School of Business Bloomington, Indiana *Davidson is Professor of Business Economics and Public Policy and Greblov is working towards his MBA degree at the Kelley School of Business Prepared for the Indiana Economic Development Corporation with the support of the Center for International Business Education and Research at the Indiana University Kelley School of Business. Information Services via the World Trade Atlas, U.S. State Export Edition. To receive free copies of the export report please contact the Indiana Economic Development Corporation’s Office of International Trade at 317.232.4949. Direct questions to the authors of the report to Larry Davidson at davidso@indiana.edu or 812.855.2773. Introduction This paper summarizes the results of our global pharmaceutical industry analysis and is intended to increase awareness of the general public – investors, policy makers, managers, employees of the companies – about its current developments. The paper has the following major goals: 1) To analyze the current situation, major challenges and the prospects of the pharmaceutical industry; 2) To identify major players of the global pharmaceutical industry and make a comparative analysis of their business practices and financial results; 3) To determine the relative position of the U.S. pharmaceutical...

Words: 10094 - Pages: 41

Premium Essay

Pharma 2020

...www.pwc.com/pharma2020 Pharma 2020: Supplying the future Which path will you take? Pharmaceuticals and Life Sciences Previous publications in this series include: Pharmaceuticals Pharma 2020: The vision Which path will you take?* Published in June 2007, this paper highlights a number of issues that will have a major bearing on the industry by 2020. The publication outlines the changes we believe will best help pharmaceutical companies realise the potential the future holds to enhance the value they provide to shareholders and society alike. Pharmaceuticals and Life Sciences Pharma 2020: Challenging business models Which path will you take? Fourth in the Pharma 2020 series and published in April 2009, this report highlights how Pharma’s fully integrated business models may not be the best option for the pharma industry in 2020; more creative collaboration models may be more attractive. This paper also evaluates the advantages and disadvantages of the alternative business models and how each stands up against the challenges facing the industry. *connectedthinking Pharma 2020: The vision  # Pharmaceuticals and Life Sciences Pharma 2020: Virtual R&D Which path will you take? This report, published in June 2008, explores opportunities to improve the R&D process. It proposes that new technologies will enable the adoption of virtual R&D; and by operating in a more connected world the industry, in collaboration with researchers, governments, healthcare payers and providers...

Words: 13197 - Pages: 53

Premium Essay

Xyz Pharma

...September 2005 Project Portfolio Management at XYZ Pharma Early morning, Monday 29th August 2005. John Smith, head of portfolio management and strategic planning, was paging through the slides he had prepared for the Portfolio Management Board (PMB) meeting which would start at 9 am, and which was scheduled to last until Friday. “We have been preparing this meeting for weeks”, he thought, “and it seems the PMB has some tough decisions to make”. The PMB of XYZ Pharma, the pharmaceutical division of XYZ, one of the world’s leading companies in the life science sector, convenes yearly in August to review the composition of the research and development (R&D) project portfolio. It also meets on a monthly basis to monitor the project portfolio and make decisions regarding new developments. According to John Smith, “The PMB is an important decision making body because it shapes the future of the company by determining its product pipeline”. The PMB members include the CEO of XYZ, the CEO of XYZ Pharma, the heads of the different business units, the heads of Development, Research, Global Marketing and Strategic Planning, the regional heads for the US, Europe and Japan and the functional managers for Regulation, Clinical, Licensing, Technical Research and Development, and Patents. The portfolio group, led by John Smith, had analysed the project portfolio carefully and had highlighted several potential threats that required action. According to John, “There will be an indepth discussion...

Words: 5468 - Pages: 22

Premium Essay

Pharma Industry

...INDIAN PHARMACEUTICAL INDUSTRY – AN OVERVIEW 1. Overview The Indian Pharma industry is one of the fastest growing sectors with approximately 20,000 manufacturing units. The industry that is highly price sensitive ranks thirteenth in the global pharmaceutical market in value terms and fourth in volume terms. The country has tremendous export potential in the areas like custom synthesis, R&D, clinical trials, and Bioinformatics. The industry produces 60,000 finished medicines and roughly 400 bulk drugs, which are used in formulations with about 20% of the manufacturers in the bulk drugs segment. India has approximately 1% share of global pharma industry, which is worth US$406 billion. This implies that there is a huge market waiting to be unfolded. The figure below explains the evolution of Indian pharmaceutical industry: Figure 1: Progress Of Indian Pharmaceutical Industry Source: Pharmabiz.com (Article by Dr. Laxman Prasad) 2. Industry Structure and Size 2.1 Industry Structure The Indian Pharma industry is highly fragmented and can broadly be classified in to two categories: organized and unorganized sector. Figure 2: Revenues of Organised vs. Unorganised Sector Source: Secondary Research The organized sector contributes about 70% of the total revenues and consists of 260 units in both manufacturing as well as formulation segment. This sector can further be divided into Indian and multinational companies. The unorganized sector is...

Words: 1530 - Pages: 7

Premium Essay

Indian Pharma

...technology, quality and range of medicines manufactured. From simple headache pills to sophisticated antibiotics and complex cardiac compounds, almost every type of medicine is now made indigenously.  Playing a key role in promoting and sustaining development in the vital field of medicines, Indian Pharma Industry boasts of quality producers and many units approved by regulatory authorities in USA and UK. International companies associated with this sector have stimulated, assisted and spearheaded this dynamic development in the past 53 years and helped to put India on the pharmaceutical map of the world.  Growth Scenario in 2010 India's pharmaceutical industry is now the third largest in the world in terms of volume. Its rank is 14th in terms of value. Between September 2008 and September 2009, the total turnover of India's pharmaceuticals industry was US$ 21.04 billion. The domestic market was worth US$ 12.26 billion. This was reported by the Department of Pharmaceuticals, Ministry of Chemicals and Fertilizers. As per a report by IMS Health India, the Indian pharmaceutical market reached US$ 10.04 billion in size in July 2010. A highly organized sector, the Indian Pharma Industry is estimated to be worth $ 4.5 billion, growing at about 8 to 9 percent annually. Know more out this in our article on Indian Pharmaceutical Industry- Future Trends Also check out Pharmaceutical Market Trends 2010 Leading...

Words: 1244 - Pages: 5