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.uk;
18
19 import io.github.tonywasher.joceanus.oceanus.decimal.OceanusMoney;
20 import io.github.tonywasher.joceanus.metis.field.MetisFieldSet;
21
22 /**
23 * Rental Tax Scheme.
24 */
25 public class MoneyWiseUKRoomRentalScheme
26 extends MoneyWiseUKIncomeScheme {
27 /**
28 * Local Report fields.
29 */
30 private static final MetisFieldSet<MoneyWiseUKRoomRentalScheme> FIELD_DEFS = MetisFieldSet.newFieldSet(MoneyWiseUKRoomRentalScheme.class);
31
32 /**
33 * Constructor.
34 */
35 public MoneyWiseUKRoomRentalScheme() {
36 }
37
38 @Override
39 protected OceanusMoney adjustAllowances(final MoneyWiseUKTaxConfig pConfig,
40 final OceanusMoney pAmount) {
41 /* Adjust against the rental allowance for room rental */
42 OceanusMoney myRemaining = adjustForAllowance(pConfig.getRentalAllowance(), pAmount);
43
44 /* If we have any income left */
45 if (myRemaining.isNonZero()) {
46 /* Adjust the basic allowance */
47 myRemaining = super.adjustAllowances(pConfig, myRemaining);
48 }
49
50 /* Return unallocated income */
51 return myRemaining;
52 }
53
54 @Override
55 protected OceanusMoney getAmountInAllowance(final MoneyWiseUKTaxConfig pConfig,
56 final OceanusMoney pAmount) {
57 /* Obtain the amount covered by the room rental allowance */
58 OceanusMoney myAmount = getAmountInBand(pConfig.getCapitalAllowance(), pAmount);
59
60 /* If we have income left over */
61 if (myAmount.compareTo(pAmount) < 0) {
62 /* Calculate remaining amount */
63 final OceanusMoney myRemaining = new OceanusMoney(pAmount);
64 myRemaining.subtractAmount(myAmount);
65
66 /* Calculate the amount covered by basic allowance */
67 final OceanusMoney myXtra = super.getAmountInAllowance(pConfig, myRemaining);
68
69 /* Determine the total amount covered by the allowance */
70 myAmount = new OceanusMoney(myAmount);
71 myAmount.addAmount(myXtra);
72 }
73
74 /* return the amount */
75 return myAmount;
76 }
77
78 @Override
79 public MetisFieldSet<MoneyWiseUKRoomRentalScheme> getDataFieldSet() {
80 return FIELD_DEFS;
81 }
82 }