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.tax;
18  
19  import io.github.tonywasher.joceanus.oceanus.date.OceanusDate;
20  import io.github.tonywasher.joceanus.oceanus.format.OceanusDataFormatter;
21  import io.github.tonywasher.joceanus.metis.field.MetisFieldItem;
22  import io.github.tonywasher.joceanus.metis.field.MetisFieldSet;
23  import io.github.tonywasher.joceanus.metis.preference.MetisPreferenceManager;
24  import io.github.tonywasher.joceanus.moneywise.data.basic.MoneyWiseTax.MoneyWiseTaxCredit;
25  
26  /**
27   * The Tax Year.
28   */
29  public abstract class MoneyWiseTaxYear
30          implements MetisFieldItem, MoneyWiseTaxCredit {
31      /**
32       * Local Report fields.
33       */
34      private static final MetisFieldSet<MoneyWiseTaxYear> FIELD_DEFS = MetisFieldSet.newFieldSet(MoneyWiseTaxYear.class);
35  
36      /*
37       * Declare Fields.
38       */
39      static {
40          FIELD_DEFS.declareLocalField(MoneyWiseTaxResource.TAXYEAR_END, MoneyWiseTaxYear::getYearEnd);
41      }
42  
43      /**
44       * The Date.
45       */
46      private final OceanusDate theYear;
47  
48      /**
49       * Constructor.
50       *
51       * @param pDate the tax year end
52       */
53      protected MoneyWiseTaxYear(final OceanusDate pDate) {
54          theYear = pDate;
55      }
56  
57      @Override
58      public OceanusDate getYearEnd() {
59          return theYear;
60      }
61  
62      /**
63       * Obtain the taxAnalysis for the year.
64       *
65       * @param pPreferences the preference manager
66       * @param pTaxSource   the tax source
67       * @return the tax analysis
68       */
69      public abstract MoneyWiseTaxAnalysis analyseTaxYear(MetisPreferenceManager pPreferences,
70                                                          MoneyWiseTaxSource pTaxSource);
71  
72      @Override
73      public String formatObject(final OceanusDataFormatter pFormatter) {
74          return toString();
75      }
76  
77      @Override
78      public String toString() {
79          return Integer.toString(theYear.getYear());
80      }
81  }