Skip to content

Commit e1484ee

Browse files
committed
fix(/series/import/request/{id}): don't show price when it's empty.
Fix #991
1 parent 5c65fb4 commit e1484ee

File tree

4 files changed

+29
-3
lines changed

4 files changed

+29
-3
lines changed

src/main/java/ru/mystamps/web/feature/series/importing/SeriesImportServiceImpl.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
*/
1818
package ru.mystamps.web.feature.series.importing;
1919

20+
import java.math.BigDecimal;
2021
import java.net.URI;
2122
import java.net.URISyntaxException;
2223
import java.util.Date;
@@ -218,8 +219,12 @@ public void saveParsedData(Integer requestId, RawParsedDataDto data) {
218219
seriesSalesParsedData.setSellerGroupId(seriesInfo.getSellerGroupId());
219220
seriesSalesParsedData.setSellerName(seriesInfo.getSellerName());
220221
seriesSalesParsedData.setSellerUrl(seriesInfo.getSellerUrl());
221-
seriesSalesParsedData.setPrice(seriesInfo.getPrice());
222-
seriesSalesParsedData.setCurrency(seriesInfo.getCurrency());
222+
223+
BigDecimal price = seriesInfo.getPrice();
224+
if (price != null) {
225+
seriesSalesParsedData.setPrice(price);
226+
seriesSalesParsedData.setCurrency(seriesInfo.getCurrency());
227+
}
223228

224229
// IMPORTANT: don't add code that modifies database above this line!
225230
// @todo #684 Series import: add integration test

src/main/resources/liquibase/version/0.4.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,6 @@
5656
<include file="0.4/2018-07-15--series_import_parsed_data_group_id_field.xml" relativeToChangelogFile="true" />
5757
<include file="0.4/2018-10-16--similar_series.xml" relativeToChangelogFile="true"/>
5858
<include file="0.4/2018-12-03--site_parsers.xml" relativeToChangelogFile="true"/>
59+
<include file="0.4/2018-12-20--nullify_currency_without_price.xml" relativeToChangelogFile="true"/>
5960

6061
</databaseChangeLog>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<databaseChangeLog
3+
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
6+
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.0.xsd">
7+
8+
<changeSet id="nullify-prices-with-currency-only" author="php-coder" context="test-data, prod-data">
9+
10+
<!-- Be caution: there is no rollback! -->
11+
<sql>
12+
UPDATE series_sales_import_parsed_data
13+
SET currency = NULL
14+
WHERE currency IS NOT NULL AND price IS NULL
15+
</sql>
16+
17+
</changeSet>
18+
19+
</databaseChangeLog>
20+

src/main/webapp/WEB-INF/views/series/import/info.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ <h3 th:text="#{t_gathered_data}">
427427
</td>
428428
</tr>
429429

430-
<tr th:if="${hasSalesInfo}" th:classappend="${#fields.hasErrors('seriesSale.price') or #fields.hasErrors('seriesSale.currency') ? 'has-error' : ''}">
430+
<tr th:if="${hasSalesInfo and (importSeriesForm.seriesSale.price != null or !disabled)}" th:classappend="${#fields.hasErrors('seriesSale.price') or #fields.hasErrors('seriesSale.currency') ? 'has-error' : ''}">
431431
<th>
432432
<label for="price" class="control-label" th:text="#{t_price}">
433433
Price

0 commit comments

Comments
 (0)