View Javadoc
1   /*
2    * MoneyWise: Finance Application
3    * Copyright 2012-2026. Tony Washer
4    *
5    * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6    * use this file except in compliance with the License.  You may obtain a copy
7    * of the License at
8    *
9    *   http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
14   * License for the specific language governing permissions and limitations under
15   * the License.
16   */
17  package io.github.tonywasher.joceanus.moneywise.atlas.data.analysis.base;
18  
19  import io.github.tonywasher.joceanus.metis.field.MetisFieldSet;
20  import io.github.tonywasher.joceanus.moneywise.data.basic.MoneyWiseAssetBase;
21  import io.github.tonywasher.joceanus.moneywise.data.basic.MoneyWiseAssetDirection;
22  import io.github.tonywasher.joceanus.moneywise.data.basic.MoneyWiseBasicResource;
23  import io.github.tonywasher.joceanus.moneywise.data.basic.MoneyWiseExchangeRate;
24  import io.github.tonywasher.joceanus.moneywise.data.basic.MoneyWiseSecurityPrice;
25  import io.github.tonywasher.joceanus.moneywise.data.basic.MoneyWiseTransAsset;
26  import io.github.tonywasher.joceanus.moneywise.data.basic.MoneyWiseTransCategory;
27  import io.github.tonywasher.joceanus.moneywise.data.basic.MoneyWiseTransTag;
28  import io.github.tonywasher.joceanus.moneywise.data.basic.MoneyWiseTransaction;
29  import io.github.tonywasher.joceanus.moneywise.data.statics.MoneyWiseTransInfoClass;
30  import io.github.tonywasher.joceanus.oceanus.base.OceanusException;
31  import io.github.tonywasher.joceanus.oceanus.date.OceanusDate;
32  import io.github.tonywasher.joceanus.oceanus.decimal.OceanusMoney;
33  import io.github.tonywasher.joceanus.oceanus.decimal.OceanusRatio;
34  import io.github.tonywasher.joceanus.oceanus.decimal.OceanusUnits;
35  import io.github.tonywasher.joceanus.prometheus.data.PrometheusDataItem;
36  import io.github.tonywasher.joceanus.prometheus.data.PrometheusDataList;
37  
38  import java.util.ArrayList;
39  import java.util.Collections;
40  import java.util.Iterator;
41  import java.util.List;
42  import java.util.Objects;
43  
44  /**
45   * Analysis Event.
46   */
47  public class MoneyWiseXAnalysisEvent
48          extends PrometheusDataItem {
49      /**
50       * Local Report fields.
51       */
52      static final MetisFieldSet<MoneyWiseXAnalysisEvent> FIELD_DEFS = MetisFieldSet.newFieldSet(MoneyWiseXAnalysisEvent.class);
53  
54      /*
55       * FieldIds.
56       */
57      static {
58          FIELD_DEFS.declareLocalField(MoneyWiseXAnalysisBaseResource.EVENT_DATE, MoneyWiseXAnalysisEvent::getDate);
59          FIELD_DEFS.declareLocalField(MoneyWiseXAnalysisBaseResource.EVENT_TYPE, MoneyWiseXAnalysisEvent::getEventType);
60          FIELD_DEFS.declareLocalField(MoneyWiseBasicResource.TRANSACTION_NAME, MoneyWiseXAnalysisEvent::getTransaction);
61          FIELD_DEFS.declareLocalField(MoneyWiseXAnalysisBaseResource.EVENT_PRICES, MoneyWiseXAnalysisEvent::getPrices);
62          FIELD_DEFS.declareLocalField(MoneyWiseXAnalysisBaseResource.EVENT_XCHGRATES, MoneyWiseXAnalysisEvent::getXchgRates);
63          FIELD_DEFS.declareLocalField(MoneyWiseXAnalysisBaseResource.EVENT_DEPRATES, MoneyWiseXAnalysisEvent::getDepRates);
64          FIELD_DEFS.declareLocalField(MoneyWiseXAnalysisBaseResource.EVENT_BALANCES, MoneyWiseXAnalysisEvent::getBalances);
65      }
66  
67      /**
68       * Non-transaction indicator.
69       */
70      private static final int NONTRANS = 0x40000000;
71  
72      /**
73       * EventType.
74       */
75      private final MoneyWiseXAnalysisEventType theEventType;
76  
77      /**
78       * Transaction.
79       */
80      private final MoneyWiseTransaction theTransaction;
81  
82      /**
83       * The Date.
84       */
85      private final OceanusDate theDate;
86  
87      /**
88       * The securityPrice List.
89       */
90      private final List<MoneyWiseSecurityPrice> thePrices;
91  
92      /**
93       * The exchangeRate List.
94       */
95      private final List<MoneyWiseExchangeRate> theXchgRates;
96  
97      /**
98       * The depositRate List.
99       */
100     private final List<MoneyWiseNewDepositRate> theDepRates;
101 
102     /**
103      * The opening balance list.
104      */
105     private final List<MoneyWiseAssetBase> theBalances;
106 
107     /**
108      * Transaction constructor.
109      *
110      * @param pList  the owning list
111      * @param pTrans the transaction.
112      */
113     public MoneyWiseXAnalysisEvent(final PrometheusDataList<MoneyWiseXAnalysisEvent> pList,
114                                    final MoneyWiseTransaction pTrans) {
115         super(pList, pTrans.getIndexedId());
116         theEventType = MoneyWiseXAnalysisEventType.TRANSACTION;
117         theTransaction = pTrans;
118         theDate = pTrans.getDate();
119         thePrices = null;
120         theXchgRates = null;
121         theDepRates = null;
122         theBalances = null;
123     }
124 
125     /**
126      * Event constructor.
127      *
128      * @param pList      the owning list
129      * @param pEventType the eventType.
130      * @param pDate      the date
131      */
132     public MoneyWiseXAnalysisEvent(final PrometheusDataList<MoneyWiseXAnalysisEvent> pList,
133                                    final MoneyWiseXAnalysisEventType pEventType,
134                                    final OceanusDate pDate) {
135         super(pList, determineId(pEventType, pDate));
136         theEventType = pEventType;
137         theTransaction = null;
138         theDate = pDate;
139         thePrices = MoneyWiseXAnalysisEventType.SECURITYPRICE == theEventType ? new ArrayList<>() : null;
140         theXchgRates = MoneyWiseXAnalysisEventType.XCHANGERATE == theEventType ? new ArrayList<>() : null;
141         theDepRates = MoneyWiseXAnalysisEventType.DEPOSITRATE == theEventType ? new ArrayList<>() : null;
142         theBalances = MoneyWiseXAnalysisEventType.OPENINGBALANCE == theEventType ? new ArrayList<>() : null;
143     }
144 
145     @Override
146     public MetisFieldSetDef getDataFieldSet() {
147         return FIELD_DEFS;
148     }
149 
150     /**
151      * Determine the id of a non-transaction event.
152      *
153      * @param pEventType the eventType
154      * @param pDate      the date
155      * @return the id
156      */
157     private static Integer determineId(final MoneyWiseXAnalysisEventType pEventType,
158                                        final OceanusDate pDate) {
159         final int myId = NONTRANS + (pDate.getId() << 2);
160         return switch (pEventType) {
161             case SECURITYPRICE -> myId - 1;
162             case XCHANGERATE -> myId;
163             case DEPOSITRATE -> myId + 1;
164             default -> myId + 2;
165         };
166     }
167 
168     /**
169      * Obtain the event type.
170      *
171      * @return the eventType
172      */
173     public MoneyWiseXAnalysisEventType getEventType() {
174         return theEventType;
175     }
176 
177     /**
178      * Obtain the transaction.
179      *
180      * @return the transaction
181      */
182     public MoneyWiseTransaction getTransaction() {
183         return theTransaction;
184     }
185 
186     /**
187      * Obtain the priceList.
188      *
189      * @return the priceList
190      */
191     private List<MoneyWiseSecurityPrice> getPrices() {
192         return thePrices;
193     }
194 
195     /**
196      * Obtain the xchgRateList.
197      *
198      * @return the xchgRateList
199      */
200     private List<MoneyWiseExchangeRate> getXchgRates() {
201         return theXchgRates;
202     }
203 
204     /**
205      * Obtain the depositRateList.
206      *
207      * @return the depositRateList
208      */
209     private List<MoneyWiseNewDepositRate> getDepRates() {
210         return theDepRates;
211     }
212 
213     /**
214      * Obtain the openingBalanceList.
215      *
216      * @return the openingBalanceList
217      */
218     private List<MoneyWiseAssetBase> getBalances() {
219         return theBalances;
220     }
221 
222     @Override
223     public int compareTo(final Object pThat) {
224         /* Handle the trivial cases */
225         if (this.equals(pThat)) {
226             return 0;
227         }
228         if (pThat == null) {
229             return -1;
230         }
231 
232         /* Non-DataItems are last */
233         if (!(pThat instanceof MoneyWiseXAnalysisEvent)) {
234             return -1;
235         }
236 
237         /* Check date and then data type */
238         final MoneyWiseXAnalysisEvent myThat = (MoneyWiseXAnalysisEvent) pThat;
239         final int iDiff = theDate.compareTo(myThat.getDate());
240         if (iDiff != 0) {
241             return iDiff;
242         }
243         if (theEventType != myThat.getEventType()) {
244             return theEventType.compareTo(myThat.getEventType());
245         }
246 
247         /* Only event types with same date are transactions */
248         return theTransaction == null ? 0 : theTransaction.compareTo(myThat.getTransaction());
249     }
250 
251     @Override
252     protected int compareValues(final PrometheusDataItem pThat) {
253         /* Check date and then data type */
254         final MoneyWiseXAnalysisEvent myThat = (MoneyWiseXAnalysisEvent) pThat;
255         final int iDiff = theDate.compareTo(myThat.getDate());
256         if (iDiff != 0) {
257             return iDiff;
258         }
259         if (theEventType != myThat.getEventType()) {
260             return theEventType.compareTo(myThat.getEventType());
261         }
262 
263         /* Only event types with same date are transactions */
264         return theTransaction == null ? 0 : theTransaction.compareTo(myThat.getTransaction());
265     }
266 
267     @Override
268     public boolean equals(final Object pThat) {
269         /* Handle trivial cases */
270         if (this == pThat) {
271             return true;
272         } else if (!(pThat instanceof MoneyWiseXAnalysisEvent)) {
273             return false;
274         }
275 
276         /* Access object correctly */
277         final MoneyWiseXAnalysisEvent myThat = (MoneyWiseXAnalysisEvent) pThat;
278 
279         /* Ensure date is identical */
280         if (!theDate.equals(myThat.getDate())) {
281             return false;
282         }
283 
284         /* Ensure eventType is identical */
285         if (theEventType != myThat.getEventType()) {
286             return false;
287         }
288 
289         /* Check transaction */
290         return Objects.equals(theTransaction, myThat.getTransaction());
291     }
292 
293     @Override
294     public int hashCode() {
295         return Objects.hash(theDate, theEventType, theTransaction);
296     }
297 
298     /**
299      * declare securityPrice.
300      *
301      * @param pPrice the security Price.
302      */
303     public void declareSecurityPrice(final MoneyWiseSecurityPrice pPrice) {
304         if (thePrices != null) {
305             thePrices.add(pPrice);
306         }
307     }
308 
309     /**
310      * declare exchangeRate.
311      *
312      * @param pRate the exchangeRate.
313      */
314     public void declareExchangeRate(final MoneyWiseExchangeRate pRate) {
315         if (theXchgRates != null) {
316             theXchgRates.add(pRate);
317         }
318     }
319 
320     /**
321      * declare depositRate.
322      *
323      * @param pRate the depositRate.
324      */
325     public void declareDepositRate(final MoneyWiseNewDepositRate pRate) {
326         if (theDepRates != null) {
327             theDepRates.add(pRate);
328         }
329     }
330 
331     /**
332      * declare opening balance.
333      *
334      * @param pAsset the asset.
335      */
336     public void declareOpeningBalance(final MoneyWiseAssetBase pAsset) {
337         if (theBalances != null) {
338             theBalances.add(pAsset);
339         }
340     }
341 
342     /**
343      * obtain the securityPrice iterator.
344      *
345      * @return the iterator.
346      */
347     public Iterator<MoneyWiseSecurityPrice> priceIterator() {
348         return thePrices != null ? thePrices.iterator() : Collections.emptyIterator();
349     }
350 
351     /**
352      * obtain the exchangeRate iterator.
353      *
354      * @return the iterator.
355      */
356     public Iterator<MoneyWiseExchangeRate> xchgRateIterator() {
357         return theXchgRates != null ? theXchgRates.iterator() : Collections.emptyIterator();
358     }
359 
360     /**
361      * obtain the depositRate iterator.
362      *
363      * @return the iterator.
364      */
365     public Iterator<MoneyWiseNewDepositRate> depRateIterator() {
366         return theDepRates != null ? theDepRates.iterator() : Collections.emptyIterator();
367     }
368 
369     /**
370      * obtain the openingBalance iterator.
371      *
372      * @return the iterator.
373      */
374     public Iterator<MoneyWiseAssetBase> balanceIterator() {
375         return theBalances != null ? theBalances.iterator() : Collections.emptyIterator();
376     }
377 
378     /**
379      * Obtain the date.
380      *
381      * @return the date
382      */
383     public OceanusDate getDate() {
384         return theDate;
385     }
386 
387     /**
388      * Set the date.
389      *
390      * @param pDate the date
391      */
392     public void setDate(final OceanusDate pDate) {
393         if (theTransaction != null) {
394             theTransaction.setDate(pDate);
395         }
396     }
397 
398     @Override
399     public boolean isHeader() {
400         return theTransaction != null && theTransaction.isHeader();
401     }
402 
403     /**
404      * Obtain the account.
405      *
406      * @return the account
407      */
408     public MoneyWiseTransAsset getAccount() {
409         return theTransaction == null ? null : theTransaction.getAccount();
410     }
411 
412     /**
413      * Set the account.
414      *
415      * @param pAccount the account
416      */
417     public void setAccount(final MoneyWiseTransAsset pAccount) {
418         if (theTransaction != null) {
419             theTransaction.setAccount(pAccount);
420         }
421     }
422 
423     /**
424      * Obtain the category.
425      *
426      * @return the category
427      */
428     public MoneyWiseTransCategory getCategory() {
429         return theTransaction == null ? null : theTransaction.getCategory();
430     }
431 
432     /**
433      * Set the category.
434      *
435      * @param pCategory the category
436      */
437     public void setCategory(final MoneyWiseTransCategory pCategory) {
438         if (theTransaction != null) {
439             theTransaction.setCategory(pCategory);
440         }
441     }
442 
443     /**
444      * Obtain the direction.
445      *
446      * @return the direction
447      */
448     public MoneyWiseAssetDirection getDirection() {
449         return theTransaction == null ? null : theTransaction.getDirection();
450     }
451 
452     /**
453      * Set the direction.
454      *
455      * @param pDirection the direction
456      */
457     public void setDirection(final MoneyWiseAssetDirection pDirection) {
458         if (theTransaction != null) {
459             theTransaction.setDirection(pDirection);
460         }
461     }
462 
463     /**
464      * Obtain the partner.
465      *
466      * @return the partner
467      */
468     public MoneyWiseTransAsset getPartner() {
469         return theTransaction == null ? null : theTransaction.getPartner();
470     }
471 
472     /**
473      * Set the partner.
474      *
475      * @param pPartner the partner
476      */
477     public void setPartner(final MoneyWiseTransAsset pPartner) {
478         if (theTransaction != null) {
479             theTransaction.setPartner(pPartner);
480         }
481     }
482 
483     /**
484      * Obtain the amount.
485      *
486      * @return the amount
487      */
488     public OceanusMoney getAmount() {
489         return theTransaction == null ? null : theTransaction.getAmount();
490     }
491 
492     /**
493      * Set the amount.
494      *
495      * @param pAmount the amount
496      * @throws OceanusException on error
497      */
498     public void setAmount(final OceanusMoney pAmount) throws OceanusException {
499         if (theTransaction != null) {
500             theTransaction.setAmount(pAmount);
501         }
502     }
503 
504     /**
505      * is the event reconciled?
506      *
507      * @return true/false
508      */
509     public Boolean isReconciled() {
510         return theTransaction == null ? Boolean.TRUE : theTransaction.isReconciled();
511     }
512 
513     /**
514      * Set the reconciled.
515      *
516      * @param pReconciled the reconciled flag
517      */
518     public void setReconciled(final Boolean pReconciled) {
519         if (theTransaction != null) {
520             theTransaction.setReconciled(pReconciled);
521         }
522     }
523 
524     /**
525      * Obtain the comment.
526      *
527      * @return the comment
528      */
529     public String getComments() {
530         return theTransaction == null ? null : theTransaction.getComments();
531     }
532 
533     /**
534      * Set the comment.
535      *
536      * @param pComment the comment
537      * @throws OceanusException on error
538      */
539     public void setComments(final String pComment) throws OceanusException {
540         if (theTransaction != null) {
541             theTransaction.setComments(pComment);
542         }
543     }
544 
545     /**
546      * Obtain the reference.
547      *
548      * @return the reference
549      */
550     public String getReference() {
551         return theTransaction == null ? null : theTransaction.getReference();
552     }
553 
554     /**
555      * Set the reference.
556      *
557      * @param pReference the reference
558      * @throws OceanusException on error
559      */
560     public void setReference(final String pReference) throws OceanusException {
561         if (theTransaction != null) {
562             theTransaction.setReference(pReference);
563         }
564     }
565 
566     /**
567      * Obtain the taxCredit.
568      *
569      * @return the taxCredit
570      */
571     public OceanusMoney getTaxCredit() {
572         return theTransaction == null ? null : theTransaction.getTaxCredit();
573     }
574 
575     /**
576      * Set the taxCredit.
577      *
578      * @param pCredit the taxCredit
579      * @throws OceanusException on error
580      */
581     public void setTaxCredit(final OceanusMoney pCredit) throws OceanusException {
582         if (theTransaction != null) {
583             theTransaction.setTaxCredit(pCredit);
584         }
585     }
586 
587     /**
588      * Obtain the employeesNI.
589      *
590      * @return the employeesNI
591      */
592     public OceanusMoney getEmployeeNatIns() {
593         return theTransaction == null ? null : theTransaction.getEmployeeNatIns();
594     }
595 
596     /**
597      * Set the employeeNI.
598      *
599      * @param pNatIns the employeeNI
600      * @throws OceanusException on error
601      */
602     public void setEmployeeNatIns(final OceanusMoney pNatIns) throws OceanusException {
603         if (theTransaction != null) {
604             theTransaction.setEmployeeNatIns(pNatIns);
605         }
606     }
607 
608     /**
609      * Obtain the employerNI.
610      *
611      * @return the employerNI
612      */
613     public OceanusMoney getEmployerNatIns() {
614         return theTransaction == null ? null : theTransaction.getEmployerNatIns();
615     }
616 
617     /**
618      * Set the employerNI.
619      *
620      * @param pNatIns the employerNI
621      * @throws OceanusException on error
622      */
623     public void setEmployerNatIns(final OceanusMoney pNatIns) throws OceanusException {
624         if (theTransaction != null) {
625             theTransaction.setEmployerNatIns(pNatIns);
626         }
627     }
628 
629     /**
630      * Obtain the deemedBenefit.
631      *
632      * @return the deemedBenefit
633      */
634     public OceanusMoney getDeemedBenefit() {
635         return theTransaction == null ? null : theTransaction.getDeemedBenefit();
636     }
637 
638     /**
639      * Set the deemedBenefit.
640      *
641      * @param pBenefit the benefit
642      * @throws OceanusException on error
643      */
644     public void setDeemedBenefit(final OceanusMoney pBenefit) throws OceanusException {
645         if (theTransaction != null) {
646             theTransaction.setDeemedBenefit(pBenefit);
647         }
648     }
649 
650     /**
651      * Obtain the withheld.
652      *
653      * @return the withheld
654      */
655     public OceanusMoney getWithheld() {
656         return theTransaction == null ? null : theTransaction.getWithheld();
657     }
658 
659     /**
660      * Set the withheld.
661      *
662      * @param pWithheld the withheld
663      * @throws OceanusException on error
664      */
665     public void setWithheld(final OceanusMoney pWithheld) throws OceanusException {
666         if (theTransaction != null) {
667             theTransaction.setWithheld(pWithheld);
668         }
669     }
670 
671     /**
672      * Obtain the partnerAmount.
673      *
674      * @return the partnerAmount
675      */
676     public OceanusMoney getPartnerAmount() {
677         return theTransaction == null ? null : theTransaction.getPartnerAmount();
678     }
679 
680     /**
681      * Set the partnerAmount.
682      *
683      * @param pAmount the amount
684      * @throws OceanusException on error
685      */
686     public void setPartnerAmount(final OceanusMoney pAmount) throws OceanusException {
687         if (theTransaction != null) {
688             theTransaction.setEmployeeNatIns(pAmount);
689         }
690     }
691 
692     /**
693      * Obtain the returnedCashAccount.
694      *
695      * @return the returnedCashAccount
696      */
697     public MoneyWiseTransAsset getReturnedCashAccount() {
698         return theTransaction == null ? null : theTransaction.getReturnedCashAccount();
699     }
700 
701     /**
702      * Set the returnedCashAccount.
703      *
704      * @param pAccount the returnedCashAccount
705      * @throws OceanusException on error
706      */
707     public void setReturnedCashAccount(final MoneyWiseTransAsset pAccount) throws OceanusException {
708         if (theTransaction != null) {
709             theTransaction.setReturnedCashAccount(pAccount);
710         }
711     }
712 
713     /**
714      * Obtain the returnedCash.
715      *
716      * @return the returnedCash
717      */
718     public OceanusMoney getReturnedCash() {
719         return theTransaction == null ? null : theTransaction.getReturnedCash();
720     }
721 
722     /**
723      * Set the returnedCash.
724      *
725      * @param pAmount the amount
726      * @throws OceanusException on error
727      */
728     public void setReturnedCash(final OceanusMoney pAmount) throws OceanusException {
729         if (theTransaction != null) {
730             theTransaction.setReturnedCash(pAmount);
731         }
732     }
733 
734     /**
735      * Obtain the accountDeltaUnits.
736      *
737      * @return the accountDeltaUnits
738      */
739     public OceanusUnits getAccountDeltaUnits() {
740         return theTransaction == null ? null : theTransaction.getAccountDeltaUnits();
741     }
742 
743     /**
744      * Set the accountDeltaUnits.
745      *
746      * @param pDelta the deltaUnits
747      * @throws OceanusException on error
748      */
749     public void setAccountDeltaUnits(final OceanusUnits pDelta) throws OceanusException {
750         if (theTransaction != null) {
751             theTransaction.setAccountDeltaUnits(pDelta);
752         }
753     }
754 
755     /**
756      * Obtain the partnerDeltaUnits.
757      *
758      * @return the partnerDeltaUnits
759      */
760     public OceanusUnits getPartnerDeltaUnits() {
761         return theTransaction == null ? null : theTransaction.getPartnerDeltaUnits();
762     }
763 
764     /**
765      * Set the partnerDeltaUnits.
766      *
767      * @param pDelta the deltaUnits
768      * @throws OceanusException on error
769      */
770     public void setPartnerDeltaUnits(final OceanusUnits pDelta) throws OceanusException {
771         if (theTransaction != null) {
772             theTransaction.setPartnerDeltaUnits(pDelta);
773         }
774     }
775 
776     /**
777      * Obtain the dilution.
778      *
779      * @return the dilution
780      */
781     public OceanusRatio getDilution() {
782         return theTransaction == null ? null : theTransaction.getDilution();
783     }
784 
785     /**
786      * Set the dilution.
787      *
788      * @param pDilution the dilution
789      * @throws OceanusException on error
790      */
791     public void setDilution(final OceanusRatio pDilution) throws OceanusException {
792         if (theTransaction != null) {
793             theTransaction.setDilution(pDilution);
794         }
795     }
796 
797     /**
798      * Obtain the transactionTags.
799      *
800      * @return the transactionTags
801      */
802     public List<MoneyWiseTransTag> getTransactionTags() {
803         return theTransaction == null ? null : theTransaction.getTransactionTags();
804     }
805 
806     /**
807      * Set the transactionTags.
808      *
809      * @param pTags the tags
810      * @throws OceanusException on error
811      */
812     public void setTransactionTags(final List<MoneyWiseTransTag> pTags) throws OceanusException {
813         if (theTransaction != null) {
814             theTransaction.setTransactionTags(pTags);
815         }
816     }
817 
818     /**
819      * Switch direction.
820      */
821     public void switchDirection() {
822         if (theTransaction != null) {
823             theTransaction.switchDirection();
824         }
825     }
826 
827     @Override
828     public int getNextVersion() {
829         return 0;
830     }
831 
832     @Override
833     public boolean isLocked() {
834         return theTransaction == null || theTransaction.isLocked();
835     }
836 
837     /**
838      * Determines whether we can switch direction.
839      *
840      * @return true/false
841      */
842     public boolean canSwitchDirection() {
843         return theTransaction != null && theTransaction.canSwitchDirection();
844     }
845 
846     /**
847      * Obtain EventInfo.
848      *
849      * @param pInfoClass the infoClass
850      * @return the Info
851      */
852     public Object getEventInfo(final MoneyWiseTransInfoClass pInfoClass) {
853         /* No info unless this is a transaction */
854         if (theTransaction == null) {
855             return null;
856         }
857 
858         /* Obtain the relevant info */
859         switch (pInfoClass) {
860             case TAXCREDIT:
861                 return theTransaction.getTaxCredit();
862             case EMPLOYEENATINS:
863                 return theTransaction.getEmployeeNatIns();
864             case EMPLOYERNATINS:
865                 return theTransaction.getEmployerNatIns();
866             case DEEMEDBENEFIT:
867                 return theTransaction.getDeemedBenefit();
868             case WITHHELD:
869                 return theTransaction.getWithheld();
870             case ACCOUNTDELTAUNITS:
871                 return theTransaction.getAccountDeltaUnits();
872             case PARTNERDELTAUNITS:
873                 return theTransaction.getPartnerDeltaUnits();
874             case DILUTION:
875                 return theTransaction.getDilution();
876             case PRICE:
877                 return theTransaction.getPrice();
878             case RETURNEDCASH:
879                 return theTransaction.getReturnedCash();
880             case RETURNEDCASHACCOUNT:
881                 return theTransaction.getReturnedCashAccount();
882             case PARTNERAMOUNT:
883                 return theTransaction.getPartnerAmount();
884             case REFERENCE:
885                 return theTransaction.getReference();
886             case COMMENTS:
887                 return theTransaction.getComments();
888             case TRANSTAG:
889                 return theTransaction.getTransactionTags();
890             default:
891                 return null;
892         }
893     }
894 }