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