BrightSide Workbench Full Report + Source Code
ContractPortfolioList.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2019 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 
19 package org.turro.financials.model.document.contract;
20 
21 import java.util.Date;
22 import java.util.TreeSet;
23 import org.turro.financials.entity.Contract;
24 import org.turro.financials.entity.Document;
25 import org.turro.financials.entity.RegisterView;
26 import org.turro.i18n.I_;
27 
32 public class ContractPortfolioList extends TreeSet<DocumentPortfolio> {
33 
35  Contract contract, Date from, Date to) {
36  fillPortfolio(documents, view, contract, from, to);
37  }
38 
39  private void fillPortfolio(DocumentByContractList documents, RegisterView view,
40  Contract contract, Date from, Date to) {
41 
42  documents.fillList(view, contract, from, to);
43 
44  double final_balance = documents.getInitialBalance(view, contract, from, to);
45 
47 
48  dp.setDocument(null);
49  dp.setDate(null);
50  dp.setConcept(I_.get("Accumulated"));
51  dp.setInvoice(null);
52  dp.setPortfolio(null);
53  dp.setSettlement(null);
54  dp.setBalance(final_balance);
55 
56  add(dp);
57 
58  for(final Document doc : documents) {
59 
60  if(doc.getDocumentDefinition().getId() != 1 &&
61  doc.getDocumentDefinition().getId() != 67 &&
62  doc.getDocumentDefinition().getId() != 2 &&
63  doc.getDocumentDefinition().getId() != 43 &&
64  doc.getDocumentDefinition().getId() != 44 &&
65  doc.getDocumentDefinition().getId() != 6 &&
66  doc.getDocumentDefinition().getId() != 7) {
67  continue;
68  }
69 
70  dp = new DocumentPortfolio();
71 
72  dp.setDocument(doc);
73  dp.setDate(doc.getDocumentDate());
74  dp.setConcept(doc.getDocumentDefinition().getName() + " " + doc.getDocumentNumber());
75 
76  double amount = doc.getTotalAmount();
77 
78  switch ((int) doc.getDocumentDefinition().getId()) {
79  case 1:
80  case 67:
81  case 2:
82  final_balance += amount;
83  dp.setInvoice(amount);
84  dp.setPortfolio(null);
85  dp.setSettlement(null);
86  dp.setBalance(final_balance);
87  break;
88  case 43:
89  case 44:
90  dp.setInvoice(null);
91  dp.setPortfolio(amount);
92  dp.setSettlement(null);
93  dp.setBalance(final_balance);
94  break;
95  case 6:
96  case 7:
97  final_balance -= amount;
98  dp.setInvoice(null);
99  dp.setPortfolio(null);
100  dp.setSettlement(amount);
101  dp.setBalance(final_balance);
102  break;
103  default:
104  break;
105  }
106 
107  add(dp);
108 
109  }
110 
111  }
112 
113 }
ContractPortfolioList(DocumentByContractList documents, RegisterView view, Contract contract, Date from, Date to)
void fillList(RegisterView view, Contract contract, Date from, Date to)
double getInitialBalance(RegisterView view, Contract contract, Date from, Date to)
static String get(String msg)
Definition: I_.java:41