show supplier name at offered article page

This commit is contained in:
Hendrik Schutter 2020-05-30 11:52:30 +02:00
parent 1a1502b38c
commit 286edb33ed
3 changed files with 10 additions and 19 deletions

View File

@ -30,7 +30,8 @@ public class SupplierOfferController {
for (ArticleOffer article : offersRepository.findAll()) { for (ArticleOffer article : offersRepository.findAll()) {
UImodelOfferedArticle tmp = new UImodelOfferedArticle(); UImodelOfferedArticle tmp = new UImodelOfferedArticle();
tmp.addData(article, "supplierName01", 4884, articleRepository.findArticleIDByRelatedID(article.id)); //TODO display supplier name with link tmp.addData(article, articleRepository.findArticleIDByRelatedID(article.id)); // TODO display supplier name
// with link
totals.add(tmp); totals.add(tmp);
} }
@ -40,16 +41,15 @@ public class SupplierOfferController {
public class UImodelOfferedArticle { public class UImodelOfferedArticle {
long offer_id; long offer_id;
String title; String title;
String manufacturer; String manufacturer;
String articlenumber; String articlenumber;
String supplierName; String supplierName;
int supplierId;
String price; String price;
String ads; String ads;
int listedArticleId; int listedArticleId;
boolean offerIsListed; //true --> offered article is listed boolean offerIsListed; // true --> offered article is listed
public long getOffer_id() { public long getOffer_id() {
return offer_id; return offer_id;
@ -58,7 +58,7 @@ public class SupplierOfferController {
public void setOffer_id(long offer_id) { public void setOffer_id(long offer_id) {
this.offer_id = offer_id; this.offer_id = offer_id;
} }
public boolean isOfferIsListed() { public boolean isOfferIsListed() {
return offerIsListed; return offerIsListed;
} }
@ -99,14 +99,6 @@ public class SupplierOfferController {
this.supplierName = supplierName; this.supplierName = supplierName;
} }
public int getSupplierId() {
return supplierId;
}
public void setSupplierId(int supplierId) {
this.supplierId = supplierId;
}
public String getPrice() { public String getPrice() {
return price; return price;
} }
@ -131,15 +123,13 @@ public class SupplierOfferController {
this.listedArticleId = listedArticleId; this.listedArticleId = listedArticleId;
} }
public void addData(ArticleOffer article, String supplierName, int supplierId, public void addData(ArticleOffer article, Optional<Integer> listedArticleId) {
Optional<Integer> listedArticleId) {
this.offer_id = article.id; this.offer_id = article.id;
this.title = article.title; this.title = article.title;
this.manufacturer = article.manufacturer; this.manufacturer = article.manufacturer;
this.articlenumber = article.articleNumber; this.articlenumber = article.articleNumber;
this.supplierName = supplierName; this.supplierName = article.cheapestSupplier.name;
this.supplierId = supplierId;
this.price = String.format("%.2f", ((float) article.pricePerUnitNet / 100)); this.price = String.format("%.2f", ((float) article.pricePerUnitNet / 100));
this.ads = (article.shouldBeAdvertised) ? "Ja" : "Nein"; this.ads = (article.shouldBeAdvertised) ? "Ja" : "Nein";

View File

@ -28,5 +28,6 @@ public class ArticleOffer {
public boolean shouldBeAdvertised; public boolean shouldBeAdvertised;
@ManyToOne(optional = false)
public Supplier cheapestSupplier;
} }

View File

@ -44,7 +44,7 @@
<td><span th:text="${article.title}"></span></td> <td><span th:text="${article.title}"></span></td>
<td><span th:text="${article.manufacturer}"></span></td> <td><span th:text="${article.manufacturer}"></span></td>
<td><span th:text="${article.articlenumber}"></span></td> <td><span th:text="${article.articlenumber}"></span></td>
<td><a th:href="@{/intern/suppliers/{id}(id = ${article.supplierId})}" th:text="${article.supplierName}"></a></td> <td><a th:href="${'/intern/suppliers/#q=' + article.supplierName}" th:text="${article.supplierName}"></a></td>
<td><span th:text="${article.price}"></span></td> <td><span th:text="${article.price}"></span></td>
<td><span th:text="${article.ads}"></span></td> <td><span th:text="${article.ads}"></span></td>
<td> <td>