Merge pull request 'feature/offered_article_supplier' (#40) from feature/offered_article_supplier into master
Reviewed-by: Jannik Seiler <seil0@mosad.xyz>
This commit is contained in:
commit
b38ffdea34
|
@ -1,6 +1,15 @@
|
|||
INSERT INTO article_offers ("manufacturer", "article_number", "price_per_unit_net", "title", "vat_percent", "should_be_advertised")
|
||||
VALUES ("McDonalds", "1", 4242, "McPizza", 7, 1);
|
||||
/*
|
||||
* add a supplier first
|
||||
*/
|
||||
|
||||
INSERT INTO article_offers ("manufacturer", "article_number", "price_per_unit_net", "title", "vat_percent", "should_be_advertised", "cheapest_supplier_id")
|
||||
VALUES ("McDonalds", "1", 4242, "McPizza", 7, 1, 1);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* There is no need for the add article, you can add one form the UI on the offerd article page
|
||||
*/
|
||||
INSERT INTO articles ("related_id", "shop_price_per_unit_net_cent", "warehouse_units_per_slot", "should_reorder", "reorder_max_price", "title", "description", "image_id")
|
||||
VALUES (1, 19.99, 10, 1, 15, "Huge Hamburger", "This huge Hamburger is awesome!", NULL);
|
||||
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
|
||||
INSERT INTO suppliers ("api_url", "name", "uuid")
|
||||
VALUES ("https://api.com", "Conrad", "fdfdfg4gdfgdf4gfg");
|
||||
|
||||
|
||||
|
|
@ -26,11 +26,11 @@ public class SupplierOfferController {
|
|||
@GetMapping("supplierOffers")
|
||||
public String internListedArticles(Model model) {
|
||||
|
||||
List<UImodelOfferedArticle> totals = new ArrayList<UImodelOfferedArticle>();
|
||||
List<UImodelOfferedArticle> totals = new ArrayList<>();
|
||||
|
||||
for (ArticleOffer article : offersRepository.findAll()) {
|
||||
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));
|
||||
totals.add(tmp);
|
||||
}
|
||||
|
||||
|
@ -40,16 +40,15 @@ public class SupplierOfferController {
|
|||
|
||||
public class UImodelOfferedArticle {
|
||||
|
||||
long offer_id;
|
||||
long offer_id;
|
||||
String title;
|
||||
String manufacturer;
|
||||
String articlenumber;
|
||||
String supplierName;
|
||||
int supplierId;
|
||||
String price;
|
||||
String ads;
|
||||
int listedArticleId;
|
||||
boolean offerIsListed; //true --> offered article is listed
|
||||
boolean offerIsListed; // true --> offered article is listed
|
||||
|
||||
public long getOffer_id() {
|
||||
return offer_id;
|
||||
|
@ -58,7 +57,7 @@ public class SupplierOfferController {
|
|||
public void setOffer_id(long offer_id) {
|
||||
this.offer_id = offer_id;
|
||||
}
|
||||
|
||||
|
||||
public boolean isOfferIsListed() {
|
||||
return offerIsListed;
|
||||
}
|
||||
|
@ -99,14 +98,6 @@ public class SupplierOfferController {
|
|||
this.supplierName = supplierName;
|
||||
}
|
||||
|
||||
public int getSupplierId() {
|
||||
return supplierId;
|
||||
}
|
||||
|
||||
public void setSupplierId(int supplierId) {
|
||||
this.supplierId = supplierId;
|
||||
}
|
||||
|
||||
public String getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
@ -131,15 +122,13 @@ public class SupplierOfferController {
|
|||
this.listedArticleId = listedArticleId;
|
||||
}
|
||||
|
||||
public void addData(ArticleOffer article, String supplierName, int supplierId,
|
||||
Optional<Integer> listedArticleId) {
|
||||
public void addData(ArticleOffer article, Optional<Integer> listedArticleId) {
|
||||
|
||||
this.offer_id = article.id;
|
||||
this.title = article.title;
|
||||
this.manufacturer = article.manufacturer;
|
||||
this.articlenumber = article.articleNumber;
|
||||
this.supplierName = supplierName;
|
||||
this.supplierId = supplierId;
|
||||
this.supplierName = article.cheapestSupplier.name;
|
||||
this.price = String.format("%.2f", ((float) article.pricePerUnitNet / 100));
|
||||
this.ads = (article.shouldBeAdvertised) ? "Ja" : "Nein";
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
<td><span th:text="${article.title}"></span></td>
|
||||
<td><span th:text="${article.manufacturer}"></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.ads}"></span></td>
|
||||
<td>
|
||||
|
|
Reference in New Issue