1
|
package eu.dnetlib.client.fundingrequest.newrequest.summarystep;
|
2
|
|
3
|
import com.github.gwtbootstrap.client.ui.base.IconAnchor;
|
4
|
import com.google.gwt.core.client.GWT;
|
5
|
import com.google.gwt.event.dom.client.ClickEvent;
|
6
|
import com.google.gwt.event.dom.client.ClickHandler;
|
7
|
import com.google.gwt.user.client.Window;
|
8
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
9
|
import com.google.gwt.user.client.ui.*;
|
10
|
import eu.dnetlib.client.DataService;
|
11
|
import eu.dnetlib.client.DataServiceAsync;
|
12
|
import eu.dnetlib.client.fundingrequest.stepinfo.AccountingFullInfo;
|
13
|
import eu.dnetlib.client.fundingrequest.stepinfo.BankAccountFullInfo;
|
14
|
import eu.dnetlib.client.fundingrequest.stepinfo.InvoiceFullInfo;
|
15
|
import eu.dnetlib.client.fundingrequest.stepinfo.PublisherContactInfo;
|
16
|
import eu.dnetlib.goldoa.domain.Currency;
|
17
|
import eu.dnetlib.shared.FundingWizardState;
|
18
|
|
19
|
/**
|
20
|
* Created by stefania on 3/25/15.
|
21
|
*/
|
22
|
public class AccountingSummaryPanel implements IsWidget {
|
23
|
|
24
|
private FlowPanel accountingSummaryPanel = new FlowPanel();
|
25
|
|
26
|
private FlowPanel accountingInnerPanel = new FlowPanel();
|
27
|
private FlowPanel accountingInfoPanel = new FlowPanel();
|
28
|
|
29
|
private IconAnchor editAnchor = new IconAnchor();
|
30
|
|
31
|
private EditAccountingListener editAccountingListener;
|
32
|
|
33
|
private DataServiceAsync dataService = GWT.create(DataService.class);
|
34
|
|
35
|
public AccountingSummaryPanel(final FundingWizardState fundingWizardState) {
|
36
|
|
37
|
accountingInnerPanel.addStyleName("uk-panel");
|
38
|
accountingInnerPanel.addStyleName("uk-panel-box");
|
39
|
|
40
|
FlowPanel thumbnail = new FlowPanel();
|
41
|
thumbnail.addStyleName("uk-thumbnail");
|
42
|
thumbnail.addStyleName("uk-align-medium-left");
|
43
|
thumbnail.add(new HTML("<img width=\"100\" height=\"117\" alt=\"Accounting\" title=\"Accounting\" " +
|
44
|
"src=\"./imgs/accounting_icon.png\">"));
|
45
|
accountingInnerPanel.add(thumbnail);
|
46
|
|
47
|
accountingInfoPanel.addStyleName("uk-nbfc");
|
48
|
|
49
|
accountingInfoPanel.add(editAnchor);
|
50
|
|
51
|
if(fundingWizardState.getPublication()!=null) {
|
52
|
|
53
|
if(fundingWizardState.getPublication().getJournal()!=null) {
|
54
|
|
55
|
if(fundingWizardState.getRequest()!=null && fundingWizardState.getRequest().getProjectparticipation()!=null
|
56
|
&& fundingWizardState.getRequest().getFundingrequested()!=null) {
|
57
|
|
58
|
if(!fundingWizardState.getRequest().getCurrency().equals(Currency.EUR)) {
|
59
|
dataService.convert(fundingWizardState.getRequest().getCurrency(), Currency.EUR,
|
60
|
fundingWizardState.getRequest().getFundingrequested(), new AsyncCallback<Float>() {
|
61
|
@Override
|
62
|
public void onFailure(Throwable throwable) {
|
63
|
AccountingFullInfo accountingFullInfo = new AccountingFullInfo(fundingWizardState.getRequest(),
|
64
|
fundingWizardState.getPublication().getJournal().getApc(), fundingWizardState.getPublication().getJournal().getDiscount(),
|
65
|
fundingWizardState.getPublication().getJournal().getApccurrency(), 0);
|
66
|
accountingInfoPanel.clear();
|
67
|
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
|
fundingWizardState.getPublication().getJournal().getApccurrency(), aFloat);
|
76
|
accountingInfoPanel.clear();
|
77
|
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
|
fundingWizardState.getPublication().getJournal().getApccurrency(), 0);
|
85
|
accountingInfoPanel.clear();
|
86
|
accountingInfoPanel.add(accountingFullInfo.asWidget());
|
87
|
addInvoiceBankInfoAndEditLink(fundingWizardState);
|
88
|
}
|
89
|
}
|
90
|
|
91
|
} else if(fundingWizardState.getPublication().getPublisher()!=null) {
|
92
|
|
93
|
if(fundingWizardState.getRequest()!=null && fundingWizardState.getRequest().getProjectparticipation()!=null
|
94
|
&& fundingWizardState.getRequest().getFundingrequested()!=null) {
|
95
|
|
96
|
if(!fundingWizardState.getRequest().getCurrency().equals(Currency.EUR)) {
|
97
|
dataService.convert(fundingWizardState.getRequest().getCurrency(), Currency.EUR,
|
98
|
fundingWizardState.getRequest().getFundingrequested(), new AsyncCallback<Float>() {
|
99
|
|
100
|
@Override
|
101
|
public void onFailure(Throwable throwable) {
|
102
|
AccountingFullInfo accountingFullInfo = new AccountingFullInfo(fundingWizardState.getRequest(),
|
103
|
fundingWizardState.getPublication().getPublisher().getApc(), fundingWizardState.getPublication().getPublisher().getDiscount(),
|
104
|
fundingWizardState.getPublication().getPublisher().getApcCurrency(), 0);
|
105
|
accountingInfoPanel.clear();
|
106
|
accountingInfoPanel.add(accountingFullInfo.asWidget());
|
107
|
addInvoiceBankInfoAndEditLink(fundingWizardState);
|
108
|
}
|
109
|
|
110
|
@Override
|
111
|
public void onSuccess(Float aFloat) {
|
112
|
AccountingFullInfo accountingFullInfo = new AccountingFullInfo(fundingWizardState.getRequest(),
|
113
|
fundingWizardState.getPublication().getPublisher().getApc(), fundingWizardState.getPublication().getPublisher().getDiscount(),
|
114
|
fundingWizardState.getPublication().getPublisher().getApcCurrency(), aFloat);
|
115
|
accountingInfoPanel.clear();
|
116
|
accountingInfoPanel.add(accountingFullInfo.asWidget());
|
117
|
addInvoiceBankInfoAndEditLink(fundingWizardState);
|
118
|
}
|
119
|
});
|
120
|
} else {
|
121
|
AccountingFullInfo accountingFullInfo = new AccountingFullInfo(fundingWizardState.getRequest(),
|
122
|
fundingWizardState.getPublication().getPublisher().getApc(), fundingWizardState.getPublication().getPublisher().getDiscount(),
|
123
|
fundingWizardState.getPublication().getPublisher().getApcCurrency(), 0);
|
124
|
accountingInfoPanel.clear();
|
125
|
accountingInfoPanel.add(accountingFullInfo.asWidget());
|
126
|
addInvoiceBankInfoAndEditLink(fundingWizardState);
|
127
|
}
|
128
|
}
|
129
|
}
|
130
|
}
|
131
|
|
132
|
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
|
|
142
|
accountingInnerPanel.add(accountingInfoPanel);
|
143
|
|
144
|
accountingSummaryPanel.add(accountingInnerPanel);
|
145
|
}
|
146
|
|
147
|
@Override
|
148
|
public Widget asWidget() {
|
149
|
return accountingSummaryPanel;
|
150
|
}
|
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
|
|
160
|
public void addStyleName(String styleName) {
|
161
|
accountingSummaryPanel.addStyleName(styleName);
|
162
|
}
|
163
|
|
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
|
|
183
|
if(fundingWizardState.getRequest()!=null && fundingWizardState.getRequest().getPublisherEmail()!=null) {
|
184
|
PublisherContactInfo publisherContactInfo = new PublisherContactInfo(fundingWizardState.getRequest().getPublisherEmail());
|
185
|
accountingInfoPanel.add(publisherContactInfo.asWidget());
|
186
|
}
|
187
|
|
188
|
accountingInfoPanel.add(editAnchor);
|
189
|
}
|
190
|
}
|