18 package org.turro.financials.model;
20 import java.util.HashSet;
21 import java.util.List;
23 import org.turro.string.Strings;
24 import org.turro.financials.db.FinancialsPU;
25 import org.turro.financials.entity.*;
40 this.document = document;
41 this.lineType = lineType;
45 HashSet<Account>
set =
new HashSet<Account>();
48 String acc = lta.getPattern();
50 if(acc.indexOf(
"%s") > -1) {
59 acc = convertPattern(acc,
"\\%sct", store.
getId() +
"");
60 acc = convertPattern(acc,
"\\%s", store.
getId() +
"");
62 if(acc.indexOf(
"%ct") > -1) {
71 acc = convertPattern(acc,
"\\%ct", contract.
getId() +
"");
73 acc = convertPattern(acc,
"\\%ltv",
convertToString(lta.getTypeValue()));
81 (lta.getTypeValue() != 0 ? (
" (" + lta.getTypeValue() +
")") :
""));
90 return Double.valueOf(value * 10).intValue() +
"";
93 private String convertPattern(String text, String pattern, String value) {
94 int l = value ==
null ? 0 : value.length();
95 if(text.contains(pattern.replaceAll(
"\\\\",
"") +
"%1") && l > 1) {
96 return text.replaceAll(pattern +
"\\%1", value.substring(0, 1));
97 }
else if(text.contains(pattern.replaceAll(
"\\\\",
"") +
"%2") && l > 2) {
98 return text.replaceAll(pattern +
"\\%2", value.substring(0, 2));
100 return text.replaceAll(pattern, value);
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"
111 for(
Contract contract : contracts) {
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() }
130 rlt.getLineType().setContractPreference(cp);
131 accs.addAll(
new AccountCreator(document, rlt.getLineType(), store).getAccounts());
145 List<Account> accounts =
new FinancialsPU().getResultList(
146 "select distinct entry.account from RegisterEntry as entry"
149 accs.addAll(accounts);
void setDescription(String description)
ContractPreference getDefaultContractPreference()
Set< RelatedDocument > getRelatedDocuments()
ContractDefinition getContractDefinition()
Set< ContractPreference > getContractPreferences()
String getFullDescription()
Set< RelatedStoreDefinition > getRelatedStoreDefinitions()
Set< RelatedLineType > getRelatedLineTypes()
void setContract(Contract contract)
void setDocumentDefinition(DocumentDefinition documentDefinition)
ContractPreference getContractPreference()
Set< LineTypeAccount > getLineTypeAccounts()
static AccountSet getOnUseAccounts()
AccountCreator(Document document, LineType lineType, Contract store)
static AccountSet getPosibleAccounts()
static String convertToString(double value)
Set< Account > getAccounts()