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.resource.OceanusBundleId;
20  import io.github.tonywasher.joceanus.oceanus.resource.OceanusBundleLoader;
21  import io.github.tonywasher.joceanus.metis.data.MetisDataItem.MetisDataFieldId;
22  
23  import java.util.EnumMap;
24  import java.util.Map;
25  import java.util.ResourceBundle;
26  
27  /**
28   * Resource IDs for MoneyWise Tax Fields.
29   */
30  public enum MoneyWiseTaxResource
31          implements OceanusBundleId, MetisDataFieldId {
32      /**
33       * Basic Allowance.
34       */
35      ALLOWANCE_BASIC("Allowance.Basic"),
36  
37      /**
38       * Rental Allowance.
39       */
40      ALLOWANCE_RENTAL("Allowance.Rental"),
41  
42      /**
43       * Capital Allowance.
44       */
45      ALLOWANCE_CAPITAL("Allowance.Capital"),
46  
47      /**
48       * Savings Allowance.
49       */
50      ALLOWANCE_SAVINGS("Allowance.Savings"),
51  
52      /**
53       * Dividend Allowance.
54       */
55      ALLOWANCE_DIVIDEND("Allowance.Dividend"),
56  
57      /**
58       * LoAge Allowance.
59       */
60      ALLOWANCE_LOAGE("Allowance.LoAge"),
61  
62      /**
63       * HiAge Allowance.
64       */
65      ALLOWANCE_HIAGE("Allowance.HiAge"),
66  
67      /**
68       * AgeAllowanceLimit.
69       */
70      LIMIT_AGEALLOWANCE("Limit.AgeAllowance"),
71  
72      /**
73       * AdditionalAllowanceLimit.
74       */
75      LIMIT_ADDALLOWANCE("Limit.AdditionalAllowance"),
76  
77      /**
78       * Scheme BaseRate.
79       */
80      SCHEME_BASE_RATE("Scheme.BaseRate"),
81  
82      /**
83       * Scheme HighRate.
84       */
85      SCHEME_HIGH_RATE("Scheme.HighRate"),
86  
87      /**
88       * Scheme AdditionalRate.
89       */
90      SCHEME_ADDITIONAL_RATE("Scheme.AdditionalRate"),
91  
92      /**
93       * Scheme Residential.
94       */
95      SCHEME_RESIDENTIAL("Scheme.Residential"),
96  
97      /**
98       * Scheme Relief Available.
99       */
100     SCHEME_RELIEF_AVAILABLE("Scheme.ReliefAvailable"),
101 
102     /**
103      * TaxBands Standard.
104      */
105     TAXBANDS_STANDARD("TaxBands.Standard"),
106 
107     /**
108      * TaxBands LoSavings.
109      */
110     TAXBANDS_LOSAVINGS("TaxBands.LoSavings"),
111 
112     /**
113      * TaxBands Amount.
114      */
115     TAXBANDS_AMOUNT("TaxBands.Amount"),
116 
117     /**
118      * TaxBands Rate.
119      */
120     TAXBANDS_RATE("TaxBands.Rate"),
121 
122     /**
123      * TaxBands TaxableIncome.
124      */
125     TAXBANDS_INCOME("TaxBands.Income"),
126 
127     /**
128      * TaxBands TaxDue.
129      */
130     TAXBANDS_TAXDUE("TaxBands.TaxDue"),
131 
132     /**
133      * TaxBands hasLoTaxBand.
134      */
135     TAXBANDS_HASLOTAXBAND("TaxBands.hasLoTaxBand"),
136 
137     /**
138      * TaxYear Name.
139      */
140     TAXYEAR_NAME("TaxYear.Name"),
141 
142     /**
143      * TaxYear End.
144      */
145     TAXYEAR_END("TaxYear.End"),
146 
147     /**
148      * TaxYear Allowances.
149      */
150     TAXYEAR_ALLOWANCES("TaxYear.Allowances"),
151 
152     /**
153      * TaxYear Bands.
154      */
155     TAXYEAR_BANDS("TaxYear.Bands"),
156 
157     /**
158      * TaxYear Capital.
159      */
160     TAXYEAR_INTEREST("TaxYear.Interest"),
161 
162     /**
163      * TaxYear Capital.
164      */
165     TAXYEAR_DIVIDEND("TaxYear.Dividend"),
166 
167     /**
168      * TaxYear Capital.
169      */
170     TAXYEAR_CAPITAL("TaxYear.Capital"),
171 
172     /**
173      * TaxYear Profit.
174      */
175     TAXYEAR_PROFIT("TaxYear.Profit"),
176 
177     /**
178      * TaxConfig Name.
179      */
180     TAXCONFIG_NAME("TaxConfig.Name"),
181 
182     /**
183      * TaxConfig GrossTaxable.
184      */
185     TAXCONFIG_GROSS("TaxConfig.GrossTaxable"),
186 
187     /**
188      * TaxConfig GrossPreSavings.
189      */
190     TAXCONFIG_PRESAVINGS("TaxConfig.GrossPreSavings"),
191 
192     /**
193      * TaxConfig Birthday.
194      */
195     TAXCONFIG_BIRTHDAY("TaxConfig.Birthday"),
196 
197     /**
198      * TaxConfig Age.
199      */
200     TAXCONFIG_AGE("TaxConfig.Age"),
201 
202     /**
203      * TaxConfig AgeAllowances.
204      */
205     TAXCONFIG_AGEALLOWANCE("TaxConfig.AgeAllowances"),
206 
207     /**
208      * Analysis TaxBuckets.
209      */
210     TAXANALYSIS_TAXBUCKETS("TaxAnalysis.TaxBuckets"),
211 
212     /**
213      * Analysis TaxProfit.
214      */
215     TAXANALYSIS_TAXPROFIT("TaxAnalysis.TaxProfit"),
216 
217     /**
218      * TaxPreference Name.
219      */
220     TAXPREF_NAME("preference.display"),
221 
222     /**
223      * TaxPreference Birthday.
224      */
225     TAXPREF_BIRTH("preference.birth"),
226 
227     /**
228      * Marginal Reduction.
229      */
230     MARGINAL_REDUCTION("Marginal.Name"),
231 
232     /**
233      * Marginal OneInTwo.
234      */
235     MARGINAL_ONEINTWO("Marginal.OneInTwo"),
236 
237     /**
238      * Marginal TwoInThree.
239      */
240     MARGINAL_TWOINTHREE("Marginal.TwoInThree"),
241 
242     /**
243      * CashType Large.
244      */
245     CASHTYPE_LARGE("CashType.Large"),
246 
247     /**
248      * CashType Small.
249      */
250     CASHTYPE_SMALL("CashType.Small"),
251 
252     /**
253      * ChargeableGain Gain.
254      */
255     CHARGEABLEGAIN_GAIN("ChargeableGain.Gain"),
256 
257     /**
258      * ChargeableGain Slice.
259      */
260     CHARGEABLEGAIN_SLICE("ChargeableGain.Slice"),
261 
262     /**
263      * ChargeableGain TotalGain.
264      */
265     CHARGEABLEGAIN_TOTALGAINS("ChargeableGain.TotalGains"),
266 
267     /**
268      * ChargeableGain TotalSlices.
269      */
270     CHARGEABLEGAIN_TOTALSLICES("ChargeableGain.TotalSlices"),
271 
272     /**
273      * ChargeableGain Ratio.
274      */
275     CHARGEABLEGAIN_RATIO("ChargeableGain.Ratio"),
276 
277     /**
278      * ChargeableGain TaxedSlices.
279      */
280     CHARGEABLEGAIN_TAXEDSLICES("ChargeableGain.TaxedSlices"),
281 
282     /**
283      * ChargeableGain NettTaxDue.
284      */
285     CHARGEABLEGAIN_NETTTAXDUE("ChargeableGain.NettTaxDue"),
286 
287     /**
288      * ChargeableGain TaxRelief.
289      */
290     CHARGEABLEGAIN_TAXRELIEF("ChargeableGain.TaxRelief");
291 
292     /**
293      * The Marginal Map.
294      */
295     private static final Map<MoneyWiseMarginalReduction, OceanusBundleId> MARGINAL_MAP = buildMarginalMap();
296 
297     /**
298      * The CashType Map.
299      */
300     private static final Map<MoneyWiseCashType, OceanusBundleId> CASHTYPE_MAP = buildCashTypeMap();
301 
302     /**
303      * The Resource Loader.
304      */
305     private static final OceanusBundleLoader LOADER = OceanusBundleLoader.getLoader(MoneyWiseTaxResource.class.getCanonicalName(),
306             ResourceBundle::getBundle);
307 
308     /**
309      * The Id.
310      */
311     private final String theKeyName;
312 
313     /**
314      * The Value.
315      */
316     private String theValue;
317 
318     /**
319      * Constructor.
320      *
321      * @param pKeyName the key name
322      */
323     MoneyWiseTaxResource(final String pKeyName) {
324         theKeyName = pKeyName;
325     }
326 
327     @Override
328     public String getKeyName() {
329         return theKeyName;
330     }
331 
332     @Override
333     public String getNameSpace() {
334         return "MoneyWise.tax";
335     }
336 
337     @Override
338     public String getValue() {
339         /* If we have not initialised the value */
340         if (theValue == null) {
341             /* Derive the value */
342             theValue = LOADER.getValue(this);
343         }
344 
345         /* return the value */
346         return theValue;
347     }
348 
349     @Override
350     public String getId() {
351         return getValue();
352     }
353 
354     /**
355      * Build marginal map.
356      *
357      * @return the map
358      */
359     private static Map<MoneyWiseMarginalReduction, OceanusBundleId> buildMarginalMap() {
360         /* Create the map and return it */
361         final Map<MoneyWiseMarginalReduction, OceanusBundleId> myMap = new EnumMap<>(MoneyWiseMarginalReduction.class);
362         myMap.put(MoneyWiseMarginalReduction.ONEINTWO, MARGINAL_ONEINTWO);
363         myMap.put(MoneyWiseMarginalReduction.TWOINTHREE, MARGINAL_TWOINTHREE);
364         return myMap;
365     }
366 
367     /**
368      * Obtain key for marginal reduction type.
369      *
370      * @param pValue the Value
371      * @return the resource key
372      */
373     protected static OceanusBundleId getKeyForMarginalReduction(final MoneyWiseMarginalReduction pValue) {
374         return OceanusBundleLoader.getKeyForEnum(MARGINAL_MAP, pValue);
375     }
376 
377     /**
378      * Build cashType map.
379      *
380      * @return the map
381      */
382     private static Map<MoneyWiseCashType, OceanusBundleId> buildCashTypeMap() {
383         /* Create the map and return it */
384         final Map<MoneyWiseCashType, OceanusBundleId> myMap = new EnumMap<>(MoneyWiseCashType.class);
385         myMap.put(MoneyWiseCashType.LARGECASH, CASHTYPE_LARGE);
386         myMap.put(MoneyWiseCashType.SMALLCASH, CASHTYPE_SMALL);
387         return myMap;
388     }
389 
390     /**
391      * Obtain key for cash type.
392      *
393      * @param pValue the Value
394      * @return the resource key
395      */
396     protected static OceanusBundleId getKeyForCashType(final MoneyWiseCashType pValue) {
397         return OceanusBundleLoader.getKeyForEnum(CASHTYPE_MAP, pValue);
398     }
399 }