1 |
35660
|
stefania.m
|
package eu.dnetlib.client.fundingrequest.newrequest.summarystep;
|
2 |
|
|
|
3 |
|
|
import com.github.gwtbootstrap.client.ui.base.IconAnchor;
|
4 |
36971
|
stefania.m
|
import com.google.gwt.core.client.GWT;
|
5 |
35660
|
stefania.m
|
import com.google.gwt.event.dom.client.ClickEvent;
|
6 |
|
|
import com.google.gwt.event.dom.client.ClickHandler;
|
7 |
47348
|
panagiotis
|
import com.google.gwt.user.client.Window;
|
8 |
36971
|
stefania.m
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
9 |
35660
|
stefania.m
|
import com.google.gwt.user.client.ui.*;
|
10 |
36971
|
stefania.m
|
import eu.dnetlib.client.DataService;
|
11 |
|
|
import eu.dnetlib.client.DataServiceAsync;
|
12 |
35747
|
stefania.m
|
import eu.dnetlib.client.fundingrequest.stepinfo.AccountingFullInfo;
|
13 |
36912
|
stefania.m
|
import eu.dnetlib.client.fundingrequest.stepinfo.BankAccountFullInfo;
|
14 |
36070
|
stefania.m
|
import eu.dnetlib.client.fundingrequest.stepinfo.InvoiceFullInfo;
|
15 |
37080
|
stefania.m
|
import eu.dnetlib.client.fundingrequest.stepinfo.PublisherContactInfo;
|
16 |
36971
|
stefania.m
|
import eu.dnetlib.goldoa.domain.Currency;
|
17 |
35660
|
stefania.m
|
import eu.dnetlib.shared.FundingWizardState;
|
18 |
|
|
|
19 |
|
|
/**
|
20 |
|
|
* Created by stefania on 3/25/15.
|
21 |
|
|
*/
|
22 |
|
|
public class AccountingSummaryPanel implements IsWidget {
|
23 |
|
|
|
24 |
35747
|
stefania.m
|
private FlowPanel accountingSummaryPanel = new FlowPanel();
|
25 |
35660
|
stefania.m
|
|
26 |
35747
|
stefania.m
|
private FlowPanel accountingInnerPanel = new FlowPanel();
|
27 |
|
|
private FlowPanel accountingInfoPanel = new FlowPanel();
|
28 |
|
|
|
29 |
35660
|
stefania.m
|
private IconAnchor editAnchor = new IconAnchor();
|
30 |
|
|
|
31 |
|
|
private EditAccountingListener editAccountingListener;
|
32 |
|
|
|
33 |
36971
|
stefania.m
|
private DataServiceAsync dataService = GWT.create(DataService.class);
|
34 |
35660
|
stefania.m
|
|
35 |
36971
|
stefania.m
|
public AccountingSummaryPanel(final FundingWizardState fundingWizardState) {
|
36 |
|
|
|
37 |
35747
|
stefania.m
|
accountingInnerPanel.addStyleName("uk-panel");
|
38 |
|
|
accountingInnerPanel.addStyleName("uk-panel-box");
|
39 |
35660
|
stefania.m
|
|
40 |
35747
|
stefania.m
|
FlowPanel thumbnail = new FlowPanel();
|
41 |
|
|
thumbnail.addStyleName("uk-thumbnail");
|
42 |
|
|
thumbnail.addStyleName("uk-align-medium-left");
|
43 |
35903
|
stefania.m
|
thumbnail.add(new HTML("<img width=\"100\" height=\"117\" alt=\"Accounting\" title=\"Accounting\" " +
|
44 |
36865
|
stefania.m
|
"src=\"./imgs/accounting_icon.png\">"));
|
45 |
35747
|
stefania.m
|
accountingInnerPanel.add(thumbnail);
|
46 |
35660
|
stefania.m
|
|
47 |
35747
|
stefania.m
|
accountingInfoPanel.addStyleName("uk-nbfc");
|
48 |
35660
|
stefania.m
|
|
49 |
37076
|
stefania.m
|
accountingInfoPanel.add(editAnchor);
|
50 |
|
|
|
51 |
35747
|
stefania.m
|
if(fundingWizardState.getPublication()!=null) {
|
52 |
35660
|
stefania.m
|
|
53 |
35747
|
stefania.m
|
if(fundingWizardState.getPublication().getJournal()!=null) {
|
54 |
35660
|
stefania.m
|
|
55 |
45991
|
panagiotis
|
if(fundingWizardState.getRequest()!=null && fundingWizardState.getRequest().getProjectparticipation()!=null
|
56 |
|
|
&& fundingWizardState.getRequest().getFundingrequested()!=null) {
|
57 |
35660
|
stefania.m
|
|
58 |
36971
|
stefania.m
|
if(!fundingWizardState.getRequest().getCurrency().equals(Currency.EUR)) {
|
59 |
|
|
dataService.convert(fundingWizardState.getRequest().getCurrency(), Currency.EUR,
|
60 |
45991
|
panagiotis
|
fundingWizardState.getRequest().getFundingrequested(), new AsyncCallback<Float>() {
|
61 |
36971
|
stefania.m
|
@Override
|
62 |
|
|
public void onFailure(Throwable throwable) {
|
63 |
|
|
AccountingFullInfo accountingFullInfo = new AccountingFullInfo(fundingWizardState.getRequest(),
|
64 |
|
|
fundingWizardState.getPublication().getJournal().getApc(), fundingWizardState.getPublication().getJournal().getDiscount(),
|
65 |
45991
|
panagiotis
|
fundingWizardState.getPublication().getJournal().getApccurrency(), 0);
|
66 |
37076
|
stefania.m
|
accountingInfoPanel.clear();
|
67 |
36971
|
stefania.m
|
accountingInfoPanel.add(accountingFullInfo.asWidget());
|
68 |
|
|
addInvoiceBankInfoAndEditLink(fundingWizardState);
|
69 |
|
|
}
|
70 |
|
|
|
71 |
|
|
@Override
|
72 |
|
|
public void onSuccess(Float aFloat) {
|
73 |
|
|
AccountingFullInfo accountingFullInfo = new AccountingFullInfo(fundingWizardState.getRequest(),
|
74 |
|
|
fundingWizardState.getPublication().getJournal().getApc(), fundingWizardState.getPublication().getJournal().getDiscount(),
|
75 |
45991
|
panagiotis
|
fundingWizardState.getPublication().getJournal().getApccurrency(), aFloat);
|
76 |
37076
|
stefania.m
|
accountingInfoPanel.clear();
|
77 |
36971
|
stefania.m
|
accountingInfoPanel.add(accountingFullInfo.asWidget());
|
78 |
|
|
addInvoiceBankInfoAndEditLink(fundingWizardState);
|
79 |
|
|
}
|
80 |
|
|
});
|
81 |
|
|
} else {
|
82 |
|
|
AccountingFullInfo accountingFullInfo = new AccountingFullInfo(fundingWizardState.getRequest(),
|
83 |
|
|
fundingWizardState.getPublication().getJournal().getApc(), fundingWizardState.getPublication().getJournal().getDiscount(),
|
84 |
45991
|
panagiotis
|
fundingWizardState.getPublication().getJournal().getApccurrency(), 0);
|
85 |
37076
|
stefania.m
|
accountingInfoPanel.clear();
|
86 |
36971
|
stefania.m
|
accountingInfoPanel.add(accountingFullInfo.asWidget());
|
87 |
|
|
addInvoiceBankInfoAndEditLink(fundingWizardState);
|
88 |
|
|
}
|
89 |
35747
|
stefania.m
|
}
|
90 |
35660
|
stefania.m
|
|
91 |
35747
|
stefania.m
|
} else if(fundingWizardState.getPublication().getPublisher()!=null) {
|
92 |
35660
|
stefania.m
|
|
93 |
45991
|
panagiotis
|
if(fundingWizardState.getRequest()!=null && fundingWizardState.getRequest().getProjectparticipation()!=null
|
94 |
|
|
&& fundingWizardState.getRequest().getFundingrequested()!=null) {
|
95 |
35660
|
stefania.m
|
|
96 |
36971
|
stefania.m
|
if(!fundingWizardState.getRequest().getCurrency().equals(Currency.EUR)) {
|
97 |
|
|
dataService.convert(fundingWizardState.getRequest().getCurrency(), Currency.EUR,
|
98 |
45991
|
panagiotis
|
fundingWizardState.getRequest().getFundingrequested(), new AsyncCallback<Float>() {
|
99 |
35747
|
stefania.m
|
|
100 |
36971
|
stefania.m
|
@Override
|
101 |
|
|
public void onFailure(Throwable throwable) {
|
102 |
|
|
AccountingFullInfo accountingFullInfo = new AccountingFullInfo(fundingWizardState.getRequest(),
|
103 |
45991
|
panagiotis
|
fundingWizardState.getPublication().getPublisher().getApc(), fundingWizardState.getPublication().getPublisher().getDiscount(),
|
104 |
|
|
fundingWizardState.getPublication().getPublisher().getApcCurrency(), 0);
|
105 |
37076
|
stefania.m
|
accountingInfoPanel.clear();
|
106 |
36971
|
stefania.m
|
accountingInfoPanel.add(accountingFullInfo.asWidget());
|
107 |
|
|
addInvoiceBankInfoAndEditLink(fundingWizardState);
|
108 |
|
|
}
|
109 |
36070
|
stefania.m
|
|
110 |
36971
|
stefania.m
|
@Override
|
111 |
|
|
public void onSuccess(Float aFloat) {
|
112 |
|
|
AccountingFullInfo accountingFullInfo = new AccountingFullInfo(fundingWizardState.getRequest(),
|
113 |
45991
|
panagiotis
|
fundingWizardState.getPublication().getPublisher().getApc(), fundingWizardState.getPublication().getPublisher().getDiscount(),
|
114 |
|
|
fundingWizardState.getPublication().getPublisher().getApcCurrency(), aFloat);
|
115 |
37076
|
stefania.m
|
accountingInfoPanel.clear();
|
116 |
36971
|
stefania.m
|
accountingInfoPanel.add(accountingFullInfo.asWidget());
|
117 |
|
|
addInvoiceBankInfoAndEditLink(fundingWizardState);
|
118 |
|
|
}
|
119 |
|
|
});
|
120 |
|
|
} else {
|
121 |
|
|
AccountingFullInfo accountingFullInfo = new AccountingFullInfo(fundingWizardState.getRequest(),
|
122 |
45991
|
panagiotis
|
fundingWizardState.getPublication().getPublisher().getApc(), fundingWizardState.getPublication().getPublisher().getDiscount(),
|
123 |
|
|
fundingWizardState.getPublication().getPublisher().getApcCurrency(), 0);
|
124 |
37076
|
stefania.m
|
accountingInfoPanel.clear();
|
125 |
36971
|
stefania.m
|
accountingInfoPanel.add(accountingFullInfo.asWidget());
|
126 |
|
|
addInvoiceBankInfoAndEditLink(fundingWizardState);
|
127 |
|
|
}
|
128 |
|
|
}
|
129 |
36070
|
stefania.m
|
}
|
130 |
35660
|
stefania.m
|
}
|
131 |
|
|
|
132 |
35747
|
stefania.m
|
editAnchor.setText("(Edit Info)");
|
133 |
|
|
editAnchor.addStyleName("editInfo");
|
134 |
|
|
editAnchor.addClickHandler(new ClickHandler() {
|
135 |
|
|
@Override
|
136 |
|
|
public void onClick(ClickEvent clickEvent) {
|
137 |
|
|
if(editAccountingListener !=null)
|
138 |
|
|
editAccountingListener.editClicked(3);
|
139 |
|
|
}
|
140 |
|
|
});
|
141 |
35660
|
stefania.m
|
|
142 |
35747
|
stefania.m
|
accountingInnerPanel.add(accountingInfoPanel);
|
143 |
35660
|
stefania.m
|
|
144 |
35747
|
stefania.m
|
accountingSummaryPanel.add(accountingInnerPanel);
|
145 |
35660
|
stefania.m
|
}
|
146 |
|
|
|
147 |
|
|
@Override
|
148 |
|
|
public Widget asWidget() {
|
149 |
35747
|
stefania.m
|
return accountingSummaryPanel;
|
150 |
35660
|
stefania.m
|
}
|
151 |
|
|
|
152 |
|
|
public interface EditAccountingListener {
|
153 |
|
|
public void editClicked(int stepNumber);
|
154 |
|
|
}
|
155 |
|
|
|
156 |
|
|
public void setEditAccountingListener(EditAccountingListener editAccountingListener) {
|
157 |
|
|
this.editAccountingListener = editAccountingListener;
|
158 |
|
|
}
|
159 |
35747
|
stefania.m
|
|
160 |
|
|
public void addStyleName(String styleName) {
|
161 |
|
|
accountingSummaryPanel.addStyleName(styleName);
|
162 |
|
|
}
|
163 |
36971
|
stefania.m
|
|
164 |
|
|
private void addInvoiceBankInfoAndEditLink(FundingWizardState fundingWizardState){
|
165 |
|
|
|
166 |
|
|
if(fundingWizardState.getInvoice()!=null) {
|
167 |
|
|
|
168 |
|
|
InvoiceFullInfo invoiceFullInfo = new InvoiceFullInfo(fundingWizardState.getInvoice());
|
169 |
|
|
accountingInfoPanel.add(invoiceFullInfo.asWidget());
|
170 |
|
|
}
|
171 |
|
|
|
172 |
|
|
if(fundingWizardState.getRequest()!=null && fundingWizardState.getRequest().getBankAccount()!=null &&
|
173 |
|
|
((fundingWizardState.getRequest().getBankAccount().getBankName()!=null && !fundingWizardState.getRequest().getBankAccount().getBankName().equals(""))
|
174 |
|
|
|| (fundingWizardState.getRequest().getBankAccount().getBankAddress()!=null && !fundingWizardState.getRequest().getBankAccount().getBankAddress().equals(""))
|
175 |
|
|
|| (fundingWizardState.getRequest().getBankAccount().getAccountHolder()!=null && !fundingWizardState.getRequest().getBankAccount().getAccountHolder().equals(""))
|
176 |
|
|
|| (fundingWizardState.getRequest().getBankAccount().getIban()!=null && !fundingWizardState.getRequest().getBankAccount().getIban().equals(""))
|
177 |
|
|
|| (fundingWizardState.getRequest().getBankAccount().getBankCode()!=null && !fundingWizardState.getRequest().getBankAccount().getBankCode().equals("")))) {
|
178 |
|
|
|
179 |
|
|
BankAccountFullInfo bankAccountFullInfo = new BankAccountFullInfo(fundingWizardState.getRequest().getBankAccount());
|
180 |
|
|
accountingInfoPanel.add(bankAccountFullInfo.asWidget());
|
181 |
|
|
}
|
182 |
37080
|
stefania.m
|
|
183 |
47348
|
panagiotis
|
if(fundingWizardState.getRequest()!=null && fundingWizardState.getRequest().getPublisherEmail()!=null) {
|
184 |
|
|
PublisherContactInfo publisherContactInfo = new PublisherContactInfo(fundingWizardState.getRequest().getPublisherEmail());
|
185 |
37080
|
stefania.m
|
accountingInfoPanel.add(publisherContactInfo.asWidget());
|
186 |
|
|
}
|
187 |
|
|
|
188 |
36971
|
stefania.m
|
accountingInfoPanel.add(editAnchor);
|
189 |
|
|
}
|
190 |
35660
|
stefania.m
|
}
|