BrightSide Workbench Full Report + Source Code
org.turro.financials.model.AccountCreator Class Reference
Collaboration diagram for org.turro.financials.model.AccountCreator:

Public Member Functions

 AccountCreator (Document document, LineType lineType, Contract store)
 
Set< AccountgetAccounts ()
 

Static Public Member Functions

static String convertToString (double value)
 
static AccountSet getPosibleAccounts ()
 
static AccountSet getOnUseAccounts ()
 

Detailed Description

Author
Lluis TurrĂ³ Cutiller lluis.nosp@m.@tur.nosp@m.ro.or.nosp@m.g

Definition at line 31 of file AccountCreator.java.

Constructor & Destructor Documentation

◆ AccountCreator()

org.turro.financials.model.AccountCreator.AccountCreator ( Document  document,
LineType  lineType,
Contract  store 
)

Definition at line 37 of file AccountCreator.java.

37  {
38  this.contract = document.getContract();
39  this.store = store;
40  this.document = document;
41  this.lineType = lineType;
42  }
Here is the call graph for this function:
Here is the caller graph for this function:

Member Function Documentation

◆ convertToString()

static String org.turro.financials.model.AccountCreator.convertToString ( double  value)
static

Definition at line 89 of file AccountCreator.java.

89  {
90  return Double.valueOf(value * 10).intValue() + "";
91  }
Here is the caller graph for this function:

◆ getAccounts()

Set<Account> org.turro.financials.model.AccountCreator.getAccounts ( )

Definition at line 44 of file AccountCreator.java.

44  {
45  HashSet<Account> set = new HashSet<Account>();
46  for(LineTypeAccount lta : lineType.getLineTypeAccounts()) {
47  Account account = new Account();
48  String acc = lta.getPattern();
49 
50  if(acc.indexOf("%s") > -1) {
51  if(Strings.isBlank(account.getDescription())) {
52  account.setDescription(store.getFullDescription());
53  }
54  acc = convertPattern(acc, "\\%sctc", store.getContractDefinition().getAsContact());
55  acc = convertPattern(acc, "\\%scte", store.getContractDefinition().getDefaultContractPreference().getAsOperating(store));
56  acc = convertPattern(acc, "\\%sctd", store.getContractDefinition().getAsCash());
57  acc = convertPattern(acc, "\\%sctt", store.getContractDefinition().getDefaultContractPreference().getAsTax(store));
58  acc = convertPattern(acc, "\\%sctr", store.getContractDefinition().getDefaultContractPreference().getAsRetention(store));
59  acc = convertPattern(acc, "\\%sct", store.getId() + "");
60  acc = convertPattern(acc, "\\%s", store.getId() + "");
61  }
62  if(acc.indexOf("%ct") > -1) {
63  if(Strings.isBlank(account.getDescription())) {
64  account.setDescription(contract.getFullDescription());
65  }
66  acc = convertPattern(acc, "\\%ctc", contract.getContractDefinition().getAsContact());
67  acc = convertPattern(acc, "\\%cte", lineType.getContractPreference().getAsOperating(contract));
68  acc = convertPattern(acc, "\\%ctd", contract.getContractDefinition().getAsCash());
69  acc = convertPattern(acc, "\\%ctt", lineType.getContractPreference().getAsTax(contract));
70  acc = convertPattern(acc, "\\%ctr", lineType.getContractPreference().getAsRetention(contract));
71  acc = convertPattern(acc, "\\%ct", contract.getId() + "");
72  }
73  acc = convertPattern(acc, "\\%ltv", convertToString(lta.getTypeValue()));
74  // No dinamyc instance
75  //acc = convertPattern(acc, "\\%ldv", convertToString(documentLine.getTax()));
76  account.setId(AccountFormat.expand(acc));
77  if(Strings.isBlank(account.getDescription())) {
78  MajorAccount ma = account.getParent();
79  if(ma != null) {
80  account.setDescription(ma.getDescription() +
81  (lta.getTypeValue() != 0 ? (" (" + lta.getTypeValue() + ")") : ""));
82  }
83  }
84  set.add(account);
85  }
86  return set;
87  }
void setDescription(String description)
Definition: Account.java:45
ContractDefinition getContractDefinition()
Definition: Contract.java:125
ContractPreference getContractPreference()
Definition: LineType.java:77
Set< LineTypeAccount > getLineTypeAccounts()
Definition: LineType.java:92
static String convertToString(double value)
Here is the call graph for this function:

◆ getOnUseAccounts()

static AccountSet org.turro.financials.model.AccountCreator.getOnUseAccounts ( )
static

Definition at line 142 of file AccountCreator.java.

142  {
143  AccountSet accs = new AccountSet();
144 
145  List<Account> accounts = new FinancialsPU().getResultList(
146  "select distinct entry.account from RegisterEntry as entry"
147  );
148 
149  accs.addAll(accounts);
150 
151  return accs;
152  }
Here is the caller graph for this function:

◆ getPosibleAccounts()

static AccountSet org.turro.financials.model.AccountCreator.getPosibleAccounts ( )
static

Definition at line 103 of file AccountCreator.java.

103  {
104  AccountSet accs = new AccountSet();
105 
106  List<Contract> contracts = new FinancialsPU().getResultList(
107  "select ctc from Contract as ctc " +
108  "order by ctc.contractDefinition.name, ctc.contractDefinition.id, ctc.id"
109  );
110 
111  for(Contract contract : contracts) {
112  for(final RelatedDocument rd : contract.getContractDefinition().getRelatedDocuments()) {
114 
115  List<Contract> stores = new FinancialsPU().getResultList(
116  "select ctc from Contract as ctc " +
117  "where stock = TRUE " +
118  "and ctc.contractDefinition = ? " +
119  "order by ctc.contractDefinition.name, ctc.contractDefinition.id, ctc.id",
120  new Object[] { rsd.getRelatedStore() }
121  );
122 
123  for(Contract store : stores) {
124  Document document = new Document();
125  document.setDocumentDefinition(rd.getDocumentDefinition());
126  document.setContract(contract);
127 
129  for(ContractPreference cp : contract.getContractPreferences()) {
130  rlt.getLineType().setContractPreference(cp);
131  accs.addAll(new AccountCreator(document, rlt.getLineType(), store).getAccounts());
132  }
133  }
134  }
135  }
136  }
137  }
138 
139  return accs;
140  }
Set< ContractPreference > getContractPreferences()
Definition: Contract.java:145
void setContract(Contract contract)
Definition: Document.java:123
void setDocumentDefinition(DocumentDefinition documentDefinition)
Definition: Document.java:175
AccountCreator(Document document, LineType lineType, Contract store)
Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following file: