19 package org.turro.financials.business;
21 import java.util.List;
22 import org.turro.financials.entity.Contract;
23 import org.turro.financials.operating.ContractItem;
24 import org.turro.financials.operating.ContractItemSet;
25 import org.turro.financials.operating.MonthItem;
26 import org.turro.financials.operating.MonthItemSet;
27 import org.turro.financials.operating.ValueItem;
28 import org.turro.i18n.I_;
29 import org.zkoss.zul.CategoryModel;
30 import org.zkoss.zul.SimpleCategoryModel;
45 SimpleCategoryModel cm =
new SimpleCategoryModel();
49 if(exists(contracts, ci.getId())) {
51 mis.
getMonth(mi.getYear(), mi.getMonth());
56 setModelValue(cm,
I_.
get(
"Sales"), mi.getStringId(), 0);
57 setModelValue(cm,
I_.
get(
"Expenses"), mi.getStringId(), 0);
58 setModelValue(cm,
I_.
get(
"Profit"), mi.getStringId(), 0);
62 if(exists(contracts, ci.getId())) {
64 double sales = mi.getMovements().getValues().getSalesAmount();
65 double expenses = mi.getMovements().getValues().getExpensesAmount();
66 setModelValue(cm,
I_.
get(
"Sales"), mi.getStringId(), sales);
67 setModelValue(cm,
I_.
get(
"Expenses"), mi.getStringId(), expenses);
68 setModelValue(cm,
I_.
get(
"Profit"), mi.getStringId(), sales - expenses);
76 SimpleCategoryModel cm =
new SimpleCategoryModel();
78 if(exists(contracts, ci.getId())) {
80 setModelValue(cm, ci.getName(), vi.getName(), vi.getValue());
88 SimpleCategoryModel cm =
new SimpleCategoryModel();
90 if(exists(contracts, ci.getId())) {
91 for(
ValueItem vi : ci.getParticipants()) {
92 setModelValue(cm, ci.getName(), vi.getName(), vi.getValue());
100 SimpleCategoryModel cm =
new SimpleCategoryModel();
102 if(exists(contracts, ci.getId())) {
103 for(
ValueItem vi : ci.getParticipants().getProviders()) {
104 setModelValue(cm, ci.getName(), vi.getName(), vi.getValue());
112 SimpleCategoryModel cm =
new SimpleCategoryModel();
114 if(exists(contracts, ci.getId())) {
115 for(
ValueItem vi : ci.getParticipants().getCustomers()) {
116 setModelValue(cm, ci.getName(), vi.getName(), vi.getValue());
124 SimpleCategoryModel cm =
new SimpleCategoryModel();
126 if(exists(contracts, ci.getId())) {
127 for(
ValueItem vi : ci.getValues().getSales()) {
128 setModelValue(cm, ci.getName(), vi.getName(), vi.getValue());
136 SimpleCategoryModel cm =
new SimpleCategoryModel();
138 if(exists(contracts, ci.getId())) {
139 for(
ValueItem vi : ci.getValues().getExpenses()) {
140 setModelValue(cm, ci.getName(), vi.getName(), vi.getValue());
147 private boolean exists(List<Contract> contracts,
long id) {
148 for(
Contract contract : contracts) {
149 if(contract.getId() ==
id) {
156 private void setModelValue(SimpleCategoryModel cm, Comparable<?> series, Comparable<?> category, Number value) {
157 Double v = (Double) cm.getValue(series, category);
158 cm.setValue(series, category, (value ==
null ? 0.0 : value.doubleValue()) + (v ==
null ? 0.0 : v));
CompanyModelWrapper(ContractItemSet items)
CategoryModel getCustomersModel(List< Contract > contracts)
CategoryModel getSalesExpensesModel(List< Contract > contracts)
CategoryModel getProvidersModel(List< Contract > contracts)
CategoryModel getExpenseStoresModel(List< Contract > contracts)
CategoryModel getStoresModel(List< Contract > contracts)
CategoryModel getParticipantsModel(List< Contract > contracts)
CategoryModel getSaleStoresModel(List< Contract > contracts)
MonthItem getMonth(int year, int month)
static String get(String msg)