Skip to content

Commit

Permalink
Fixed error with parse data
Browse files Browse the repository at this point in the history
  • Loading branch information
yamelsenih committed Dec 21, 2024
1 parent 42d747d commit 62535d8
Showing 1 changed file with 25 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. *
************************************************************************************/
package org.spin.grpc.service.form.import_file_loader;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.nio.charset.Charset;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

import org.adempiere.core.domains.models.I_AD_ImpFormat;
Expand Down Expand Up @@ -582,27 +582,32 @@ public static ListEntitiesResponse.Builder listFilePreview(ListFilePreviewReques
info = "";
}
}
String entry = info;

String entry = row.parse(info);
// TODO: Reuse ADempiere Parser
Value.Builder valueBuilder = Value.newBuilder();
if (row.isDate()) {
Timestamp dateValue = Timestamp.valueOf(entry);
valueBuilder = ValueManager.getValueFromTimestamp(dateValue);
} else if (row.isNumber()) {
BigDecimal numberValue = null;
if (!Util.isEmpty(entry, true)) {
numberValue = new BigDecimal(entry);
if (row.isDivideBy100()) {
numberValue = numberValue.divide(
BigDecimal.valueOf(100)
);
if(!Util.isEmpty(entry)) {
try {
if (row.isDate()) {
Timestamp dateValue = Timestamp.valueOf(entry);
valueBuilder = ValueManager.getValueFromTimestamp(dateValue);
} else if (row.isNumber()) {
BigDecimal numberValue = null;
if (!Util.isEmpty(entry, true)) {
numberValue = new BigDecimal(entry);
if (row.isDivideBy100()) {
numberValue = numberValue.divide(
BigDecimal.valueOf(100)
);
}
}
valueBuilder = ValueManager.getValueFromBigDecimal(numberValue);
} else {
valueBuilder = ValueManager.getValueFromString(entry);
}
} catch (Exception e) {
e.printStackTrace();
}
valueBuilder = ValueManager.getValueFromBigDecimal(numberValue);
} else {
valueBuilder = ValueManager.getValueFromString(entry);
}

lineValues.putFields(
row.getColumnName(),
valueBuilder.build()
Expand Down

0 comments on commit 62535d8

Please sign in to comment.