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

Public Member Functions

 AccountsForDocumentLine (DocumentLine documentLine)
 
Set< RegisterEntrygetEntries (RegisterView view, Set< Long > bookDefs)
 
double getSubtotal (DocumentLine line)
 
double getRetained (DocumentLine line)
 
double getDiscount (DocumentLine line)
 
Double getTaxable (DocumentLine line)
 
Double getTaxValue (DocumentLine line)
 
Double getEquivalenceSurchargeValue (DocumentLine line)
 
Double getAmount (DocumentLine line)
 

Detailed Description

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

Definition at line 30 of file AccountsForDocumentLine.java.

Constructor & Destructor Documentation

◆ AccountsForDocumentLine()

org.turro.financials.model.AccountsForDocumentLine.AccountsForDocumentLine ( DocumentLine  documentLine)

Definition at line 37 of file AccountsForDocumentLine.java.

37  {
38  this.documentLine = documentLine;
39  this.contract = documentLine.getDocument().getContract();
40  this.store = documentLine.getStore();
41  this.lineType = documentLine.getLineType();
42  this.contractPreference = documentLine.getContractPreference();
43  }
Here is the call graph for this function:

Member Function Documentation

◆ getAmount()

Double org.turro.financials.model.AccountsForDocumentLine.getAmount ( DocumentLine  line)

Definition at line 221 of file AccountsForDocumentLine.java.

221  {
222 // if(line.getDocument().getContract().getOperatingModifier().isSumTax(line)) {
223 // return (getTaxable(line) * (1 + line.getFullTax() / 100)) - getRetained(line);
224 // } else {
225 // return getTaxable(line) - getRetained(line);
226 // }
227  return line.getAmount();
228  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getDiscount()

double org.turro.financials.model.AccountsForDocumentLine.getDiscount ( DocumentLine  line)

Definition at line 193 of file AccountsForDocumentLine.java.

193  {
194  //return ((getSubtotal(line) - line.getDiscountMoney()) * (line.getDiscountPerCent() / 100)) + line.getDiscountMoney();
195  return line.getDiscount();
196  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getEntries()

Set<RegisterEntry> org.turro.financials.model.AccountsForDocumentLine.getEntries ( RegisterView  view,
Set< Long >  bookDefs 
)

Definition at line 46 of file AccountsForDocumentLine.java.

46  {
47  if(store == null || lineType == null || documentLine.getSubtotal() == 0) return Collections.EMPTY_SET;
48  //int fractionDigits = documentLine.getDocument().getCurrency().getDefaultFractionDigits();
49  HashSet<RegisterEntry> set = new HashSet<>();
50  for(LineTypeAccount lta : lineType.getLineTypeAccounts()) {
51  if((view == null || lta.getView() == null || lta.getView().getId() == view.getId()) &&
52  (lta.getOperatingModifier() == null || documentLine.getDocument().getContract().getOperatingModifier().equals(lta.getOperatingModifier()))) {
53  Account account = new Account();
54  String acc = lta.getPattern();
55  if(acc.contains("%s")) {
56  if(Strings.isBlank(account.getDescription()) &&
57  !acc.contains("%sctt") && !acc.contains("%sctr")) {
58  account.setDescription(store.getFullDescription());
59  }
60  acc = convertPattern(acc, "\\%sctc", store.getContractDefinition().getAsContact());
61  acc = convertPattern(acc, "\\%scte", store.getContractDefinition().getDefaultContractPreference().getAsOperating(store));
62  acc = convertPattern(acc, "\\%sctd", store.getContractDefinition().getAsCash());
63  acc = convertPattern(acc, "\\%sctt", store.getContractDefinition().getDefaultContractPreference().getAsTax(store));
64  acc = convertPattern(acc, "\\%sctr", store.getContractDefinition().getDefaultContractPreference().getAsRetention(store));
65  acc = convertPattern(acc, "\\%sct", store.getId() + "");
66  acc = convertPattern(acc, "\\%s", store.getId() + "");
67  }
68  if(acc.contains("%ct")) {
69  if(Strings.isBlank(account.getDescription()) &&
70  !acc.contains("%ctt") && !acc.contains("%ctr") && !acc.contains("%ctq")) {
71  account.setDescription(contract.getFullDescription());
72  }
73  acc = convertPattern(acc, "\\%ctc", contract.getContractDefinition().getAsContact());
74  acc = convertPattern(acc, "\\%cte", contractPreference.getAsOperating(contract));
75  acc = convertPattern(acc, "\\%ctd", contract.getContractDefinition().getAsCash());
76  acc = convertPattern(acc, "\\%ctt", contractPreference.getAsTax(contract));
77  acc = convertPattern(acc, "\\%ctr", contractPreference.getAsRetention(contract));
78  acc = convertPattern(acc, "\\%ct", contract.getId() + "");
79  }
80  acc = convertPattern(acc, "\\%ltv", convertToString(lta.getTypeValue()));
81  acc = convertPattern(acc, "\\%ldv", convertToString(documentLine.getTax()));
82  acc = convertPattern(acc, "\\%ldq", convertToString(documentLine.getEquivalenceSurcharge()));
83  acc = convertPattern(acc, "\\%ldr", convertToString(documentLine.getRetention()));
84  account.setId(AccountFormat.expand(acc));
85  if(Strings.isBlank(account.getDescription())) {
86  MajorAccount ma = account.getParent();
87  if(ma != null) {
88  String extra = "";
89  if(lta.getType().equals(LineTypeAccountType.LTAT_TAX)) {
90  if(lta.getTypeValue() != 0) {
91  extra = " (" + lta.getTypeValue() + ")";
92  } else if(documentLine.getTax() != 0) {
93  extra = " (" + documentLine.getTax() + ")";
94  }
95  } else if(lta.getType().equals(LineTypeAccountType.LTAT_REQ)) {
96  if(lta.getTypeValue() != 0) {
97  extra = " (" + lta.getTypeValue() + ")";
98  } else if(documentLine.getEquivalenceSurcharge()!= 0) {
99  extra = " (" + documentLine.getEquivalenceSurcharge()+ ")";
100  }
101  } else if(lta.getType().equals(LineTypeAccountType.LTAT_RETENTION)) {
102  if(lta.getTypeValue() != 0) {
103  extra = " (" + lta.getTypeValue() + ")";
104  } else if(documentLine.getRetention() != 0) {
105  extra = " (" + documentLine.getRetention() + ")";
106  }
107  }
108  account.setDescription(ma.getDescription() + extra);
109  }
110  }
111  RegisterEntry re = new RegisterEntry();
112  re.setAccount(account);
113  re.setConcept(lineType.getComposedName());
114  double amount = 0;
115  if(lta.getType().equals(LineTypeAccountType.LTAT_TOTAL)) {
116  //amount = new Round(documentLine.getAmount() * lta.getCoefficient()).decimals(fractionDigits).value();
117  amount = getAmount(documentLine) * lta.getCoefficient();
118  } else if(lta.getType().equals(LineTypeAccountType.LTAT_TAX_BASE)) {
119  //amount = new Round(documentLine.getTaxable() * lta.getCoefficient()).decimals(fractionDigits).value();
120  amount = getTaxable(documentLine) * lta.getCoefficient();
121  } else if(lta.getType().equals(LineTypeAccountType.LTAT_TAX)) {
122  if(lta.getTypeValue() == 0 || lta.getTypeValue() == documentLine.getTax()) {
123  //amount = new Round(documentLine.getTaxValue() * lta.getCoefficient()).decimals(fractionDigits).value();
124  amount = getTaxValue(documentLine) * lta.getCoefficient();
125  }
126  } else if(lta.getType().equals(LineTypeAccountType.LTAT_REQ)) {
127  if(lta.getTypeValue() == 0 || lta.getTypeValue() == documentLine.getEquivalenceSurcharge()) {
128  //amount = new Round(documentLine.getTaxValue() * lta.getCoefficient()).decimals(fractionDigits).value();
129  amount = getEquivalenceSurchargeValue(documentLine) * lta.getCoefficient();
130  }
131  } else if(lta.getType().equals(LineTypeAccountType.LTAT_RETENTION)) {
132  if(lta.getTypeValue() == 0 || lta.getTypeValue() == documentLine.getRetention()) {
133  //amount = new Round(documentLine.getTaxValue() * lta.getCoefficient()).decimals(fractionDigits).value();
134  amount = getRetained(documentLine) * lta.getCoefficient();
135  }
136  } else if(lta.getType().equals(LineTypeAccountType.LTAT_DISCOUNT)) {
137  //amount = new Round(documentLine.getDiscount() * lta.getCoefficient()).decimals(fractionDigits).value();
138  amount = getDiscount(documentLine) * lta.getCoefficient();
139  }
140  if(lta.getPosition().equals(AccountPosition.ACC_DEBIT)) {
141  re.setDebit(amount);
142  } else {
143  re.setCredit(amount);
144  }
145  if(re.getDebit() != 0 || re.getCredit() != 0) {
146  MajorAccount ma = account.getParent();
147  if(ma != null) {
149  if(bf != null) {
150  bookDefs.add(bf.getId());
151  }
152  }
153  set.add(re);
154  }
155  }
156  }
157  return set;
158  }
void setDescription(String description)
Definition: Account.java:45
ContractDefinition getContractDefinition()
Definition: Contract.java:125
OperatingModifier getOperatingModifier()
Definition: Contract.java:228
Set< LineTypeAccount > getLineTypeAccounts()
Definition: LineType.java:92
Here is the call graph for this function:

◆ getEquivalenceSurchargeValue()

Double org.turro.financials.model.AccountsForDocumentLine.getEquivalenceSurchargeValue ( DocumentLine  line)

Definition at line 212 of file AccountsForDocumentLine.java.

212  {
213 // if(line.getEquivalenceSurcharge() > 0) {
214 // return getFullTaxValue(line) * line.getEquivalenceSurcharge() / line.getFullTax();
215 // }
216 // return 0.0;
217  return line.getEquivalenceSurchargeValue();
218  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getRetained()

double org.turro.financials.model.AccountsForDocumentLine.getRetained ( DocumentLine  line)

Definition at line 188 of file AccountsForDocumentLine.java.

188  {
189  //return (line.getSubtotal() - line.getDiscount()) * (line.getRetention() / 100);
190  return line.getRetained();
191  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getSubtotal()

double org.turro.financials.model.AccountsForDocumentLine.getSubtotal ( DocumentLine  line)

Definition at line 183 of file AccountsForDocumentLine.java.

183  {
184  //return line.getQuantity() == 0 ? line.getPrice() : line.getPrice() * line.getQuantity();
185  return line.getSubtotal();
186  }
Here is the call graph for this function:

◆ getTaxable()

Double org.turro.financials.model.AccountsForDocumentLine.getTaxable ( DocumentLine  line)

Definition at line 198 of file AccountsForDocumentLine.java.

198  {
199  //return getSubtotal(line) - getDiscount(line);
200  return line.getTaxable();
201  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getTaxValue()

Double org.turro.financials.model.AccountsForDocumentLine.getTaxValue ( DocumentLine  line)

Definition at line 203 of file AccountsForDocumentLine.java.

203  {
204 // if(line.getTax() > 0) {
205 // return getFullTaxValue(line) * line.getTax() / line.getFullTax();
206 // }
207 // return 0.0;
208 // //return (getRealAmount(line) + getRetained(line)) - getTaxable(line);
209  return line.getRealTaxValue();
210  }
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: