Project

General

Profile

1 35839 stefania.m
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 36971 stefania.m
import eu.dnetlib.goldoa.domain.Currency;
7 35839 stefania.m
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 46304 panagiotis
    public AccountingInlineInfo(Request request, double apc, double discount, Currency currency, float fundedRequestedInEuros) {
18 35839 stefania.m
19 36971 stefania.m
        accountingInfoContents = "<div>";
20 35839 stefania.m
21
        accountingInfoContents += "<dl><dt class=\"chronologySubTitle\">ACCOUNTING</dt></dl>";
22 36909 stefania.m
23 36971 stefania.m
        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 45991 panagiotis
        accountingInfoContents += "<dd>Project participation: " + Math.round(request.getProjectparticipation()*100) / 100.0 + " %";
28
        if(request.getRequestCoFunders()!=null && !request.getRequestCoFunders().isEmpty()) {
29 37077 stefania.m
            accountingInfoContents += " (";
30 45991 panagiotis
            for(int i=0; i<request.getRequestCoFunders().size(); i++) {
31 37077 stefania.m
                if(i!=0)
32
                    accountingInfoContents += ", ";
33 45991 panagiotis
                accountingInfoContents += request.getRequestCoFunders().get(i).getPk().getFunder().getName() + " - "
34
                        + Math.round(request.getRequestCoFunders().get(i).getPercentage()*100) / 100.0 + " %";
35 37077 stefania.m
            }
36
            accountingInfoContents += ") ";
37
        }
38
        accountingInfoContents += "</dd>";
39 36069 stefania.m
40 36971 stefania.m
        if(!request.getCurrency().equals(Currency.EUR))
41 45991 panagiotis
            accountingInfoContents += "<dd>Funding requested: " + Math.round(request.getFundingrequested()*100) / 100.0 + " "
42 36971 stefania.m
                    + request.getCurrency().getName() + " (" + Math.round(fundedRequestedInEuros*100) / 100.0 + " Euros)</dd>";
43
        else
44 45991 panagiotis
            accountingInfoContents += "<dd>Funding requested: " + Math.round(request.getFundingrequested()*100) / 100.0 + " "
45 36971 stefania.m
                    + request.getCurrency().getName() + "</dd>";
46 36909 stefania.m
47 35839 stefania.m
        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
}