Project

General

Profile

1
package eu.dnetlib.client.fundingrequest.stepinfo;
2

    
3
import com.google.gwt.user.client.ui.HTML;
4
import com.google.gwt.user.client.ui.IsWidget;
5
import com.google.gwt.user.client.ui.Widget;
6
import eu.dnetlib.goldoa.domain.Currency;
7
import eu.dnetlib.goldoa.domain.Request;
8

    
9
/**
10
 * Created by stefania on 3/30/15.
11
 */
12
public class AccountingInlineInfo implements IsWidget {
13

    
14
    private HTML accountingInlineInfo = new HTML();
15
    private String accountingInfoContents = "";
16

    
17
    public AccountingInlineInfo(Request request, double apc, double discount, Currency currency, float fundedRequestedInEuros) {
18

    
19
        accountingInfoContents = "<div>";
20

    
21
        accountingInfoContents += "<dl><dt class=\"chronologySubTitle\">ACCOUNTING</dt></dl>";
22

    
23
        accountingInfoContents += "<dd>APCs (from OpenAIRE database): " + Math.round(apc*100) / 100.0 + " " + currency.getName();
24
        accountingInfoContents += " - " + Math.round(discount*100) / 100.0 + "% discount</dd>";
25
        accountingInfoContents += "<dd>APCs (provided by user): " + Math.round(request.getApc()*100) / 100.0 + " " + request.getCurrency().getName();
26
        accountingInfoContents += " - " + Math.round(request.getDiscount()*100) / 100.0 + "% discount</dd>";
27
        accountingInfoContents += "<dd>Project participation: " + Math.round(request.getProjectparticipation()*100) / 100.0 + " %";
28
        if(request.getRequestCoFunders()!=null && !request.getRequestCoFunders().isEmpty()) {
29
            accountingInfoContents += " (";
30
            for(int i=0; i<request.getRequestCoFunders().size(); i++) {
31
                if(i!=0)
32
                    accountingInfoContents += ", ";
33
                accountingInfoContents += request.getRequestCoFunders().get(i).getPk().getFunder().getName() + " - "
34
                        + Math.round(request.getRequestCoFunders().get(i).getPercentage()*100) / 100.0 + " %";
35
            }
36
            accountingInfoContents += ") ";
37
        }
38
        accountingInfoContents += "</dd>";
39

    
40
        if(!request.getCurrency().equals(Currency.EUR))
41
            accountingInfoContents += "<dd>Funding requested: " + Math.round(request.getFundingrequested()*100) / 100.0 + " "
42
                    + request.getCurrency().getName() + " (" + Math.round(fundedRequestedInEuros*100) / 100.0 + " Euros)</dd>";
43
        else
44
            accountingInfoContents += "<dd>Funding requested: " + Math.round(request.getFundingrequested()*100) / 100.0 + " "
45
                    + request.getCurrency().getName() + "</dd>";
46

    
47
        accountingInfoContents += "</div>";
48
        accountingInlineInfo.setHTML(accountingInfoContents);
49
    }
50

    
51
    @Override
52
    public Widget asWidget() {
53
        return accountingInlineInfo;
54
    }
55

    
56
    public void addStyleName(String styleName) {
57
        accountingInlineInfo.addStyleName(styleName);
58
    }
59
}
(2-2/32)