19 package org.turro.financials.command;
21 import org.turro.financials.db.FinancialsPU;
22 import org.turro.financials.entity.Contract;
23 import org.turro.financials.model.AccountFormat;
24 import org.turro.jpa.Dao;
25 import org.turro.math.Zero;
34 private double invoice, balance;
35 private boolean filled =
false;
38 this.contract = contract;
42 if(!filled) fillData();
47 if(!filled) fillData();
52 if(!filled) fillData();
53 return Zero.
near(balance, 2) ? 0.0 : balance;
56 private void fillData() {
63 "select sum(re.debit - re.credit) from RegisterEntry as re " +
68 if(o instanceof Number) {
69 balance = ((Number) o).doubleValue();
72 "select sum(re.credit) from RegisterEntry as re " +
73 "where(re.account.id like '" + AccountFormat.expand(
"400." + contract.
getId()) +
"' " +
74 "or re.account.id like '" + AccountFormat.expand(
"410." + contract.
getId()) +
"')");
75 if(o instanceof Number) {
76 invoice = ((Number) o).doubleValue();
81 "select sum(re.debit - re.credit) from RegisterEntry as re " +
82 "where (re.account.id like '" + AccountFormat.expand(
"430." + contract.
getId()) +
"' " +
83 "or re.account.id like '" + AccountFormat.expand(
"431." + contract.
getId()) +
"' " +
84 "or re.account.id like '" + AccountFormat.expand(
"440." + contract.
getId()) +
"' " +
85 "or re.account.id like '" + AccountFormat.expand(
"441." + contract.
getId()) +
"')");
86 if(o instanceof Number) {
87 balance = -((Number) o).doubleValue();
90 "select sum(re.debit) from RegisterEntry as re " +
91 "where (re.account.id like '" + AccountFormat.expand(
"430." + contract.
getId()) +
"' " +
92 "or re.account.id like '" + AccountFormat.expand(
"440." + contract.
getId()) +
"')");
93 if(o instanceof Number) {
94 invoice = ((Number) o).doubleValue();
ContractPortfolio(Contract contract)
ContractDefinition getContractDefinition()
Object getSingleResult(WhereClause wc)
static boolean near(double value, int digits)