OpenConcerto

Dépôt officiel du code source de l'ERP OpenConcerto
sonarqube

svn://code.openconcerto.org/openconcerto

Rev

Rev 104 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 104 Rev 147
Line 1... Line 1...
1
package org.openconcerto.modules.finance.accounting.exchangerates;
1
package org.openconcerto.modules.finance.accounting.exchangerates;
2
 
2
 
-
 
3
import java.awt.GraphicsEnvironment;
3
import java.io.File;
4
import java.io.File;
4
import java.io.IOException;
5
import java.io.IOException;
5
import java.math.BigDecimal;
6
import java.math.BigDecimal;
6
import java.sql.ResultSet;
7
import java.sql.ResultSet;
7
import java.sql.SQLException;
8
import java.sql.SQLException;
Line 128... Line 129...
128
                    importReport(d, report, converter, root);
129
                    importReport(d, report, converter, root);
129
                }
130
                }
130
            }
131
            }
131
        } catch (Exception e) {
132
        } catch (Exception e) {
132
            e.printStackTrace();
133
            e.printStackTrace();
-
 
134
            if (!GraphicsEnvironment.isHeadless()) {
133
            JOptionPane.showMessageDialog(null, "Impossible de mettre à jour les taux de change");
135
                JOptionPane.showMessageDialog(null, "Impossible de mettre à jour les taux de change");
-
 
136
            }
134
        }
137
        }
135
    }
138
    }
136
 
139
 
137
    @Override
140
    @Override
138
    public List<ModulePreferencePanelDesc> getPrefDescriptors() {
141
    public List<ModulePreferencePanelDesc> getPrefDescriptors() {
Line 176... Line 179...
176
            String code = ExchangeRatesDownloader.supportedCurrencyCodes.get(i);
179
            String code = ExchangeRatesDownloader.supportedCurrencyCodes.get(i);
177
            BigDecimal tauxCommercial;
180
            BigDecimal tauxCommercial;
178
            if (this.commercialConverter != null) {
181
            if (this.commercialConverter != null) {
179
                tauxCommercial = commercialConverter.convert(BigDecimal.ONE, report.getMainCurrencyCode(), code, date, true);
182
                tauxCommercial = commercialConverter.convert(BigDecimal.ONE, report.getMainCurrencyCode(), code, date, true);
180
            } else {
183
            } else {
-
 
184
                try {
181
                tauxCommercial = converter.convert(BigDecimal.ONE, report.getMainCurrencyCode(), code, date, true);
185
                    tauxCommercial = converter.convert(BigDecimal.ONE, report.getMainCurrencyCode(), code, date, true);
-
 
186
                } catch (IllegalStateException e) {
-
 
187
                    // Aucun taux n'existe encore dans la base.
-
 
188
                    tauxCommercial = null;
-
 
189
                }
182
            }
190
            }
183
            if (tauxCommercial == null) {
191
            if (tauxCommercial == null) {
184
                tauxCommercial = BigDecimal.ONE;
192
                tauxCommercial = BigDecimal.ONE;
185
            }
193
            }
186
            tauxCommercial = tauxCommercial.setScale(4, BigDecimal.ROUND_HALF_UP);
194
            tauxCommercial = tauxCommercial.setScale(4, BigDecimal.ROUND_HALF_UP);