Skip to content

Commit

Permalink
misc
Browse files Browse the repository at this point in the history
  • Loading branch information
Goulven.Furet authored and Goulven.Furet committed Oct 16, 2023
1 parent d9586b6 commit af922c1
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public int hashCode() {
@Override
public boolean equals(Object obj) {

if (obj instanceof UnindexedKeyVal) {
if (obj instanceof UnindexedKeyVal || obj instanceof UnindexedKeyValTimestamp) {
return ((UnindexedKeyVal)obj).key.equals(key);
}
return false;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@

package org.open4goods.model.product;

import java.text.DecimalFormat;

import org.open4goods.model.constants.Currency;
import org.open4goods.model.constants.ProductState;
import org.open4goods.model.data.DataFragment;
Expand All @@ -10,7 +12,9 @@
import org.springframework.data.elasticsearch.annotations.FieldType;

public class AggregatedPrice extends Price {


private static final DecimalFormat df = new DecimalFormat("0.00");

@Field(index = false, store = false, type = FieldType.Keyword)
private String datasourceName;
@Field(index = false, store = false, type = FieldType.Keyword)
Expand Down Expand Up @@ -74,7 +78,24 @@ public AggregatedPrice(double price, Currency currency) {
}



/**
* A human readable price (2 decimals max, skipped if int)
* @return
*/
public String shortPrice() {

Double p = super.getPrice();
boolean isInt = p == Math.rint(p);

if (isInt) {
return String.valueOf(p.intValue());
} else {
return String.valueOf(df.format(p));
}

}


public AggregatedPrice() {
super();
}
Expand Down
18 changes: 6 additions & 12 deletions ui/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,6 @@ brandConfig:
CONTINENTAL EDISON: "http://www.service-client.fr/wp-content/uploads/2016/08/CONTINENTAL-EDISON.jpg"
CHIQ: "https://www.buysmarte.com.au/media/manufacturer/chiq.jpg"







management:

health:
Expand Down Expand Up @@ -110,11 +104,11 @@ spring:


#Css and js mimification
wro4j:
filterUrl : /resources
cacheGzippedContent: true
ignoreMissingResources: false
managerFactory:
preProcessors: removeSourceMaps, cssImport, jsMin
#wro4j:
# filterUrl : /resources
# cacheGzippedContent: true
# ignoreMissingResources: false
# managerFactory:
# preProcessors: removeSourceMaps, cssImport, jsMin


6 changes: 4 additions & 2 deletions ui/src/main/resources/templates/inc/product-price.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
<div class="card-header border-0 bg-white text-center pb-0">
<h2 class="h3 ">Meilleur prix</h2>
<span class="d-block">
<span class="display-2 fw-bold">
<th:block th:text="${#numbers.formatDecimal(product.bestPrice().price, 1, 2)}"></th:block>
<span class="display-3 fw-bold">
<th:block th:text="${product.bestPrice().shortPrice()}"></th:block>


<span class="align-baseline font-medium" th:text="#{'symbol.'+${product.bestPrice().currency}}"></span>
</span>
</span>
Expand Down

0 comments on commit af922c1

Please sign in to comment.