BrightSide Workbench Full Report + Source Code
SettlementEntry.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2011 Lluis TurrĂ³ Cutiller <http://www.turro.org/>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Affero General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Affero General Public License for more details.
14  *
15  * You should have received a copy of the GNU Affero General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 package org.turro.financials.treasury.settlement;
19 
20 import org.turro.math.Zero;
21 import org.turro.util.CompareUtil;
22 
27 public class SettlementEntry implements Comparable<SettlementEntry> {
28 
29  private String account, name;
30  private double amount;
31  private boolean checked = true;
32 
33  public SettlementEntry(String account, String name) {
34  this.account = account;
35  this.name = name;
36  }
37 
38  public String getAccount() {
39  return account;
40  }
41 
42  public double getAmount() {
43  return Zero.near(amount, 2) ? 0.0 : amount;
44  }
45 
46  public void setAmount(double amount) {
47  this.amount = amount;
48  }
49 
50  public boolean isChecked() {
51  return checked;
52  }
53 
54  public void setChecked(boolean checked) {
55  this.checked = checked;
56  }
57 
58  public boolean isCreditor() {
59  return account.matches(SettlementSet.CREDITOR_EXP.replaceAll("\\%", "[0-9]*"));
60  }
61 
62  public boolean isCreditorIRPF() {
63  return account.matches(SettlementSet.CREDITOR_EXP.replaceAll("\\%", "1[1-9][0-9]*"));
64  }
65 
66  public boolean isCreditorVAT() {
67  return account.matches(SettlementSet.CREDITOR_EXP.replaceAll("\\%", "0[0-9]*"));
68  }
69 
70  public boolean isDebtor() {
71  return account.matches(SettlementSet.DEBTOR_EXP.replaceAll("\\%", "[0-9]*")) ||
72  account.matches(SettlementSet.ON_ACCOUNT_EXP.replaceAll("\\%", "[0-9]*"));
73  }
74 
75  public String getName() {
76  return name;
77  }
78 
79  @Override
80  public int compareTo(SettlementEntry o) {
81  return CompareUtil.compare(account, o.account);
82  }
83 
84 }
static boolean near(double value, int digits)
Definition: Zero.java:30